123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488 |
- #include "pte_osal.h"
- #include "test.h"
- const char * error_string;
- int assertE;
- ///@todo: add cancellable wait for thread end for DSP/BIOS
- ///@todo: look at removing/changing ftime
- static void runBarrierTests(void)
- {
- printf("Barrier test #1\n");
- pthread_test_barrier1();
- printf("Barrier test #2\n");
- pthread_test_barrier2();
- printf("Barrier test #3\n");
- pthread_test_barrier3();
- printf("Barrier test #4\n");
- pthread_test_barrier4();
- printf("Barrier test #5\n");
- pthread_test_barrier5();
- }
- static void runSemTests(void)
- {
- printf("Semaphore test #1\n");
- pthread_test_semaphore1();
- printf("Semaphore test #2\n");
- pthread_test_semaphore2();
- printf("Semaphore test #3\n");
- pthread_test_semaphore3();
- printf("Semaphore test #4\n");
- pthread_test_semaphore4();
- printf("Semaphore test #4t\n");
- pthread_test_semaphore4t();
- printf("Semaphore test #5\n");
- pthread_test_semaphore5();
- printf("Semaphore test #6\n");
- pthread_test_semaphore6();
- }
- static void runThreadTests(void)
- {
- printf("Create test #1\n");
- pthread_test_create1();
- printf("Create test #2\n");
- pthread_test_create2();
- printf("Create test #3\n");
- pthread_test_create3();
- printf("Join test #0\n");
- pthread_test_join0();
- printf("Join test #1\n");
- pthread_test_join1();
- printf("Join test #2\n");
- pthread_test_join2();
- printf("Join test #3\n");
- pthread_test_join3();
- printf("Join test #4\n");
- pthread_test_join4();
- printf("Kill test #1\n");
- pthread_test_kill1();
- printf("Exit test #1\n");
- pthread_test_exit1();
- printf("Exit test #2\n");
- pthread_test_exit2();
- printf("Exit test #3\n");
- pthread_test_exit3();
- printf("Exit test #4\n");
- pthread_test_exit4();
- printf("Exit test #5\n");
- pthread_test_exit5();
- /* These tests can not be run in series with other tests,
- * as they rely on knowing what is on the reuse queue.
- */
- /*
- printf("Reuse test #1\n");
- pthread_test_reuse1();
- printf("Reuse test #2\n");
- pthread_test_reuse2();
- */
- printf("Priority test #1\n");
- pthread_test_priority1();
- printf("Priority test #2\n");
- pthread_test_priority2();
- // printf("Inherit test #1\n");
- // pthread_test_inherit1(); ///@todo
- }
- static void runMiscTests(void)
- {
- printf("Valid test #1\n");
- pthread_test_valid1();
- printf("Valid test #2\n");
- pthread_test_valid2();
- printf("Self test #1\n");
- pthread_test_self1();
- printf("Self test #2\n");
- pthread_test_self2();
- printf("Equal test #1\n");
- pthread_test_equal1();
- printf("Count test #1\n");
- pthread_test_count1();
- printf("Delay test #1\n");
- pthread_test_delay1();
- printf("Delay test #2\n");
- pthread_test_delay2();
- printf("Once test #1\n");
- pthread_test_once1();
- printf("Once test #2\n");
- pthread_test_once2();
- printf("Once test #3\n");
- pthread_test_once3();
- printf("Once test #4\n");
- pthread_test_once4();
- printf("TSD test #1\n");
- pthread_test_tsd1();
- printf("TSD test #2\n");
- pthread_test_tsd2();
- #ifdef THREAD_SAFE_ERRNO
- printf("Errno test #1\n");
- pthread_test_errno1();
- #endif // THREAD_SAFE_ERRNO
- printf("Detach test #1\n");
- pthread_test_detach1();
- }
- static void runMutexTests(void)
- {
- printf("Mutex test #1\n");
- pthread_test_mutex1();
- printf("Mutex test #1(e)\n");
- pthread_test_mutex1e();
- printf("Mutex test #1(n)\n");
- pthread_test_mutex1n();
- printf("Mutex test #1(r)\n");
- pthread_test_mutex1e();
- printf("Mutex test #2\n");
- pthread_test_mutex2();
- printf("Mutex test #2(e)\n");
- pthread_test_mutex2e();
- printf("Mutex test #2(r)\n");
- pthread_test_mutex2r();
- printf("Mutex test #3\n");
- pthread_test_mutex3();
- printf("Mutex test #3(e)\n");
- pthread_test_mutex3e();
- printf("Mutex test #3(r)\n");
- pthread_test_mutex3r();
- printf("Mutex test #4\n");
- pthread_test_mutex4();
- printf("Mutex test #5\n");
- pthread_test_mutex5();
- printf("Mutex test #6\n");
- pthread_test_mutex6();
- printf("Mutex test #6e\n");
- pthread_test_mutex6e();
- printf("Mutex test #6es\n");
- pthread_test_mutex6es();
- printf("Mutex test #6n\n");
- pthread_test_mutex6n();
- printf("Mutex test #6r\n");
- pthread_test_mutex6r();
- printf("Mutex test #6rs\n");
- pthread_test_mutex6rs();
- printf("Mutex test #6s\n");
- pthread_test_mutex6s();
- printf("Mutex test #7\n");
- pthread_test_mutex7();
- printf("Mutex test #7e\n");
- pthread_test_mutex7e();
- printf("Mutex test #7n\n");
- pthread_test_mutex7n();
- printf("Mutex test #7r\n");
- pthread_test_mutex7r();
- printf("Mutex test #8\n");
- pthread_test_mutex8();
- printf("Mutex test #8e\n");
- pthread_test_mutex8e();
- printf("Mutex test #8n\n");
- pthread_test_mutex8n();
- printf("Mutex test #8r\n");
- pthread_test_mutex8r();
- }
- static void runSpinTests()
- {
- printf("Spin test #1\n");
- pthread_test_spin1();
- printf("Spin test #2\n");
- pthread_test_spin2();
- printf("Spin test #3\n");
- pthread_test_spin3();
- printf("Spin test #4\n");
- pthread_test_spin4();
- }
- static void runCondvarTests()
- {
- printf("Condvar test #1\n");
- pthread_test_condvar1();
- printf("Condvar test #1-1\n");
- pthread_test_condvar1_1();
- printf("Condvar test #1-2\n");
- pthread_test_condvar1_2();
- printf("Condvar test #2\n");
- pthread_test_condvar2();
- printf("Condvar test #2-1\n");
- pthread_test_condvar2_1();
- printf("Condvar test #3\n");
- pthread_test_condvar3();
- printf("Condvar test #3-1\n");
- pthread_test_condvar3_1();
- printf("Condvar test #3-2\n");
- pthread_test_condvar3_2();
- printf("Condvar test #3-3\n");
- pthread_test_condvar3_3();
- printf("Condvar test #4\n");
- pthread_test_condvar4();
- printf("Condvar test #5\n");
- pthread_test_condvar5();
- printf("Condvar test #6\n");
- pthread_test_condvar6();
- printf("Condvar test #7\n");
- pthread_test_condvar7();
- printf("Condvar test #8\n");
- pthread_test_condvar8();
- printf("Condvar test #9\n");
- pthread_test_condvar9();
- }
- static void runStressTests()
- {
- printf("Stress test #1\n");
- pthread_test_stress1();
- }
- static void runRwlockTests()
- {
- printf("Rwlock test #1\n");
- pthread_test_rwlock1();
- printf("Rwlock test #2\n");
- pthread_test_rwlock2();
- printf("Rwlock test #2t\n");
- pthread_test_rwlock2t();
- printf("Rwlock test #3\n");
- pthread_test_rwlock3();
- printf("Rwlock test #3t\n");
- pthread_test_rwlock3t();
- printf("Rwlock test #4\n");
- pthread_test_rwlock4();
- printf("Rwlock test #4t\n");
- pthread_test_rwlock4t();
- printf("Rwlock test #5\n");
- pthread_test_rwlock5();
- printf("Rwlock test #5t\n");
- pthread_test_rwlock5t();
- printf("Rwlock test #6\n");
- pthread_test_rwlock6();
- printf("Rwlock test #6t\n");
- pthread_test_rwlock6t();
- printf("Rwlock test #6t2\n");
- pthread_test_rwlock6t2();
- printf("Rwlock test #7\n");
- pthread_test_rwlock7();
- printf("Rwlock test #8\n");
- pthread_test_rwlock8();
- }
- static void runCancelTests()
- {
- printf("Cancel test #1\n");
- pthread_test_cancel1();
- printf("Cancel test #2\n");
- pthread_test_cancel2();
- printf("Cancel test #3\n");
- pthread_test_cancel3();
- printf("Cancel test #4\n");
- pthread_test_cancel4();
- printf("Cancel test #5\n");
- pthread_test_cancel5();
- printf("Cancel test #6a\n");
- pthread_test_cancel6a();
- printf("Cancel test #6d\n");
- pthread_test_cancel6d();
- /* Cleanup only occurs for async cancellation.
- * If we don't support this, can't test it...
- */
- printf("Cleanup test #0\n");
- pthread_test_cleanup0();
- printf("Cleanup test #1\n");
- pthread_test_cleanup1();
- printf("Cleanup test #2\n");
- pthread_test_cleanup2();
- printf("Cleanup test #3\n");
- pthread_test_cleanup3();
- }
- static void runBenchTests()
- {
- printf("Benchmark test #1\n");
- pthread_test_bench1();
- printf("Benchmark test #2\n");
- pthread_test_bench2();
- printf("Benchmark test #3\n");
- pthread_test_bench3();
- printf("Benchmark test #4\n");
- pthread_test_bench4();
- }
- static void runExceptionTests()
- {
- printf("Exception test #1\n");
- pthread_test_exception1();
- /* This test intentially crashes the app
- (unhandled exception)
- printf("Exception test #2\n");
- pthread_test_exception2();
- */
- printf("Exception test #3\n");
- pthread_test_exception3();
- }
- void pte_test_main()
- {
- int i;
- if (!pthread_init())
- {
- printf("Failed to initialize pthreads library.\n");
- return;
- }
- printf("Running tests...\n");
- for (i=0;i<2;i++)
- {
- printf("=========================\n");
- printf(" Test iteration #%d\n\n",i);
- printf("=========================\n");
- runThreadTests();
- runMiscTests();
- runMutexTests();
- runSemTests();
- runCondvarTests();
- runBarrierTests();
- runSpinTests();
- runRwlockTests();
- runCancelTests();
- runExceptionTests();
- runBenchTests();
- runStressTests();
- }
- printf("Tests complete!\n");
- }
|