diff --git a/testing/ostest/aio.c b/testing/ostest/aio.c index 8a6fe96372d..fb15de4b19e 100644 --- a/testing/ostest/aio.c +++ b/testing/ostest/aio.c @@ -319,7 +319,7 @@ void aio_test(void) do { - usleep(500 * 1000); + usleep(50 * 1000); ret = check_done(); } while (ret < 0); @@ -333,7 +333,7 @@ void aio_test(void) * task end of the last test case -- especially the dangling SIGPOLL. */ - usleep(500 * 1000); + usleep(50 * 1000); printf("AIO test case 2: Use LIO_WAIT for transfer complete\n"); g_fildes = open(AIO_FILEPATH, O_RDWR | O_CREAT | O_TRUNC); @@ -371,7 +371,7 @@ void aio_test(void) * task end of the last test case -- especially the dangling SIGPOLL. */ - usleep(500 * 1000); + usleep(50 * 1000); printf("AIO test case 3: Use aio_suspend for transfer complete\n"); g_fildes = open(AIO_FILEPATH, O_RDWR | O_CREAT | O_TRUNC); @@ -439,7 +439,7 @@ void aio_test(void) * task end of the last test case -- especially the dangling SIGPOLL. */ - usleep(500 * 1000); + usleep(50 * 1000); printf("AIO test case 4: Use individual signals for transfer complete\n"); g_fildes = open(AIO_FILEPATH, O_RDWR | O_CREAT | O_TRUNC); @@ -502,7 +502,7 @@ void aio_test(void) * task end of the last test case -- especially the dangling SIGPOLL. */ - usleep(500 * 1000); + usleep(50 * 1000); printf("AIO test case 5:" " Use list complete signal for transfer complete\n"); @@ -566,7 +566,7 @@ void aio_test(void) * task end of the last test case -- especially the dangling SIGPOLL. */ - usleep(500 * 1000); + usleep(50 * 1000); printf("AIO test case 6: Cancel I/O by AIO control block\n"); g_fildes = open(AIO_FILEPATH, O_RDWR | O_CREAT | O_TRUNC); @@ -599,7 +599,7 @@ void aio_test(void) do { - usleep(500 * 1000); + usleep(50 * 1000); ret = check_done(); } while (ret < 0); @@ -613,7 +613,7 @@ void aio_test(void) * task end of the last test case -- especially the dangling SIGPOLL. */ - usleep(500 * 1000); + usleep(50 * 1000); printf("AIO test case 7:Cancel I/O by file descriptor\n"); g_fildes = open(AIO_FILEPATH, O_RDWR | O_CREAT | O_TRUNC); @@ -646,7 +646,7 @@ void aio_test(void) do { - usleep(500 * 1000); + usleep(50 * 1000); ret = check_done(); } while (ret < 0); diff --git a/testing/ostest/fpu.c b/testing/ostest/fpu.c index 841d458c7d9..66f0ffceeed 100644 --- a/testing/ostest/fpu.c +++ b/testing/ostest/fpu.c @@ -62,11 +62,11 @@ #ifdef HAVE_FPU #ifndef CONFIG_TESTING_OSTEST_FPULOOPS -# define CONFIG_TESTING_OSTEST_FPULOOPS 16 +# define CONFIG_TESTING_OSTEST_FPULOOPS 8 #endif #ifndef CONFIG_TESTING_OSTEST_FPUMSDELAY -# define CONFIG_TESTING_OSTEST_FPUMSDELAY 750 +# define CONFIG_TESTING_OSTEST_FPUMSDELAY 10 #endif #ifndef CONFIG_TESTING_OSTEST_FPUPRIORITY diff --git a/testing/ostest/posixtimer.c b/testing/ostest/posixtimer.c index ea47261b2ae..ba9ab926140 100644 --- a/testing/ostest/posixtimer.c +++ b/testing/ostest/posixtimer.c @@ -204,9 +204,9 @@ void timer_test(void) printf("timer_test: Starting timer\n"); - timer.it_value.tv_sec = 2; + timer.it_value.tv_sec = 1; timer.it_value.tv_nsec = 0; - timer.it_interval.tv_sec = 2; + timer.it_interval.tv_sec = 1; timer.it_interval.tv_nsec = 0; status = timer_settime(timerid, 0, &timer, NULL); @@ -219,7 +219,7 @@ void timer_test(void) /* Take the semaphore */ - for (i = 0; i < 5; i++) + for (i = 0; i < 3; i++) { printf("timer_test: Waiting on semaphore\n"); FFLUSH(); diff --git a/testing/ostest/prioinherit.c b/testing/ostest/prioinherit.c index a9ffe3d4fe9..f1052bb89d7 100644 --- a/testing/ostest/prioinherit.c +++ b/testing/ostest/prioinherit.c @@ -215,7 +215,7 @@ static FAR void *highpri_thread(FAR void *parameter) printf("highpri_thread-%d: Started\n", threadno); FFLUSH(); - sleep(1); + usleep(10 * 1000); printf("highpri_thread-%d: Calling sem_wait()\n", threadno); g_highstate[threadno - 1] = WAITING; @@ -363,7 +363,7 @@ static FAR void *lowpri_thread(FAR void *parameter) printf(" I still have a count on the semaphore\n"); sem_enumholders(&g_sem); FFLUSH(); - sleep(1); + usleep(10 * 1000); } /* Account for all of the semaphore counts. At any given time if there @@ -574,7 +574,7 @@ void priority_inheritance(void) } printf("priority_inheritance: Waiting...\n"); - sleep(2); + usleep(20 * 1000); dump_nfreeholders("priority_inheritance:"); /* Start the medium priority thread */ @@ -615,7 +615,7 @@ void priority_inheritance(void) } printf("priority_inheritance: Waiting...\n"); - sleep(1); + usleep(10 * 1000); dump_nfreeholders("priority_inheritance:"); /* Start the high priority threads */ diff --git a/testing/ostest/pthread_cleanup.c b/testing/ostest/pthread_cleanup.c index 00a6b91d429..171cbdb3066 100644 --- a/testing/ostest/pthread_cleanup.c +++ b/testing/ostest/pthread_cleanup.c @@ -122,7 +122,7 @@ static void test_cleanup(void) return; } - usleep(500 * 1000); + usleep(50 * 1000); status = pthread_cancel(thread1); if (status != 0) diff --git a/testing/ostest/pthread_exit.c b/testing/ostest/pthread_exit.c index bc4ca5eac5e..040f9d572be 100644 --- a/testing/ostest/pthread_exit.c +++ b/testing/ostest/pthread_exit.c @@ -51,10 +51,10 @@ static FAR void *pthread_exit_thread(FAR void *parameter) { unsigned me = (unsigned)pthread_self(); - printf("pthread_exit_thread %u: Sleeping for 10 second\n", me); - sleep(5); + printf("pthread_exit_thread %u: Sleeping for 100 ms\n", me); + usleep(50 * 1000); printf("pthread_exit_thread %u: Still running...\n", me); - sleep(5); + usleep(50 * 1000); printf("pthread_exit_thread %u: Exiting\n", me); return NULL; } @@ -80,9 +80,9 @@ static FAR void *pthread_exit_main(FAR void *arg) printf("Thread creation failed, return code %d", ret); } - printf("pthread_exit_main %u: Sleeping for 5 seconds\n", me); + printf("pthread_exit_main %u: Sleeping for 50 ms\n", me); fflush(stdout); - sleep(5); + usleep(50 * 1000); printf("pthread_exit_main %u: Calling pthread_exit()\n", me); pthread_exit(NULL); diff --git a/testing/ostest/pthread_rwlock.c b/testing/ostest/pthread_rwlock.c index ed4159d80af..d69621f6d4f 100644 --- a/testing/ostest/pthread_rwlock.c +++ b/testing/ostest/pthread_rwlock.c @@ -336,7 +336,7 @@ static FAR void *timeout_thread2(FAR void *data) pthread_yield(); status = clock_gettime(CLOCK_REALTIME, &time); - time.tv_sec += 2; + time.tv_sec += 1; status = pthread_rwlock_timedwrlock(rc->rw_lock, &time); if (status != ETIMEDOUT) @@ -347,7 +347,7 @@ static FAR void *timeout_thread2(FAR void *data) } status = clock_gettime(CLOCK_REALTIME, &time); - time.tv_sec += 2; + time.tv_sec += 1; status = pthread_rwlock_timedrdlock(rc->rw_lock, &time); if (status != ETIMEDOUT) @@ -357,7 +357,7 @@ static FAR void *timeout_thread2(FAR void *data) } status = clock_gettime(CLOCK_REALTIME, &time); - time.tv_sec += 2; + time.tv_sec += 10; sem_post(rc->sem1); status = pthread_rwlock_timedrdlock(rc->rw_lock, &time); diff --git a/testing/ostest/pthread_rwlock_cancel.c b/testing/ostest/pthread_rwlock_cancel.c index ab8e84c0c02..cf388d644ef 100644 --- a/testing/ostest/pthread_rwlock_cancel.c +++ b/testing/ostest/pthread_rwlock_cancel.c @@ -180,7 +180,7 @@ static void test_timeout(void) for (i = 0; i < 10; i++) { - usleep(300 * 1000); /* Give threads few seconds to run */ + usleep(30 * 1000); /* Give threads few seconds to run */ } status = pthread_cancel(thread1); diff --git a/testing/ostest/restart.c b/testing/ostest/restart.c index 891a5b5d663..0bee23e9ff2 100644 --- a/testing/ostest/restart.c +++ b/testing/ostest/restart.c @@ -127,26 +127,16 @@ static int restart_main(int argc, char *argv[]) } #endif - /* Were we restarted? */ + /* Let the main task restart */ - switch (g_restartstep) + g_restartstep++; + sem_post(&g_sem); + + /* Don't call printf here, to avoid recover sem failed during restart */ + + for (; ; ) { - case 0: - for (; ; ) - { - sleep(2); - printf("restart_main: I am still here\n"); - } - break; - case 1: - if (sem_wait(&g_sem) != 0) - { - printf("restart_main: ERROR thread sem_wait failed\n"); - ASSERT(false); - } - break; - default: - break; + sleep(1); } return 0; /* Won't get here unless we were restarted */ @@ -192,11 +182,12 @@ void restart_test(void) printf("restart_main: Started restart_main at PID=%d\n", pid); - /* Wait a bit and restart the task */ + /* Check the child task result */ - sleep(5); + sem_wait(&g_sem); + ASSERT(g_restartstep == 1); - g_restartstep = 1; + /* Restart the task */ ret = task_restart(pid); if (ret < 0) @@ -205,15 +196,14 @@ void restart_test(void) ASSERT(false); } - /* Start the task wait for a semaphore */ - - printf("restart_main: Started restart_main at PID=%d\n", pid); + /* Check the child task result */ - /* Wait a bit and restart the task */ + sem_wait(&g_sem); + ASSERT(g_restartstep == 2); - sleep(5); + printf("restart_main: Started restart_main at PID=%d\n", pid); - g_restartstep = 2; + /* Restart the task */ ret = task_restart(pid); if (ret < 0) @@ -222,7 +212,10 @@ void restart_test(void) ASSERT(false); } - sleep(1); + /* Check the child task result */ + + sem_wait(&g_sem); + ASSERT(g_restartstep == 3); } sem_destroy(&g_sem); diff --git a/testing/ostest/robust.c b/testing/ostest/robust.c index 9a2baa20fe4..24205c1201f 100644 --- a/testing/ostest/robust.c +++ b/testing/ostest/robust.c @@ -71,7 +71,7 @@ static FAR void *robust_waiter(FAR void *parameter) printf("robust_waiter: Exiting with mutex\n"); } - sleep(2); + usleep(20 * 1000); return NULL; } @@ -208,7 +208,7 @@ void robust_test(void) do { - sleep(1); + usleep(10 * 1000); } while (kill(waiter, 0) == 0 || errno != ESRCH); diff --git a/testing/ostest/schedlock.c b/testing/ostest/schedlock.c index 69d2ef0a387..282cb636d77 100644 --- a/testing/ostest/schedlock.c +++ b/testing/ostest/schedlock.c @@ -252,7 +252,7 @@ void sched_lock_test(void) } printf("sched_lock: Waiting...\n"); - sleep(1); + usleep(10 * 1000); pthread_join(g_highpri, NULL); pthread_join(g_lowpri, NULL); diff --git a/testing/ostest/semtimed.c b/testing/ostest/semtimed.c index ce3f163c111..a93b8252fe4 100644 --- a/testing/ostest/semtimed.c +++ b/testing/ostest/semtimed.c @@ -55,8 +55,8 @@ static void *poster_func(void *parameter) /* Wait for one second, then post the semaphore */ - printf("poster_func: Waiting for 1 second\n"); - sleep(1); + printf("poster_func: Waiting for 10 ms\n"); + usleep(10 * 1000); printf("poster_func: Posting\n"); status = sem_post(&sem); diff --git a/testing/ostest/sighand.c b/testing/ostest/sighand.c index c368a37f1e3..394bf9b2eaf 100644 --- a/testing/ostest/sighand.c +++ b/testing/ostest/sighand.c @@ -293,10 +293,18 @@ void sighand_test(void) printf("sighand_test: Started waiter_main pid=%d\n", waiterpid); } - /* Wait a bit */ + /* Wait the child thread enter sem_wait() */ - FFLUSH(); - sleep(2); + while (1) + { + usleep(1000); + + sem_getvalue(&sem1, &status); + if (status < 0) + { + break; + } + } /* Then signal the waiter thread. */ @@ -314,12 +322,7 @@ void sighand_test(void) /* Wait a bit */ - FFLUSH(); - status = sleep(2); - while (status) - { - status = sleep(status); - } + usleep(2000); /* Then check the result */ diff --git a/testing/ostest/signest.c b/testing/ostest/signest.c index 5e8e6596140..009213eb371 100644 --- a/testing/ostest/signest.c +++ b/testing/ostest/signest.c @@ -522,7 +522,7 @@ void signest_test(void) sem_post(&g_interferer_sem); do { - usleep(500 * 1000L); + usleep(50 * 1000L); } while (g_waiter_running || g_interferer_running); diff --git a/testing/ostest/sporadic.c b/testing/ostest/sporadic.c index 5e6986ba774..290ac6b44d5 100644 --- a/testing/ostest/sporadic.c +++ b/testing/ostest/sporadic.c @@ -88,7 +88,7 @@ static void *nuisance_func(void *parameter) { /* Sleep gracefully for awhile */ - usleep(500 * 1000); + usleep(50 * 1000); /* Then hog some CPU time */ @@ -344,19 +344,19 @@ void sporadic_test(void) /* Wait a while then kill the FIFO thread */ - sleep(15); + usleep(150 * 1000); ret = pthread_cancel(fifo_thread); pthread_join(fifo_thread, &result); /* Wait a bit longer then kill the nuisance thread */ - sleep(10); + usleep(100 * 1000); ret = pthread_cancel(nuisance_thread); pthread_join(nuisance_thread, &result); /* Wait a bit longer then kill the sporadic thread */ - sleep(10); + usleep(100 * 1000); ret = pthread_cancel(sporadic_thread); pthread_join(sporadic_thread, &result); sched_unlock(); diff --git a/testing/ostest/sporadic2.c b/testing/ostest/sporadic2.c index acc7f34e164..e3a24d7f754 100644 --- a/testing/ostest/sporadic2.c +++ b/testing/ostest/sporadic2.c @@ -290,7 +290,7 @@ static void sporadic_test_case(int32_t budget_1_ns, int32_t budget_2_ns) sem_post(&g_sporadic_sem); sem_post(&g_sporadic_sem); - sleep(100); + sleep(1); ret = pthread_cancel(sporadic_thread1); pthread_join(sporadic_thread1, &result); diff --git a/testing/ostest/suspend.c b/testing/ostest/suspend.c index a1d6f6b877c..1df96bd6f9d 100644 --- a/testing/ostest/suspend.c +++ b/testing/ostest/suspend.c @@ -96,7 +96,7 @@ void suspend_test(void) printf("suspend_test: Is the victim saying anything?\n"); FFLUSH(); - sleep(10); + usleep(10 * 1000); /* Then signal the victim thread. */ @@ -110,7 +110,7 @@ void suspend_test(void) printf("suspend_test: Is the victim still jabbering?\n"); FFLUSH(); - sleep(10); + usleep(10 * 1000); printf("suspend_test: Signaling pid=%d with SIGCONT\n", victim); ret = kill(victim, SIGCONT); @@ -122,7 +122,7 @@ void suspend_test(void) printf("suspend_test: The victim should continue the rant.\n"); FFLUSH(); - sleep(10); + usleep(10 * 1000); printf("suspend_test: Signaling pid=%d with SIGKILL\n", victim); ret = kill(victim, SIGKILL); @@ -133,7 +133,8 @@ void suspend_test(void) } FFLUSH(); - sleep(1); + + sleep(1); /* Wait for the task to exit */ ret = kill(victim, 0); if (ret >= 0) { diff --git a/testing/ostest/timedmqueue.c b/testing/ostest/timedmqueue.c index 5a4dcb29a13..f7af0ac1ef2 100644 --- a/testing/ostest/timedmqueue.c +++ b/testing/ostest/timedmqueue.c @@ -135,7 +135,7 @@ static void *sender_thread(void *arg) ASSERT(false); } - ts.tv_sec += 5; + ts.tv_sec += 1; /* The first TEST_SEND_NMSGS-1 send should succeed. The last * one should fail with errno == ETIMEDOUT @@ -236,7 +236,7 @@ static void *receiver_thread(void *arg) ASSERT(false); } - ts.tv_sec += 5; + ts.tv_sec += 1; /* The first TEST_SEND_NMSGS-1 send should succeed. The last * one should fail with errno == ETIMEDOUT diff --git a/testing/ostest/timedmutex.c b/testing/ostest/timedmutex.c index 303dc260c01..bfba0270194 100644 --- a/testing/ostest/timedmutex.c +++ b/testing/ostest/timedmutex.c @@ -107,7 +107,7 @@ static void *thread_func(FAR void *parameter) /* Release the lock and wait a bit in case the main thread wants it. */ pthread_mutex_unlock(&g_mutex); - usleep(500 * 1000); + usleep(50 * 1000); } g_running = false; diff --git a/testing/ostest/timedwait.c b/testing/ostest/timedwait.c index ab3f6794cc3..4d7a22873f2 100644 --- a/testing/ostest/timedwait.c +++ b/testing/ostest/timedwait.c @@ -65,7 +65,7 @@ static void *thread_waiter(void *parameter) ASSERT(false); } - printf("thread_waiter: Starting 5 second wait for condition\n"); + printf("thread_waiter: Starting 1 second wait for condition\n"); status = clock_gettime(CLOCK_REALTIME, &ts); if (status != 0) @@ -74,7 +74,7 @@ static void *thread_waiter(void *parameter) ASSERT(false); } - ts.tv_sec += 5; + ts.tv_sec += 1; /* The wait -- no-one is ever going to awaken us */ diff --git a/testing/ostest/vfork.c b/testing/ostest/vfork.c index bd6cfabadb9..fb57d91062e 100644 --- a/testing/ostest/vfork.c +++ b/testing/ostest/vfork.c @@ -70,7 +70,7 @@ int vfork_test(void) } else { - sleep(1); + usleep(10 * 1000); if (g_vforkchild) { printf("vfork_test: Child %d ran successfully\n", pid); diff --git a/testing/ostest/waitpid.c b/testing/ostest/waitpid.c index 2be66e8c944..2230b22d15c 100644 --- a/testing/ostest/waitpid.c +++ b/testing/ostest/waitpid.c @@ -66,7 +66,7 @@ static int waitpid_main(int argc, char *argv[]) pid_t me = getpid(); printf("waitpid_main: PID %d Started\n", me); - sleep(3); + usleep(30 * 1000); printf("waitpid_main: PID %d exitting with result=%d\n", me, RETURN_STATUS); return RETURN_STATUS; @@ -237,7 +237,7 @@ int waitpid_test(void) /* Wait a bit to make sure that the other threads complete */ waitpid_last(); - sleep(1); + usleep(10 * 1000); #ifdef CONFIG_SCHED_HAVE_PARENT /* Start the children and wait for first one to complete */ @@ -294,7 +294,7 @@ int waitpid_test(void) /* Wait a bit to make sure that the other threads complete */ waitpid_last(); - sleep(1); + usleep(10 * 1000); /* Start the children and wait for any one to complete */ @@ -343,7 +343,7 @@ int waitpid_test(void) /* Wait a bit to make sure that the other threads complete */ waitpid_last(); - sleep(1); + usleep(10 * 1000); /* Start the children and wait for first one to complete */ @@ -392,7 +392,7 @@ int waitpid_test(void) /* Wait a bit to make sure that the other threads complete */ waitpid_last(); - sleep(1); + usleep(10 * 1000); #endif return 0; diff --git a/testing/ostest/wdog.c b/testing/ostest/wdog.c index ca692f27453..f4602a15e35 100644 --- a/testing/ostest/wdog.c +++ b/testing/ostest/wdog.c @@ -305,7 +305,7 @@ static void wdog_test_run(FAR wdtest_param_t *param) /* Sleep for 1s */ - wdtest_delay(USEC_PER_SEC); + wdtest_delay(USEC_PER_SEC / 100); /* Testing wd_gettime */ diff --git a/testing/ostest/wqueue.c b/testing/ostest/wqueue.c index 9d0444a968b..e5c07e100bd 100644 --- a/testing/ostest/wqueue.c +++ b/testing/ostest/wqueue.c @@ -41,7 +41,7 @@ * Pre-processor Definitions ****************************************************************************/ -#define SLEEP_TIME (100 * 1000) +#define SLEEP_TIME (10 * 1000) #define TEST_COUNT (100) #define VERIFY_COUNT (100)