logo

system-testsuite

Unix system testsuite (highlights broken bits in GNU and BusyBox)
commit: 8f91c206fa921852c677fdb694e32bb5efd6a6fb
parent f2e309234dc1852396686467f855f5b375eb47ab
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Sat,  5 Feb 2022 13:50:33 +0100

puts: New test

Diffstat:

MKyuafile3++-
MMakefile15++++++++++++++-
Aputs.c24++++++++++++++++++++++++
3 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/Kyuafile b/Kyuafile @@ -1,5 +1,5 @@ syntax(2) ---Copyright © 2021 Haelwenn (lanodan) Monnier <contact+system-testsuite@hacktivis.me> +--Copyright © 2021-2022 Haelwenn (lanodan) Monnier <contact+system-testsuite@hacktivis.me> --SPDX-License-Identifier: BSD-3-Clause test_suite("system-testsuite") @@ -8,3 +8,4 @@ test_suite("system-testsuite") atf_test_program{name="true"} atf_test_program{name="false"} atf_test_program{name="sed"} +atf_test_program{name="puts"} diff --git a/Makefile b/Makefile @@ -1,2 +1,15 @@ -test: +LIBS = -latf-c +BINS = puts + +all: $(BINS) + +.c: + $(CC) $(CFLAGS) $(LDFLAGS) $(LIBS) -o $@ $< + +.PHONY: clean +clean: + rm -f $(BINS) + +.PHONY: test +test: $(BINS) kyua test || (kyua report --verbose; false) diff --git a/puts.c b/puts.c @@ -0,0 +1,24 @@ +#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(); +}