logo

system-testsuite

Unix system testsuite (highlights broken bits in GNU and BusyBox)

puts.c (604B)


  1. #include <atf-c.h> // ATF*, atf*
  2. #include <stdio.h> // fopen, fclose, fputs
  3. #include <errno.h> // errno
  4. #include <string.h> // strerror
  5. ATF_TC(puts_devfull);
  6. ATF_TC_HEAD(puts_devfull, tc)
  7. {
  8. atf_tc_set_md_var(tc, "descr", "Checking for write error on /dev/full");
  9. }
  10. ATF_TC_BODY(puts_devfull, tc)
  11. {
  12. FILE *devfull = fopen("/dev/full", "w");
  13. ATF_CHECK_MSG(devfull != NULL, "%s", strerror(errno));
  14. ATF_CHECK_ERRNO(ENOSPC, fputs("hello world", devfull) < 0);
  15. ATF_CHECK_MSG(fclose(devfull) == 0, "%s", strerror(errno));
  16. }
  17. ATF_TP_ADD_TCS(tp)
  18. {
  19. ATF_TP_ADD_TC(tp, puts_devfull);
  20. return atf_no_error();
  21. }