cmd_result_t test_parameters(int u, args_t *a) /* * Function: test_parameters * Purpose: Set the parameters for the specified tests. * Parameters: u - unit number * a - arguments, expects tuples of the form: * [Test name/#] Arguments. * if arguments is null string ("") then previously * set arguments are discarded and defaults used. * Returns: cmd_result_t. */ { char *tid, *p; /* Testid, parameters */ test_t *t; /* Test pointer */ COMPILER_REFERENCE(u); if (0 == ARG_CNT(a)) { return(CMD_USAGE); } while (NULL != (tid = ARG_GET(a))) { p = ARG_GET(a); /* Parameter */ t = test_find(tid); if (NULL == t) { printk("%s: Error: Unable to find test: %s\n", ARG_CMD(a), tid); return(CMD_FAIL); } if (!p || !*p) { /* Clear parameter */ if (!t->t_override_string) { printk("%s: Warning: No arguments to clear for test: %s\n", ARG_CMD(a), t->t_name); continue; } sal_free(t->t_override_string); t->t_override_string = NULL; } else { /* Set Arguments */ if (t->t_override_string) { sal_free(t->t_override_string); } if (!(t->t_override_string = (char *)sal_alloc(strlen(p) + 1, "test_parm"))) { printk("%s: Error: Out of memory\n", ARG_CMD(a)); return(CMD_FAIL); } sal_strcpy(t->t_override_string, p); printk("%s: Parameter set: %s(\"%s\")\n", ARG_CMD(a), t->t_name, t->t_override_string); } } return(CMD_OK); }
void test() { unsigned s=0; for(auto r=Range(flags); +r ; ++r) s+=(*r); if( s!=count ) fail(2); for(ulen cnt=1000; cnt ; cnt--) { test_find(); } }
int main(int argc, char* argv[]) { test_basic(); test_iteration(); test_find(); test_erase(); test_list(); test_unordered(); int a = sizeof(obj); int b = sizeof(boost::optional<obj&>); int xx = 0; return boost::report_errors(); }
void test_slist(struct cag_test_series *tests) { test_it(tests); test_new(tests); test_prepend(tests); test_insert(tests); test_insertp(tests); test_distance(tests); test_front(tests); test_erase(tests); test_copy(tests); test_reverse(tests); test_copy_over(tests); test_sort(tests); test_find(tests); }
void test_insert( uint32_t num_nodes , uint32_t num_inserts , uint32_t num_duplicates , bool near ) { typedef Kokkos::UnorderedMap<uint32_t,uint32_t, Device> map_type; typedef Kokkos::UnorderedMap<const uint32_t,const uint32_t, Device> const_map_type; const uint32_t expected_inserts = (num_inserts + num_duplicates -1u) / num_duplicates; map_type map; map.rehash(num_nodes,false); if (near) { Impl::TestInsert<map_type,true> test_insert(map, num_inserts, num_duplicates); test_insert.testit(); } else { Impl::TestInsert<map_type,false> test_insert(map, num_inserts, num_duplicates); test_insert.testit(); } const bool print_list = false; if (print_list) { Kokkos::Impl::UnorderedMapPrint<map_type> f(map); f.apply(); } const uint32_t map_size = map.size(); ASSERT_FALSE( map.failed_insert()); { EXPECT_EQ(expected_inserts, map_size); { uint32_t find_errors = 0; Impl::TestFind<const_map_type> test_find(map, num_inserts, num_duplicates); test_find.testit(find_errors); EXPECT_EQ( 0u, find_errors); } map.begin_erase(); Impl::TestErase<map_type,false> test_erase(map, num_inserts, num_duplicates); test_erase.testit(); map.end_erase(); EXPECT_EQ(0u, map.size()); } }
cmd_result_t test_run(int u, args_t *a) /* * Function: test_run * Purpose: Perform "run" command for test. * Parameters: none - Run all selected tests with loaded parameters. * "test [options]" * Returns: Test result. */ { test_t *test; int rv; int loops = -1; if (test_active) { cli_out("%s: Already running: %s\n", ARG_CMD(a), test_active->t_name); return(CMD_FAIL); } else if (!sh_check_attached(ARG_CMD(a), u)) { return(CMD_FAIL); } if (!ARG_CNT(a)) { rv = test_run_selected(u); } else { if (NULL == (test = test_find(ARG_CUR(a)))) { cli_out("%s: Unknown test: %s\n", ARG_CMD(a), ARG_CUR(a)); return(CMD_FAIL); } if (!(test->t_flags & _test_chip(u)) && !(test_options & TEST_O_OVERRIDE)) { cli_out("Error: Test %d (%s) not supported on %s\n" "Error: use \"testmode +override\" to override and run\n", test->t_test, test->t_name, SOC_UNIT_GROUP(u)); return(CMD_FAIL); } ARG_NEXT(a); /* Move arg pointer */ /* If there is an argument which is an integer, it's a loop count */ if (ARG_CUR(a) && isint(ARG_CUR(a))) { loops = strtoul(_ARG_GET(a), NULL, 10); } rv = test_dispatch(u, test, loops, ARG_CNT(a) ? a : NULL); } return(rv == TEST_INTR ? CMD_INTR : rv); }
void test_buildin() { int failures=0; printf("*** Testing of builtin ***\n"); failures += test_length(); failures += test_copy(); failures += test_find(); failures += test_sort(); if(failures) { printf("\n\n!!! ERROR has occured during testing !!!\n\n"); } else { printf("\n\nOK. Everything is fine.\n\n"); } }
cmd_result_t test_clear(int u, args_t *a) /* * Function: test_clear * Purpose: Clear previous test results for a test. * Parameters: u - unit number * a - arguments, expects testname/#. * Returns: cmd_result_t */ { char *tid; test_t *t; COMPILER_REFERENCE(u); if (0 == ARG_CNT(a)) { return(CMD_USAGE); } while (NULL != (tid = ARG_GET(a))) { if (!strcmp(tid, "*")) { /* Clear all tests */ for (t = test_list; t < &test_list[test_cnt]; t++) { t->t_runs = 0; t->t_success = 0; t->t_fail = 0; } } else { /* Clear specific test */ t = test_find(tid); if (NULL == t) { cli_out("%s: Error: Unable to find test: %s\n", ARG_CMD(a), tid); return(CMD_FAIL); } t->t_runs = 0; t->t_success = 0; t->t_fail = 0; } } return(CMD_OK); }
void test_insert_close( uint32_t num_nodes , uint32_t num_inserts , uint32_t num_duplicates ) { typedef Kokkos::UnorderedMap<uint32_t,uint32_t, Device> map_type; typedef Kokkos::UnorderedMap<const uint32_t,const uint32_t, Device> const_map_type; const uint32_t expected_inserts = (num_inserts + num_duplicates -1u) / num_duplicates; map_type map(num_nodes); Device::fence(); Impl::test_insert_close<map_type> test_insert_close(map, num_inserts, num_duplicates); Device::fence(); const uint32_t map_size = map.size(); const bool failed_inserts = map.failed_inserts(); ASSERT_FALSE( failed_inserts ); if (!failed_inserts) { ASSERT_EQ(map_size, expected_inserts); { uint32_t find_errors = 0; Impl::test_find<const_map_type> test_find(map, num_inserts, num_duplicates, find_errors); ASSERT_EQ( find_errors, 0u); } map.begin_erase(); Impl::test_erase_close<map_type> erase_close(map, num_inserts, num_duplicates); map.end_erase(); ASSERT_EQ(map.size(), 0u); } }
int main (int argc, ACE_TCHAR *argv[]) { ACE_START_TEST (ACE_TEXT ("Naming_Test")); ACE_TCHAR temp_file [BUFSIZ]; ACE_Naming_Context *ns_context; ACE_NEW_RETURN (ns_context, ACE_Naming_Context, -1); ACE_Name_Options *name_options = ns_context->name_options (); name_options->parse_args (argc, argv); int unicode = 0; #if (defined (ACE_WIN32) && defined (ACE_USES_WCHAR)) unicode = 1; #endif /* ACE_WIN32 && ACE_USES_WCHAR */ if (unicode && name_options->use_registry () == 1) { name_options->namespace_dir (ACE_TEXT ("Software\\ACE\\Name Service")); name_options->database (ACE_TEXT ("Version 1")); } else { ACE_OS::strcpy (temp_file, ACE::basename (name_options->process_name (), ACE_DIRECTORY_SEPARATOR_CHAR)); ACE_OS_String::strcat (temp_file, ACE_TEXT ("XXXXXX")); // Set the database name using mktemp to generate a unique file name name_options->database (ACE_OS::mktemp (temp_file)); } ACE_ASSERT (ns_context->open (ACE_Naming_Context::PROC_LOCAL, 1) != -1); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("time to test %d iterations using %s\n"), ACE_NS_MAX_ENTRIES, name_options->use_registry () ? ACE_TEXT ("Registry") : ACE_TEXT ("ACE"))); ACE_Profile_Timer timer; timer.start (); // Add some bindings to the database test_bind (*ns_context); print_time (timer, "Binds"); timer.start (); // Should find the entries test_find (*ns_context, 1, 0); print_time (timer, "Successful Finds"); timer.start (); // Rebind with negative values test_rebind (*ns_context); print_time (timer, "Rebinds"); timer.start (); // Should find the entries test_find (*ns_context, -1, 0); print_time (timer, "Successful Finds"); timer.start (); // Should not find the entries test_find_failure (*ns_context); print_time (timer, "UnSuccessful Finds"); timer.start (); // Remove all bindings from database test_unbind (*ns_context); print_time (timer, "Unbinds"); ACE_OS::sprintf (temp_file, ACE_TEXT ("%s%s%s"), name_options->namespace_dir (), ACE_DIRECTORY_SEPARATOR_STR, name_options->database ()); delete ns_context; // Remove any existing files. No need to check return value here // since we don't care if the file doesn't exist. ACE_OS::unlink (temp_file); ACE_END_TEST; return 0; }
static int args_parse_test(cmd_args_t *args, char *str) { ListIterator si, ti; subsystem_t *s; test_t *t; char *sub_str, *test_str; int sub_num, test_num; int sub_all = 0, test_all = 0; int rc, flag = 0; test_str = strchr(str, ':'); if (test_str == NULL) { fprintf(stderr, "Test must be of the " "form <subsystem:test>\n"); return -EINVAL; } sub_str = str; test_str[0] = '\0'; test_str = test_str + 1; sub_num = strtol(sub_str, NULL, 0); test_num = strtol(test_str, NULL, 0); if (!strncasecmp(sub_str, "all", strlen(sub_str)) || (sub_num == -1)) sub_all = 1; if (!strncasecmp(test_str,"all",strlen(test_str)) || (test_num == -1)) test_all = 1; si = list_iterator_create(subsystems); if (sub_all) { if (test_all) { /* Add all tests from all subsystems */ while ((s = list_next(si))) { ti = list_iterator_create(s->sub_tests); while ((t = list_next(ti))) { if ((rc = test_add(args, t))) { list_iterator_destroy(ti); goto error_run; } } list_iterator_destroy(ti); } } else { /* Add a specific test from all subsystems */ while ((s = list_next(si))) { if ((t=test_find(s->sub_desc.name,test_str))) { if ((rc = test_add(args, t))) goto error_run; flag = 1; } } if (!flag) fprintf(stderr, "No tests '%s:%s' could be " "found\n", sub_str, test_str); } } else { if (test_all) { /* Add all tests from a specific subsystem */ while ((s = list_next(si))) { if (strncasecmp(sub_str, s->sub_desc.name, strlen(sub_str))) continue; ti = list_iterator_create(s->sub_tests); while ((t = list_next(ti))) { if ((rc = test_add(args, t))) { list_iterator_destroy(ti); goto error_run; } } list_iterator_destroy(ti); } } else { /* Add a specific test from a specific subsystem */ if ((t = test_find(sub_str, test_str))) { if ((rc = test_add(args, t))) goto error_run; } else { fprintf(stderr, "Test '%s:%s' could not be " "found\n", sub_str, test_str); return -EINVAL; } } } list_iterator_destroy(si); return 0; error_run: list_iterator_destroy(si); fprintf(stderr, "Test '%s:%s' not added to run list: %d\n", sub_str, test_str, rc); return rc; }
int run_main (int argc, ACE_TCHAR *argv[]) { ACE_START_TEST (ACE_TEXT ("Naming_Test")); ACE_TCHAR temp_file [BUFSIZ]; ACE_Naming_Context *ns_context = 0; ACE_NEW_RETURN (ns_context, ACE_Naming_Context, -1); ACE_Name_Options *name_options = ns_context->name_options (); name_options->parse_args (argc, argv); /* ** NOTE! This is an experimental value and is not magic in any way. It ** works for me, on one system. It's needed because in the particular ** case here where the underlying mmap will allocate a small area and ** then try to grow it, it always moves it to a new location, which ** totally screws things up. I once tried forcing the realloc to do ** MAP_FIXED but that's not a good solution since it may overwrite other ** mapped areas of memory, like the heap, or the C library, and get very ** unexpected results. (Steve Huston, 24-August-2007) */ # if defined (linux) && defined (__x86_64__) name_options->base_address ((char*)0x3c00000000); #endif bool unicode = false; #if (defined (ACE_WIN32) && defined (ACE_USES_WCHAR)) unicode = true; #endif /* ACE_WIN32 && ACE_USES_WCHAR */ if (unicode && name_options->use_registry () == 1) { name_options->namespace_dir (ACE_TEXT ("Software\\ACE\\Name Service")); name_options->database (ACE_TEXT ("Version 1")); } else { const ACE_TCHAR* pname = ACE::basename (name_options->process_name (), ACE_DIRECTORY_SEPARATOR_CHAR); // Allow the user to determine where the context file will be // located just in case the current directory is not suitable for // locking. We don't just set namespace_dir () on name_options // because that is not sufficient to work around locking problems // for Tru64 when the current directory is NFS mounted from a // system that does not properly support locking. ACE_TCHAR temp_dir [MAXPATHLEN]; if (ACE::get_temp_dir (temp_dir, MAXPATHLEN - 15) == -1) // -15 for ace-file-XXXXXX { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Temporary path too long, ") ACE_TEXT ("defaulting to current directory\n")), -1); } else { ACE_OS::chdir (temp_dir); } ACE_OS::strcpy (temp_file, pname); ACE_OS::strcat (temp_file, ACE_TEXT ("XXXXXX")); // Set the database name using mktemp to generate a unique file name name_options->database (ACE_OS::mktemp (temp_file)); } if (ns_context->open (ACE_Naming_Context::PROC_LOCAL, 1) == -1) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("ns_context->open (PROC_LOCAL) %p\n"), ACE_TEXT ("failed")), -1); } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("time to test %d iterations using %s\n"), ACE_NS_MAX_ENTRIES, name_options->use_registry () ? ACE_TEXT ("Registry") : ACE_TEXT ("ACE"))); ACE_Profile_Timer timer; timer.start (); // Add some bindings to the database test_bind (*ns_context); print_time (timer, "Binds"); timer.start (); // Should find the entries test_find (*ns_context, 1, 0); print_time (timer, "Successful Finds"); timer.start (); // Rebind with negative values test_rebind (*ns_context); print_time (timer, "Rebinds"); timer.start (); // Should find the entries test_find (*ns_context, -1, 0); print_time (timer, "Successful Finds"); timer.start (); // Should not find the entries test_find_failure (*ns_context); print_time (timer, "UnSuccessful Finds"); timer.start (); // Remove all bindings from database test_unbind (*ns_context); print_time (timer, "Unbinds"); ACE_OS::sprintf (temp_file, ACE_TEXT ("%s%s%s"), name_options->namespace_dir (), ACE_DIRECTORY_SEPARATOR_STR, name_options->database ()); delete ns_context; // Remove any existing files. No need to check return value here // since we don't care if the file doesn't exist. ACE_OS::unlink (temp_file); ACE_END_TEST; return 0; }
int main(int argc, char** argv) { test_find(); return 0; }
cmd_result_t test_print_list(int u, args_t *a) /* * Function: test_print_list * Purpose: Print some/all of the tests and status. * Parameters: u - unit # * "*" for all tests * List of tests * Nothing for all (same as *) * Returns: CMD_OK - success * CMD_FAIL - failed to find test or if a test failed. */ { test_t *test; char *s; int header = FALSE; int i, supported, all, fail; cmd_result_t result = CMD_OK; uint32 chip = _test_chip(u); int num_fail = 0; COMPILER_REFERENCE(u); /* Check for print all */ if (ARG_CNT(a) > 0) { supported = (0 == strcmp(_ARG_CUR(a), "*")); all = (0 == sal_strcasecmp(_ARG_CUR(a), "all")); fail = (0 == sal_strcasecmp(_ARG_CUR(a), "fail")); if (supported || all || fail) { /* Consume Argument */ ARG_NEXT(a); } } else if (ARG_CNT(a) == 0) { supported = TRUE; all = FALSE; fail = FALSE; } else { supported = FALSE; all = FALSE; fail = FALSE; } /* If "all" or supported, consume argument and list tests */ if (fail) { for (i = 0; i < test_cnt; i++) { if (test_list[i].t_fail) { cli_out("%d ", test_list[i].t_test); num_fail++; } } if (num_fail == 0) { cli_out("All tests passed"); } cli_out("\n"); return(result); } if (all || supported) { int t_loops = 0, t_runs = 0, t_success = 0, t_fail = 0; if (chip == 0) { /* No chip - print all */ all = TRUE; } test_print_header(TRUE); test_print_separator(); for (i = 0; i < test_cnt; i++) { if (all || (supported && (chip & test_list[i].t_flags)) || (test_list[i].t_flags & T_F_SEL_ALL)) { test_print_entry(u, &test_list[i]); t_loops += test_list[i].t_loops; t_runs += test_list[i].t_runs; t_success += test_list[i].t_success; t_fail += test_list[i].t_fail; } } test_print_summary(t_loops, t_runs, t_success, t_fail); test_print_separator(); /* In order for the automated tests to automatically diagnose that a test failed, we need this function to return something when an individual test fails. */ if (t_runs == 0) { /* * We want return CMD_FAIL if no tests were run */ result = CMD_FAIL; } else if (t_fail > 0) { /* * We also want to return CMD_FAIL if any tests failed. */ result = CMD_FAIL; } return(result); } while ((s = ARG_GET(a)) != NULL) { test = test_find(s); if (!test) { cli_out("%s: Unable to locate test: %s\n", ARG_CMD(a), s); result = CMD_FAIL; continue; } if (!header) { test_print_header(FALSE); test_print_separator(); header = TRUE; } test_print_entry(u, test); } return(result); }
cmd_result_t test_select(int u, args_t *a) /* * Function: test_select * Purpose: Select a set of tests, prefix with + to add, - to remove. * Parameters: u - unit # * a - list of tests to select, deselect (* means all) * Returns: 0 - success, -1 failed. */ { enum {ADD, DEL, XOR} option; int silent; cmd_result_t error = CMD_OK; char *s; test_t *ts, *te; /* Test start/end pointers */ COMPILER_REFERENCE(u); while ((s = ARG_GET(a)) != NULL) { if ('+' == *s) { option = ADD; s++; } else if ('-' == *s) { option = DEL; s++; } else { option = XOR; } if (!strcmp("*", s)) { /* Do it to all of the tests */ ts = &test_list[0]; te = &test_list[test_cnt-1]; silent = TRUE; } else { silent = FALSE; ts = te = test_find(s); if (!ts) { cli_out("%s: Unable to locate test: %s\n", ARG_CMD(a), s); return(CMD_FAIL); } } while (ts <= te) { switch(option) { case ADD: error = _test_select(u, ts, silent); break; case DEL: _test_unselect(u, ts); break; case XOR: if (_test_select_check(u, ts)) { _test_unselect(u, ts); } else { error = _test_select(u, ts, silent); } break; } ts++; } } return(error); }
void runTest() { Source a ("a"); Source b ("b"); Source c ("c"); Source d ("d"); Source e ("e"); Source f ("f"); Source g ("g"); // // a { b { d { f }, e }, c { g } } // a.add ( b ); a.add ( c ); c.add ( g ); b.add ( d ); b.add ( e ); d.add ( f ); beginTestCase ("peel_name"); test_peel_name ("a", "a", ""); test_peel_name ("foo/bar", "foo", "bar"); test_peel_name ("foo/goo/bar", "foo", "goo/bar"); test_peel_name ("", "", ""); beginTestCase ("peel_leading_slash"); test_peel_leading_slash ("foo/", "foo/", false); test_peel_leading_slash ("foo", "foo", false); test_peel_leading_slash ("/foo/", "foo/", true); test_peel_leading_slash ("/foo", "foo", true); beginTestCase ("peel_trailing_slashstar"); test_peel_trailing_slashstar ("/foo/goo/*", "/foo/goo", true); test_peel_trailing_slashstar ("foo/goo/*", "foo/goo", true); test_peel_trailing_slashstar ("/foo/goo/", "/foo/goo", false); test_peel_trailing_slashstar ("foo/goo", "foo/goo", false); test_peel_trailing_slashstar ("", "", false); test_peel_trailing_slashstar ("/", "", false); test_peel_trailing_slashstar ("/*", "", true); test_peel_trailing_slashstar ("//", "/", false); test_peel_trailing_slashstar ("**", "*", true); test_peel_trailing_slashstar ("*/", "*", false); beginTestCase ("find_one"); test_find_one (a, &b, "b"); test_find_one (a, nullptr, "d"); test_find_one (b, &e, "e"); test_find_one (d, &f, "f"); beginTestCase ("find_path"); test_find_path (a, "a", nullptr); test_find_path (a, "e", nullptr); test_find_path (a, "a/b", nullptr); test_find_path (a, "a/b/e", nullptr); test_find_path (a, "b/e/g", nullptr); test_find_path (a, "b/e/f", nullptr); test_find_path (a, "b", &b); test_find_path (a, "b/e", &e); test_find_path (a, "b/d/f", &f); beginTestCase ("find_one_deep"); test_find_one_deep (a, "z", nullptr); test_find_one_deep (a, "g", &g); test_find_one_deep (a, "b", &b); test_find_one_deep (a, "d", &d); test_find_one_deep (a, "f", &f); beginTestCase ("find"); test_find (a, "", &a, false); test_find (a, "*", &a, true); test_find (a, "/b", &b, false); test_find (a, "b", &b, false); test_find (a, "d", &d, false); test_find (a, "/b*", &b, true); test_find (a, "b*", &b, true); test_find (a, "d*", &d, true); test_find (a, "/b/*", &b, true); test_find (a, "b/*", &b, true); test_find (a, "d/*", &d, true); test_find (a, "a", nullptr, false); test_find (a, "/d", nullptr, false); test_find (a, "/d*", nullptr, true); test_find (a, "/d/*", nullptr, true); }