int run_main (int argc, ACE_TCHAR *argv[]) { ACE_START_TEST (ACE_TEXT ("Map_Manager_Test")); ACE_LOG_MSG->clr_flags (ACE_Log_Msg::VERBOSE_LITE); int result = 0; size_t table_size = ACE_MAX_ITERATIONS / 2; size_t iterations = ACE_MAX_ITERATIONS; int test_iterators = 1; if (argc > 1) table_size = ACE_OS::atoi (argv[1]); if (argc > 2) iterations = ACE_OS::atoi (argv[2]); if (argc > 3) test_iterators = ACE_OS::atoi (argv[3]); if (table_size == 0) { ACE_ERROR ((LM_ERROR, "LM_ERROR@Table size is 0\n")); ++result; } else { // Test the <ACE_Map_Manager>. result += run_test (&test_map_manager, table_size, iterations, test_iterators, ACE_TEXT ("Map_Manager")); // Test the <ACE_Hash_Map_Manager>. result += run_test (&test_hash_map_manager, table_size, iterations, test_iterators, ACE_TEXT ("Hash_Map_Manager")); // Test the <ACE_Hash_Map_Manager>. result += run_test (&test_active_map_manager, table_size, iterations, test_iterators, ACE_TEXT ("Active_Map_Manager")); // Test the <ACE_Cache_Map_Manager>. result += run_test (&test_cache_map_manager, table_size, iterations, test_iterators, ACE_TEXT ("Cache_Map_Manager")); // Test the <ACE_Hash_Cache_Map_Manager>. result += run_test (&test_hash_cache_map_manager, table_size, iterations, test_iterators, ACE_TEXT ("Hash_Cache_Map_Manager")); } ACE_LOG_MSG->set_flags (ACE_Log_Msg::VERBOSE_LITE); ACE_END_TEST; return result; }
/* * Take one step along the current "run" path * * Called with a real direction to begin a new run, and with zero * to continue a run in progress. */ void run_step(int dir) { int x, y; /* Start run */ if (dir) { /* Initialize */ run_init(dir); /* Hack -- Set the run counter */ p_ptr->running = (p_ptr->command_arg ? p_ptr->command_arg : 1000); /* Calculate torch radius */ p_ptr->update |= (PU_TORCH); } /* Continue run */ else { if (!p_ptr->running_withpathfind) { /* Update run */ if (run_test()) { /* Disturb */ disturb(0, 0); /* Done */ return; } } else { /* Abort if we have finished */ if (pf_result_index < 0) { disturb(0, 0); p_ptr->running_withpathfind = FALSE; return; } /* Abort if we would hit a wall */ else if (pf_result_index == 0) { /* Get next step */ y = p_ptr->py + ddy[pf_result[pf_result_index] - '0']; x = p_ptr->px + ddx[pf_result[pf_result_index] - '0']; /* Known wall */ if ((cave_info[y][x] & (CAVE_MARK)) && !cave_floor_bold(y, x)) { disturb(0,0); p_ptr->running_withpathfind = FALSE; return; } } /* * Hack -- walking stick lookahead. * * If the player has computed a path that is going to end up in a wall, * we notice this and convert to a normal run. This allows us to click * on unknown areas to explore the map. * * We have to look ahead two, otherwise we don't know which is the last * direction moved and don't initialise the run properly. */ else if (pf_result_index > 0) { /* Get next step */ y = p_ptr->py + ddy[pf_result[pf_result_index] - '0']; x = p_ptr->px + ddx[pf_result[pf_result_index] - '0']; /* Known wall */ if ((cave_info[y][x] & (CAVE_MARK)) && !cave_floor_bold(y, x)) { disturb(0,0); p_ptr->running_withpathfind = FALSE; return; } /* Get step after */ y = y + ddy[pf_result[pf_result_index-1] - '0']; x = x + ddx[pf_result[pf_result_index-1] - '0']; /* Known wall */ if ((cave_info[y][x] & (CAVE_MARK)) && !cave_floor_bold(y, x)) { p_ptr->running_withpathfind = FALSE; run_init(pf_result[pf_result_index] - '0'); } } p_ptr->run_cur_dir = pf_result[pf_result_index--] - '0'; } } /* Decrease counter */ p_ptr->running--; /* Take time */ p_ptr->energy_use = 100; /* Move the player */ move_player(p_ptr->run_cur_dir); }
int main(void) { run_test(test); return 0; }
int main(int argc, char *argv[]) { MPI_Init(&argc, &argv); mpi = vex::mpi::comm_data(MPI_COMM_WORLD); if (mpi.rank == 0) std::cout << "World size: " << mpi.size << std::endl; try { vex::Context ctx( vex::Filter::Exclusive( vex::Filter::Env && vex::Filter::Count(1) ) ); mpi.precondition(!ctx.empty(), "No OpenCL devices found"); for(int i = 0; i < mpi.size; ++i) { if (i == mpi.rank) std::cout << mpi.rank << ": " << ctx.device(0) << std::endl; MPI_Barrier(mpi.comm); } boost::this_thread::sleep_for(boost::chrono::milliseconds(100)); if (mpi.rank == 0) std::cout << std::endl; run_test("Allocate mpi::vector", [&]() -> bool { const size_t n = 1024; bool rc = true; vex::mpi::vector<double> x(mpi.comm, ctx, n); rc = rc && x.local_size() == n; rc = rc && x.global_size() == n * mpi.size; return rc; }); run_test("Assign constant to mpi::vector", [&]() -> bool { const size_t n = 1024; bool rc = true; vex::mpi::vector<double> x(mpi.comm, ctx, n); x = 42; rc = rc && x[n/2] == 42; return rc; }); run_test("Copy constructor for mpi::vector", [&]() -> bool { const size_t n = 1024; bool rc = true; vex::mpi::vector<double> x(mpi.comm, ctx, n); x = 42; vex::mpi::vector<double> y = x; rc = rc && y[n/2] == 42; return rc; }); run_test("Assign arithmetic expression to mpi::vector", [&]() -> bool { const size_t n = 1024; bool rc = true; vex::mpi::vector<double> x(mpi.comm, ctx, n); vex::mpi::vector<double> y(mpi.comm, ctx, n); x = 42; y = vex::cos(x / 7); rc = rc && fabs(y[n/2] - cos(6.0)) < 1e-8; return rc; }); run_test("Reduce mpi::vector", [&]() -> bool { const size_t n = 1024; bool rc = true; vex::mpi::vector<double> x(mpi.comm, ctx, n); vex::mpi::Reductor<double, vex::SUM> sum(mpi.comm, ctx); x = 1; rc = rc && fabs(sum(x) - x.global_size()) < 1e-8; return rc; }); run_test("Allocate mpi::multivector", [&]() -> bool { const size_t n = 1024; const size_t m = 3; bool rc = true; vex::mpi::multivector<double,m> x(mpi.comm, ctx, n); rc = rc && x.local_size() == n; rc = rc && x.global_size() == n * mpi.size; return rc; }); run_test("Assign constant to mpi::multivector", [&]() -> bool { const size_t n = 1024; const size_t m = 3; bool rc = true; vex::mpi::multivector<double,m> x(mpi.comm, ctx, n); x = 42; rc = rc && x(0)[n/2] == 42; rc = rc && x(1)[n/2] == 42; rc = rc && x(2)[n/2] == 42; x = std::make_tuple(6, 7, 42); rc = rc && x(0)[n/2] == 6; rc = rc && x(1)[n/2] == 7; rc = rc && x(2)[n/2] == 42; return rc; }); run_test("Assign arithmetic expression to mpi::multivector", [&]() -> bool { const size_t n = 1024; const size_t m = 3; bool rc = true; vex::mpi::multivector<double,m> x(mpi.comm, ctx, n); vex::mpi::multivector<double,m> y(mpi.comm, ctx, n); x = std::make_tuple(6, 7, 42); y = vex::cos(x / 7); rc = rc && fabs(y(0)[n/2] - cos(6.0 / 7.0)) < 1e-8; rc = rc && fabs(y(1)[n/2] - cos(7.0 / 7.0)) < 1e-8; rc = rc && fabs(y(2)[n/2] - cos(42.0 / 7.0)) < 1e-8; return rc; }); run_test("Reduce mpi::multivector", [&]() -> bool { const size_t n = 1024; const size_t m = 3; bool rc = true; vex::mpi::multivector<double, m> x(mpi.comm, ctx, n); vex::mpi::Reductor<double, vex::SUM> sum(mpi.comm, ctx); x = std::make_tuple(1, 2, 3); auto s = sum(x); rc = rc && fabs(s[0] - 1 * x.global_size()) < 1e-8; rc = rc && fabs(s[1] - 2 * x.global_size()) < 1e-8; rc = rc && fabs(s[2] - 3 * x.global_size()) < 1e-8; return rc; }); run_test("Assign multiexpression to mpi::multivector", [&]() -> bool { const size_t n = 1024; const size_t m = 3; bool rc = true; vex::mpi::multivector<double, m> x(mpi.comm, ctx, n); vex::mpi::vector<double> y0(mpi.comm, ctx, n); vex::mpi::vector<double> y1(mpi.comm, ctx, n); y0 = 1; y1 = 2; int the_answer = 42; x = std::tie(y1 - y0, y1 + y0, the_answer); rc = rc && x(0)[42] == 1; rc = rc && x(1)[42] == 3; rc = rc && x(2)[42] == 42; return rc; }); run_test("Assign multiexpression to tied mpi::vectors", [&]() -> bool { const size_t n = 1024; bool rc = true; vex::mpi::vector<double> x0(mpi.comm, ctx, n); vex::mpi::vector<double> x1(mpi.comm, ctx, n); vex::mpi::vector<double> x2(mpi.comm, ctx, n); vex::mpi::vector<double> y0(mpi.comm, ctx, n); vex::mpi::vector<double> y1(mpi.comm, ctx, n); y0 = 1; y1 = 2; int the_answer = 42; vex::tie(x0, x1, x2) = std::tie(y1 - y0, y1 + y0, the_answer); rc = rc && x0[42] == 1; rc = rc && x1[42] == 3; rc = rc && x2[42] == 42; return rc; }); run_test("Matrix-vector product", [&]() -> bool { const size_t n = 1024; const size_t m = 3; const size_t n2 = n * n; bool rc = true; size_t chunk_size = (n2 + mpi.size - 1) / mpi.size; size_t chunk_start = chunk_size * mpi.rank; size_t chunk_end = std::min(n2, chunk_start + chunk_size); chunk_size = chunk_end - chunk_start; auto part = mpi.restore_partitioning(chunk_size); std::vector<int> row; std::vector<int> col; std::vector<double> val; row.reserve(chunk_size + 1); col.reserve(5 * chunk_size); val.reserve(5 * chunk_size); row.push_back(0); for(size_t idx = part[mpi.rank]; idx < part[mpi.rank + 1]; ++idx) { size_t i = idx % n; size_t j = idx / n; if (i == 0 || i + 1 == n || j == 0 || j + 1 == n) { col.push_back(idx); val.push_back(0); } else { col.push_back(idx - n); val.push_back(-1); col.push_back(idx - 1); val.push_back(-1); col.push_back(idx); val.push_back(4.5); col.push_back(idx + 1); val.push_back(-1); col.push_back(idx + n); val.push_back(-1); } row.push_back(col.size()); } vex::mpi::SpMat<double, int, int> A(mpi.comm, ctx, chunk_size, chunk_size, row.data(), col.data(), val.data() ); vex::mpi::vector<double> x(mpi.comm, ctx, chunk_size); vex::mpi::vector<double> y(mpi.comm, ctx, chunk_size); vex::mpi::multivector<double, m> mx(mpi.comm, ctx, chunk_size); vex::mpi::multivector<double, m> my(mpi.comm, ctx, chunk_size); x = 1; y = A * x; mx = std::make_tuple(1, 2, 3); my = A * mx; vex::mpi::Reductor<double, vex::MIN> min(mpi.comm, ctx); vex::mpi::Reductor<double, vex::MAX> max(mpi.comm, ctx); vex::mpi::Reductor<double, vex::SUM> sum(mpi.comm, ctx); rc = rc && min(y) == 0; rc = rc && max(y) == 0.5; rc = rc && sum(y) == 0.5 * (n - 2) * (n - 2); auto vmin = min(my); auto vmax = max(my); auto vsum = sum(my); for(size_t i = 0; i < m; ++i) { rc = rc && vmin[i] == 0; rc = rc && vmax[i] == 0.5 * (i + 1); rc = rc && vsum[i] == 0.5 * (i + 1) * (n - 2) * (n - 2); } return rc; }); run_test("Use element_index in mpi::vector expression", [&]() -> bool { const size_t n = 1024; bool rc = true; vex::mpi::vector<double> x(mpi.comm, ctx, n); auto part = mpi.restore_partitioning(n); x = vex::element_index(part[mpi.rank]); for (int i = 0; i < 100; ++i) { size_t idx = rand() % n; rc = rc && x[idx] == part[mpi.rank] + idx; } return rc; }); } catch (const cl::Error &err) { std::cerr << "OpenCL error (" << mpi.rank << "): " << err << std::endl; } catch (const std::exception &err) { std::cerr << "Error (" << mpi.rank << "): " << err.what() << std::endl; } MPI_Finalize(); return !all_passed; }
void node_testmess(xml_data_node *node) { xml_data_node *child_node; xml_attribute_node *attr_node; int result; pile_init(&command_pile); command_pool = pool_alloc_lib(NULL); memset(&new_command, 0, sizeof(new_command)); command_count = 0; /* 'driver' attribute */ attr_node = xml_get_attribute(node, "driver"); if (!attr_node) { error_missingattribute("driver"); return; } current_testcase.driver = attr_node->value; /* 'name' attribute */ attr_node = xml_get_attribute(node, "name"); current_testcase.name = attr_node ? attr_node->value : current_testcase.driver; /* 'bios' attribute */ attr_node = xml_get_attribute(node, "bios"); current_testcase.bios = attr_node ? attr_node->value : NULL; /* 'ramsize' attribute */ attr_node = xml_get_attribute(node, "ramsize"); current_testcase.ram = attr_node ? ram_parse_string(attr_node->value) : 0; /* 'wavwrite' attribute */ attr_node = xml_get_attribute(node, "wavwrite"); current_testcase.wavwrite = attr_node && (atoi(attr_node->value) != 0); /* 'enabled' attribute */ attr_node = xml_get_attribute(node, "enabled"); current_testcase.enabled = (!attr_node || atoi(attr_node->value)) ? TRUE : FALSE; /* report the beginning of the test case */ report_testcase_begin(current_testcase.name); if (current_testcase.enabled) { current_testcase.commands = NULL; for (child_node = node->child; child_node; child_node = child_node->next) { if (!strcmp(child_node->name, "wait")) node_wait(child_node); else if (!strcmp(child_node->name, "input")) node_input(child_node); else if (!strcmp(child_node->name, "rawinput")) node_rawinput(child_node); else if (!strcmp(child_node->name, "switch")) node_switch(child_node); else if (!strcmp(child_node->name, "screenshot")) node_screenshot(child_node); else if (!strcmp(child_node->name, "checkblank")) node_checkblank(child_node); else if (!strcmp(child_node->name, "imagecreate")) node_imagecreate(child_node); else if (!strcmp(child_node->name, "imageload")) node_imageload(child_node); else if (!strcmp(child_node->name, "memverify")) node_memverify(child_node); else if (!strcmp(child_node->name, "imageverify")) node_imageverify(child_node); else if (!strcmp(child_node->name, "trace")) node_trace(child_node); else if (!strcmp(child_node->name, "reset")) node_soft_reset(child_node); else if (!strcmp(child_node->name, "hardreset")) node_hard_reset(child_node); } memset(&new_command, 0, sizeof(new_command)); new_command.command_type = MESSTEST_COMMAND_END; if (!append_command()) { error_outofmemory(); return; } result = run_test(0, NULL); } else { /* report that the test case was skipped */ report_message(MSG_INFO, "Test case skipped"); result = 0; } report_testcase_ran(result); pile_delete(&command_pile); pool_free_lib(command_pool); }
int main(int argc, char *argv[]) { struct weston_config *config; struct weston_config_section *section; const char *name; char *s; int r, b, i; int32_t n; uint32_t u; config = run_test(t0); assert(config); weston_config_destroy(config); config = run_test(t1); assert(config); section = weston_config_get_section(config, "mollusc", NULL, NULL); assert(section == NULL); section = weston_config_get_section(config, "foo", NULL, NULL); r = weston_config_section_get_string(section, "a", &s, NULL); assert(r == 0 && strcmp(s, "b") == 0); free(s); section = weston_config_get_section(config, "foo", NULL, NULL); r = weston_config_section_get_string(section, "b", &s, NULL); assert(r == -1 && errno == ENOENT && s == NULL); section = weston_config_get_section(config, "foo", NULL, NULL); r = weston_config_section_get_string(section, "name", &s, NULL); assert(r == 0 && strcmp(s, "Roy Batty") == 0); free(s); section = weston_config_get_section(config, "bar", NULL, NULL); r = weston_config_section_get_string(section, "a", &s, "boo"); assert(r == -1 && errno == ENOENT && strcmp(s, "boo") == 0); free(s); section = weston_config_get_section(config, "bar", NULL, NULL); r = weston_config_section_get_int(section, "number", &n, 600); assert(r == 0 && n == 5252); section = weston_config_get_section(config, "bar", NULL, NULL); r = weston_config_section_get_int(section, "+++", &n, 700); assert(r == -1 && errno == ENOENT && n == 700); section = weston_config_get_section(config, "bar", NULL, NULL); r = weston_config_section_get_uint(section, "number", &u, 600); assert(r == 0 && u == 5252); section = weston_config_get_section(config, "bar", NULL, NULL); r = weston_config_section_get_uint(section, "+++", &u, 600); assert(r == -1 && errno == ENOENT && u == 600); section = weston_config_get_section(config, "bar", NULL, NULL); r = weston_config_section_get_bool(section, "flag", &b, 600); assert(r == 0 && b == 0); section = weston_config_get_section(config, "stuff", NULL, NULL); r = weston_config_section_get_bool(section, "flag", &b, -1); assert(r == 0 && b == 1); section = weston_config_get_section(config, "stuff", NULL, NULL); r = weston_config_section_get_bool(section, "bonk", &b, -1); assert(r == -1 && errno == ENOENT && b == -1); section = weston_config_get_section(config, "bucket", "color", "blue"); r = weston_config_section_get_string(section, "contents", &s, NULL); assert(r == 0 && strcmp(s, "live crabs") == 0); free(s); section = weston_config_get_section(config, "bucket", "color", "red"); r = weston_config_section_get_string(section, "contents", &s, NULL); assert(r == 0 && strcmp(s, "sand") == 0); free(s); section = weston_config_get_section(config, "bucket", "color", "pink"); assert(section == NULL); r = weston_config_section_get_string(section, "contents", &s, "eels"); assert(r == -1 && errno == ENOENT && strcmp(s, "eels") == 0); free(s); section = NULL; i = 0; while (weston_config_next_section(config, §ion, &name)) assert(strcmp(section_names[i++], name) == 0); assert(i == 5); weston_config_destroy(config); config = run_test(t2); assert(config == NULL); config = run_test(t3); assert(config == NULL); config = run_test(t4); assert(config == NULL); weston_config_destroy(NULL); assert(weston_config_next_section(NULL, NULL, NULL) == 0); section = weston_config_get_section(NULL, "bucket", NULL, NULL); assert(section == NULL); return 0; }
void compares_tests(void) { test_fixture_start(); fixture_setup(&setup); run_test(test_eq_compare_true); run_test(test_eq_compare_false); run_test(test_ne_compare_true); run_test(test_ne_compare_false); run_test(test_lt_compare_true); run_test(test_lt_compare_false); run_test(test_le_compare_true); run_test(test_le_compare_false); run_test(test_ge_compare_true); run_test(test_ge_compare_false); run_test(test_gt_compare_true); run_test(test_gt_compare_false); run_test(test_compares_prefer_numbers); run_test(test_compares_convert_string_to_numbers); run_test(test_leading_spaces_ok); run_test(test_trailing_spaces_ok); run_test(test_spaces_before_op_ok); run_test(test_spaces_after_op_ok); run_test(test_spaces_in_op_fail); run_test(test_wrong_op_fail); test_fixture_end(); }
TEST_F(MemoryFootprintTest, test_TC_MEMKIND_DEFAULT_only_malloc_large_allocations_1_thread) { run_test(MEMKIND_DEFAULT, 2 * MB, 10 * MB, 1, 1.0, 100); }
TEST_F(MemoryFootprintTest, test_TC_MEMKIND_DEFAULT_random_malloc80_free20_random_small_allocations_10_thread) { run_test(MEMKIND_DEFAULT, 128, 15 * KB, 10, 0.8); }
TEST_F(MemoryFootprintTest, test_TC_MEMKIND_DEFAULT_only_malloc_small_allocations_1_thread) { run_test(MEMKIND_DEFAULT, 128, 15 * KB, 1); }
TEST_F(MemoryFootprintTest, test_TC_MEMKIND_DEFAULT_only_malloc_medium_allocations_1_thread) { run_test(MEMKIND_DEFAULT, 16 * KB, 1 * MB, 1); }
static bool run_test(const char *cmd, struct test *test) { char *output; FILE *outf; int status; if (test->done) return test->answer; if (test->depends) { size_t len; const char *deps = test->depends; char *dep; /* Space-separated dependencies, could be ! for inverse. */ while ((len = strcspn(deps, " "))) { bool positive = true; if (deps[len]) { dep = strdup(deps); dep[len] = '\0'; } else { dep = (char *)deps; } if (dep[0] == '!') { dep++; positive = false; } if (run_test(cmd, find_test(dep)) != positive) { test->answer = false; test->done = true; return test->answer; } deps += len; deps += strspn(deps, " "); } } outf = fopen(INPUT_FILE, "w"); if (!outf) err(1, "creating %s", INPUT_FILE); fprintf(outf, "%s", PRE_BOILERPLATE); switch (test->style & ~(EXECUTE|MAY_NOT_COMPILE)) { case INSIDE_MAIN: fprintf(outf, "%s", MAIN_START_BOILERPLATE); fprintf(outf, "%s", test->fragment); fprintf(outf, "%s", MAIN_END_BOILERPLATE); break; case OUTSIDE_MAIN: fprintf(outf, "%s", test->fragment); fprintf(outf, "%s", MAIN_START_BOILERPLATE); fprintf(outf, "%s", MAIN_BODY_BOILERPLATE); fprintf(outf, "%s", MAIN_END_BOILERPLATE); break; case DEFINES_FUNC: fprintf(outf, "%s", test->fragment); fprintf(outf, "%s", MAIN_START_BOILERPLATE); fprintf(outf, "%s", USE_FUNC_BOILERPLATE); fprintf(outf, "%s", MAIN_BODY_BOILERPLATE); fprintf(outf, "%s", MAIN_END_BOILERPLATE); break; case DEFINES_EVERYTHING: fprintf(outf, "%s", test->fragment); break; default: abort(); } fclose(outf); if (verbose > 1) if (system("cat " INPUT_FILE) == -1); if (test->link) { char *newcmd; newcmd = malloc(strlen(cmd) + strlen(" ") + strlen(test->link) + 1); sprintf(newcmd, "%s %s", cmd, test->link); if (verbose > 1) printf("Extra link line: %s", newcmd); cmd = newcmd; } output = run(cmd, &status); if (status != 0 || strstr(output, "warning")) { if (verbose) printf("Compile %s for %s, status %i: %s\n", status ? "fail" : "warning", test->name, status, output); if ((test->style & EXECUTE) && !(test->style & MAY_NOT_COMPILE)) errx(1, "Test for %s did not compile:\n%s", test->name, output); test->answer = false; free(output); } else { /* Compile succeeded. */ free(output); /* We run INSIDE_MAIN tests for sanity checking. */ if ((test->style & EXECUTE) || (test->style & INSIDE_MAIN)) { output = run("./" OUTPUT_FILE, &status); if (!(test->style & EXECUTE) && status != 0) errx(1, "Test for %s failed with %i:\n%s", test->name, status, output); if (verbose && status) printf("%s exited %i\n", test->name, status); free(output); } test->answer = (status == 0); } test->done = true; if (test->answer && test->overrides) { struct test *override = find_test(test->overrides); override->done = true; override->answer = true;
THD_FUNCTION(Thread1, arg) { (void)arg; /* * Activate the serial driver 0 using the driver default configuration. */ sdStart(&SD1, NULL); /* Activate the ADC driver 1 using its config */ adcStart(&ADCD1, &config); while (chnGetTimeout(&SD1, TIME_INFINITE)) { print(start_msg); chThdSleepMilliseconds(2000); /* Test 1 - 1ch1d, no circular */ run_test(test_1_msg, 1, 1, false); /* Test 2 - 1ch8d, no circular */ run_test(test_2_msg, 1, 8, false); /* Test 3 - 4chd1, no circular */ run_test(test_3_msg, 4, 1, false); /* Test 4 - 4ch8d, no circular */ run_test(test_4_msg, 4, 8, false); /* Test 5 - 1ch1d, circular */ run_test(test_5_msg, 1, 1, true); /* Test 6 - 1ch8d, circular */ run_test(test_6_msg, 1, 8, true); /* Test 7 - 4ch1d, circular */ run_test(test_7_msg, 4, 1, true); /* Test 8 - 4ch8d, circular */ run_test(test_8_msg, 4, 8, true); /* Test 9 - 1ch1d, synchronous */ print(test_9_msg); cb_arg = 0; group.num_channels = 1; group.circular = false; group.end_cb = adc_callback; cb_expect = 1; adcConvert(&ADCD1, &group, buffer, 1); while (ADCD1.state == ADC_ACTIVE) ; sniprintf(out_string, 128, chn_fmt_string, group.channels[0]); print(out_string); sniprintf(out_string, 128, raw_fmt_string, buffer[0]); print(out_string); buffer[0] = adcMSP430XAdjustTemp(&group, buffer[0]); sniprintf(out_string, 128, cooked_fmt_string, buffer[0]); print(out_string); if (cb_arg == cb_expect) { print(success_string); } else { print(fail_string); } } }
void test_fixture_part1(void) { test_fixture_start(); run_test(test_ft_memset); run_test(test_ft_bzero); run_test(test_ft_memcpy); run_test(test_ft_memccpy); run_test(test_ft_memmove); run_test(test_ft_memchr); run_test(test_ft_memcmp); run_test(test_ft_strlen); run_test(test_ft_strdup); run_test(test_ft_strcpy); run_test(test_ft_strncpy); run_test(test_ft_strcat); run_test(test_ft_strncat); run_test(test_ft_strlcat); run_test(test_ft_strchr); run_test(test_ft_strrchr); run_test(test_ft_strstr); run_test(test_ft_strnstr); run_test(test_ft_strcmp); run_test(test_ft_strncmp); run_test(test_ft_atoi); run_test(test_ft_isalpha); run_test(test_ft_isdigit); run_test(test_ft_isalnum); run_test(test_ft_isascii); run_test(test_ft_isprint); run_test(test_ft_toupper); run_test(test_ft_tolower); test_fixture_end(); }
END_TEST START_TEST(test_proto2_interrupt) { run_test(0, PROTO_2, 10, 100, setup_asfds_proto2_interrupt); }
TEST_F(MemoryFootprintTest, test_TC_MEMKIND_DEFAULT_random_malloc80_free20_random_medium_allocations_1_thread) { run_test(MEMKIND_DEFAULT, 16 * KB, 1 * MB, 1, 0.8); }
END_TEST START_TEST(test_proto2_interrupt_no_match) { run_test(0, PROTO_2, 10, 5, setup_asfds_proto2_interrupt_no_match); }
TEST_F(MemoryFootprintTest, test_TC_MEMKIND_HBW_only_malloc_small_allocations_10_thread) { run_test(MEMKIND_HBW, 128, 15 * KB, 10); }
// ---- testing ------ //To compile: gcc eigen_decomp.c -lm //The lm links with the math library so we can use sqrt int main() { run_test(); return 0; }
TEST_F(MemoryFootprintTest, test_TC_MEMKIND_HBW_only_malloc_medium_allocations_10_thread) { run_test(MEMKIND_HBW, 16 * KB, 1 * MB, 10); }
void menu() { small_uint_t cmd; int full_duplex; printf(&debug, "Free memory: %d bytes\n", mem_available(&pool)); printf(&debug, "Ethernet: %s", eth_get_carrier(ð) ? "Cable OK" : "No cable"); if (eth_get_speed(ð, &full_duplex)) { printf(&debug, ", %s", full_duplex ? "Full Duplex" : "Half Duplex"); } printf(&debug, ", %u interrupts\n", eth.intr); printf(&debug, "Transmit: %ld packets, %ld collisions, %ld errors\n", eth.netif.out_packets, eth.netif.out_collisions, eth.netif.out_errors); printf(&debug, "Receive: %ld packets, %ld errors, %ld lost\n", eth.netif.in_packets, eth.netif.in_errors, eth.netif.in_discards); printf(&debug, "\n 1. Transmit 1 packet"); printf(&debug, "\n 2. Transmit 2 packets"); printf(&debug, "\n 3. Transmit 8 packets"); printf(&debug, "\n 4. Run send/receive test"); printf(&debug, "\n 5. Packet size: %d bytes", packet_size); printf(&debug, "\n 6. Local loopback: %s", local_loop ? "Enabled" : "Disabled"); puts(&debug, "\n\n"); for (;;) { /* Ввод команды. */ puts(&debug, "Command: "); while (peekchar (&debug) < 0) timer_delay(&timer, 50); cmd = getchar(&debug); putchar(&debug, '\n'); if (cmd == '\n' || cmd == '\r') break; if (cmd == '1') { send_packets(1); break; } if (cmd == '2') { send_packets(2); break; } if (cmd == '3') { send_packets(8); break; } if (cmd == '4') { run_test(); break; } if (cmd == '5') { try_again: printf(&debug, "Enter packet size (1-1518): "); packet_size = get_short(packet_size); if (packet_size <= 0 || packet_size > 1518) { printf(&debug, "Invalid value, try again."); goto try_again; } putchar(&debug, '\n'); data_pattern = mem_realloc(data_pattern, packet_size); if (!data_pattern) { printf(&debug, "No memory for data_pattern\n"); uos_halt(1); } int i; for (i = 0; i < packet_size; i++) data_pattern[i] = i; if (packet_size >= 6) memset(data_pattern, 0xFF, 6); if (packet_size >= 12) memcpy(data_pattern + 6, eth.netif.ethaddr, 6); break; } if (cmd == '6') { local_loop = !local_loop; eth_set_loop(ð, local_loop); break; } if (cmd == CTL('E')) { /* Регистры Ethernet. */ putchar(&debug, '\n'); eth_debug(ð, &debug); putchar(&debug, '\n'); continue; } if (cmd == CTL('T')) { /* Список задач uOS. */ printf(&debug, "\nFree memory: %u bytes\n\n", mem_available(&pool)); task_print(&debug, 0); task_print(&debug, (task_t*) stack_console); task_print(&debug, (task_t*) stack_test); task_print(&debug, (task_t*) eth.stack); putchar(&debug, '\n'); continue; } } }
TEST_F(MemoryFootprintTest, test_TC_MEMKIND_HBW_only_malloc_large_allocations_10_thread) { run_test(MEMKIND_HBW, 2 * MB, 10 * MB, 10, 100); }
int main(int argc, char *argv[]) { int c; int test_loops = 1; int test_normal = FALSE; int test_optimize = FALSE; setlocale(LC_ALL, ""); while ((c = getopt(argc, argv, "cf:h:l:norsx")) != -1) { switch (c) { case 'c': continuous = TRUE; break; case 'f': foot_lines = atoi(optarg); break; case 'h': head_lines = atoi(optarg); break; case 'l': test_loops = atoi(optarg); assert(test_loops >= 0); break; case 'n': test_normal = TRUE; break; case 'o': test_optimize = TRUE; break; case 'r': reverse_loops = TRUE; break; case 's': single_step = TRUE; break; case 'x': extend_corner = TRUE; break; default: usage(); } } if (!test_normal && !test_optimize) { test_normal = TRUE; test_optimize = TRUE; } #if USE_TRACE trace(TRACE_TIMES); #endif CATCHALL(finish); /* arrange interrupts to terminate */ (void) initscr(); /* initialize the curses library */ keypad(stdscr, TRUE); /* enable keyboard mapping */ (void) nonl(); /* tell curses not to do NL->CR/NL on output */ (void) cbreak(); /* take input chars one at a time, no wait for \n */ (void) noecho(); /* don't echo input */ scrollok(stdscr, TRUE); while (test_loops-- > 0) { if (test_normal) run_test(FALSE); if (test_optimize) run_test(TRUE); } cleanup(); /* we're done */ ExitProgram(EXIT_SUCCESS); }
TEST_F(MemoryFootprintTest, test_TC_MEMKIND_HBW_random_malloc80_free20_random_small_allocations_1_thread) { run_test(MEMKIND_HBW, 128, 15 * KB, 1, 0.8); }
int main (int argc, char **argv) { int retval,cid,rapl_cid=-1,numcmp; int EventSet = PAPI_NULL; long long *values; int num_events=0; int code; char event_names[MAX_RAPL_EVENTS][PAPI_MAX_STR_LEN]; char units[MAX_RAPL_EVENTS][PAPI_MIN_STR_LEN]; int data_type[MAX_RAPL_EVENTS]; int r,i, do_wrap = 0; const PAPI_component_info_t *cmpinfo = NULL; PAPI_event_info_t evinfo; long long before_time,after_time; double elapsed_time; /* Set TESTS_QUIET variable */ tests_quiet( argc, argv ); if ( argc > 1 ) if ( strstr( argv[1], "-w" ) ) do_wrap = 1; /* PAPI Initialization */ retval = PAPI_library_init( PAPI_VER_CURRENT ); if ( retval != PAPI_VER_CURRENT ) { test_fail(__FILE__, __LINE__,"PAPI_library_init failed\n",retval); } if (!TESTS_QUIET) { printf("Trying all RAPL events\n"); } numcmp = PAPI_num_components(); for(cid=0; cid<numcmp; cid++) { if ( (cmpinfo = PAPI_get_component_info(cid)) == NULL) { test_fail(__FILE__, __LINE__,"PAPI_get_component_info failed\n", 0); } if (strstr(cmpinfo->name,"rapl")) { rapl_cid=cid; if (!TESTS_QUIET) { printf("Found rapl component at cid %d\n",rapl_cid); } if (cmpinfo->disabled) { if (!TESTS_QUIET) { printf("RAPL component disabled: %s\n", cmpinfo->disabled_reason); } test_skip(__FILE__,__LINE__,"RAPL component disabled",0); } break; } } /* Component not found */ if (cid==numcmp) { test_skip(__FILE__,__LINE__,"No rapl component found\n",0); } /* Create EventSet */ retval = PAPI_create_eventset( &EventSet ); if (retval != PAPI_OK) { test_fail(__FILE__, __LINE__, "PAPI_create_eventset()",retval); } /* Add all events */ code = PAPI_NATIVE_MASK; r = PAPI_enum_cmp_event( &code, PAPI_ENUM_FIRST, rapl_cid ); while ( r == PAPI_OK ) { retval = PAPI_event_code_to_name( code, event_names[num_events] ); if ( retval != PAPI_OK ) { printf("Error translating %#x\n",code); test_fail( __FILE__, __LINE__, "PAPI_event_code_to_name", retval ); } retval = PAPI_get_event_info(code,&evinfo); if (retval != PAPI_OK) { test_fail( __FILE__, __LINE__, "Error getting event info\n",retval); } strncpy(units[num_events],evinfo.units,sizeof(units[0])-1); // buffer must be null terminated to safely use strstr operation on it below units[num_events][sizeof(units[0])-1] = '\0'; data_type[num_events] = evinfo.data_type; retval = PAPI_add_event( EventSet, code ); if (retval != PAPI_OK) { break; /* We've hit an event limit */ } num_events++; r = PAPI_enum_cmp_event( &code, PAPI_ENUM_EVENTS, rapl_cid ); } values=calloc(num_events,sizeof(long long)); if (values==NULL) { test_fail(__FILE__, __LINE__, "No memory",retval); } if (!TESTS_QUIET) { printf("\nStarting measurements...\n\n"); } /* Start Counting */ before_time=PAPI_get_real_nsec(); retval = PAPI_start( EventSet); if (retval != PAPI_OK) { test_fail(__FILE__, __LINE__, "PAPI_start()",retval); } /* Run test */ run_test(TESTS_QUIET); /* Stop Counting */ after_time=PAPI_get_real_nsec(); retval = PAPI_stop( EventSet, values); if (retval != PAPI_OK) { test_fail(__FILE__, __LINE__, "PAPI_stop()",retval); } elapsed_time=((double)(after_time-before_time))/1.0e9; if (!TESTS_QUIET) { printf("\nStopping measurements, took %.3fs, gathering results...\n\n", elapsed_time); printf("Scaled energy measurements:\n"); for(i=0;i<num_events;i++) { if (strstr(units[i],"nJ")) { printf("%-40s%12.6f J\t(Average Power %.1fW)\n", event_names[i], (double)values[i]/1.0e9, ((double)values[i]/1.0e9)/elapsed_time); } } printf("\n"); printf("Energy measurement counts:\n"); for(i=0;i<num_events;i++) { if (strstr(event_names[i],"ENERGY_CNT")) { printf("%-40s%12lld\t%#08llx\n", event_names[i], values[i], values[i]); } } printf("\n"); printf("Scaled Fixed values:\n"); for(i=0;i<num_events;i++) { if (!strstr(event_names[i],"ENERGY")) { if (data_type[i] == PAPI_DATATYPE_FP64) { union { long long ll; double fp; } result; result.ll=values[i]; printf("%-40s%12.3f %s\n", event_names[i], result.fp, units[i]); } } } printf("\n"); printf("Fixed value counts:\n"); for(i=0;i<num_events;i++) { if (!strstr(event_names[i],"ENERGY")) { if (data_type[i] == PAPI_DATATYPE_UINT64) { printf("%-40s%12lld\t%#08llx\n", event_names[i], values[i], values[i]); } } } } #ifdef WRAP_TEST double max_time; unsigned long long max_value = 0; int repeat; for(i=0;i<num_events;i++) { if (strstr(event_names[i],"ENERGY_CNT")) { if (max_value < (unsigned) values[i]) { max_value = values[i]; } } } max_time = elapsed_time * (0xffffffff / max_value); printf("\n"); printf ("Approximate time to energy measurement wraparound: %.3f sec or %.3f min.\n", max_time, max_time/60); if (do_wrap) { printf ("Beginning wraparound execution."); /* Start Counting */ before_time=PAPI_get_real_nsec(); retval = PAPI_start( EventSet); if (retval != PAPI_OK) { test_fail(__FILE__, __LINE__, "PAPI_start()",retval); } /* Run test */ repeat = (int)(max_time/elapsed_time); for (i=0;i< repeat;i++) { run_test(1); printf("."); fflush(stdout); } printf("\n"); /* Stop Counting */ after_time=PAPI_get_real_nsec(); retval = PAPI_stop( EventSet, values); if (retval != PAPI_OK) { test_fail(__FILE__, __LINE__, "PAPI_stop()",retval); } elapsed_time=((double)(after_time-before_time))/1.0e9; printf("\nStopping measurements, took %.3fs\n\n", elapsed_time); printf("Scaled energy measurements:\n"); for(i=0;i<num_events;i++) { if (strstr(units[i],"nJ")) { printf("%-40s%12.6f J\t(Average Power %.1fW)\n", event_names[i], (double)values[i]/1.0e9, ((double)values[i]/1.0e9)/elapsed_time); } } printf("\n"); printf("Energy measurement counts:\n"); for(i=0;i<num_events;i++) { if (strstr(event_names[i],"ENERGY_CNT")) { printf("%-40s%12lld\t%#08llx\n", event_names[i], values[i], values[i]); } } } #endif /* Done, clean up */ retval = PAPI_cleanup_eventset( EventSet ); if (retval != PAPI_OK) { test_fail(__FILE__, __LINE__, "PAPI_cleanup_eventset()",retval); } retval = PAPI_destroy_eventset( &EventSet ); if (retval != PAPI_OK) { test_fail(__FILE__, __LINE__, "PAPI_destroy_eventset()",retval); } test_pass( __FILE__, NULL, 0 ); return 0; }
TEST_F(MemoryFootprintTest, test_TC_MEMKIND_HBW_random_malloc80_free20_random_medium_allocations_10_thread) { run_test(MEMKIND_HBW, 16 * KB, 1 * MB, 10, 0.8); }
int main(int argc, char **argv) { for (unsigned i = 0; i < NUM_RUNS; i++) run_test(); }
TEST_F(MemoryFootprintTest, test_TC_MEMKIND_HBW_random_malloc80_free20_random_large_allocations_10_thread) { run_test(MEMKIND_HBW, 2 * MB, 10 * MB, 10, 0.8, 100); }
static int run_one_test(int dropMode, int serverFinishedPermute, int serverHelloPermute, int clientFinishedPermute) { int fnIdx = 0; int res, filterIdx; filter_fn* local_filters = full ? filters_full : filters; const char** local_filter_names = full ? filter_names_full : filter_names; const char** permutation_namesX = full ? permutation_names5 : permutation_names3; int filter_count = full ? 12 : 8; run_id = ((dropMode * 2 + serverFinishedPermute) * (full ? 120 : 6) + serverHelloPermute) * (full ? 120 : 6) + clientFinishedPermute; filter_clear_state(); if (full) { filter_chain[fnIdx++] = filter_permute_ServerHelloFull; state_permute_ServerHelloFull.order = permutations5[serverHelloPermute]; filter_chain[fnIdx++] = filter_permute_ClientFinishedFull; state_permute_ClientFinishedFull.order = permutations5[clientFinishedPermute]; } else { filter_chain[fnIdx++] = filter_permute_ServerHello; state_permute_ServerHello.order = permutations3[serverHelloPermute]; filter_chain[fnIdx++] = filter_permute_ClientFinished; state_permute_ClientFinished.order = permutations3[clientFinishedPermute]; } filter_chain[fnIdx++] = filter_permute_ServerFinished; state_permute_ServerFinished.order = permutations2[serverFinishedPermute]; if (dropMode) { for (filterIdx = 0; filterIdx < filter_count; filterIdx++) { if (dropMode & (1 << filterIdx)) { filter_chain[fnIdx++] = local_filters[filterIdx]; } } } filter_chain[fnIdx++] = NULL; res = run_test(); switch (res) { case 0: fprintf(stdout, "%i ++ ", run_id); break; case 1: fprintf(stdout, "%i -- ", run_id); break; case 2: fprintf(stdout, "%i !! ", run_id); break; case 3: fprintf(stdout, "%i TT ", run_id); break; } fprintf(stdout, "SHello(%s), ", permutation_namesX[serverHelloPermute]); fprintf(stdout, "SFinished(%s), ", permutation_names2[serverFinishedPermute]); fprintf(stdout, "CFinished(%s) :- ", permutation_namesX[clientFinishedPermute]); if (dropMode) { for (filterIdx = 0; filterIdx < filter_count; filterIdx++) { if (dropMode & (1 << filterIdx)) { if (dropMode & ((1 << filterIdx) - 1)) { fprintf(stdout, ", "); } fprintf(stdout, "%s", local_filter_names[filterIdx]); } } } fprintf(stdout, "\n"); return res; }
rc_t run_tests (void) { VDBManager * mgr; rc_t rc; if (verbose) printf("%s call VDBManagerMakeUpdate\n", __func__); rc = VDBManagerMakeUpdate (&mgr, NULL); if (rc) { LOGERR (klogInt, rc, "Failed to open VDBManager"); return rc; } else { VSchema * schema; if (verbose) printf("%s call VDBManagerMakeSchema\n", __func__); rc = VDBManagerMakeSchema (mgr, &schema); printf("%s schema == %p\n", __func__, (void*)schema); if (rc) LOGERR (klogInt, rc, "Failed to make empty schema"); else { if(verbose) printf("%s call VSchemaParseText\n", __func__); rc = VSchemaParseText (schema, "rowlen_schema", schema_text, string_size (schema_text)); if (rc) LOGERR (klogInt, rc, "Failed to parse internal schema"); else { int ix; for ( ix = 0; ix < 6; ++ix) { VTable * table; rc_t orc; if (verbose) printf("%s call open_table\n", __func__); rc = open_table (mgr, schema, &table); if (rc) { LOGERR (klogErr, rc, "Failed to open table"); break; } if (verbose) printf("%s call run_test\n", __func__); rc = run_test (table, &tests[ix]); if (rc) { pLOGERR (klogErr, rc, "Failed $(D)", PLOG_S(D), tests[ix].test_name); } if (verbose) printf("%s call VTableRelease\n", __func__); orc = VTableRelease (table); if (orc) { LOGERR (klogErr, rc, "failed to close table"); } if (orc && (rc == 0)) rc = orc; if (rc) break; } } if (verbose) printf("%s call VSchemaRelease\n", __func__); VSchemaRelease (schema); } if (verbose) printf("%s call VDBManagerRelease\n", __func__); VDBManagerRelease (mgr); } return rc; }