You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

44 lines
819 B

  1. #include "config.h"
  2. #include <stdarg.h>
  3. #include <stddef.h>
  4. #include <setjmp.h>
  5. #include <cmocka.h>
  6. #include <cmocka_private.h>
  7. #include <errno.h>
  8. #include <sys/types.h>
  9. #include <sys/stat.h>
  10. #ifdef HAVE_UNISTD_H
  11. #include <unistd.h>
  12. #endif
  13. #ifdef HAVE_IO_H
  14. #include <io.h>
  15. #endif
  16. #include <fcntl.h>
  17. /**************************************
  18. *** assert_return_code
  19. **************************************/
  20. static void test_assert_return_code_fail(void **state)
  21. {
  22. int fd;
  23. (void)state; /* unused */
  24. fd = open("this_file_doesnt_exist.cmocka", 0);
  25. assert_return_code(fd, errno);
  26. if (fd >= 0) {
  27. close(fd);
  28. }
  29. }
  30. int main(void) {
  31. const struct CMUnitTest tests[] = {
  32. cmocka_unit_test(test_assert_return_code_fail),
  33. };
  34. return cmocka_run_group_tests(tests, NULL, NULL);
  35. }