int do_hw_test(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) { char *cmd; if (argc != 2) { printf("Usage:\n%s\n", cmdtp->usage); return 1; } cmd = argv[1]; switch (cmd[0]) { case 'a': /* all */ test_pld(); test_led(); test_dipsw(); test_sm107(); test_net(); test_sata(); test_pci(); break; case 'p': /* pld or pci */ if (cmd[1] == 'l') test_pld(); else test_pci(); break; case 'l': /* led */ test_led(); break; case 'd': /* dipsw */ test_dipsw(); break; case 's': /* sm107 or sata */ if (cmd[1] == 'm') test_sm107(); else test_sata(); break; case 'n': /* net */ test_net(); break; default: printf("Usage:\n%s\n", cmdtp->usage); return 1; } return 0; }
int main(int, char**) { srand(time(0)); ON_3dPoint center(0.0, 0.0, 0.0); double radius = 10.0; ON_Sphere sphere(center, radius); ON_Brep *brep = ON_BrepSphere(sphere); ON_3dPoint p1(0.0, 0.0, 0.0); ON_3dPoint p2(0.0, 0.0, radius); // Point-point intersection bu_log("*** Point-point intersection ***\n"); test_ppi(p1, p1); test_ppi(p1, p2); // Point-curve intersection bu_log("*** Point-curve intersection ***\n"); // brep->m_C3[0] is an arc curve that starts from (0, 0, -R) // to (0, 0, R) through (R, 0, 0) which forms a semicircle. ON_Curve *curve = brep->m_C3[0]; ON_3dPoint mid = curve->PointAt(curve->Domain().Mid()); bu_log("debug: %f %f %f\n", mid[0], mid[1], mid[2]); bu_log("** Part 1 **\n"); test_pci(p1, *curve); test_pci(p2, *curve); // Now we use some randomized points (should intersect) bu_log("** Part 2 **\n"); for (int i = 0; i < 10; i++) { double x = rand_f(0.0, radius); double y = 0.0; double z = sqrt(radius*radius-x*x); if (rand() % 2) z = -z; // sometimes we have it negative ON_3dPoint test_pt(x, y, z); test_pci(test_pt, *curve); } // More randomize points (maybe no intersection) bu_log("** Part 3 **\n"); for (int i = 0; i < 10; i++) { // We use test points randomly distributed inside a cube // from (-R, -R, -R) to (R, R, R) double x = rand_f(-radius, radius); double y = rand_f(-radius, radius); double z = rand_f(-radius, radius); ON_3dPoint test_pt(x, y, z); test_pci(test_pt, *curve); } // Point-surface intersection bu_log("*** Point-surface intersection ***\n"); bu_log("** Part 1 **\n"); ON_Surface *surf = brep->m_S[0]; test_psi(p1, *surf); test_psi(p2, *surf); // Now we use some randomized points (should intersect) bu_log("** Part 2 **\n"); for (int i = 0; i < 10; i++) { double x = rand_f(-radius, radius); double y_range = sqrt(radius*radius-x*x); double y = rand_f(-y_range, y_range); double z = sqrt(y_range*y_range-y*y); if (rand() % 2) z = -z; // sometimes we have it negative ON_3dPoint test_pt(x, y, z); test_psi(test_pt, *surf); } // More randomize points (maybe no intersection) bu_log("** Part 3 **\n"); for (int i = 0; i < 10; i++) { // We use test points randomly distributed inside a cube // from (-R, -R, -R) to (R, R, R) double x = rand_f(-radius, radius); double y = rand_f(-radius, radius); double z = rand_f(-radius, radius); ON_3dPoint test_pt(x, y, z); test_psi(test_pt, *surf); } delete brep; bu_log("All finished.\n"); return 0; }
/* * This function is run in the secondary instance to test that creation of * objects fails in a secondary */ static int run_object_creation_tests(void) { const unsigned flags = 0; const unsigned size = 1024; const unsigned elt_size = 64; const unsigned cache_size = 64; const unsigned priv_data_size = 32; printf("### Testing object creation - expect lots of mz reserve errors!\n"); rte_errno = 0; if ((rte_memzone_reserve("test_mz", size, rte_socket_id(), flags) == NULL) && (rte_memzone_lookup("test_mz") == NULL)) { printf("Error: unexpected return value from rte_memzone_reserve\n"); return -1; } printf("# Checked rte_memzone_reserve() OK\n"); rte_errno = 0; if ((rte_ring_create( "test_ring", size, rte_socket_id(), flags) == NULL) && (rte_ring_lookup("test_ring") == NULL)){ printf("Error: unexpected return value from rte_ring_create()\n"); return -1; } printf("# Checked rte_ring_create() OK\n"); rte_errno = 0; if ((rte_mempool_create("test_mp", size, elt_size, cache_size, priv_data_size, NULL, NULL, NULL, NULL, rte_socket_id(), flags) == NULL) && (rte_mempool_lookup("test_mp") == NULL)){ printf("Error: unexpected return value from rte_mempool_create()\n"); return -1; } printf("# Checked rte_mempool_create() OK\n"); #ifdef RTE_LIBRTE_HASH const struct rte_hash_parameters hash_params = { .name = "test_mp_hash" }; rte_errno=0; if ((rte_hash_create(&hash_params) != NULL) && (rte_hash_find_existing(hash_params.name) == NULL)){ printf("Error: unexpected return value from rte_hash_create()\n"); return -1; } printf("# Checked rte_hash_create() OK\n"); const struct rte_fbk_hash_params fbk_params = { .name = "test_fbk_mp_hash" }; rte_errno=0; if ((rte_fbk_hash_create(&fbk_params) != NULL) && (rte_fbk_hash_find_existing(fbk_params.name) == NULL)){ printf("Error: unexpected return value from rte_fbk_hash_create()\n"); return -1; } printf("# Checked rte_fbk_hash_create() OK\n"); #endif #ifdef RTE_LIBRTE_LPM rte_errno=0; struct rte_lpm_config config; config.max_rules = rte_socket_id(); config.number_tbl8s = 256; config.flags = 0; if ((rte_lpm_create("test_lpm", size, &config) != NULL) && (rte_lpm_find_existing("test_lpm") == NULL)){ printf("Error: unexpected return value from rte_lpm_create()\n"); return -1; } printf("# Checked rte_lpm_create() OK\n"); #endif /* Run a test_pci call */ if (test_pci() != 0) { printf("PCI scan failed in secondary\n"); if (getuid() == 0) /* pci scans can fail as non-root */ return -1; } else printf("PCI scan succeeded in secondary\n"); return 0; } /* if called in a primary process, just spawns off a secondary process to * run validation tests - which brings us right back here again... * if called in a secondary process, this runs a series of API tests to check * how things run in a secondary instance. */ int test_mp_secondary(void) { if (rte_eal_process_type() == RTE_PROC_PRIMARY) { if (!test_pci_run) { printf("=== Running pre-requisite test of test_pci\n"); test_pci(); printf("=== Requisite test done\n"); } return run_secondary_instances(); } printf("IN SECONDARY PROCESS\n"); return run_object_creation_tests(); } static struct test_command multiprocess_cmd = { .command = "multiprocess_autotest", .callback = test_mp_secondary, }; REGISTER_TEST_COMMAND(multiprocess_cmd);