/** test with long sequence of adds, removes and updates, and lookups */
static void
test_long_table(struct lruhash* table) 
{
	/* assuming it all fits in the hastable, this check will work */
	testdata_t* ref[HASHTESTMAX * 100];
	size_t i;
	memset(ref, 0, sizeof(ref));
	/* test assumption */
	if(0) log_info(" size %d x %d < %d", (int)test_slabhash_sizefunc(NULL, NULL), 
		(int)HASHTESTMAX, (int)table->space_max);
	unit_assert( test_slabhash_sizefunc(NULL, NULL)*HASHTESTMAX < table->space_max);
	if(0) lruhash_status(table, "unit test", 1);
	srandom(48);
	for(i=0; i<1000; i++) {
		/* what to do? */
		if(i == 500) {
			lruhash_clear(table);
			memset(ref, 0, sizeof(ref));
			continue;
		}
		switch(random() % 4) {
			case 0:
			case 3:
				testadd(table, ref);
				break;
			case 1:
				testremove(table, ref);
				break;
			case 2:
				testlookup(table, ref);
				break;
			default:
				unit_assert(0);
		}
		if(0) lruhash_status(table, "unit test", 1);
		check_table(table);
		unit_assert( table->num <= HASHTESTMAX );
	}

	/* test more, but 'ref' assumption does not hold anymore */
	for(i=0; i<1000; i++) {
		/* what to do? */
		switch(random() % 4) {
			case 0:
			case 3:
				testadd_unlim(table, ref);
				break;
			case 1:
				testremove_unlim(table, ref);
				break;
			case 2:
				testlookup_unlim(table, ref);
				break;
			default:
				unit_assert(0);
		}
		if(0) lruhash_status(table, "unlim", 1);
		check_table(table);
	}
}
예제 #2
0
static void *test_thr_main(void *arg)
{
    struct test_thr *t = (struct test_thr *)arg;
    int i;
    for(i = 0; i < 1000; i++) {
        switch(random() % 4) {
        case 0:
        case 3:
            testadd(t->table, NULL);
            break;
        case 1:
            testremove(t->table, NULL);
            break;
        case 2:
            testlookup(t->table, NULL);
            break;
        default:
            unit_assert(0);
        }
        if(i % 100 == 0)
            check_table(t->table);
    }
    check_table(t->table);
    return NULL;
}
예제 #3
0
static void test_long_table(struct lruhash* table)
{
    testdata *ref[MAXHASH * 100];
    size_t i;
    memset(ref, 0, sizeof(ref));

    unit_assert(sizefunc(NULL, NULL)*MAXHASH < table->space_max);

    srandom(48);
    for(i = 0; i < 1000; i++) {
        if(i == 500) {
            lruhash_clear(table);
            memset(ref, 0, sizeof(ref));
            continue;
        }
        switch(random() % 4) {
        case 0:
        case 3:
            testadd(table, ref);
            break;
        case 1:
            testremove(table, ref);
            break;
        case 2:
            testlookup(table, ref);
            break;
        default:
            unit_assert(0);
        }
        check_table(table);
        unit_assert(table->num <= MAXHASH);
    }
}
예제 #4
0
/** test with long sequence of adds, removes and updates, and lookups */
static void
test_long_table(struct slabhash* table) 
{
	/* assuming it all fits in the hashtable, this check will work */
	testdata_type* ref[HASHTESTMAX * 100];
	size_t i;
	memset(ref, 0, sizeof(ref));
	/* test assumption */
	if(0) slabhash_status(table, "unit test", 1);
	srandom(48);
	for(i=0; i<1000; i++) {
		/* what to do? */
		if(i == 500) {
			slabhash_clear(table);
			memset(ref, 0, sizeof(ref));
			continue;
		}
		switch(random() % 4) {
			case 0:
			case 3:
				testadd(table, ref);
				break;
			case 1:
				testremove(table, ref);
				break;
			case 2:
				testlookup(table, ref);
				break;
			default:
				unit_assert(0);
		}
		if(0) slabhash_status(table, "unit test", 1);
		check_table(table);
	}

	/* test more, but 'ref' assumption does not hold anymore */
	for(i=0; i<1000; i++) {
		/* what to do? */
		switch(random() % 4) {
			case 0:
			case 3:
				testadd_unlim(table, ref);
				break;
			case 1:
				testremove_unlim(table, ref);
				break;
			case 2:
				testlookup_unlim(table, ref);
				break;
			default:
				unit_assert(0);
		}
		if(0) slabhash_status(table, "unlim", 1);
		check_table(table);
	}
}
예제 #5
0
void
testRoutine1(uint64_t arg)
{
    int size=1024;
    char str[size];

    HomeDir_printStats(homedir, str, size);
    printf("%s\n", str);
    testcreate();
    HomeDir_printStats(homedir, str, size);
    printf("%s\n", str);
    testget();
    HomeDir_printStats(homedir, str, size);
    printf("%s\n", str);
    testremove();
    HomeDir_printStats(homedir, str, size);
    printf("%s\n", str);
    fthKill(222);
}
void testRoutine1(uint64_t arg) {
	int size = 1024;
	char str[size];

	int seq = __sync_fetch_and_add(&g_seq, 1);
	printf("\n%d fth begins\n", seq);
	HomeDir_printStats(homedir, str, size);
	printf("%s\n", str);
	if (seq % 3 == 0) {
		testcreate(seq);
	} else if (seq % 3 == 1) {
		testget(seq);
	} else if (seq % 3 == 2) {
		testremove(seq);
	}
	if (__sync_add_and_fetch(&threads_done, 1) == nthreads * ncores) {
		printf("\nTotal Iterations Completed: %d\n", nthreads * ncores);
		fthKill(222);
	}
	printf("\n%d ends\n", seq);
	fthYield(1);
}