Skip to content

Commit

Permalink
Feature: Test for Bad Thread Exit
Browse files Browse the repository at this point in the history
In this commit, I have introduced a fault injection test for exiting
with a bad return value. Not that this test is not enabled by default,
because the kernel may no support this check in some targets.
  • Loading branch information
ppenna committed Feb 11, 2019
1 parent dce8cd5 commit b7acd36
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/test/kthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#define UTEST_KTHREAD_BAD_START 0 /**< Test bad thread start? */
#define UTEST_KTHREAD_BAD_ARG 0 /**< Test bad thread argument? */
#define UTEST_KTHREAD_BAD_JOIN 0 /**< Test bad thread join? */
#define UTEST_KTHREAD_BAD_EXIT 0 /**< Test bad thread exit? */
/**@}*/

/**
Expand Down Expand Up @@ -130,6 +131,12 @@ void test_fault_kthread_create(void)
test_assert(kthread_join(tid[0], (void *)(UBASE_VIRT - PAGE_SIZE)) < 0);
test_assert(kthread_join(tid[0], NULL) == 0);
#endif

/* Exit with bad return value. */
#if (defined(UTEST_KTHREAD_BAD_EXIT) && (UTEST_KTHREAD_BAD_EXIT == 1))
test_assert(kthread_exit((void *)(KBASE_VIRT)) < 0);
test_assert(kthread_exit((void *)(UBASE_VIRT - PAGE_SIZE)) < 0);
#endif
}

/*============================================================================*
Expand Down

0 comments on commit b7acd36

Please sign in to comment.