Home | History | Annotate | Line # | Download | only in integration
      1      1.1  christos #include "test/jemalloc_test.h"
      2      1.1  christos 
      3      1.1  christos void *
      4      1.1  christos thd_start(void *arg) {
      5      1.1  christos 	bool e0, e1;
      6      1.1  christos 	size_t sz = sizeof(bool);
      7  1.1.1.2  christos 	expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz, NULL,
      8      1.1  christos 	    0), 0, "Unexpected mallctl failure");
      9      1.1  christos 
     10      1.1  christos 	if (e0) {
     11      1.1  christos 		e1 = false;
     12  1.1.1.2  christos 		expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz,
     13      1.1  christos 		    (void *)&e1, sz), 0, "Unexpected mallctl() error");
     14  1.1.1.2  christos 		expect_true(e0, "tcache should be enabled");
     15      1.1  christos 	}
     16      1.1  christos 
     17      1.1  christos 	e1 = true;
     18  1.1.1.2  christos 	expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz,
     19      1.1  christos 	    (void *)&e1, sz), 0, "Unexpected mallctl() error");
     20  1.1.1.2  christos 	expect_false(e0, "tcache should be disabled");
     21      1.1  christos 
     22      1.1  christos 	e1 = true;
     23  1.1.1.2  christos 	expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz,
     24      1.1  christos 	    (void *)&e1, sz), 0, "Unexpected mallctl() error");
     25  1.1.1.2  christos 	expect_true(e0, "tcache should be enabled");
     26      1.1  christos 
     27      1.1  christos 	e1 = false;
     28  1.1.1.2  christos 	expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz,
     29      1.1  christos 	    (void *)&e1, sz), 0, "Unexpected mallctl() error");
     30  1.1.1.2  christos 	expect_true(e0, "tcache should be enabled");
     31      1.1  christos 
     32      1.1  christos 	e1 = false;
     33  1.1.1.2  christos 	expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz,
     34      1.1  christos 	    (void *)&e1, sz), 0, "Unexpected mallctl() error");
     35  1.1.1.2  christos 	expect_false(e0, "tcache should be disabled");
     36      1.1  christos 
     37      1.1  christos 	free(malloc(1));
     38      1.1  christos 	e1 = true;
     39  1.1.1.2  christos 	expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz,
     40      1.1  christos 	    (void *)&e1, sz), 0, "Unexpected mallctl() error");
     41  1.1.1.2  christos 	expect_false(e0, "tcache should be disabled");
     42      1.1  christos 
     43      1.1  christos 	free(malloc(1));
     44      1.1  christos 	e1 = true;
     45  1.1.1.2  christos 	expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz,
     46      1.1  christos 	    (void *)&e1, sz), 0, "Unexpected mallctl() error");
     47  1.1.1.2  christos 	expect_true(e0, "tcache should be enabled");
     48      1.1  christos 
     49      1.1  christos 	free(malloc(1));
     50      1.1  christos 	e1 = false;
     51  1.1.1.2  christos 	expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz,
     52      1.1  christos 	    (void *)&e1, sz), 0, "Unexpected mallctl() error");
     53  1.1.1.2  christos 	expect_true(e0, "tcache should be enabled");
     54      1.1  christos 
     55      1.1  christos 	free(malloc(1));
     56      1.1  christos 	e1 = false;
     57  1.1.1.2  christos 	expect_d_eq(mallctl("thread.tcache.enabled", (void *)&e0, &sz,
     58      1.1  christos 	    (void *)&e1, sz), 0, "Unexpected mallctl() error");
     59  1.1.1.2  christos 	expect_false(e0, "tcache should be disabled");
     60      1.1  christos 
     61      1.1  christos 	free(malloc(1));
     62      1.1  christos 	return NULL;
     63      1.1  christos }
     64      1.1  christos 
     65      1.1  christos TEST_BEGIN(test_main_thread) {
     66      1.1  christos 	thd_start(NULL);
     67      1.1  christos }
     68      1.1  christos TEST_END
     69      1.1  christos 
     70      1.1  christos TEST_BEGIN(test_subthread) {
     71      1.1  christos 	thd_t thd;
     72      1.1  christos 
     73      1.1  christos 	thd_create(&thd, thd_start, NULL);
     74      1.1  christos 	thd_join(thd, NULL);
     75      1.1  christos }
     76      1.1  christos TEST_END
     77      1.1  christos 
     78      1.1  christos int
     79      1.1  christos main(void) {
     80      1.1  christos 	/* Run tests multiple times to check for bad interactions. */
     81      1.1  christos 	return test(
     82      1.1  christos 	    test_main_thread,
     83      1.1  christos 	    test_subthread,
     84      1.1  christos 	    test_main_thread,
     85      1.1  christos 	    test_subthread,
     86      1.1  christos 	    test_main_thread);
     87      1.1  christos }
     88