This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
The following commit(s) were added to refs/heads/master by this push: new 97440889a testing: ostest: Add ASSERT in case of errors 97440889a is described below commit 97440889ace371ff58f2735d5819d37a053abce7 Author: Masayuki Ishikawa <masayuki.ishik...@gmail.com> AuthorDate: Sat Oct 15 23:36:29 2022 +0900 testing: ostest: Add ASSERT in case of errors Summary: - This commit adds ASSERT in case of errors to stop the execution of ostest - Also, add some 'ERROR' messages Impact: - None Testing: - Run ostest with several configs Signed-off-by: Masayuki Ishikawa <masayuki.ishik...@jp.sony.com> --- testing/ostest/aio.c | 24 +++++++++++ testing/ostest/barrier.c | 3 ++ testing/ostest/cancel.c | 49 +++++++++++++++++++++- testing/ostest/cond.c | 10 +++++ testing/ostest/dev_null.c | 3 ++ testing/ostest/fpu.c | 5 +++ testing/ostest/getopt.c | 14 +++++++ testing/ostest/mqueue.c | 48 +++++++++++++++++----- testing/ostest/mutex.c | 5 +++ testing/ostest/nsem.c | 8 ++++ testing/ostest/ostest_main.c | 8 ++++ testing/ostest/posixtimer.c | 19 +++++++-- testing/ostest/prioinherit.c | 52 ++++++++++++++++++------ testing/ostest/pthread_cleanup.c | 9 +++++ testing/ostest/pthread_rwlock.c | 74 ++++++++++++++++++++++++++-------- testing/ostest/pthread_rwlock_cancel.c | 23 ++++++++++- testing/ostest/restart.c | 8 ++++ testing/ostest/rmutex.c | 9 +++++ testing/ostest/robust.c | 18 +++++++++ testing/ostest/roundrobin.c | 5 +++ testing/ostest/sem.c | 13 ++++++ testing/ostest/semtimed.c | 15 ++++++- testing/ostest/setvbuf.c | 12 ++++++ testing/ostest/sigev_thread.c | 14 +++++-- testing/ostest/sighand.c | 20 +++++++++ testing/ostest/signest.c | 10 +++++ testing/ostest/sigprocmask.c | 15 +++++++ testing/ostest/specific.c | 8 ++++ testing/ostest/sporadic.c | 14 +++++++ testing/ostest/sporadic2.c | 12 ++++++ testing/ostest/suspend.c | 6 +++ testing/ostest/timedmqueue.c | 38 +++++++++++++---- testing/ostest/timedmutex.c | 18 ++++++--- testing/ostest/timedwait.c | 8 ++++ testing/ostest/tls.c | 1 + testing/ostest/vfork.c | 4 +- testing/ostest/waitpid.c | 14 +++++++ 37 files changed, 553 insertions(+), 63 deletions(-) diff --git a/testing/ostest/aio.c b/testing/ostest/aio.c index 7eddbc76e..7f3e9ab07 100644 --- a/testing/ostest/aio.c +++ b/testing/ostest/aio.c @@ -179,6 +179,7 @@ static int check_done(void) else if (aiocbp->aio_result < 0) { printf(" ERROR: Failed I/O transfer\n"); + ASSERT(false); } /* Successful completion r */ @@ -246,6 +247,7 @@ static int remove_done(void) else if (aiocbp->aio_result < 0) { printf(" ERROR: Failed I/O transfer\n"); + ASSERT(false); g_aiocb[i] = NULL; completed++; } @@ -299,6 +301,7 @@ void aio_test(void) { printf("aio_test: ERROR: Failed to open %s: %d\n", AIO_FILEPATH, errno); + ASSERT(false); goto errout_with_procmask; } @@ -307,6 +310,7 @@ void aio_test(void) if (ret < 0) { printf("aio_test: ERROR: lio_listio failed: %d\n", errno); + ASSERT(false); goto errout_with_fildes; } @@ -334,6 +338,7 @@ void aio_test(void) { printf("aio_test: ERROR: Failed to open %s: %d\n", AIO_FILEPATH, errno); + ASSERT(false); goto errout_with_procmask; } @@ -342,6 +347,7 @@ void aio_test(void) if (ret < 0) { printf("aio_test: ERROR: lio_listio failed: %d\n", errno); + ASSERT(false); goto errout_with_fildes; } @@ -349,6 +355,7 @@ void aio_test(void) if (ret < 0) { printf("aio_test: ERROR: Not done\n"); + ASSERT(false); goto errout_with_fildes; } @@ -369,6 +376,7 @@ void aio_test(void) { printf("aio_test: ERROR: Failed to open %s: %d\n", AIO_FILEPATH, errno); + ASSERT(false); goto errout_with_procmask; } @@ -377,6 +385,7 @@ void aio_test(void) if (ret < 0) { printf("aio_test: ERROR: lio_listio failed: %d\n", errno); + ASSERT(false); goto errout_with_fildes; } @@ -389,6 +398,7 @@ void aio_test(void) if (ret < 0) { printf("aio_test: ERROR: aio_suspend failed: %d\n", errno); + ASSERT(false); goto errout_with_fildes; } @@ -396,6 +406,7 @@ void aio_test(void) if (completed < 1) { printf("aio_test: ERROR: Signalled, but no I/O completed\n"); + ASSERT(false); goto errout_with_fildes; } @@ -412,6 +423,7 @@ void aio_test(void) { printf("aio_test: ERROR: Total is %d, should be %d\n", total, AIO_NCTRLBLKS); + ASSERT(false); goto errout_with_fildes; } @@ -432,6 +444,7 @@ void aio_test(void) { printf("aio_test: ERROR: Failed to open %s: %d\n", AIO_FILEPATH, errno); + ASSERT(false); goto errout_with_procmask; } @@ -441,6 +454,7 @@ void aio_test(void) if (ret < 0) { printf("aio_test: ERROR: lio_listio failed: %d\n", errno); + ASSERT(false); goto errout_with_fildes; } @@ -464,6 +478,7 @@ void aio_test(void) { printf("aio_test: ERROR: sigwaitinfo failed: %d\n", errcode); + ASSERT(false); goto errout_with_fildes; } } @@ -493,6 +508,7 @@ void aio_test(void) { printf("aio_test: ERROR: Failed to open %s: %d\n", AIO_FILEPATH, errno); + ASSERT(false); goto errout_with_procmask; } @@ -506,6 +522,7 @@ void aio_test(void) if (ret < 0) { printf("aio_test: ERROR: lio_listio failed: %d\n", errno); + ASSERT(false); goto errout_with_fildes; } @@ -529,6 +546,7 @@ void aio_test(void) { printf("aio_test: ERROR: sigwaitinfo failed: %d\n", errcode); + ASSERT(false); goto errout_with_fildes; } } @@ -553,6 +571,7 @@ void aio_test(void) { printf("aio_test: ERROR: Failed to open %s: %d\n", AIO_FILEPATH, errno); + ASSERT(false); goto errout_with_procmask; } @@ -561,6 +580,7 @@ void aio_test(void) if (ret < 0) { printf("aio_test: ERROR: lio_listio failed: %d\n", errno); + ASSERT(false); goto errout_with_fildes; } @@ -568,6 +588,7 @@ void aio_test(void) if (ret < 0) { printf("aio_test: ERROR: aio_cancel failed: %d\n", errno); + ASSERT(false); goto errout_with_fildes; } @@ -597,6 +618,7 @@ void aio_test(void) { printf("aio_test: ERROR: Failed to open %s: %d\n", AIO_FILEPATH, errno); + ASSERT(false); goto errout_with_procmask; } @@ -605,6 +627,7 @@ void aio_test(void) if (ret < 0) { printf("aio_test: ERROR: lio_listio failed: %d\n", errno); + ASSERT(false); goto errout_with_fildes; } @@ -612,6 +635,7 @@ void aio_test(void) if (ret < 0) { printf("aio_test: ERROR: aio_cancel failed: %d\n", errno); + ASSERT(false); goto errout_with_fildes; } diff --git a/testing/ostest/barrier.c b/testing/ostest/barrier.c index 8fc9768d0..0117ca02d 100644 --- a/testing/ostest/barrier.c +++ b/testing/ostest/barrier.c @@ -78,6 +78,7 @@ static void *barrier_func(void *parameter) { printf("barrier_func: ERROR thread %d could not get semaphore value\n", id); + ASSERT(false); } FFLUSH(); @@ -142,6 +143,7 @@ void barrier_test(void) printf("barrier_test: ERROR thread %d create, status=%d\n", i, status); printf("barrier_test: Test aborted with waiting threads\n"); + ASSERT(false); goto abort_test; } else @@ -161,6 +163,7 @@ void barrier_test(void) { printf("barrier_test: ERROR thread %d join, status=%d\n", i, status); + ASSERT(false); } else { diff --git a/testing/ostest/cancel.c b/testing/ostest/cancel.c index 353a80693..4104c0368 100644 --- a/testing/ostest/cancel.c +++ b/testing/ostest/cancel.c @@ -81,6 +81,7 @@ static FAR void *sem_waiter(FAR void *parameter) { printf("sem_waiter: ERROR pthread_mutex_lock failed, status=%d\n", status); + ASSERT(false); } printf("sem_waiter: Starting wait for condition\n"); @@ -96,6 +97,7 @@ static FAR void *sem_waiter(FAR void *parameter) printf("sem_waiter: " "ERROR pthread_setcancelstate failed, status=%d\n", status); + ASSERT(false); } } @@ -108,6 +110,7 @@ static FAR void *sem_waiter(FAR void *parameter) { printf("sem_waiter: ERROR pthread_cond_wait failed, status=%d\n", status); + ASSERT(false); } if (!parameter) @@ -121,6 +124,7 @@ static FAR void *sem_waiter(FAR void *parameter) printf("sem_waiter: " "ERROR pthread_mutex_unlock failed, status=%d\n", status); + ASSERT(false); } /* Set the cancelable state */ @@ -131,12 +135,14 @@ static FAR void *sem_waiter(FAR void *parameter) { printf("sem_waiter: " "ERROR pthread_setcancelstate failed, status=%d\n", status); + ASSERT(false); } } else { printf("sem_waiter: " "ERROR pthread_cond_wait returned after being cancelled!\n"); + ASSERT(false); } /* Why is this here? Because pthread_setcancelstate() is not a @@ -165,6 +171,7 @@ static void mqueue_cleaner(FAR void *arg) if (mq_close(*mqcancel) < 0) { printf("mqueue_cleaner: ERROR mq_close failed\n"); + ASSERT(false); } } #endif @@ -192,6 +199,7 @@ static FAR void *mqueue_waiter(FAR void *parameter) if (mqcancel < 0) { printf("mqueue_waiter: ERROR mq_open failed\n"); + ASSERT(false); pthread_exit((pthread_addr_t)0xdeadbeef); } @@ -206,6 +214,7 @@ static FAR void *mqueue_waiter(FAR void *parameter) if (mq_close(mqcancel) < 0) { printf("mqueue_waiter: ERROR mq_close failed\n"); + ASSERT(false); } printf("mqueue_waiter: Exit with status 0x12345678\n"); @@ -261,6 +270,7 @@ static FAR void *asynch_waiter(FAR void *parameter) printf("asynch_waiter: " "ERROR pthread_setcancelstate failed, status=%d\n", status); + ASSERT(false); } /* Set the asynchronous cancellation type */ @@ -272,6 +282,7 @@ static FAR void *asynch_waiter(FAR void *parameter) printf("asynch_waiter: " "ERROR pthread_setcanceltype failed, status=%d\n", status); + ASSERT(false); } /* Then wait a bit. We should be canceled aynchronously while waiting, but @@ -294,6 +305,7 @@ static FAR void *asynch_waiter(FAR void *parameter) printf("asynch_waiter: " "ERROR pthread_setcancelstate failed, status=%d\n", status); + ASSERT(false); } /* Set the cancelable state */ @@ -318,6 +330,7 @@ static void start_thread(FAR void *(*entry)(FAR void *), pthread_t *waiter, { printf("start_thread: " "ERROR pthread_mutex_init failed, status=%d\n", status); + ASSERT(false); } /* Initialize the condition variable */ @@ -328,6 +341,7 @@ static void start_thread(FAR void *(*entry)(FAR void *), pthread_t *waiter, { printf("start_thread: ERROR pthread_cond_init failed, status=%d\n", status); + ASSERT(false); } /* Set up attributes */ @@ -335,14 +349,18 @@ static void start_thread(FAR void *(*entry)(FAR void *), pthread_t *waiter, status = pthread_attr_init(&attr); if (status != 0) { - printf("start_thread: pthread_attr_init failed, status=%d\n", status); + printf("start_thread: " + "ERROR pthread_attr_init failed, status=%d\n", status); + ASSERT(false); } status = pthread_attr_setstacksize(&attr, STACKSIZE); if (status != 0) { - printf("start_thread: pthread_attr_setstacksize failed, status=%d\n", + printf("start_thread: " + "ERROR pthread_attr_setstacksize failed, status=%d\n", status); + ASSERT(false); } /* Start the waiter thread */ @@ -354,6 +372,7 @@ static void start_thread(FAR void *(*entry)(FAR void *), pthread_t *waiter, { printf("start_thread: ERROR pthread_create failed, status=%d\n", status); + ASSERT(false); } /* Make sure that the waiter thread gets a chance to run */ @@ -375,6 +394,7 @@ static void restart_thread(FAR void *(*entry)(FAR void *), pthread_t *waiter, { printf("restart_thread: " "ERROR pthread_cond_destroy failed, status=%d\n", status); + ASSERT(false); } /* Destroy the mutex. @@ -388,6 +408,7 @@ static void restart_thread(FAR void *(*entry)(FAR void *), pthread_t *waiter, { printf("restart_thread: " "ERROR pthread_mutex_destroy failed, status=%d\n", status); + ASSERT(false); } /* Then restart the thread */ @@ -430,6 +451,7 @@ void cancel_test(void) { printf("cancel_test: ERROR pthread_cancel failed, status=%d\n", status); + ASSERT(false); } /* Then join to the thread to pick up the result (if we don't do @@ -442,6 +464,7 @@ void cancel_test(void) { printf("cancel_test: ERROR pthread_join failed, status=%d\n", status); + ASSERT(false); } else { @@ -450,6 +473,7 @@ void cancel_test(void) { printf("cancel_test: ERROR expected result=%p\n", PTHREAD_CANCELED); + ASSERT(false); } else { @@ -487,6 +511,7 @@ void cancel_test(void) { printf("cancel_test: ERROR pthread_cancel failed, status=%d\n", status); + ASSERT(false); } /* Then join to the thread to pick up the result (if we don't do @@ -499,6 +524,7 @@ void cancel_test(void) { printf("cancel_test: ERROR pthread_join failed, status=%d\n", status); + ASSERT(false); } else { @@ -507,6 +533,7 @@ void cancel_test(void) { printf("cancel_test: ERROR expected result=%p\n", PTHREAD_CANCELED); + ASSERT(false); } else { @@ -530,6 +557,7 @@ void cancel_test(void) if (status != 0) { printf("cancel_test: ERROR pthread_detach, status=%d\n", status); + ASSERT(false); } /* Then cancel it. It should be in the pthread_cond_wait now -- wait a @@ -544,6 +572,7 @@ void cancel_test(void) { printf("cancel_test: ERROR pthread_cancel failed, status=%d\n", status); + ASSERT(false); } #ifdef CONFIG_CANCELLATION_POINTS @@ -562,12 +591,14 @@ void cancel_test(void) if (status == 0) { printf("cancel_test: ERROR pthread_join succeeded\n"); + ASSERT(false); } else if (status != ESRCH) { printf("cancel_test:" " ERROR pthread_join failed but with wrong status=%d\n", status); + ASSERT(false); } else { @@ -605,6 +636,7 @@ void cancel_test(void) { printf("cancel_test: ERROR pthread_cancel failed, status=%d\n", status); + ASSERT(false); } /* Signal the thread. It should wake up and restore the cancelable state. @@ -616,6 +648,7 @@ void cancel_test(void) { printf("cancel_test: ERROR pthread_mutex_lock failed, status=%d\n", status); + ASSERT(false); } status = pthread_cond_signal(&cond); @@ -623,6 +656,7 @@ void cancel_test(void) { printf("cancel_test: ERROR pthread_cond_signal failed, status=%d\n", status); + ASSERT(false); } status = pthread_mutex_unlock(&mutex); @@ -630,6 +664,7 @@ void cancel_test(void) { printf("cancel_test: ERROR pthread_mutex_unlock failed, status=%d\n", status); + ASSERT(false); } /* Then join to the thread to pick up the result (if we don't do @@ -641,6 +676,7 @@ void cancel_test(void) if (status != 0) { printf("cancel_test: ERROR pthread_join failed, status=%d\n", status); + ASSERT(false); } else { @@ -649,6 +685,7 @@ void cancel_test(void) { printf("cancel_test: ERROR expected result=%p\n", PTHREAD_CANCELED); + ASSERT(false); } else { @@ -673,6 +710,7 @@ void cancel_test(void) if (mqcancel == (mqd_t)-1) { printf("sender_thread: ERROR mq_open failed\n"); + ASSERT(false); pthread_exit((pthread_addr_t)1); } @@ -692,6 +730,7 @@ void cancel_test(void) { printf("cancel_test: ERROR pthread_cancel failed, status=%d\n", status); + ASSERT(false); } /* Then join to the thread to pick up the result (if we don't do @@ -704,6 +743,7 @@ void cancel_test(void) { printf("cancel_test: ERROR pthread_join failed, status=%d\n", status); + ASSERT(false); } else { @@ -712,6 +752,7 @@ void cancel_test(void) { printf("cancel_test: ERROR expected result=%p\n", PTHREAD_CANCELED); + ASSERT(false); } else { @@ -725,6 +766,7 @@ void cancel_test(void) if (mq_close(mqcancel) < 0) { printf("sender_thread: ERROR mq_close failed\n"); + ASSERT(false); } #else printf("Skipped\n"); @@ -750,6 +792,7 @@ void cancel_test(void) { printf("cancel_test: ERROR pthread_cancel failed, status=%d\n", status); + ASSERT(false); } /* Then join to the thread to pick up the result (if we don't do @@ -762,6 +805,7 @@ void cancel_test(void) { printf("cancel_test: ERROR pthread_join failed, status=%d\n", status); + ASSERT(false); } else { @@ -770,6 +814,7 @@ void cancel_test(void) { printf("cancel_test: ERROR expected result=%p\n", PTHREAD_CANCELED); + ASSERT(false); } else { diff --git a/testing/ostest/cond.c b/testing/ostest/cond.c index f04f6db64..95e78a88f 100644 --- a/testing/ostest/cond.c +++ b/testing/ostest/cond.c @@ -79,6 +79,7 @@ static void *thread_waiter(void *parameter) { printf("waiter_thread: " "ERROR pthread_mutex_lock failed, status=%d\n", status); + ASSERT(false); waiter_nerrors++; } @@ -105,6 +106,7 @@ static void *thread_waiter(void *parameter) printf("waiter_thread: " "ERROR pthread_cond_wait failed, status=%d\n", status); + ASSERT(false); waiter_nerrors++; } @@ -116,6 +118,7 @@ static void *thread_waiter(void *parameter) if (!data_available) { printf("waiter_thread: ERROR data not available after wait\n"); + ASSERT(false); waiter_nerrors++; } @@ -130,6 +133,7 @@ static void *thread_waiter(void *parameter) { printf("waiter_thread: ERROR waiter: " "pthread_mutex_unlock failed, status=%d\n", status); + ASSERT(false); waiter_nerrors++; } @@ -157,6 +161,7 @@ static void *thread_signaler(void *parameter) { printf("thread_signaler: " "ERROR pthread_mutex_lock failed, status=%d\n", status); + ASSERT(false); signaler_nerrors++; } @@ -174,6 +179,7 @@ static void *thread_signaler(void *parameter) printf("thread_signaler: " "ERROR data already available, waiter_state=%d\n", waiter_state); + ASSERT(false); signaler_already++; } @@ -185,6 +191,7 @@ static void *thread_signaler(void *parameter) { printf("thread_signaler: " "ERROR pthread_cond_signal failed, status=%d\n", status); + ASSERT(false); signaler_nerrors++; } @@ -195,6 +202,7 @@ static void *thread_signaler(void *parameter) { printf("thread_signaler: " "ERROR pthread_mutex_unlock failed, status=%d\n", status); + ASSERT(false); signaler_nerrors++; } @@ -245,6 +253,7 @@ void cond_test(void) { printf("cond_test: " "ERROR pthread_mutex_init failed, status=%d\n", status); + ASSERT(false); } /* Initialize the condition variable */ @@ -255,6 +264,7 @@ void cond_test(void) { printf("cond_test: " "ERROR pthread_condinit failed, status=%d\n", status); + ASSERT(false); } /* Start the waiter thread at higher priority */ diff --git a/testing/ostest/dev_null.c b/testing/ostest/dev_null.c index e5820e12d..e59e9540a 100644 --- a/testing/ostest/dev_null.c +++ b/testing/ostest/dev_null.c @@ -47,6 +47,7 @@ int dev_null(void) if (fd < 0) { printf("dev_null: ERROR Failed to open /dev/null\n"); + ASSERT(false); return -1; } @@ -54,6 +55,7 @@ int dev_null(void) if (nbytes < 0) { printf("dev_null: ERROR Failed to read from /dev/null\n"); + ASSERT(false); close(fd); return -1; } @@ -64,6 +66,7 @@ int dev_null(void) if (nbytes < 0) { printf("dev_null: ERROR Failed to write to /dev/null\n"); + ASSERT(false); close(fd); return -1; } diff --git a/testing/ostest/fpu.c b/testing/ostest/fpu.c index adf13d548..43df0fc16 100644 --- a/testing/ostest/fpu.c +++ b/testing/ostest/fpu.c @@ -227,6 +227,7 @@ static int fpu_task(int argc, char *argv[]) printf("ERROR FPU#%d: save1 and save2 do not match\n", id); fpu_dump(fpu->save1, "Values after math operations (save1)"); fpu_dump(fpu->save2, "Values after verify re-read (save2)"); + ASSERT(false); return EXIT_FAILURE; } @@ -247,6 +248,7 @@ static int fpu_task(int argc, char *argv[]) printf("ERROR FPU#%d: save1 and save2 do not match\n", id); fpu_dump(fpu->save1, "Values before waiting (save1)"); fpu_dump(fpu->save2, "Values after waiting (save2)"); + ASSERT(false); return EXIT_FAILURE; } } @@ -277,6 +279,7 @@ void fpu_test(void) if (task1 < 0) { printf("fpu_test: ERROR Failed to start task FPU#1\n"); + ASSERT(false); } else { @@ -292,6 +295,7 @@ void fpu_test(void) if (task2 < 0) { printf("fpu_test: ERROR Failed to start task FPU#1\n"); + ASSERT(false); } else { @@ -306,6 +310,7 @@ void fpu_test(void) #else printf("fpu_test: ERROR: The FPU test is not properly configured\n"); + ASSERT(false); #endif printf("fpu_test: Returning\n"); } diff --git a/testing/ostest/getopt.c b/testing/ostest/getopt.c index d94a28146..57f1d7d22 100644 --- a/testing/ostest/getopt.c +++ b/testing/ostest/getopt.c @@ -199,6 +199,7 @@ static int getopt_short_test(int noptions, int argc, FAR char **argv, if (optind < 1 || optind > argc) { printf("ERROR: optind=%d\n", optind); + ASSERT(false); } /* Parse until getopt(), but do not process anything if ndx exceeds @@ -211,6 +212,7 @@ static int getopt_short_test(int noptions, int argc, FAR char **argv, { printf("ERROR: arg %d: ret=%d (expected %d)\n", ndx + 1, ret, expected[ndx].ret); + ASSERT(false); } if ((expected[ndx].arg == NULL && @@ -222,6 +224,7 @@ static int getopt_short_test(int noptions, int argc, FAR char **argv, ndx + 1, optarg == NULL ? "null" : optarg, expected[ndx].arg == NULL ? "null" : expected[ndx].arg); + ASSERT(false); } } @@ -235,6 +238,7 @@ static int getopt_short_test(int noptions, int argc, FAR char **argv, if (ndx != noptions && ndx != noptions + 1) { printf("ERROR: ndx=%d (expected %d)\n", ndx, noptions); + ASSERT(false); } return OK; @@ -264,6 +268,7 @@ static int getopt_long_test(int noptions, int argc, FAR char **argv, if (optind < 1 || optind > argc) { printf("ERROR: optind=%d\n", optind); + ASSERT(false); } /* Parse until getop_long(), but do not process anything if ndx exceeds @@ -276,12 +281,14 @@ static int getopt_long_test(int noptions, int argc, FAR char **argv, { printf("ERROR: arg %d: ret=%d (expected %d)\n", ndx + 1, ret, expected[ndx].ret); + ASSERT(false); } if (expected[ndx].flag != g_flag) { printf("ERROR: arg %d; flag=%d (expected %d)\n", ndx + 1, expected[ndx].flag, g_flag); + ASSERT(false); } if ((expected[ndx].arg == NULL && @@ -293,6 +300,7 @@ static int getopt_long_test(int noptions, int argc, FAR char **argv, ndx + 1, optarg == NULL ? "null" : optarg, expected[ndx].arg == NULL ? "null" : expected[ndx].arg); + ASSERT(false); } } @@ -307,6 +315,7 @@ static int getopt_long_test(int noptions, int argc, FAR char **argv, if (ndx != noptions && ndx != noptions + 1) { printf("ERROR: ndx=%d (expected %d)\n", ndx, noptions); + ASSERT(false); } return OK; @@ -336,6 +345,7 @@ static int getopt_longonly_test(int noptions, int argc, FAR char **argv, if (optind < 1 || optind > argc) { printf("ERROR: optind=%d\n", optind); + ASSERT(false); } /* Parse until getop_long(), but do not process anything if ndx exceeds @@ -348,12 +358,14 @@ static int getopt_longonly_test(int noptions, int argc, FAR char **argv, { printf("ERROR: arg %d: ret=%d (expected %d)\n", ndx + 1, ret, expected[ndx].ret); + ASSERT(false); } if (expected[ndx].flag != g_flag) { printf("ERROR: arg %d; flag=%d (expected %d)\n", ndx + 1, expected[ndx].flag, g_flag); + ASSERT(false); } if ((expected[ndx].arg == NULL && @@ -365,6 +377,7 @@ static int getopt_longonly_test(int noptions, int argc, FAR char **argv, ndx + 1, optarg == NULL ? "null" : optarg, expected[ndx].arg == NULL ? "null" : expected[ndx].arg); + ASSERT(false); } } @@ -379,6 +392,7 @@ static int getopt_longonly_test(int noptions, int argc, FAR char **argv, if (ndx != noptions && ndx != noptions + 1) { printf("ERROR: ndx=%d (expected %d)\n", ndx, noptions); + ASSERT(false); } return OK; diff --git a/testing/ostest/mqueue.c b/testing/ostest/mqueue.c index 3fe8e0fad..1b4b3191c 100644 --- a/testing/ostest/mqueue.c +++ b/testing/ostest/mqueue.c @@ -98,6 +98,7 @@ static void *sender_thread(void *arg) if (g_send_mqfd == (mqd_t)-1) { printf("sender_thread: ERROR mq_open failed\n"); + ASSERT(false); pthread_exit((pthread_addr_t)1); } @@ -114,6 +115,7 @@ static void *sender_thread(void *arg) { printf("sender_thread: ERROR mq_send failure=%d on msg %d\n", status, i); + ASSERT(false); nerrors++; } else @@ -127,6 +129,7 @@ static void *sender_thread(void *arg) if (mq_close(g_send_mqfd) < 0) { printf("sender_thread: ERROR mq_close failed\n"); + ASSERT(false); } else { @@ -168,6 +171,7 @@ static void *receiver_thread(void *arg) if (g_recv_mqfd == (mqd_t)-1) { printf("receiver_thread: ERROR mq_open failed\n"); + ASSERT(false); pthread_exit((pthread_addr_t)1); } @@ -187,6 +191,7 @@ static void *receiver_thread(void *arg) { printf("receiver_thread: ERROR mq_receive failure on msg %d, " "errno=%d\n", i, errno); + ASSERT(false); nerrors++; } else @@ -197,8 +202,9 @@ static void *receiver_thread(void *arg) else if (nbytes != TEST_MSGLEN) { printf("receiver_thread: " - "mq_receive return bad size %d on msg %d\n", + "ERROR mq_receive return bad size %d on msg %d\n", nbytes, i); + ASSERT(false); nerrors++; } else if (memcmp(TEST_MESSAGE, msg_buffer, nbytes) != 0) @@ -240,6 +246,7 @@ static void *receiver_thread(void *arg) if (mq_close(g_recv_mqfd) < 0) { printf("receiver_thread: ERROR mq_close failed\n"); + ASSERT(false); nerrors++; } else @@ -276,15 +283,18 @@ void mqueue_test(void) status = pthread_attr_init(&attr); if (status != 0) { - printf("mqueue_test: pthread_attr_init failed, status=%d\n", + printf("mqueue_test: ERROR pthread_attr_init failed, status=%d\n", status); + ASSERT(false); } status = pthread_attr_setstacksize(&attr, STACKSIZE); if (status != 0) { - printf("mqueue_test: pthread_attr_setstacksize failed, status=%d\n", + printf("mqueue_test: " + "ERROR pthread_attr_setstacksize failed, status=%d\n", status); + ASSERT(false); } prio_min = sched_get_priority_min(SCHED_FIFO); @@ -295,8 +305,10 @@ void mqueue_test(void) status = pthread_attr_setschedparam(&attr, &sparam); if (status != OK) { - printf("mqueue_test: pthread_attr_setschedparam failed, status=%d\n", + printf("mqueue_test: " + "ERROR pthread_attr_setschedparam failed, status=%d\n", status); + ASSERT(false); } else { @@ -307,7 +319,9 @@ void mqueue_test(void) status = pthread_create(&receiver, &attr, receiver_thread, NULL); if (status != 0) { - printf("mqueue_test: pthread_create failed, status=%d\n", status); + printf("mqueue_test: " + "ERROR pthread_create failed, status=%d\n", status); + ASSERT(false); } /* Start the sending thread at lower priority */ @@ -316,22 +330,28 @@ void mqueue_test(void) status = pthread_attr_init(&attr); if (status != 0) { - printf("mqueue_test: pthread_attr_init failed, status=%d\n", status); + printf("mqueue_test: " + "ERROR pthread_attr_init failed, status=%d\n", status); + ASSERT(false); } status = pthread_attr_setstacksize(&attr, STACKSIZE); if (status != 0) { - printf("mqueue_test: pthread_attr_setstacksize failed, status=%d\n", + printf("mqueue_test: " + "ERROR pthread_attr_setstacksize failed, status=%d\n", status); + ASSERT(false); } sparam.sched_priority = (prio_min + prio_mid) / 2; status = pthread_attr_setschedparam(&attr, &sparam); if (status != OK) { - printf("mqueue_test: pthread_attr_setschedparam failed, status=%d\n", + printf("mqueue_test: " + "ERROR pthread_attr_setschedparam failed, status=%d\n", status); + ASSERT(false); } else { @@ -342,7 +362,9 @@ void mqueue_test(void) status = pthread_create(&sender, &attr, sender_thread, NULL); if (status != 0) { - printf("mqueue_test: pthread_create failed, status=%d\n", status); + printf("mqueue_test: " + "ERROR pthread_create failed, status=%d\n", status); + ASSERT(false); } printf("mqueue_test: Waiting for sender to complete\n"); @@ -351,6 +373,7 @@ void mqueue_test(void) { printf("mqueue_test: ERROR sender thread exited with %d errors\n", (int)((intptr_t)result)); + ASSERT(false); } /* Wake up the receiver thread with a signal */ @@ -387,6 +410,7 @@ void mqueue_test(void) expected); printf(" ERROR Instead exited with nerrors=%d\n", (int)((intptr_t)result)); + ASSERT(false); } /* Message queues are global resources and persist for the life the @@ -400,14 +424,17 @@ void mqueue_test(void) if (mq_close(g_recv_mqfd) < 0) { printf("mqueue_test: ERROR mq_close failed\n"); + ASSERT(false); } } else if (result != PTHREAD_CANCELED && g_recv_mqfd) { printf("mqueue_test: ERROR send mqd_t left open\n"); + ASSERT(false); if (mq_close(g_recv_mqfd) < 0) { printf("mqueue_test: ERROR mq_close failed\n"); + ASSERT(false); } } @@ -416,9 +443,11 @@ void mqueue_test(void) if (g_send_mqfd) { printf("mqueue_test: ERROR receiver mqd_t left open\n"); + ASSERT(false); if (mq_close(g_send_mqfd) < 0) { printf("sender_thread: ERROR mq_close failed\n"); + ASSERT(false); } } @@ -427,5 +456,6 @@ void mqueue_test(void) if (mq_unlink("mqueue") < 0) { printf("mqueue_test: ERROR mq_unlink failed\n"); + ASSERT(false); } } diff --git a/testing/ostest/mutex.c b/testing/ostest/mutex.c index 68b7808b8..3503bd879 100644 --- a/testing/ostest/mutex.c +++ b/testing/ostest/mutex.c @@ -66,6 +66,7 @@ static void *thread_func(FAR void *parameter) { printf("ERROR thread %d: pthread_mutex_lock failed, status=%d\n", id, status); + ASSERT(false); } if (my_mutex == 1) @@ -73,6 +74,7 @@ static void *thread_func(FAR void *parameter) printf("ERROR thread=%d: " "my_mutex should be zero, instead my_mutex=%d\n", id, my_mutex); + ASSERT(false); nerrors[ndx]++; } @@ -89,6 +91,7 @@ static void *thread_func(FAR void *parameter) { printf("ERROR thread %d: pthread_mutex_unlock failed, status=%d\n", id, status); + ASSERT(false); } } @@ -128,6 +131,7 @@ void mutex_test(void) if (status != 0) { printf("ERROR in thread#1 creation\n"); + ASSERT(false); } printf("Starting thread 2\n"); @@ -139,6 +143,7 @@ void mutex_test(void) if (status != 0) { printf("ERROR in thread#2 creation\n"); + ASSERT(false); } #ifdef SDCC diff --git a/testing/ostest/nsem.c b/testing/ostest/nsem.c index faa92e55b..ffb3d4aff 100644 --- a/testing/ostest/nsem.c +++ b/testing/ostest/nsem.c @@ -63,6 +63,7 @@ static FAR void *nsem_peer(void *parameter) { int errcode = errno; printf("nsem_peer: ERROR: sem_open(1) failed: %d\n", errcode); + ASSERT(false); return NULL; } @@ -74,6 +75,7 @@ static FAR void *nsem_peer(void *parameter) { int errcode = errno; printf("nsem_peer: ERROR: sem_open(2) failed: %d\n", errcode); + ASSERT(false); return NULL; } @@ -119,6 +121,7 @@ void nsem_test(void) { int errcode = errno; printf("nsem_peer: ERROR: sem_open(1) failed: %d\n", errcode); + ASSERT(false); return; } @@ -142,6 +145,7 @@ void nsem_test(void) printf("nsem_test: " "ERROR: pthread_attr_setschedparam failed, status=%d\n", status); + ASSERT(false); } else { @@ -152,6 +156,7 @@ void nsem_test(void) if (status != 0) { printf("nsem_test: ERROR: Peer thread creation failed: %d\n", status); + ASSERT(false); return; } @@ -163,6 +168,7 @@ void nsem_test(void) { int errcode = errno; printf("nsem_test: ERROR: sem_wait(1) failed: %d\n", errcode); + ASSERT(false); pthread_cancel(peer); return; } @@ -182,6 +188,7 @@ void nsem_test(void) { int errcode = errno; printf("nsem_test: ERROR: sem_open(2) failed: %d\n", errcode); + ASSERT(false); pthread_cancel(peer); return; } @@ -194,6 +201,7 @@ void nsem_test(void) { int errcode = errno; printf("nsem_test: ERROR: sem_wait(1) failed: %d\n", errcode); + ASSERT(false); pthread_cancel(peer); return; } diff --git a/testing/ostest/ostest_main.c b/testing/ostest/ostest_main.c index d95ec64cf..93ccb186f 100644 --- a/testing/ostest/ostest_main.c +++ b/testing/ostest/ostest_main.c @@ -166,6 +166,7 @@ static void show_variable(const char *var_name, const char *exptd_value, printf("show_variable: ERROR Variable=%s has the wrong " "value\n", var_name); + ASSERT(false); printf("show_variable: found=%s expected=%s\n", actual_value, exptd_value); } @@ -175,6 +176,7 @@ static void show_variable(const char *var_name, const char *exptd_value, printf("show_variable: ERROR Variable=%s has a value when it " "should not\n", var_name); + ASSERT(false); printf("show_variable: value=%s\n", actual_value); } @@ -183,6 +185,7 @@ static void show_variable(const char *var_name, const char *exptd_value, { printf("show_variable: ERROR Variable=%s has no value\n", var_name); + ASSERT(false); printf("show_variable: Should have had value=%s\n", exptd_value); } @@ -227,6 +230,7 @@ static int user_main(int argc, char *argv[]) { printf("user_main: ERROR expected argc=%d got argc=%d\n", NARGS + 1, argc); + ASSERT(false); } for (i = 0; i <= NARGS; i++) @@ -241,6 +245,7 @@ static int user_main(int argc, char *argv[]) printf("user_main: ERROR argv[%d]: " "Expected \"%s\" found \"%s\"\n", i, g_argv[i - 1], argv[i]); + ASSERT(false); } } @@ -275,6 +280,7 @@ static int user_main(int argc, char *argv[]) if (ret < 0) { printf("user_main: ERROR: sigaction failed: %d\n", errno); + ASSERT(false); } } #endif @@ -648,6 +654,7 @@ int main(int argc, FAR char **argv) if (result == ERROR) { printf("ostest_main: ERROR Failed to start user_main\n"); + ASSERT(false); ostest_result = ERROR; } else @@ -661,6 +668,7 @@ int main(int argc, FAR char **argv) { printf("ostest_main: ERROR Failed to wait for user_main to " "terminate\n"); + ASSERT(false); ostest_result = ERROR; } #endif diff --git a/testing/ostest/posixtimer.c b/testing/ostest/posixtimer.c index eb5cbed34..bc8346405 100644 --- a/testing/ostest/posixtimer.c +++ b/testing/ostest/posixtimer.c @@ -64,6 +64,7 @@ static void timer_expiration(int signo, siginfo_t *info, void *ucontext) { printf("timer_expiration: ERROR expected signo=%d\n", MY_TIMER_SIGNAL); + ASSERT(false); } /* Check siginfo */ @@ -72,6 +73,7 @@ static void timer_expiration(int signo, siginfo_t *info, void *ucontext) { printf("timer_expiration: ERROR sival_int=%d expected %d\n", info->si_value.sival_int, SIGVALUE_INT); + ASSERT(false); } else { @@ -82,6 +84,7 @@ static void timer_expiration(int signo, siginfo_t *info, void *ucontext) { printf("timer_expiration: ERROR expected si_signo=%d, got=%d\n", MY_TIMER_SIGNAL, info->si_signo); + ASSERT(false); } if (info->si_code == SI_TIMER) @@ -92,6 +95,7 @@ static void timer_expiration(int signo, siginfo_t *info, void *ucontext) { printf("timer_expiration: ERROR si_code=%d, expected SI_TIMER=%d\n", info->si_code, SI_TIMER); + ASSERT(false); } /* Check ucontext_t */ @@ -106,12 +110,14 @@ static void timer_expiration(int signo, siginfo_t *info, void *ucontext) { printf("timer_expiration: ERROR sigprocmask failed, status=%d\n", status); + ASSERT(false); } if (oldset != allsigs) { printf("timer_expiration: ERROR sigprocmask=%jx expected=%jx\n", (uintmax_t)oldset, (uintmax_t)allsigs); + ASSERT(false); } } @@ -144,6 +150,7 @@ void timer_test(void) { printf("timer_test: ERROR sigprocmask failed, status=%d\n", status); + ASSERT(false); } printf("timer_test: Registering signal handler\n"); @@ -157,6 +164,7 @@ void timer_test(void) if (status != OK) { printf("timer_test: ERROR sigaction failed, status=%d\n" , status); + ASSERT(false); } #ifndef SDCC @@ -179,7 +187,8 @@ void timer_test(void) status = timer_create(CLOCK_REALTIME, ¬ify, &timerid); if (status != OK) { - printf("timer_test: timer_create failed, errno=%d\n", errno); + printf("timer_test: ERROR timer_create failed, errno=%d\n", errno); + ASSERT(false); goto errorout; } @@ -195,7 +204,8 @@ void timer_test(void) status = timer_settime(timerid, 0, &timer, NULL); if (status != OK) { - printf("timer_test: timer_settime failed, errno=%d\n", errno); + printf("timer_test: ERROR timer_settime failed, errno=%d\n", errno); + ASSERT(false); goto errorout; } @@ -217,11 +227,13 @@ void timer_test(void) else { printf("timer_test: ERROR sem_wait failed, errno=%d\n", error); + ASSERT(false); } } else { printf("timer_test: ERROR awakened with no error!\n"); + ASSERT(false); } printf("timer_test: g_nsigreceived=%d\n", g_nsigreceived); @@ -236,7 +248,8 @@ errorout: status = timer_delete(timerid); if (status != OK) { - printf("timer_test: timer_create failed, errno=%d\n", errno); + printf("timer_test: ERROR timer_create failed, errno=%d\n", errno); + ASSERT(false); } /* Detach the signal handler */ diff --git a/testing/ostest/prioinherit.c b/testing/ostest/prioinherit.c index faec46f33..3b9e4a30f 100644 --- a/testing/ostest/prioinherit.c +++ b/testing/ostest/prioinherit.c @@ -116,7 +116,8 @@ static void sleep_and_display(int n, int us) if (status != 0) { - printf("priority_inheritance: sched_getparam failed\n"); + printf("priority_inheritance: ERROR sched_getparam failed\n"); + ASSERT(false); } if (us == 0 || g_priority_tracking[n] != sparam.sched_priority) @@ -227,7 +228,9 @@ static FAR void *highpri_thread(FAR void *parameter) if (ret != 0) { - printf("highpri_thread-%d: sem_take failed: %d\n", threadno, ret); + printf("highpri_thread-%d: " + "ERROR sem_take failed: %d\n", threadno, ret); + ASSERT(false); } else if (g_middlestate == RUNNING) { @@ -239,6 +242,7 @@ static FAR void *highpri_thread(FAR void *parameter) printf("highpri_thread-%d: ERROR -- " "midpri_thread has already exited!\n", threadno); + ASSERT(false); } sem_post(&g_sem); @@ -325,6 +329,7 @@ static FAR void *lowpri_thread(FAR void *parameter) { printf("lowpri_thread-%d: ERROR pthread_getschedparam failed: %d\n", threadno, ret); + ASSERT(false); } else { @@ -333,6 +338,7 @@ static FAR void *lowpri_thread(FAR void *parameter) if (sparam.sched_priority != g_lowpri) { printf(" ERROR should have been %d\n", g_lowpri); + ASSERT(false); } } @@ -340,7 +346,8 @@ static FAR void *lowpri_thread(FAR void *parameter) ret = sem_wait(&g_sem); if (ret != 0) { - printf("lowpri_thread-%d: sem_take failed: %d\n", threadno, ret); + printf("lowpri_thread-%d: ERROR sem_take failed: %d\n", threadno, ret); + ASSERT(false); } else { @@ -377,6 +384,7 @@ static FAR void *lowpri_thread(FAR void *parameter) { printf("lowpri_thread-%d: ERROR sem_getvalue failed: %d\n", threadno, errno); + ASSERT(false); } printf("lowpri_thread-%d: Sem count: %d, No. highpri thread: %d\n", @@ -401,6 +409,7 @@ static FAR void *lowpri_thread(FAR void *parameter) printf("lowpri_thread-%d: %s the middle priority task has already" " exitted!\n", threadno, count >= 0 ? "SUCCESS" : "ERROR"); + ASSERT(count >= 0); printf(" g_middlestate: %d sem count=%d\n", (int)g_middlestate, count); for (i = 0; i < NHIGHPRI_THREADS; i++) @@ -418,6 +427,7 @@ static FAR void *lowpri_thread(FAR void *parameter) { printf("lowpri_thread-%d: ERROR pthread_getschedparam failed: %d\n", threadno, ret); + ASSERT(false); } else { @@ -438,6 +448,7 @@ static FAR void *lowpri_thread(FAR void *parameter) if (sparam.sched_priority != expected) { printf(" ERROR should have been %d\n", expected); + ASSERT(false); } } @@ -446,6 +457,7 @@ static FAR void *lowpri_thread(FAR void *parameter) { printf("lowpri_thread-%d: ERROR pthread_getschedparam failed: %d\n", threadno, ret); + ASSERT(false); } else { @@ -457,6 +469,7 @@ static FAR void *lowpri_thread(FAR void *parameter) if (sparam.sched_priority != g_lowpri) { printf(" ERROR should have been %d\n", g_lowpri); + ASSERT(false); } } @@ -505,7 +518,8 @@ void priority_inheritance(void) status = sched_getparam(getpid(), &sparam); if (status != 0) { - printf("priority_inheritance: sched_getparam failed\n"); + printf("priority_inheritance: ERROR sched_getparam failed\n"); + ASSERT(false); sparam.sched_priority = PTHREAD_DEFAULT_PRIORITY; } @@ -530,8 +544,9 @@ void priority_inheritance(void) if (status != 0) { printf("priority_inheritance: " - "pthread_attr_init failed, status=%d\n", + "ERROR pthread_attr_init failed, status=%d\n", status); + ASSERT(false); } sparam.sched_priority = g_lowpri; @@ -539,8 +554,9 @@ void priority_inheritance(void) if (status != OK) { printf("priority_inheritance: " - "pthread_attr_setschedparam failed, status=%d\n", + "ERROR pthread_attr_setschedparam failed, status=%d\n", status); + ASSERT(false); } else { @@ -554,7 +570,8 @@ void priority_inheritance(void) if (status != 0) { printf("priority_inheritance: " - "pthread_create failed, status=%d\n", status); + "ERROR pthread_create failed, status=%d\n", status); + ASSERT(false); } } @@ -569,7 +586,8 @@ void priority_inheritance(void) if (status != 0) { printf("priority_inheritance: " - "pthread_attr_init failed, status=%d\n", status); + "ERROR pthread_attr_init failed, status=%d\n", status); + ASSERT(false); } sparam.sched_priority = g_medpri; @@ -577,8 +595,9 @@ void priority_inheritance(void) if (status != OK) { printf("priority_inheritance: " - "pthread_attr_setschedparam failed, status=%d\n", + "ERROR pthread_attr_setschedparam failed, status=%d\n", status); + ASSERT(false); } else { @@ -591,8 +610,10 @@ void priority_inheritance(void) status = pthread_create(&medpri, &attr, medpri_thread, NULL); if (status != 0) { - printf("priority_inheritance: pthread_create failed, status=%d\n", + printf("priority_inheritance: " + "ERROR pthread_create failed, status=%d\n", status); + ASSERT(false); } printf("priority_inheritance: Waiting...\n"); @@ -611,7 +632,8 @@ void priority_inheritance(void) if (status != 0) { printf("priority_inheritance: " - "pthread_attr_init failed, status=%d\n", status); + "ERROR pthread_attr_init failed, status=%d\n", status); + ASSERT(false); } sparam.sched_priority = g_highpri - i; @@ -619,7 +641,9 @@ void priority_inheritance(void) if (status != OK) { printf("priority_inheritance: " - "pthread_attr_setschedparam failed, status=%d\n", status); + "ERROR pthread_attr_setschedparam failed, status=%d\n", + status); + ASSERT(false); } else { @@ -635,7 +659,8 @@ void priority_inheritance(void) if (status != 0) { printf("priority_inheritance: " - "pthread_create failed, status=%d\n", status); + "ERRROR pthread_create failed, status=%d\n", status); + ASSERT(false); } } @@ -715,6 +740,7 @@ void priority_inheritance(void) { printf("priority_inheritance: ERROR: FAIL Priorities were not " "correctly restored.\n"); + ASSERT(false); } else { diff --git a/testing/ostest/pthread_cleanup.c b/testing/ostest/pthread_cleanup.c index bed35f3e4..ccb8fe957 100644 --- a/testing/ostest/pthread_cleanup.c +++ b/testing/ostest/pthread_cleanup.c @@ -65,6 +65,7 @@ static void cleanup(FAR void * data) printf("pthread_cleanup:" "ERROR pthread_mutex_unlock in cleanup handler. " "Status: %d\n", status); + ASSERT(false); } } @@ -78,6 +79,7 @@ static void *cleanup_thread(FAR void * data) { printf("pthread_cleanup: ERROR pthread_mutex_lock, status=%d\n", status); + ASSERT(false); return NULL; } @@ -90,6 +92,7 @@ static void *cleanup_thread(FAR void * data) { printf("pthread_cleanup: ERROR wait returned. Status: %d\n", status); + ASSERT(false); } } @@ -111,6 +114,7 @@ static void test_cleanup(void) if (status != 0) { printf("pthread_cleanup: ERROR pthread_create, status=%d\n", status); + ASSERT(false); return; } @@ -120,17 +124,20 @@ static void test_cleanup(void) if (status != 0) { printf("pthread_cleanup: ERROR pthread_cancel, status=%d\n", status); + ASSERT(false); } status = pthread_join(thread1, &result); if (status != 0) { printf("pthread_cleanup: ERROR pthread_join, status=%d\n", status); + ASSERT(false); } else if (result != PTHREAD_CANCELED) { printf("pthread_cleanup: " "ERROR pthread_join returned wrong result: %p\n", result); + ASSERT(false); } #ifdef CONFIG_CANCELLATION_POINTS @@ -141,6 +148,7 @@ static void test_cleanup(void) { printf("pthread_cleanup: ERROR pthread_mutex_trylock, status=%d\n", status); + ASSERT(false); } status = pthread_mutex_unlock(&sync.lock); @@ -148,6 +156,7 @@ static void test_cleanup(void) { printf("pthread_cleanup: ERROR pthread_mutex_unlock, status=%d\n", status); + ASSERT(false); } #endif } diff --git a/testing/ostest/pthread_rwlock.c b/testing/ostest/pthread_rwlock.c index dc079535c..326fa3cd8 100644 --- a/testing/ostest/pthread_rwlock.c +++ b/testing/ostest/pthread_rwlock.c @@ -63,7 +63,8 @@ static FAR void *race_cond_thread1(FAR void *data) status = pthread_rwlock_wrlock(rc->rw_lock); if (status != 0) { - printf("pthread_rwlock: Failed to lock for writing\n"); + printf("pthread_rwlock: ERROR Failed to lock for writing\n"); + ASSERT(false); } sem_post(rc->sem2); @@ -80,14 +81,18 @@ static FAR void *race_cond_thread1(FAR void *data) status = pthread_rwlock_unlock(rc->rw_lock); if (status != 0) { - printf("pthread_rwlock: Failed to unlock lock held for writing\n"); + printf("pthread_rwlock: " + "ERROR Failed to unlock lock held for writing\n"); + ASSERT(false); } status = pthread_rwlock_rdlock(rc->rw_lock); if (status != 0) { printf("pthread_rwlock: " - "Failed to open rwlock for reading. Status: %d\n", status); + "ERROR Failed to open rwlock for reading. Status: %d\n", + status); + ASSERT(false); } sem_wait(rc->sem1); @@ -103,14 +108,18 @@ static FAR void *race_cond_thread1(FAR void *data) status = pthread_rwlock_unlock(rc->rw_lock); if (status != 0) { - printf("pthread_rwlock: Failed to unlock lock held for writing\n"); + printf("pthread_rwlock: " + "ERROR Failed to unlock lock held for writing\n"); + ASSERT(false); } status = pthread_rwlock_rdlock(rc->rw_lock); if (status != 0) { printf("pthread_rwlock: " - "Failed to open rwlock for reading. Status: %d\n", status); + "ERROR Failed to open rwlock for reading. Status: %d\n", + status); + ASSERT(false); } sem_post(rc->sem2); @@ -128,7 +137,9 @@ static FAR void *race_cond_thread1(FAR void *data) if (status != 0) { printf("pthread_rwlock: " - "Failed to unlock lock held for reading. Status: %d\n", status); + "ERROR Failed to unlock lock held for reading. Status: %d\n", + status); + ASSERT(false); } return NULL; @@ -146,7 +157,8 @@ static FAR void *race_cond_thread2(FAR void *data) if (status != 0) { printf("pthread_rwlock: " - "Failed to wait on semaphore. Status: %d\n", status); + "ERROR Failed to wait on semaphore. Status: %d\n", status); + ASSERT(false); } if (g_race_cond_thread_pos++ != 1) @@ -178,7 +190,9 @@ static FAR void *race_cond_thread2(FAR void *data) if (status != 0) { printf("pthread_rwlock: " - "Failed to open rwlock for reading. Status: %d\n", status); + "ERROR Failed to open rwlock for reading. Status: %d\n", + status); + ASSERT(false); } if (g_race_cond_thread_pos++ != 3) @@ -190,7 +204,9 @@ static FAR void *race_cond_thread2(FAR void *data) status = pthread_rwlock_unlock(rc->rw_lock); if (status != 0) { - printf("pthread_rwlock: Failed to unlock lock held for writing\n"); + printf("pthread_rwlock: " + "ERROR Failed to unlock lock held for writing\n"); + ASSERT(false); } sem_post(rc->sem1); @@ -212,7 +228,9 @@ static FAR void *race_cond_thread2(FAR void *data) if (status != 0) { printf("pthread_rwlock: " - "Failed to open rwlock for reading. Status: %d\n", status); + "ERROR Failed to open rwlock for reading. Status: %d\n", + status); + ASSERT(false); } if (g_race_cond_thread_pos++ != 7) @@ -225,7 +243,9 @@ static FAR void *race_cond_thread2(FAR void *data) if (status != 0) { printf("pthread_rwlock: " - "Failed to unlock lock held for writing. Status: %d\n", status); + "ERROR Failed to unlock lock held for writing. Status: %d\n", + status); + ASSERT(false); } return NULL; @@ -246,18 +266,21 @@ static void test_two_threads(void) { printf("pthread_rwlock: " "ERROR pthread_rwlock_init failed, status=%d\n", status); + ASSERT(false); } status = sem_init(&sem1, 0, 0); if (status != 0) { printf("pthread_rwlock: ERROR sem_init failed, status=%d\n", status); + ASSERT(false); } status = sem_init(&sem2, 0, 0); if (status != 0) { printf("pthread_rwlock: ERROR sem_init failed, status=%d\n", status); + ASSERT(false); } rc.sem1 = &sem1; @@ -279,8 +302,9 @@ static void * timeout_thread1(FAR void * data) status = pthread_rwlock_wrlock(rc->rw_lock); if (status != 0) { - printf("pthread_rwlock: Failed to acquire rw_lock. Status: %d\n", + printf("pthread_rwlock: ERROR Failed to acquire rw_lock. Status: %d\n", status); + ASSERT(false); } sem_wait(rc->sem1); @@ -288,8 +312,9 @@ static void * timeout_thread1(FAR void * data) status = pthread_rwlock_unlock(rc->rw_lock); if (status != 0) { - printf("pthread_rwlock: Failed to unlock rw_lock. Status: %d\n", + printf("pthread_rwlock: ERROR Failed to unlock rw_lock. Status: %d\n", status); + ASSERT(false); } return NULL; @@ -307,7 +332,9 @@ static void * timeout_thread2(FAR void * data) status = pthread_rwlock_timedwrlock(rc->rw_lock, &time); if (status != ETIMEDOUT) { - printf("pthread_rwlock: Failed to properly timeout write lock\n"); + printf("pthread_rwlock: " + "ERROR Failed to properly timeout write lock\n"); + ASSERT(false); } status = clock_gettime(CLOCK_REALTIME, &time); @@ -316,7 +343,8 @@ static void * timeout_thread2(FAR void * data) status = pthread_rwlock_timedrdlock(rc->rw_lock, &time); if (status != ETIMEDOUT) { - printf("pthread_rwlock: Failed to properly timeout rd lock\n"); + printf("pthread_rwlock: ERROR Failed to properly timeout rd lock\n"); + ASSERT(false); } status = clock_gettime(CLOCK_REALTIME, &time); @@ -326,13 +354,15 @@ static void * timeout_thread2(FAR void * data) status = pthread_rwlock_timedrdlock(rc->rw_lock, &time); if (status != 0) { - printf("pthread_rwlock: Failed to properly acquire rdlock\n"); + printf("pthread_rwlock: ERROR Failed to properly acquire rdlock\n"); + ASSERT(false); } status = pthread_rwlock_unlock(rc->rw_lock); if (status != 0) { - printf("pthread_rwlock: Failed to release rdlock\n"); + printf("pthread_rwlock: ERROR Failed to release rdlock\n"); + ASSERT(false); } return NULL; @@ -353,18 +383,21 @@ static void test_timeout(void) { printf("pthread_rwlock: ERROR pthread_rwlock_init failed, status=%d\n", status); + ASSERT(false); } status = sem_init(&sem1, 0, 0); if (status != 0) { printf("pthread_rwlock: ERROR sem_init failed, status=%d\n", status); + ASSERT(false); } status = sem_init(&sem2, 0, 0); if (status != 0) { printf("pthread_rwlock: ERROR sem_init failed, status=%d\n", status); + ASSERT(false); } rc.sem1 = &sem1; @@ -395,6 +428,7 @@ void pthread_rwlock_test(void) printf("pthread_rwlock: " "ERROR pthread_rwlock_init failed, status=%d\n", status); + ASSERT(false); } status = pthread_rwlock_trywrlock(&rw_lock); @@ -403,6 +437,7 @@ void pthread_rwlock_test(void) printf("pthread_rwlock: " "ERROR pthread_rwlock_trywrlock failed, status=%d\n", status); + ASSERT(false); } status = pthread_rwlock_unlock(&rw_lock); @@ -411,6 +446,7 @@ void pthread_rwlock_test(void) printf("pthread_rwlock: " "ERROR pthread_rwlock_unlock failed, status=%d\n", status); + ASSERT(false); } status = pthread_rwlock_trywrlock(&rw_lock); @@ -419,6 +455,7 @@ void pthread_rwlock_test(void) printf("pthread_rwlock: " "ERROR pthread_rwlock_trywrlock failed, status=%d\n", status); + ASSERT(false); } status = pthread_rwlock_trywrlock(&rw_lock); @@ -426,6 +463,7 @@ void pthread_rwlock_test(void) { printf("pthread_rwlock: ERROR " "able to acquire write lock when write lock already acquired\n"); + ASSERT(false); } status = pthread_rwlock_tryrdlock(&rw_lock); @@ -433,6 +471,7 @@ void pthread_rwlock_test(void) { printf("pthread_rwlock: ERROR " "able to acquire read lock when write lock already acquired\n"); + ASSERT(false); } status = pthread_rwlock_unlock(&rw_lock); @@ -441,6 +480,7 @@ void pthread_rwlock_test(void) printf("pthread_rwlock: " "ERROR pthread_rwlock_unlock failed, status=%d\n", status); + ASSERT(false); } test_two_threads(); diff --git a/testing/ostest/pthread_rwlock_cancel.c b/testing/ostest/pthread_rwlock_cancel.c index 24700296e..b087e47e3 100644 --- a/testing/ostest/pthread_rwlock_cancel.c +++ b/testing/ostest/pthread_rwlock_cancel.c @@ -56,6 +56,7 @@ static void * timeout_thread1(FAR void * data) { printf("pthread_rwlock_cancel: " "ERROR Acquired held write_lock. Status: %d\n", status); + ASSERT(false); } } @@ -77,7 +78,8 @@ static void * timeout_thread2(FAR void * data) if (status != 0) { printf("pthread_rwlock_cancel: " - "Failed to acquire read_lock. Status: %d\n", status); + "ERROR Failed to acquire read_lock. Status: %d\n", status); + ASSERT(false); } sched_yield(); /* Not a cancellation point. */ @@ -88,7 +90,9 @@ static void * timeout_thread2(FAR void * data) if (status != 0) { printf("pthread_rwlock_cancel: " - "Failed to release read_lock. Status: %d\n", status); + "ERROR Failed to release read_lock. Status: %d\n", + status); + ASSERT(false); } } @@ -101,6 +105,7 @@ static void * timeout_thread2(FAR void * data) printf("pthread_rwlock_cancel: " "ERROR Acquired held read_lock for writing." " Status: %d\n", status); + ASSERT(false); } } @@ -122,6 +127,7 @@ static void test_timeout(void) { printf("pthread_rwlock_cancel: " "ERROR pthread_rwlock_init(read_lock), status=%d\n", status); + ASSERT(false); } status = pthread_rwlock_init(&write_lock, NULL); @@ -129,6 +135,7 @@ static void test_timeout(void) { printf("pthread_rwlock_cancel: " "ERROR pthread_rwlock_init(write_lock), status=%d\n", status); + ASSERT(false); } status = pthread_rwlock_rdlock(&read_lock); @@ -136,6 +143,7 @@ static void test_timeout(void) { printf("pthread_rwlock_cancel: " "ERROR pthread_rwlock_rdlock, status=%d\n", status); + ASSERT(false); } status = pthread_rwlock_wrlock(&write_lock); @@ -143,6 +151,7 @@ static void test_timeout(void) { printf("pthread_rwlock_cancel: " "ERROR pthread_rwlock_wrlock, status=%d\n", status); + ASSERT(false); } sync.read_lock = &read_lock; @@ -153,6 +162,7 @@ static void test_timeout(void) { printf("pthread_rwlock_cancel: " "ERROR pthread_create, status=%d\n", status); + ASSERT(false); } status = pthread_create(&thread2, NULL, timeout_thread2, &sync); @@ -160,6 +170,7 @@ static void test_timeout(void) { printf("pthread_rwlock_cancel: " "ERROR pthread_create, status=%d\n", status); + ASSERT(false); } for (i = 0; i < 10; i++) @@ -172,6 +183,7 @@ static void test_timeout(void) { printf("pthread_rwlock_cancel: " "ERROR pthread_cancel, status=%d\n", status); + ASSERT(false); } status = pthread_cancel(thread2); @@ -179,6 +191,7 @@ static void test_timeout(void) { printf("pthread_rwlock_cancel: " "ERROR pthread_cancel, status=%d\n", status); + ASSERT(false); } pthread_join(thread1, NULL); @@ -196,6 +209,7 @@ static void test_timeout(void) printf("pthread_rwlock_cancel: " "ERROR able to acquire write lock when write lock already " "acquired, status=%d\n", status); + ASSERT(false); } status = pthread_rwlock_tryrdlock(&write_lock); @@ -204,6 +218,7 @@ static void test_timeout(void) printf("pthread_rwlock_cancel: " "ERROR able to acquire read lock when write lock already " "acquired, status=%d\n", status); + ASSERT(false); } status = pthread_rwlock_unlock(&read_lock); @@ -211,6 +226,7 @@ static void test_timeout(void) { printf("pthread_rwlock_cancel: " "ERROR pthread_rwlock_unlock, status=%d\n", status); + ASSERT(false); } status = pthread_rwlock_unlock(&write_lock); @@ -218,6 +234,7 @@ static void test_timeout(void) { printf("pthread_rwlock_cancel: " "ERROR pthread_rwlock_unlock, status=%d\n", status); + ASSERT(false); } status = pthread_rwlock_rdlock(&read_lock); @@ -225,6 +242,7 @@ static void test_timeout(void) { printf("pthread_rwlock_cancel: " "ERROR pthread_rwlock_rdlock, status=%d\n", status); + ASSERT(false); } status = pthread_rwlock_wrlock(&write_lock); @@ -232,6 +250,7 @@ static void test_timeout(void) { printf("pthread_rwlock_cancel: " "ERROR pthread_rwlock_wrlock, status=%d\n", status); + ASSERT(false); } #endif /* CONFIG_CANCELLATION_POINTS */ #endif /* CONFIG_PTHREAD_CLEANUP */ diff --git a/testing/ostest/restart.c b/testing/ostest/restart.c index 4323ae84a..f2bc8a2f1 100644 --- a/testing/ostest/restart.c +++ b/testing/ostest/restart.c @@ -82,6 +82,7 @@ static int restart_main(int argc, char *argv[]) { printf("restart_main: ERROR: Expected argc=%d got argc=%d\n", NARGS + 1, argc); + ASSERT(false); } for (i = 0; i <= NARGS; i++) @@ -92,6 +93,7 @@ static int restart_main(int argc, char *argv[]) printf("restart_main: ERROR: " "Expected argv[%d]=\"%s\" got \"%s\"\n", i, argv[i], g_argv[i - 1]); + ASSERT(false); } } @@ -110,11 +112,13 @@ static int restart_main(int argc, char *argv[]) g_varname); printf("restart_main: found=%s expected=%s\n", actual, g_varvalue); + ASSERT(false); } } else { printf("restart_main: ERROR: Variable=%s has no value\n", g_varname); + ASSERT(false); } #endif @@ -133,6 +137,7 @@ static int restart_main(int argc, char *argv[]) if (sem_wait(&g_sem) != 0) { printf("restart_main: ERROR thread sem_wait failed\n"); + ASSERT(false); } break; default: @@ -169,6 +174,7 @@ void restart_test(void) if (ret < 0) { printf("restart_main: ERROR Failed to start restart_main\n"); + ASSERT(false); } else { @@ -186,6 +192,7 @@ void restart_test(void) if (ret < 0) { printf("restart_main: ERROR: task_restart failed\n"); + ASSERT(false); } /* Start the task wait for a semaphore */ @@ -202,6 +209,7 @@ void restart_test(void) if (ret < 0) { printf("restart_main: ERROR: task_restart failed\n"); + ASSERT(false); } sleep(1); diff --git a/testing/ostest/rmutex.c b/testing/ostest/rmutex.c index 3fd10cd4f..a4f406f7e 100644 --- a/testing/ostest/rmutex.c +++ b/testing/ostest/rmutex.c @@ -54,6 +54,7 @@ static void thread_inner(int id, int level) printf("thread_inner[%d, %d]: " "ERROR pthread_mutex_lock failed: %d\n", id, level, status); + ASSERT(false); } printf("thread_inner[%d, %d]: Locked\n", id, level); @@ -66,6 +67,7 @@ static void thread_inner(int id, int level) printf("thread_inner[%d, %d]: " "ERROR pthread_mutex_trylock failed: %d\n", id, level, status); + ASSERT(false); } else { @@ -77,6 +79,7 @@ static void thread_inner(int id, int level) printf("thread_inner[%d, %d]: ERROR " "pthread_mutex_unlock after try-lock failed: %d\n", id, level, status); + ASSERT(false); } } @@ -95,6 +98,7 @@ static void thread_inner(int id, int level) printf("thread_inner[%d, %d]: " "ERROR pthread_mutex_unlock failed: %d\n", id, level, status); + ASSERT(false); } printf("thread_inner[%d, %d]: Unlocked\n", id, level); @@ -138,6 +142,7 @@ void recursive_mutex_test(void) { printf("recursive_mutex_test: " "ERROR pthread_mutexattr_settype failed, status=%d\n", status); + ASSERT(false); } status = pthread_mutexattr_gettype(&mattr, &type); @@ -145,12 +150,14 @@ void recursive_mutex_test(void) { printf("recursive_mutex_test: " "ERROR pthread_mutexattr_gettype failed, status=%d\n", status); + ASSERT(false); } if (type != PTHREAD_MUTEX_RECURSIVE) { printf("recursive_mutex_test: " "ERROR pthread_mutexattr_gettype return type=%d\n", type); + ASSERT(false); } /* Initialize the mutex */ @@ -161,6 +168,7 @@ void recursive_mutex_test(void) { printf("recursive_mutex_test: " "ERROR pthread_mutex_init failed, status=%d\n", status); + ASSERT(false); } /* Start the threads -- all at the same, default priority */ @@ -180,6 +188,7 @@ void recursive_mutex_test(void) { printf("recursive_mutex_test: ERROR thread#%d creation: %d\n", i + 1, status); + ASSERT(false); } } diff --git a/testing/ostest/robust.c b/testing/ostest/robust.c index fef270044..28a396bd3 100644 --- a/testing/ostest/robust.c +++ b/testing/ostest/robust.c @@ -53,12 +53,14 @@ static FAR void *robust_waiter(FAR void *parameter) { printf("thread_waiter: ERROR: pthread_mutex_lock failed, status=%d\n", status); + ASSERT(false); } if (status != 0) { printf("robust_waiter: ERROR: pthread_mutex_lock failed, status=%d\n", status); + ASSERT(false); } else { @@ -92,6 +94,7 @@ void robust_test(void) printf("robust_test: ERROR: " "pthread_mutexattr_init failed, status=%d\n", status); + ASSERT(false); nerrors++; } @@ -101,6 +104,7 @@ void robust_test(void) printf("robust_test: ERROR: " "pthread_mutexattr_setrobust failed, status=%d\n", status); + ASSERT(false); nerrors++; } @@ -109,6 +113,7 @@ void robust_test(void) { printf("robust_test: ERROR: pthread_mutex_init failed, status=%d\n", status); + ASSERT(false); nerrors++; } @@ -121,6 +126,7 @@ void robust_test(void) { printf("robust_test: ERROR: pthread_attr_init failed, status=%d\n", status); + ASSERT(false); nerrors++; } @@ -130,6 +136,7 @@ void robust_test(void) printf("robust_test: ERROR: " "pthread_attr_setstacksize failed, status=%d\n", status); + ASSERT(false); nerrors++; } @@ -143,6 +150,7 @@ void robust_test(void) printf("robust_test: ERROR: " "pthread_create failed, status=%d\n", status); printf(" ERROR: Terminating test\n"); + ASSERT(false); nerrors++; return; } @@ -159,6 +167,7 @@ void robust_test(void) if (status == 0) { printf("robust_test: ERROR: pthread_mutex_lock succeeded\n"); + ASSERT(false); nerrors++; } else if (status != EOWNERDEAD) @@ -166,6 +175,7 @@ void robust_test(void) printf("robust_test: ERROR: pthread_mutex_lock failed with %d\n", status); printf(" ERROR: expected %d (EOWNERDEAD)\n", EOWNERDEAD); + ASSERT(false); nerrors++; } @@ -178,6 +188,7 @@ void robust_test(void) if (status == 0) { printf("robust_test: ERROR: pthread_mutex_lock succeeded\n"); + ASSERT(false); nerrors++; } else if (status != EOWNERDEAD) @@ -185,6 +196,7 @@ void robust_test(void) printf("robust_test: ERROR: pthread_mutex_lock failed with %d\n", status); printf(" ERROR: expected %d (EOWNERDEAD)\n", EOWNERDEAD); + ASSERT(false); nerrors++; } @@ -196,6 +208,7 @@ void robust_test(void) { printf("robust_test: ERROR: pthread_mutex_consistent failed: %d\n", status); + ASSERT(false); nerrors++; } @@ -205,6 +218,7 @@ void robust_test(void) { printf("robust_test: ERROR: pthread_mutex_lock failed with: %d\n", status); + ASSERT(false); nerrors++; } @@ -217,6 +231,7 @@ void robust_test(void) if (status != 0) { printf("robust_test: ERROR: pthread_join failed, status=%d\n", status); + ASSERT(false); nerrors++; } else @@ -226,6 +241,7 @@ void robust_test(void) { printf("robust_test: ERROR: expected result=%p\n", PTHREAD_CANCELED); + ASSERT(false); nerrors++; } } @@ -237,6 +253,7 @@ void robust_test(void) { printf("robust_test: ERROR: pthread_mutex_unlock failed, status=%d\n", status); + ASSERT(false); nerrors++; } @@ -245,6 +262,7 @@ void robust_test(void) { printf("robust_test: ERROR: pthread_mutex_unlock failed, status=%d\n", status); + ASSERT(false); nerrors++; } diff --git a/testing/ostest/roundrobin.c b/testing/ostest/roundrobin.c index 095e41ef1..32fce24df 100644 --- a/testing/ostest/roundrobin.c +++ b/testing/ostest/roundrobin.c @@ -159,6 +159,7 @@ void rr_test(void) if (status != OK) { printf("rr_test: ERROR: pthread_attr_init failed, status=%d\n", status); + ASSERT(false); } sparam.sched_priority = sched_get_priority_min(SCHED_FIFO); @@ -167,6 +168,7 @@ void rr_test(void) { printf("rr_test: ERROR: pthread_attr_setschedparam failed, status=%d\n", status); + ASSERT(false); } else { @@ -178,6 +180,7 @@ void rr_test(void) { printf("rr_test: ERROR: pthread_attr_setschedpolicy failed, status=%d\n", status); + ASSERT(false); } else { @@ -199,6 +202,7 @@ void rr_test(void) if (status != 0) { printf(" ERROR: Thread 1 creation failed: %d\n", status); + ASSERT(false); } printf(" First get_primes_thread: %d\n", (int)get_primes1_thread); @@ -209,6 +213,7 @@ void rr_test(void) if (status != 0) { printf(" ERROR: Thread 2 creation failed: %d\n", status); + ASSERT(false); } printf(" Second get_primes_thread: %d\n", (int)get_primes2_thread); diff --git a/testing/ostest/sem.c b/testing/ostest/sem.c index f4ef058a9..57e7156c4 100644 --- a/testing/ostest/sem.c +++ b/testing/ostest/sem.c @@ -57,6 +57,7 @@ static void *waiter_func(void *parameter) { printf("waiter_func: " "ERROR thread %d could not get semaphore value\n", id); + ASSERT(false); } else { @@ -69,6 +70,7 @@ static void *waiter_func(void *parameter) if (status != 0) { printf("waiter_func: ERROR thread %d sem_wait failed\n", id); + ASSERT(false); } printf("waiter_func: Thread %d awakened\n", id); @@ -78,6 +80,7 @@ static void *waiter_func(void *parameter) { printf("waiter_func: " "ERROR thread %d could not get semaphore value\n", id); + ASSERT(false); } else { @@ -106,6 +109,7 @@ static void *poster_func(void *parameter) { printf("poster_func: " "ERROR thread %d could not get semaphore value\n", id); + ASSERT(false); } else { @@ -120,6 +124,7 @@ static void *poster_func(void *parameter) if (status != 0) { printf("poster_func: ERROR thread %d sem_wait failed\n", id); + ASSERT(false); } pthread_yield(); @@ -129,6 +134,7 @@ static void *poster_func(void *parameter) { printf("poster_func: " "ERROR thread %d could not get semaphore value\n", id); + ASSERT(false); } else { @@ -184,6 +190,7 @@ void sem_test(void) { printf("sem_test: ERROR: " "pthread_attr_setschedparam failed, status=%d\n", status); + ASSERT(false); } else { @@ -197,6 +204,7 @@ void sem_test(void) { printf("sem_test: ERROR: " "Thread 1 creation failed: %d\n", status); + ASSERT(false); } printf("sem_test: Starting waiter thread 2\n"); @@ -205,6 +213,7 @@ void sem_test(void) { printf("sem_test: ERROR: " "pthread_attr_init failed, status=%d\n", status); + ASSERT(false); } sparam.sched_priority = prio_mid; @@ -213,6 +222,7 @@ void sem_test(void) { printf("sem_test: ERROR: " "pthread_attr_setschedparam failed, status=%d\n", status); + ASSERT(false); } else { @@ -225,6 +235,7 @@ void sem_test(void) if (status != 0) { printf("sem_test: ERROR: Thread 2 creation failed: %d\n", status); + ASSERT(false); } printf("sem_test: Starting poster thread 3\n"); @@ -233,6 +244,7 @@ void sem_test(void) { printf("sem_test: ERROR: " "pthread_attr_init failed, status=%d\n", status); + ASSERT(false); } sparam.sched_priority = (prio_min + prio_mid) / 2; @@ -254,6 +266,7 @@ void sem_test(void) { printf("sem_test: ERROR: Thread 3 creation failed: %d\n", status); printf(" Canceling waiter threads\n"); + ASSERT(false); pthread_cancel(waiter_thread1); pthread_cancel(waiter_thread2); diff --git a/testing/ostest/semtimed.c b/testing/ostest/semtimed.c index 8e36c97e9..633cf70cb 100644 --- a/testing/ostest/semtimed.c +++ b/testing/ostest/semtimed.c @@ -59,6 +59,7 @@ static void *poster_func(void *parameter) if (status != OK) { printf("poster_func: ERROR: sem_post failed\n"); + ASSERT(false); } return NULL; @@ -72,11 +73,13 @@ static void ostest_gettime(struct timespec *tp) if (status != OK) { printf("ostest_gettime: ERROR: clock_gettime failed\n"); + ASSERT(false); } else if (tp->tv_sec < 0 || tp->tv_nsec < 0 || tp->tv_nsec >= 1000 * 1000 * 1000) { printf("ostest_gettime: ERROR: clock_gettime returned bogus time\n"); + ASSERT(false); } } @@ -106,6 +109,7 @@ void semtimed_test(void) if (status != OK) { printf("semtimed_test: ERROR: sem_init failed\n"); + ASSERT(false); } /* First, @@ -126,6 +130,7 @@ void semtimed_test(void) if (status == OK) { printf("semtimed_test: ERROR: sem_timedwait succeeded\n"); + ASSERT(false); } else { @@ -137,6 +142,7 @@ void semtimed_test(void) { printf("semtimed_test: ERROR: sem_timedwait failed with: %d\n", errcode); + ASSERT(false); } } @@ -157,6 +163,7 @@ void semtimed_test(void) { printf("semtimed_test: ERROR: pthread_attr_init failed, status=%d\n", status); + ASSERT(false); } prio_min = sched_get_priority_min(SCHED_FIFO); @@ -169,6 +176,7 @@ void semtimed_test(void) { printf("semtimed_test: ERROR: " "pthread_attr_setschedparam failed, status=%d\n", status); + ASSERT(false); } else { @@ -182,14 +190,17 @@ void semtimed_test(void) { printf("semtimed_test: ERROR: pthread_attr_init failed, status=%d\n", status); + ASSERT(false); } sparam.sched_priority = (prio_min + prio_mid) / 2; status = pthread_attr_setschedparam(&attr, &sparam); if (status != OK) { - printf("semtimed_test: pthread_attr_setschedparam failed, status=%d\n", + printf("semtimed_test: " + "ERROR pthread_attr_setschedparam failed, status=%d\n", status); + ASSERT(false); } else { @@ -202,6 +213,7 @@ void semtimed_test(void) { printf("semtimed_test: ERROR: Poster thread creation failed: %d\n", status); + ASSERT(false); sem_destroy(&sem); return; } @@ -223,6 +235,7 @@ void semtimed_test(void) { printf("semtimed_test: ERROR: sem_timedwait failed with: %d\n", errcode); + ASSERT(false); } else { diff --git a/testing/ostest/setvbuf.c b/testing/ostest/setvbuf.c index fc3394961..c5449fca6 100644 --- a/testing/ostest/setvbuf.c +++ b/testing/ostest/setvbuf.c @@ -47,6 +47,7 @@ int setvbuf_test(void) if (stream == NULL) { printf("setvbuf_test ERROR: fopen(dev/console, rw) failed\n"); + ASSERT(false); return ERROR; } @@ -55,6 +56,7 @@ int setvbuf_test(void) { printf("setvbuf_test ERROR: " "setvbuf(stream, NULL, _IONBF, 0) failed\n"); + ASSERT(false); } fprintf(stream, "setvbuf_test: Using NO buffering\r\n"); @@ -72,6 +74,7 @@ int setvbuf_test(void) if (stream == NULL) { printf("setvbuf_test ERROR: fopen(dev/console, rw) failed\n"); + ASSERT(false); return ERROR; } @@ -80,6 +83,7 @@ int setvbuf_test(void) { printf("ssetvbuf_test ERROR: " "setvbuf(stream, NULL, _IOFBF, 0) failed\n"); + ASSERT(false); } fprintf(stream, "setvbuf_test: Using default FULL buffering\r\n"); @@ -97,6 +101,7 @@ int setvbuf_test(void) if (stream == NULL) { printf("setvbuf_test ERROR: fopen(dev/console, rw) failed\n"); + ASSERT(false); return ERROR; } @@ -105,6 +110,7 @@ int setvbuf_test(void) { printf("ssetvbuf_test ERROR: " "setvbuf(stream, NULL, _IOFBF, 64) failed\n"); + ASSERT(false); } fprintf(stream, "setvbuf_test: Using FULL buffering, buffer size 64\r\n"); @@ -122,6 +128,7 @@ int setvbuf_test(void) if (stream == NULL) { printf("setvbuf_test ERROR: fopen(dev/console, rw) failed\n"); + ASSERT(false); return ERROR; } @@ -130,6 +137,7 @@ int setvbuf_test(void) { printf("ssetvbuf_test ERROR: " "setvbuf(stream, buffer, _IOFBF, 64) failed\n"); + ASSERT(false); } fprintf(stream, @@ -148,6 +156,7 @@ int setvbuf_test(void) if (stream == NULL) { printf("setvbuf_test ERROR: fopen(dev/console, rw) failed\n"); + ASSERT(false); return ERROR; } @@ -156,6 +165,7 @@ int setvbuf_test(void) { printf("setvbuf_test ERROR: " "setvbuf(stream, NULL, _IOLBF, 64) failed\n"); + ASSERT(false); } fprintf(stream, "setvbuf_test: Using LINE buffering, buffer size 64\r\n"); @@ -173,6 +183,7 @@ int setvbuf_test(void) if (stream == NULL) { printf("setvbuf_test ERROR: fopen(dev/console, rw) failed\n"); + ASSERT(false); return ERROR; } @@ -181,6 +192,7 @@ int setvbuf_test(void) { printf("setvbuf_test ERROR: " "setvbuf(stream, buffer, _IOLBF, 64) failed\n"); + ASSERT(false); } fprintf(stream, diff --git a/testing/ostest/sigev_thread.c b/testing/ostest/sigev_thread.c index c35b8178c..89e9b593d 100644 --- a/testing/ostest/sigev_thread.c +++ b/testing/ostest/sigev_thread.c @@ -87,7 +87,9 @@ void sigev_thread_test(void) status = timer_create(CLOCK_REALTIME, ¬ify, &timerid); if (status != OK) { - printf("sigev_thread_test: timer_create failed, errno=%d\n", errno); + printf("sigev_thread_test: " + "ERROR timer_create failed, errno=%d\n", errno); + ASSERT(false); goto errorout; } @@ -103,7 +105,9 @@ void sigev_thread_test(void) status = timer_settime(timerid, 0, &timer, NULL); if (status != OK) { - printf("sigev_thread_test: timer_settime failed, errno=%d\n", errno); + printf("sigev_thread_test: " + "ERROR timer_settime failed, errno=%d\n", errno); + ASSERT(false); goto errorout; } @@ -126,6 +130,7 @@ void sigev_thread_test(void) { printf("sigev_thread_test: ERROR sem_wait failed, errno=%d\n", error); + ASSERT(false); goto errorout; } } @@ -141,6 +146,7 @@ void sigev_thread_test(void) { printf("sigev_thread_callback: ERROR sival_int=%d expected %d\n", g_value_received, SIGVALUE_INT); + ASSERT(false); } errorout: @@ -152,7 +158,9 @@ errorout: status = timer_delete(timerid); if (status != OK) { - printf("sigev_thread_test: timer_create failed, errno=%d\n", errno); + printf("sigev_thread_test: " + "ERROR timer_create failed, errno=%d\n", errno); + ASSERT(false); } printf("sigev_thread_test: Done\n"); diff --git a/testing/ostest/sighand.c b/testing/ostest/sighand.c index e4a79cd71..2f209d532 100644 --- a/testing/ostest/sighand.c +++ b/testing/ostest/sighand.c @@ -95,6 +95,7 @@ static void wakeup_action(int signo, siginfo_t *info, void *ucontext) if (signo != WAKEUP_SIGNAL) { printf("wakeup_action: ERROR expected signo=%d\n" , WAKEUP_SIGNAL); + ASSERT(false); } /* Check siginfo */ @@ -103,6 +104,7 @@ static void wakeup_action(int signo, siginfo_t *info, void *ucontext) { printf("wakeup_action: ERROR sival_int=%d expected %d\n", info->si_value.sival_int, SIGVALUE_INT); + ASSERT(false); } else { @@ -113,6 +115,7 @@ static void wakeup_action(int signo, siginfo_t *info, void *ucontext) { printf("wakeup_action: ERROR expected si_signo=%d, got=%d\n", WAKEUP_SIGNAL, info->si_signo); + ASSERT(false); } printf("wakeup_action: si_code=%d\n" , info->si_code); @@ -129,12 +132,14 @@ static void wakeup_action(int signo, siginfo_t *info, void *ucontext) { printf("wakeup_action: ERROR sigprocmask failed, status=%d\n", status); + ASSERT(false); } if (oldset != allsigs) { printf("wakeup_action: ERROR sigprocmask=%jx expected=%jx\n", (uintmax_t)oldset, (uintmax_t)allsigs); + ASSERT(false); } /* Checkout sem_wait */ @@ -144,6 +149,7 @@ static void wakeup_action(int signo, siginfo_t *info, void *ucontext) { int error = errno; printf("wakeup_action: ERROR sem_wait failed, errno=%d\n" , error); + ASSERT(false); } else { @@ -168,6 +174,7 @@ static int waiter_main(int argc, char *argv[]) { printf("waiter_main: ERROR sigprocmask failed, status=%d\n", status); + ASSERT(false); } printf("waiter_main: Registering signal handler\n"); @@ -181,6 +188,7 @@ static int waiter_main(int argc, char *argv[]) if (status != OK) { printf("waiter_main: ERROR sigaction failed, status=%d\n" , status); + ASSERT(false); } #ifndef SDCC @@ -206,11 +214,13 @@ static int waiter_main(int argc, char *argv[]) else { printf("waiter_main: ERROR sem_wait failed, errno=%d\n" , error); + ASSERT(false); } } else { printf("waiter_main: ERROR awakened with no error!\n"); + ASSERT(false); } /* Detach the signal handler */ @@ -236,6 +246,7 @@ static int poster_main(int argc, char *argv[]) { int error = errno; printf("poster_main: sem_post failed error=%d\n", error); + ASSERT(false); } printf("poster_main: done\n"); @@ -275,6 +286,7 @@ void sighand_test(void) { printf("sighand_test: ERROR sigprocmask failed, status=%d\n", status); + ASSERT(false); } printf("sighand_test: Registering SIGCHLD handler\n"); @@ -288,6 +300,7 @@ void sighand_test(void) if (status != OK) { printf("waiter_main: ERROR sigaction failed, status=%d\n" , status); + ASSERT(false); } #endif @@ -298,6 +311,7 @@ void sighand_test(void) if (status != OK) { printf("sighand_test: ERROR sched_getparam() failed\n"); + ASSERT(false); param.sched_priority = PTHREAD_DEFAULT_PRIORITY; } @@ -306,6 +320,7 @@ void sighand_test(void) if (waiterpid == ERROR) { printf("sighand_test: ERROR failed to start waiter_main\n"); + ASSERT(false); } else { @@ -327,6 +342,7 @@ void sighand_test(void) if (status != OK) { printf("sighand_test: ERROR sigqueue failed\n"); + ASSERT(false); task_delete(waiterpid); } @@ -337,6 +353,7 @@ void sighand_test(void) if (posterpid == ERROR) { printf("sighand_test: ERROR failed to start poster_main\n"); + ASSERT(false); } else { @@ -357,16 +374,19 @@ void sighand_test(void) if (!thread1exited) { printf("sighand_test: ERROR waiter task did not exit\n"); + ASSERT(false); } if (!thread2exited) { printf("sighand_test: ERROR poster task did not exit\n"); + ASSERT(false); } if (!sigreceived) { printf("sighand_test: ERROR signal handler did not run\n"); + ASSERT(false); } /* Detach the signal handler */ diff --git a/testing/ostest/signest.c b/testing/ostest/signest.c index 5f6f81945..045012b9d 100644 --- a/testing/ostest/signest.c +++ b/testing/ostest/signest.c @@ -124,6 +124,7 @@ static int waiter_main(int argc, char *argv[]) if (ret < 0) { printf("waiter_main: ERROR sigprocmask failed: %d\n", errno); + ASSERT(false); return EXIT_FAILURE; } @@ -231,6 +232,7 @@ void signest_test(void) if (ret < 0) { printf("signest_test: ERROR sched_getparam() failed\n"); + ASSERT(false); param.sched_priority = PTHREAD_DEFAULT_PRIORITY; } @@ -243,6 +245,7 @@ void signest_test(void) if (waiterpid == ERROR) { printf("signest_test: ERROR failed to start waiter_main\n"); + ASSERT(false); return; } @@ -257,6 +260,7 @@ void signest_test(void) if (interferepid == ERROR) { printf("signest_test: ERROR failed to start interfere_main\n"); + ASSERT(false); goto errout_with_waiter; } @@ -464,35 +468,41 @@ errout_with_waiter: if (g_waiter_running) { printf("signest_test: ERROR waiter is still running\n"); + ASSERT(false); } if (g_interferer_running) { printf("signest_test: ERROR interferer is still running\n"); + ASSERT(false); } if (total_signals != total_handled) { printf("signest_test: ERROR only %d of %d signals were handled\n", total_handled, total_signals); + ASSERT(false); } if (odd_signals != g_odd_handled) { printf("signest_test: ERROR only %d of %d ODD signals were handled\n", g_odd_handled, odd_signals); + ASSERT(false); } if (even_signals != g_even_handled) { printf("signest_test: ERROR only %d of %d EVEN signals were handled\n", g_even_handled, even_signals); + ASSERT(false); } if (g_odd_nested > 0) { printf("signest_test: ERROR %d ODD signals were nested\n", g_odd_nested); + ASSERT(false); } sem_destroy(&g_waiter_sem); diff --git a/testing/ostest/sigprocmask.c b/testing/ostest/sigprocmask.c index 005d66c57..0c744fd6b 100644 --- a/testing/ostest/sigprocmask.c +++ b/testing/ostest/sigprocmask.c @@ -69,6 +69,7 @@ void sigprocmask_test(void) { int errcode = errno; printf("sigprocmask_test: ERROR sigprocmask failed: %d\n", errcode); + ASSERT(false); goto errout; } @@ -79,6 +80,7 @@ void sigprocmask_test(void) { int errcode = errno; printf("sigprocmask_test: ERROR sigemptyset failed: %d\n", errcode); + ASSERT(false); goto errout; } @@ -87,6 +89,7 @@ void sigprocmask_test(void) { int errcode = errno; printf("sigprocmask_test: ERROR sigprocmask failed: %d\n", errcode); + ASSERT(false); goto errout_with_mask; } @@ -101,6 +104,7 @@ void sigprocmask_test(void) { int errcode = errno; printf("sigprocmask_test: ERROR sigaddset failed: %d\n", errcode); + ASSERT(false); goto errout_with_mask; } @@ -109,6 +113,7 @@ void sigprocmask_test(void) { int errcode = errno; printf("sigprocmask_test: ERROR sighold failed: %d\n", errcode); + ASSERT(false); goto errout_with_mask; } } @@ -120,6 +125,7 @@ void sigprocmask_test(void) { int errcode = errno; printf("sigprocmask_test: ERROR sigprocmask failed: %d\n", errcode); + ASSERT(false); goto errout_with_mask; } @@ -128,6 +134,7 @@ void sigprocmask_test(void) if (memcmp(&currmask, &newmask, sizeof(sigset_t)) != 0) { printf("sigprocmask_test: ERROR unexpected sigprocmask\n"); + ASSERT(false); goto errout_with_mask; } @@ -138,6 +145,7 @@ void sigprocmask_test(void) { int errcode = errno; printf("sigprocmask_test: ERROR sigfillset failed: %d\n", errcode); + ASSERT(false); goto errout; } @@ -146,6 +154,7 @@ void sigprocmask_test(void) { int errcode = errno; printf("sigprocmask_test: ERROR sigprocmask failed: %d\n", errcode); + ASSERT(false); goto errout_with_mask; } @@ -160,6 +169,7 @@ void sigprocmask_test(void) { int errcode = errno; printf("sigprocmask_test: ERROR sigdelset failed: %d\n", errcode); + ASSERT(false); goto errout_with_mask; } @@ -168,6 +178,7 @@ void sigprocmask_test(void) { int errcode = errno; printf("sigprocmask_test: ERROR sigrelse failed: %d\n", errcode); + ASSERT(false); goto errout_with_mask; } } @@ -179,6 +190,7 @@ void sigprocmask_test(void) { int errcode = errno; printf("sigprocmask_test: ERROR sigprocmask failed: %d\n", errcode); + ASSERT(false); goto errout_with_mask; } @@ -187,6 +199,7 @@ void sigprocmask_test(void) if (memcmp(&currmask, &newmask, sizeof(sigset_t)) != 0) { printf("sigprocmask_test: ERROR unexpected sigprocmask\n"); + ASSERT(false); goto errout_with_mask; } @@ -195,6 +208,7 @@ void sigprocmask_test(void) { int errcode = errno; printf("sigprocmask_test: ERROR sigprocmask failed: %d\n", errcode); + ASSERT(false); goto errout; } @@ -208,6 +222,7 @@ errout_with_mask: { int errcode = errno; printf("sigprocmask_test: ERROR sigprocmask failed: %d\n", errcode); + ASSERT(false); goto errout; } diff --git a/testing/ostest/specific.c b/testing/ostest/specific.c index eca1695f9..92032ea43 100644 --- a/testing/ostest/specific.c +++ b/testing/ostest/specific.c @@ -53,6 +53,7 @@ static void *thread_func(FAR void *parameter) if (ret != 0) { printf("ERROR: pthread_setspecific() failed: %d\n", ret); + ASSERT(false); } /* Check the thread-specific data */ @@ -62,6 +63,7 @@ static void *thread_func(FAR void *parameter) { printf("ERROR: pthread_getspecific() failed: Returned %p vs %p\n", data, (FAR void *)0xcafebabe); + ASSERT(false); } return NULL; @@ -87,6 +89,7 @@ void specific_test(void) if (ret != 0) { printf("ERROR: pthread_key_create() failed: %d\n", ret); + ASSERT(false); } /* Set the pthread specific data for the main thread */ @@ -95,6 +98,7 @@ void specific_test(void) if (ret != 0) { printf("ERROR: pthread_setspecific() failed: %d\n", ret); + ASSERT(false); } /* Check the thread-specific data */ @@ -104,6 +108,7 @@ void specific_test(void) { printf("ERROR: pthread_getspecific() failed: Returned %p vs %p\n", data, (FAR void *)0xf00dface); + ASSERT(false); } /* Start a thread */ @@ -118,6 +123,7 @@ void specific_test(void) if (ret != 0) { printf("ERROR: pthread_create() failed: %d\n", ret); + ASSERT(false); } /* Wait for the thread to terminate */ @@ -135,6 +141,7 @@ void specific_test(void) { printf("ERROR: pthread_getspecific() failed: Returned %p vs %p\n", data, (FAR void *)0xf00dface); + ASSERT(false); } /* Destroy the pthread key */ @@ -143,5 +150,6 @@ void specific_test(void) if (ret != 0) { printf("ERROR: pthread_key_delete() failed: %d\n", ret); + ASSERT(false); } } diff --git a/testing/ostest/sporadic.c b/testing/ostest/sporadic.c index dcb2c677f..20649b27b 100644 --- a/testing/ostest/sporadic.c +++ b/testing/ostest/sporadic.c @@ -118,6 +118,7 @@ static void *fifo_func(void *parameter) if (ret < 0) { printf("ERROR: sched_getparam failed\n"); + ASSERT(false); return NULL; } @@ -155,6 +156,7 @@ static FAR void *sporadic_func(FAR void *parameter) if (ret < 0) { printf("ERROR: sched_getparam failed\n"); + ASSERT(false); return NULL; } @@ -218,6 +220,7 @@ void sporadic_test(void) if (ret != OK) { printf("sporadic_test: ERROR: sched_getparam failed, ret=%d\n", ret); + ASSERT(false); } sparam.sched_priority = prio_high + 2; @@ -225,6 +228,7 @@ void sporadic_test(void) if (ret != OK) { printf("sporadic_test: ERROR: sched_setparam failed, ret=%d\n", ret); + ASSERT(false); } ret = pthread_attr_init(&attr); @@ -232,6 +236,7 @@ void sporadic_test(void) { printf("sporadic_test: ERROR: pthread_attr_init failed, ret=%d\n", ret); + ASSERT(false); } /* This semaphore will prevent anything from running until we are ready */ @@ -249,6 +254,7 @@ void sporadic_test(void) printf("sporadic_test: ERROR: pthread_attr_setschedpolicy failed, " "ret=%d\n", ret); + ASSERT(false); } sparam.sched_priority = prio_high + 1; @@ -258,6 +264,7 @@ void sporadic_test(void) printf("sporadic_test: ERROR: pthread_attr_setschedparam failed, " "ret=%d\n", ret); + ASSERT(false); } ret = pthread_create(&nuisance_thread, &attr, nuisance_func, NULL); @@ -265,6 +272,7 @@ void sporadic_test(void) { printf("sporadic_test: ERROR: FIFO thread creation failed: %d\n", ret); + ASSERT(false); } /* Start a FIFO thread at the middle priority */ @@ -276,6 +284,7 @@ void sporadic_test(void) printf("sporadic_test: ERROR: pthread_attr_setschedparam failed, " "ret=%d\n", ret); + ASSERT(false); } ret = pthread_create(&fifo_thread, &attr, fifo_func, NULL); @@ -283,6 +292,7 @@ void sporadic_test(void) { printf("sporadic_test: ERROR: FIFO thread creation failed: %d\n", ret); + ASSERT(false); } /* Start a sporadic thread, with the following parameters: */ @@ -297,6 +307,7 @@ void sporadic_test(void) printf("sporadic_test: ERROR: pthread_attr_setschedpolicy failed, " "ret=%d\n", ret); + ASSERT(false); } sparam.sched_priority = prio_high; @@ -313,6 +324,7 @@ void sporadic_test(void) printf("sporadic_test: ERROR: pthread_attr_setsched param failed, " "ret=%d\n", ret); + ASSERT(false); } ret = pthread_create(&sporadic_thread, &attr, sporadic_func, @@ -321,6 +333,7 @@ void sporadic_test(void) { printf("sporadic_test: ERROR: sporadic thread creation failed: %d\n", ret); + ASSERT(false); } g_start_time = time(NULL); @@ -355,6 +368,7 @@ void sporadic_test(void) if (ret != OK) { printf("sporadic_test: ERROR: sched_setparam failed, ret=%d\n", ret); + ASSERT(false); } } diff --git a/testing/ostest/sporadic2.c b/testing/ostest/sporadic2.c index cbbf3569a..d9cc5c505 100644 --- a/testing/ostest/sporadic2.c +++ b/testing/ostest/sporadic2.c @@ -128,6 +128,7 @@ static FAR void *sporadic_func(FAR void *parameter) if (ret < 0) { printf("ERROR: sched_getparam failed\n"); + ASSERT(false); return NULL; } @@ -186,6 +187,7 @@ static void sporadic_test_case(int32_t budget_1_ns, int32_t budget_2_ns) if (ret != OK) { printf("sporadic_test: ERROR: sched_getparam failed, ret=%d\n", ret); + ASSERT(false); } /* Temporarily set our priority to PRIO_HIGH + 2 */ @@ -195,6 +197,7 @@ static void sporadic_test_case(int32_t budget_1_ns, int32_t budget_2_ns) if (ret != OK) { printf("sporadic_test: ERROR: sched_setparam failed, ret=%d\n", ret); + ASSERT(false); } ret = pthread_attr_init(&attr); @@ -202,6 +205,7 @@ static void sporadic_test_case(int32_t budget_1_ns, int32_t budget_2_ns) { printf("sporadic_test: ERROR: pthread_attr_init failed, ret=%d\n", ret); + ASSERT(false); } /* This semaphore will prevent anything from running until we are ready */ @@ -216,6 +220,7 @@ static void sporadic_test_case(int32_t budget_1_ns, int32_t budget_2_ns) printf("sporadic_test: ERROR: pthread_attr_setschedpolicy failed, " "ret=%d\n", ret); + ASSERT(false); } sparam.sched_priority = PRIO_HIGH1; @@ -232,6 +237,7 @@ static void sporadic_test_case(int32_t budget_1_ns, int32_t budget_2_ns) printf("sporadic_test: ERROR: pthread_attr_setsched param failed, " "ret=%d\n", ret); + ASSERT(false); } ret = pthread_create(&sporadic_thread1, &attr, sporadic_func, @@ -240,6 +246,7 @@ static void sporadic_test_case(int32_t budget_1_ns, int32_t budget_2_ns) { printf("sporadic_test: ERROR: sporadic thread creation failed: %d\n", ret); + ASSERT(false); } ret = pthread_attr_setschedpolicy(&attr, SCHED_SPORADIC); @@ -248,6 +255,7 @@ static void sporadic_test_case(int32_t budget_1_ns, int32_t budget_2_ns) printf("sporadic_test: ERROR: pthread_attr_setschedpolicy failed, " "ret=%d\n", ret); + ASSERT(false); } sparam.sched_priority = PRIO_HIGH2; @@ -260,6 +268,7 @@ static void sporadic_test_case(int32_t budget_1_ns, int32_t budget_2_ns) printf("sporadic_test: ERROR: pthread_attr_setsched param failed, " "ret=%d\n", ret); + ASSERT(false); } ret = pthread_create(&sporadic_thread2, &attr, sporadic_func, @@ -268,6 +277,7 @@ static void sporadic_test_case(int32_t budget_1_ns, int32_t budget_2_ns) { printf("sporadic_test: ERROR: sporadic thread creation failed: %d\n", ret); + ASSERT(false); } ret = pthread_attr_setschedpolicy(&attr, SCHED_FIFO); @@ -276,6 +286,7 @@ static void sporadic_test_case(int32_t budget_1_ns, int32_t budget_2_ns) printf("sporadic_test: ERROR: pthread_attr_setschedpolicy failed, " "ret=%d\n", ret); + ASSERT(false); } g_start_time = time(NULL); @@ -296,6 +307,7 @@ static void sporadic_test_case(int32_t budget_1_ns, int32_t budget_2_ns) if (ret != OK) { printf("sporadic_test: ERROR: sched_setparam failed, ret=%d\n", ret); + ASSERT(false); } } diff --git a/testing/ostest/suspend.c b/testing/ostest/suspend.c index a24cf555f..0d60feba9 100644 --- a/testing/ostest/suspend.c +++ b/testing/ostest/suspend.c @@ -63,6 +63,7 @@ void suspend_test(void) if (ret < 0) { printf("suspend_test: ERROR sched_getparam() failed\n"); + ASSERT(false); param.sched_priority = PTHREAD_DEFAULT_PRIORITY; } @@ -71,6 +72,7 @@ void suspend_test(void) if (victim == ERROR) { printf("suspend_test: ERROR failed to start victim_main\n"); + ASSERT(false); } else { @@ -90,6 +92,7 @@ void suspend_test(void) if (ret < 0) { printf("suspend_test: ERROR kill() failed\n"); + ASSERT(false); } printf("suspend_test: Is the victim still jabbering?\n"); @@ -101,6 +104,7 @@ void suspend_test(void) if (ret < 0) { printf("suspend_test: ERROR kill() failed\n"); + ASSERT(false); } printf("suspend_test: The victim should continue the rant.\n"); @@ -112,6 +116,7 @@ void suspend_test(void) if (ret < 0) { printf("suspend_test: ERROR kill() failed\n"); + ASSERT(false); } FFLUSH(); @@ -120,6 +125,7 @@ void suspend_test(void) if (ret >= 0) { printf("suspend_test: ERROR kill() on the dead victim succeeded!\n"); + ASSERT(false); } printf("suspend_test: done\n"); diff --git a/testing/ostest/timedmqueue.c b/testing/ostest/timedmqueue.c index 7689ae220..15a421ef5 100644 --- a/testing/ostest/timedmqueue.c +++ b/testing/ostest/timedmqueue.c @@ -112,6 +112,7 @@ static void *sender_thread(void *arg) if (g_send_mqfd == (mqd_t)-1) { printf("sender_thread: ERROR mq_open failed\n"); + ASSERT(false); pthread_exit((pthread_addr_t)1); } @@ -128,6 +129,7 @@ static void *sender_thread(void *arg) if (status != 0) { printf("sender_thread: ERROR clock_gettime failed\n"); + ASSERT(false); } ts.tv_sec += 5; @@ -148,6 +150,7 @@ static void *sender_thread(void *arg) { printf("sender_thread: ERROR mq_timedsend " "failure=%d on msg %d\n", errno, i); + ASSERT(false); nerrors++; } } @@ -156,6 +159,7 @@ static void *sender_thread(void *arg) if (i == TEST_SEND_NMSGS - 1) { printf("sender_thread: ERROR mq_timedsend of msg %d\n", i); + ASSERT(false); nerrors++; } else @@ -170,6 +174,7 @@ static void *sender_thread(void *arg) if (mq_close(g_send_mqfd) < 0) { printf("sender_thread: ERROR mq_close failed\n"); + ASSERT(false); } else { @@ -212,6 +217,7 @@ static void *receiver_thread(void *arg) if (g_recv_mqfd == (mqd_t)-1) { printf("receiver_thread: ERROR mq_open failed\n"); + ASSERT(false); pthread_exit((pthread_addr_t)1); } @@ -224,6 +230,7 @@ static void *receiver_thread(void *arg) if (status != 0) { printf("sender_thread: ERROR clock_gettime failed\n"); + ASSERT(false); } ts.tv_sec += 5; @@ -245,13 +252,15 @@ static void *receiver_thread(void *arg) { printf("receiver_thread: ERROR mq_timedreceive " "failure=%d on msg %d\n", errno, i); + ASSERT(false); nerrors++; } } else if (nbytes != TEST_MSGLEN) { printf("receiver_thread: mq_timedreceive return " - "bad size %d on msg %d\n", nbytes, i); + "ERROR bad size %d on msg %d\n", nbytes, i); + ASSERT(false); nerrors++; } else if (memcmp(TEST_MESSAGE, msg_buffer, nbytes) != 0) @@ -282,6 +291,7 @@ static void *receiver_thread(void *arg) else if (i == TEST_SEND_NMSGS - 1) { printf("receiver_thread: ERROR mq_timedreceive of msg %d\n", i); + ASSERT(false); nerrors++; } else @@ -295,6 +305,7 @@ static void *receiver_thread(void *arg) if (mq_close(g_recv_mqfd) < 0) { printf("receiver_thread: ERROR mq_close failed\n"); + ASSERT(false); nerrors++; } else @@ -322,22 +333,25 @@ void timedmqueue_test(void) status = pthread_attr_init(&attr); if (status != 0) { - printf("timedmqueue_test: pthread_attr_init failed, status=%d\n", + printf("timedmqueue_test: ERROR pthread_attr_init failed, status=%d\n", status); + ASSERT(false); } status = pthread_attr_setstacksize(&attr, STACKSIZE); if (status != 0) { - printf("timedmqueue_test: pthread_attr_setstacksize failed, " + printf("timedmqueue_test: ERROR pthread_attr_setstacksize failed, " "status=%d\n", status); + ASSERT(false); } status = pthread_create(&sender, &attr, sender_thread, NULL); if (status != 0) { - printf("timedmqueue_test: pthread_create failed, status=%d\n", + printf("timedmqueue_test: ERROR pthread_create failed, status=%d\n", status); + ASSERT(false); } /* Wait for the sending thread to complete */ @@ -348,6 +362,7 @@ void timedmqueue_test(void) { printf("timedmqueue_test: ERROR sender thread exited with %d errors\n", (int)((intptr_t)result)); + ASSERT(false); } /* Start the receiving thread at the default priority */ @@ -356,22 +371,25 @@ void timedmqueue_test(void) status = pthread_attr_init(&attr); if (status != 0) { - printf("timedmqueue_test: pthread_attr_init failed, status=%d\n", + printf("timedmqueue_test: ERROR pthread_attr_init failed, status=%d\n", status); + ASSERT(false); } status = pthread_attr_setstacksize(&attr, STACKSIZE); if (status != 0) { - printf("timedmqueue_test: pthread_attr_setstacksize failed, " + printf("timedmqueue_test: ERROR pthread_attr_setstacksize failed, " "status=%d\n", status); + ASSERT(false); } status = pthread_create(&receiver, &attr, receiver_thread, NULL); if (status != 0) { - printf("timedmqueue_test: pthread_create failed, status=%d\n", + printf("timedmqueue_test: ERROR pthread_create failed, status=%d\n", status); + ASSERT(false); } /* Wait for the receiving thread to complete */ @@ -382,6 +400,7 @@ void timedmqueue_test(void) { printf("timedmqueue_test: ERROR receiver thread exited " "with %d errors\n", (int)((intptr_t)result)); + ASSERT(false); } /* Make sure that the message queues were properly closed (otherwise, we @@ -391,18 +410,22 @@ void timedmqueue_test(void) if (g_send_mqfd) { printf("timedmqueue_test: ERROR send mqd_t left open\n"); + ASSERT(false); if (mq_close(g_send_mqfd) < 0) { printf("timedmqueue_test: ERROR mq_close failed\n"); + ASSERT(false); } } if (g_recv_mqfd) { printf("timedmqueue_test: ERROR receive mqd_t left open\n"); + ASSERT(false); if (mq_close(g_recv_mqfd) < 0) { printf("timedmqueue_test: ERROR mq_close failed\n"); + ASSERT(false); } } @@ -411,6 +434,7 @@ void timedmqueue_test(void) if (mq_unlink("timedmq") < 0) { printf("timedmqueue_test: ERROR mq_unlink failed\n"); + ASSERT(false); } printf("timedmqueue_test: Test complete\n"); diff --git a/testing/ostest/timedmutex.c b/testing/ostest/timedmutex.c index 44526a8f2..0a35362d4 100644 --- a/testing/ostest/timedmutex.c +++ b/testing/ostest/timedmutex.c @@ -64,7 +64,9 @@ static void *thread_func(FAR void *parameter) if (status < 0) { int errcode = errno; - fprintf(stderr, "pthread: clock_gettime() failed: %d\n", errcode); + fprintf(stderr, "pthread: " + "ERROR clock_gettime() failed: %d\n", errcode); + ASSERT(false); g_result = errcode; break; } @@ -86,9 +88,10 @@ static void *thread_func(FAR void *parameter) } else { - fprintf(stderr, - "pthread: pthread_mutex_timedlock() failed: %d\n", + fprintf(stderr, "pthread: " + "ERROR pthread_mutex_timedlock() failed: %d\n", status); + ASSERT(false); } g_result = status; @@ -129,7 +132,8 @@ void timedmutex_test(void) status = pthread_mutex_lock(&g_mutex); if (status != OK) { - fprintf(stderr, "mutex_test: Failed to get mutex: %d\n", status); + fprintf(stderr, "mutex_test: ERROR Failed to get mutex: %d\n", status); + ASSERT(false); goto errout_with_mutex; } @@ -145,6 +149,7 @@ void timedmutex_test(void) if (status != 0) { fprintf(stderr, "mutex_test: ERROR in thread creation: %d\n", status); + ASSERT(false); goto errout_with_lock; } @@ -170,7 +175,8 @@ void timedmutex_test(void) status = pthread_mutex_lock(&g_mutex); if (status != OK) { - fprintf(stderr, "mutex_test: Failed to get mutex: %d\n", status); + fprintf(stderr, "mutex_test: ERROR Failed to get mutex: %d\n", status); + ASSERT(false); goto errout_with_mutex; } @@ -187,11 +193,13 @@ void timedmutex_test(void) if (g_running) { fprintf(stderr, "mutex_test: ERROR: The pthread is still running!\n"); + ASSERT(false); } else if (g_result != ETIMEDOUT) { fprintf(stderr, "mutex_test: ERROR: Result was not ETIMEDOUT: %d\n", g_result); + ASSERT(false); } else { diff --git a/testing/ostest/timedwait.c b/testing/ostest/timedwait.c index bc242d834..e04b91b16 100644 --- a/testing/ostest/timedwait.c +++ b/testing/ostest/timedwait.c @@ -58,6 +58,7 @@ static void *thread_waiter(void *parameter) { printf("thread_waiter: ERROR pthread_mutex_lock failed, status=%d\n", status); + ASSERT(false); } printf("thread_waiter: Starting 5 second wait for condition\n"); @@ -66,6 +67,7 @@ static void *thread_waiter(void *parameter) if (status != 0) { printf("thread_waiter: ERROR clock_gettime failed\n"); + ASSERT(false); } ts.tv_sec += 5; @@ -83,6 +85,7 @@ static void *thread_waiter(void *parameter) { printf("thread_waiter: " "ERROR pthread_cond_timedwait failed, status=%d\n", status); + ASSERT(false); } } else @@ -90,6 +93,7 @@ static void *thread_waiter(void *parameter) printf("thread_waiter: ERROR " "pthread_cond_timedwait returned without timeout, status=%d\n", status); + ASSERT(false); } /* Release the mutex */ @@ -100,6 +104,7 @@ static void *thread_waiter(void *parameter) { printf("thread_waiter: ERROR pthread_mutex_unlock failed, status=%d\n", status); + ASSERT(false); } printf("thread_waiter: Exit with status 0x12345678\n"); @@ -128,6 +133,7 @@ void timedwait_test(void) { printf("timedwait_test: ERROR pthread_mutex_init failed, status=%d\n", status); + ASSERT(false); } /* Initialize the condition variable */ @@ -138,6 +144,7 @@ void timedwait_test(void) { printf("timedwait_test: ERROR pthread_condinit failed, status=%d\n", status); + ASSERT(false); } /* Start the waiter thread at higher priority */ @@ -185,6 +192,7 @@ void timedwait_test(void) { printf("timedwait_test: ERROR pthread_join failed, status=%d\n", status); + ASSERT(false); } else { diff --git a/testing/ostest/tls.c b/testing/ostest/tls.c index 3d2626d8d..fd1e3171a 100644 --- a/testing/ostest/tls.c +++ b/testing/ostest/tls.c @@ -85,6 +85,7 @@ static bool verify_tls_info(uintptr_t value) printf("tls: ERROR Element %d: Set %lx / read %lx\n", i, (unsigned long)value, (unsigned long)info->tl_elem[i]); + ASSERT(false); fail = true; } } diff --git a/testing/ostest/vfork.c b/testing/ostest/vfork.c index 4147f2bd1..390669ba8 100644 --- a/testing/ostest/vfork.c +++ b/testing/ostest/vfork.c @@ -61,7 +61,8 @@ int vfork_test(void) } else if (pid < 0) { - printf("vfork_test: vfork() failed: %d\n", errno); + printf("vfork_test: ERROR vfork() failed: %d\n", errno); + ASSERT(false); return -1; } else @@ -74,6 +75,7 @@ int vfork_test(void) else { printf("vfork_test: ERROR Child %d did not run\n", pid); + ASSERT(false); return -1; } } diff --git a/testing/ostest/waitpid.c b/testing/ostest/waitpid.c index 352d4f2fc..5b9e9b6db 100644 --- a/testing/ostest/waitpid.c +++ b/testing/ostest/waitpid.c @@ -75,6 +75,7 @@ static void waitpid_start_children(void) { printf("waitpid_start_child: " "ERROR Failed to start waitpid_main\n"); + ASSERT(false); } else { @@ -109,6 +110,7 @@ static void waitpid_last(void) if (pid < 0) { printf("waitpid_last: ERROR: Nothing to wait for\n"); + ASSERT(false); return; } @@ -138,6 +140,7 @@ static void waitpid_last(void) { printf("waitpid_last: ERROR: PID %d waitpid failed: %d\n", g_waitpids[NCHILDREN - 1], errcode); + ASSERT(false); } } else if (WEXITSTATUS(stat_loc) != RETURN_STATUS) @@ -147,6 +150,7 @@ static void waitpid_last(void) g_waitpids[NCHILDREN - 1], WEXITSTATUS(stat_loc), RETURN_STATUS); + ASSERT(false); } else { @@ -198,18 +202,21 @@ int waitpid_test(void) { printf("waitpid_test: ERROR: PID %d waitpid failed: %d\n", g_waitpids[0], errcode); + ASSERT(false); } } else if (ret != g_waitpids[0]) { printf("waitpid_test: ERROR: PID %d wait returned PID %d\n", g_waitpids[0], ret); + ASSERT(false); } else if (WEXITSTATUS(stat_loc) != RETURN_STATUS) { printf("waitpid_test: ERROR: " "PID %d return status is %d, expected %d\n", g_waitpids[0], WEXITSTATUS(stat_loc), RETURN_STATUS); + ASSERT(false); } else { @@ -253,18 +260,21 @@ int waitpid_test(void) { printf("waitpid_test: ERROR: PID %d waitid failed: %d\n", g_waitpids[0], errcode); + ASSERT(false); } } else if (info.si_pid != g_waitpids[0]) { printf("waitpid_test: ERROR: PID %d waitid returned PID %d\n", g_waitpids[0], info.si_pid); + ASSERT(false); } else if (info.si_status != RETURN_STATUS) { printf("waitpid_test: ERROR: " "PID %d return status is %d, expected %d\n", info.si_pid, info.si_status, RETURN_STATUS); + ASSERT(false); } else { @@ -305,6 +315,7 @@ int waitpid_test(void) else { printf("waitpid_test: ERROR: waitid failed: %d\n", errcode); + ASSERT(false); } } else if (info.si_status != RETURN_STATUS) @@ -312,6 +323,7 @@ int waitpid_test(void) printf("waitpid_test: ERROR: " "PID %d return status is %d, expected %d\n", info.si_pid, info.si_status, RETURN_STATUS); + ASSERT(false); } else { @@ -352,6 +364,7 @@ int waitpid_test(void) else { printf("waitpid_test: ERROR: wait failed: %d\n", errcode); + ASSERT(false); } } else if (WEXITSTATUS(stat_loc) != RETURN_STATUS) @@ -359,6 +372,7 @@ int waitpid_test(void) printf("waitpid_test: ERROR: " "PID %d return status is %d, expected %d\n", ret, WEXITSTATUS(stat_loc), RETURN_STATUS); + ASSERT(false); } else {