rtt_utest_internal.h 555 B

123456789101112131415161718192021222324
  1. #include <utest.h>
  2. #include <pthread.h>
  3. static void posix_unit_test(void)
  4. {
  5. pthread_t new_th; /* Create a new thread. */
  6. int err_val;
  7. if (pthread_create(&new_th, NULL, (void *(*)(void *))posix_testcase, NULL) != 0) {
  8. perror("Error creating thread\n");
  9. }
  10. /* Wait for thread to return */
  11. if (pthread_join(new_th, (void*)&err_val) != 0) {
  12. perror("Error in pthread_join()\n");
  13. }
  14. rt_thread_mdelay(1000);
  15. uassert_true(err_val == 0);
  16. }
  17. static void testcase(void)
  18. {
  19. UTEST_UNIT_RUN(posix_unit_test);
  20. }