logo

system-testsuite

Unix system testsuite (highlights broken bits in GNU and BusyBox)
commit: 78b1ce88a92f169486e96c84da0bb9fcb05f045d
parent 30fdba8706f379c76435f5be3fe30079523059f4
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date:   Thu,  3 Mar 2022 22:55:07 +0100

Add check on strlen(NULL)

Diffstat:

MKyuafile3++-
MMakefile2+-
Astrlen.c21+++++++++++++++++++++
3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/Kyuafile b/Kyuafile @@ -4,9 +4,10 @@ syntax(2) test_suite("system-testsuite") --- /BEGIN/,$ | LC_ALL=C.UTF-8 sort +-- /BEGIN/,$|LC_ALL=C.UTF-8 sort atf_test_program{name="abs"} atf_test_program{name="true"} atf_test_program{name="false"} atf_test_program{name="sed"} atf_test_program{name="puts"} +atf_test_program{name="strlen"} diff --git a/Makefile b/Makefile @@ -1,5 +1,5 @@ LIBS = -latf-c -BINS = puts abs +BINS = puts abs strlen all: $(BINS) diff --git a/strlen.c b/strlen.c @@ -0,0 +1,21 @@ +#include <atf-c.h> // ATF*, atf* +#include <stdio.h> // fopen, fclose, fputs +#include <errno.h> // errno +#include <string.h> // strerror + +ATF_TC(strlen_null); +ATF_TC_HEAD(strlen_null, tc) +{ + atf_tc_set_md_var(tc, "descr", "works with being passed NULL"); +} +ATF_TC_BODY(strlen_null, tc) +{ + ATF_CHECK(strlen(NULL) == 0); +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, strlen_null); + + return atf_no_error(); +}