Skip to content

Commit

Permalink
Feature: Test for Bad Thread Join Argument
Browse files Browse the repository at this point in the history
In this commit, I have introduced fault injection tests for joining a
thread using a bad pointer to get the return value of the terminating
thread. Note that this test is not enabled by default, because the
kernel may not support this checking in some targets.
  • Loading branch information
ppenna committed Feb 11, 2019
1 parent 24a05a2 commit dce8cd5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/test/kthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,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? */
/**@}*/

/**
Expand Down Expand Up @@ -121,6 +122,14 @@ void test_fault_kthread_create(void)
test_assert(kthread_create(&tid[0], task, NULL) == 0);
test_assert(kthread_join(2, NULL) < 0);
test_assert(kthread_join(tid[0], NULL) == 0);

/* Join with bad return value. */
#if (defined(UTEST_KTHREAD_BAD_JOIN) && (UTEST_KTHREAD_BAD_JOIN == 1))
test_assert(kthread_create(&tid[0], task, NULL) == 0);
test_assert(kthread_join(tid[0], (void *)(KBASE_VIRT)) < 0);
test_assert(kthread_join(tid[0], (void *)(UBASE_VIRT - PAGE_SIZE)) < 0);
test_assert(kthread_join(tid[0], NULL) == 0);
#endif
}

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

0 comments on commit dce8cd5

Please sign in to comment.