perror_tc.c 516 B

123456789101112131415161718192021222324252627
  1. #include <stdio.h>
  2. static int perror_entry(void)
  3. {
  4. FILE *stream;
  5. stream = fopen( "nulltest.txt", "r" );
  6. if(stream == NULL)
  7. {
  8. printf("perror test:");
  9. perror("nulltest.txt");
  10. return -1;
  11. }
  12. fclose(stream);
  13. return 0;
  14. }
  15. #include <utest.h>
  16. static void test_perror(void)
  17. {
  18. uassert_int_equal(perror_entry(), 0);
  19. }
  20. static void testcase(void)
  21. {
  22. UTEST_UNIT_RUN(test_perror);
  23. }
  24. UTEST_TC_EXPORT(testcase, "rtt_posix_testcase.stdio_h."__FILE__, RT_NULL, RT_NULL, 10);