puts.c (604B)
- #include <atf-c.h> // ATF*, atf*
- #include <stdio.h> // fopen, fclose, fputs
- #include <errno.h> // errno
- #include <string.h> // strerror
- ATF_TC(puts_devfull);
- ATF_TC_HEAD(puts_devfull, tc)
- {
- atf_tc_set_md_var(tc, "descr", "Checking for write error on /dev/full");
- }
- ATF_TC_BODY(puts_devfull, tc)
- {
- FILE *devfull = fopen("/dev/full", "w");
- ATF_CHECK_MSG(devfull != NULL, "%s", strerror(errno));
- ATF_CHECK_ERRNO(ENOSPC, fputs("hello world", devfull) < 0);
- ATF_CHECK_MSG(fclose(devfull) == 0, "%s", strerror(errno));
- }
- ATF_TP_ADD_TCS(tp)
- {
- ATF_TP_ADD_TC(tp, puts_devfull);
- return atf_no_error();
- }