void main(void) { int rv; /* return value from tests */ TC_START("Test Nanokernel LIFO"); initNanoObjects(); /* * Start the fiber. The fiber will be given a higher priority than the * main task. */ task_fiber_start(fiberStack, FIBER_STACKSIZE, fiberEntry, 0, 0, FIBER_PRIORITY, 0); rv = taskLifoWaitTest(); if (rv == TC_PASS) { rv = taskLifoNonWaitTest(); } if (rv == TC_PASS) { rv = test_multiple_waiters(); } /* test timeouts */ if (rv == TC_PASS) { rv = test_timeout(); } TC_END_RESULT(rv); TC_END_REPORT(rv); }
void map_tests(void) { int i; fprintf(stderr, "Running map tests\n"); mapreduce_set_timeout(1); test_timeout(); for (i = 0; i < 100; ++i) { test_bad_syntax_functions(); test_runtime_exception(); test_runtime_error(); test_map_no_emit(); test_map_single_emit(); test_map_multiple_emits(); } test_timeout(); }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { int retval = 1; try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); if (parse_args (argc, argv) != 0) return 1; CORBA::Object_var tmp = orb->string_to_object(ior); CORBA::Object_var object = orb->resolve_initial_references ("PolicyCurrent"); CORBA::PolicyCurrent_var policy_current = CORBA::PolicyCurrent::_narrow (object.in ()); CORBA::Any timeout_as_any; timeout_as_any <<= timeout_period; CORBA::PolicyList policy_list (1); policy_list.length (1); policy_list[0] = orb->create_policy (TAO::CONNECTION_TIMEOUT_POLICY_TYPE, timeout_as_any); policy_current->set_policy_overrides (policy_list, CORBA::ADD_OVERRIDE); for (CORBA::ULong l = 0; l != policy_list.length (); ++l) { policy_list[l]->destroy (); } retval = test_timeout (tmp.in ()); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return retval; }
int main(void) { uint32_t n; uint32_t time; init_timeout(); time = 20; for (n=5; n<40; n++) { test_timeout(counter, n, time); } delete_timeout(); return 0; }
int run_main (int argc, ACE_TCHAR *argv[]) { ACE_START_TEST (ACE_TEXT ("Semaphore_Test")); #if defined (ACE_HAS_THREADS) parse_args (argc, argv); ACE_OS::srand (ACE_OS::time (0L)); # if !defined (ACE_HAS_STHREADS) && !defined (ACE_HAS_POSIX_SEM) //Test timed waits. for (size_t i = 0; i < test_timeout_count; i++) if (test_timeout () != 0) test_result = 1; # endif /* ACE_HAS_STHREADS && ACE_HAS_POSIX_SEM */ // Release the semaphore a certain number of times. s.release (n_release_count); if (ACE_Thread_Manager::instance ()->spawn_n (ACE_static_cast (size_t, n_workers), ACE_THR_FUNC (worker), 0, THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("spawn_n")), 1); ACE_Thread_Manager::instance ()->wait (); # if !defined (ACE_HAS_STHREADS) && !defined (ACE_HAS_POSIX_SEM) size_t percent = (timeouts * 100) / (n_workers * n_iterations); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Worker threads timed out %d percent of the time\n"), percent)); # endif /* ACE_HAS_STHREADS && ACE_HAS_POSIX_SEM */ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Semaphore Test successful\n"))); #else ACE_UNUSED_ARG (argc); ACE_UNUSED_ARG (argv); ACE_ERROR ((LM_INFO, ACE_TEXT ("Threads not supported on this platform\n"))); #endif /* ACE_HAS_THREADS */ ACE_END_TEST; return test_result; }
void main(void) { int rv; /* return value from tests */ TC_START("Test Nanokernel Semaphores"); initNanoObjects(); rv = testSemTaskNoWait(); if (rv != TC_PASS) { goto doneTests; } rv = testSemIsrNoWait(); if (rv != TC_PASS) { goto doneTests; } semTestState = STS_INIT; /* * Start the fiber. The fiber will be given a higher priority than the * main task. */ task_fiber_start(fiberStack, FIBER_STACKSIZE, fiberEntry, 0, 0, FIBER_PRIORITY, 0); rv = testSemWait(); if (rv != TC_PASS) { goto doneTests; } rv = test_multiple_waiters(); if (rv != TC_PASS) { goto doneTests; } rv = test_timeout(); if (rv != TC_PASS) { goto doneTests; } doneTests: TC_END_RESULT(rv); TC_END_REPORT(rv); }
int run_main (int argc, ACE_TCHAR *argv[]) { ACE_START_TEST (ACE_TEXT ("Auto_Event_Test")); #if defined (ACE_HAS_THREADS) parse_args (argc, argv); ACE_OS::srand ((u_int) ACE_OS::time (0L)); //Test timed waits. for (size_t i = 0; i < test_timeout_count; i++) if (test_timeout () != 0) test_result = 1; if (ACE_Thread_Manager::instance ()->spawn_n (static_cast<size_t> (n_workers), ACE_THR_FUNC (worker), 0, THR_NEW_LWP) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("spawn_n")), 1); // Release the first worker. evt.signal (); ACE_Thread_Manager::instance ()->wait (); size_t percent = (timeouts * 100) / (n_workers * n_iterations); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Worker threads timed out %d percent of the time\n"), (int)percent)); if (test_result == 0) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Auto_Event Test successful\n"))); #else ACE_UNUSED_ARG (argc); ACE_UNUSED_ARG (argv); ACE_ERROR ((LM_INFO, ACE_TEXT ("Threads not supported on this platform\n"))); #endif /* ACE_HAS_THREADS */ ACE_END_TEST; return test_result; }
static void test_reslist(abts_case *tc, void *data) { int i; apr_status_t rv; apr_reslist_t *rl; my_parameters_t *params; apr_thread_pool_t *thrp; my_thread_info_t thread_info[CONSUMER_THREADS]; rv = apr_thread_pool_create(&thrp, CONSUMER_THREADS/2, CONSUMER_THREADS, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); /* Create some parameters that will be passed into each * constructor and destructor call. */ params = apr_pcalloc(p, sizeof(*params)); params->sleep_upon_construct = CONSTRUCT_SLEEP_TIME; params->sleep_upon_destruct = DESTRUCT_SLEEP_TIME; /* We're going to want 10 blocks of data from our target rmm. */ rv = apr_reslist_create(&rl, RESLIST_MIN, RESLIST_SMAX, RESLIST_HMAX, RESLIST_TTL, my_constructor, my_destructor, params, p); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); for (i = 0; i < CONSUMER_THREADS; i++) { thread_info[i].tid = i; thread_info[i].tc = tc; thread_info[i].reslist = rl; thread_info[i].work_delay_sleep = WORK_DELAY_SLEEP_TIME; rv = apr_thread_pool_push(thrp, resource_consuming_thread, &thread_info[i], 0, NULL); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); } rv = apr_thread_pool_destroy(thrp); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); test_timeout(tc, rl); test_shrinking(tc, rl); ABTS_INT_EQUAL(tc, RESLIST_SMAX, params->c_count - params->d_count); rv = apr_reslist_destroy(rl); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); }
int main (int __sane_unused__ argc, char **argv) { int detected, opened, i; SANE_Int dn[MAX_DEVICES]; #ifdef HAVE_LIBUSB_LEGACY printf ("\n%s built with old libusb\n\n", argv[0]); #endif #ifdef HAVE_LIBUSB printf ("\n%s built with libusb-1.0\n\n", argv[0]); #endif #ifdef HAVE_USBCALLS printf ("\n%s built with usbcalls\n\n", argv[0]); #endif #if !defined(HAVE_LIBUSB_LEGACY) && !defined(HAVE_LIBUSB) && !defined(HAVE_USBCALLS) printf ("\n%s relying on deprecated scanner kernel module\n", argv[0]); #endif /* start sanei_usb */ assert (test_init (1)); /* test timeout function */ assert (test_timeout ()); /* count available devices */ detected = 0; for (i = 0; i < device_number; i++) { if (devices[i].missing == 0 && devices[i].devname != NULL) { detected++; } } printf ("%d devices found.\n", detected); /* rescan devices : detected count shouldn't change */ assert (test_scan_devices (detected, 0)); /* test corner cases with mock device */ assert (test_store_device ()); /* get vendor/product id for all available devices devname */ assert (test_vendor_by_devname ()); /* get vendor/product id for all available devices id */ assert (test_vendor_by_id ()); /* open all available devices */ assert (test_open_all (dn, detected)); opened = get_opened(); /* rescan devices : detected and opened count shouldn't change */ assert (test_scan_devices (detected, opened)); /* try to open an inexisting device */ assert (test_open_invalid ()); /* increase sanei _sub use count */ assert (test_init (2)); /* there should be still as many detected devices */ assert (count_detected (detected)); /* there should be still as many opened devices */ assert (count_opened (opened)); assert (test_exit (1)); /* there should be still as many opened devices */ assert (count_opened (opened)); /* count devices again , sanei_usb_exit() shouldn't have * change the count */ assert (count_detected (detected)); /* claim all available devices */ assert (test_claim_all (dn, opened)); /* then release them all */ assert (test_release_all (dn, opened)); /* close all opened devices */ assert (test_close_all (dn, opened)); /* check there is no opened device */ assert (count_opened (0)); /* finally free resources */ assert (test_exit (0)); /* check there is no more devices */ assert (count_detected (0)); /* test attach matching device with a mock */ assert (test_attach ()); /* try to call sanei_usb_exit() when it not initialized */ assert (test_exit (0)); /* scan devices when sanei usb is not initialized */ assert (test_scan_devices (0, 0)); /* we re start use of sanei usb so we check we have left it * it he correct state after "closing" it. */ printf ("\n============================================================\n"); printf ("restart use of sanei usb after having freed all resources...\n\n"); assert (test_init (1)); /* we should have the same initial count of detected devices */ assert (count_detected (detected)); /* finally free resources */ assert (test_exit (0)); /* all the tests are OK ! */ return 0; }
/** * @brief Entry point to timer tests * * This is the entry point to the CPU and thread tests. * * @return N/A */ void main(void) { int rv; /* return value from tests */ thread_detected_error = 0; thread_evidence = 0; TC_START("Test kernel CPU and thread routines"); TC_PRINT("Initializing kernel objects\n"); rv = kernel_init_objects(); if (rv != TC_PASS) { goto tests_done; } #ifdef HAS_POWERSAVE_INSTRUCTION TC_PRINT("Testing k_cpu_idle()\n"); rv = test_kernel_cpu_idle(0); if (rv != TC_PASS) { goto tests_done; } #ifndef CONFIG_ARM TC_PRINT("Testing k_cpu_atomic_idle()\n"); rv = test_kernel_cpu_idle(1); if (rv != TC_PASS) { goto tests_done; } #endif #endif TC_PRINT("Testing interrupt locking and unlocking\n"); rv = test_kernel_interrupts(irq_lock_wrapper, irq_unlock_wrapper, -1); if (rv != TC_PASS) { goto tests_done; } #ifdef TICK_IRQ /* Disable interrupts coming from the timer. */ TC_PRINT("Testing irq_disable() and irq_enable()\n"); rv = test_kernel_interrupts(irq_disable_wrapper, irq_enable_wrapper, TICK_IRQ); if (rv != TC_PASS) { goto tests_done; } #endif TC_PRINT("Testing some kernel context routines\n"); rv = test_kernel_ctx_task(); if (rv != TC_PASS) { goto tests_done; } TC_PRINT("Spawning a thread from a task\n"); thread_evidence = 0; k_thread_spawn(thread_stack1, THREAD_STACKSIZE, thread_entry, k_current_get(), NULL, NULL, K_PRIO_COOP(THREAD_PRIORITY), 0, 0); if (thread_evidence != 1) { rv = TC_FAIL; TC_ERROR(" - thread did not execute as expected!\n"); goto tests_done; } /* * The thread ran, now wake it so it can test k_current_get and * k_is_in_isr. */ TC_PRINT("Thread to test k_current_get() and " "k_is_in_isr()\n"); k_sem_give(&sem_thread); if (thread_detected_error != 0) { rv = TC_FAIL; TC_ERROR(" - failure detected in thread; " "thread_detected_error = %d\n", thread_detected_error); goto tests_done; } TC_PRINT("Thread to test k_yield()\n"); k_sem_give(&sem_thread); if (thread_detected_error != 0) { rv = TC_FAIL; TC_ERROR(" - failure detected in thread; " "thread_detected_error = %d\n", thread_detected_error); goto tests_done; } k_sem_give(&sem_thread); rv = test_timeout(); if (rv != TC_PASS) { goto tests_done; } tests_done: TC_END_RESULT(rv); TC_END_REPORT(rv); }
void main(void) { int rv; /* return value from tests */ TC_START("Test Nanokernel CPU and thread routines"); TC_PRINT("Initializing nanokernel objects\n"); rv = initNanoObjects(); if (rv != TC_PASS) { goto doneTests; } TC_PRINT("Testing nano_cpu_idle()\n"); rv = nano_cpu_idleTest(); if (rv != TC_PASS) { goto doneTests; } TC_PRINT("Testing interrupt locking and unlocking\n"); rv = nanoCpuDisableInterruptsTest(irq_lockWrapper, irq_unlockWrapper, -1); if (rv != TC_PASS) { goto doneTests; } /* * The Cortex-M3/M4 use the SYSTICK exception for the system timer, which is * not considered an IRQ by the irq_enable/Disable APIs. */ #if !defined(CONFIG_CPU_CORTEX_M3_M4) /* Disable interrupts coming from the timer. */ TC_PRINT("Testing irq_disable() and irq_enable()\n"); rv = nanoCpuDisableInterruptsTest(irq_disableWrapper, irq_enableWrapper, TICK_IRQ); if (rv != TC_PASS) { goto doneTests; } #endif rv = nanoCtxTaskTest(); if (rv != TC_PASS) { goto doneTests; } TC_PRINT("Spawning a fiber from a task\n"); fiberEvidence = 0; task_fiber_start(fiberStack1, FIBER_STACKSIZE, fiberEntry, (int) sys_thread_self_get(), 0, FIBER_PRIORITY, 0); if (fiberEvidence != 1) { rv = TC_FAIL; TC_ERROR(" - fiber did not execute as expected!\n"); goto doneTests; } /* * The fiber ran, now wake it so it can test sys_thread_self_get and * sys_execution_context_type_get. */ TC_PRINT("Fiber to test sys_thread_self_get() and sys_execution_context_type_get\n"); nano_task_sem_give(&wakeFiber); if (fiberDetectedError != 0) { rv = TC_FAIL; TC_ERROR(" - failure detected in fiber; fiberDetectedError = %d\n", fiberDetectedError); goto doneTests; } TC_PRINT("Fiber to test fiber_yield()\n"); nano_task_sem_give(&wakeFiber); if (fiberDetectedError != 0) { rv = TC_FAIL; TC_ERROR(" - failure detected in fiber; fiberDetectedError = %d\n", fiberDetectedError); goto doneTests; } nano_task_sem_give(&wakeFiber); rv = test_timeout(); if (rv != TC_PASS) { goto doneTests; } /* Cortex-M3/M4 does not implement connecting non-IRQ exception handlers */ #if !defined(CONFIG_CPU_CORTEX_M3_M4) /* * Test divide by zero exception handler. * * WARNING: This code has been very carefully crafted so that it does * what it is supposed to. Both "error" and "excHandlerExecuted" must be * volatile to prevent the compiler from issuing a "divide by zero" * warning (since otherwise in knows "excHandlerExecuted" is zero), * and to ensure the compiler issues the two byte "idiv" instruction * that the exception handler is designed to deal with. */ volatile int error; /* used to create a divide by zero error */ TC_PRINT("Verifying exception handler installed\n"); excHandlerExecuted = 0; error = error / excHandlerExecuted; TC_PRINT("excHandlerExecuted: %d\n", excHandlerExecuted); rv = (excHandlerExecuted == 1) ? TC_PASS : TC_FAIL; #endif doneTests: TC_END_RESULT(rv); TC_END_REPORT(rv); }