From 65cda8a11df4718d963ef0624eb2f6e0f5201a8c Mon Sep 17 00:00:00 2001 From: K Rin Date: Sun, 20 Apr 2025 17:59:34 +0800 Subject: [PATCH] bin/cat: add test for reading data from stdin Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/1671 Closes: https://github.com/freebsd/freebsd-src/pull/1671 --- bin/cat/tests/Makefile | 1 + contrib/netbsd-tests/bin/cat/stdin_test.out | 1 + contrib/netbsd-tests/bin/cat/t_cat.sh | 15 +++++++++++++++ 3 files changed, 17 insertions(+) create mode 100644 contrib/netbsd-tests/bin/cat/stdin_test.out diff --git a/bin/cat/tests/Makefile b/bin/cat/tests/Makefile index 2f48c7d4e0c..347f4826ba4 100644 --- a/bin/cat/tests/Makefile +++ b/bin/cat/tests/Makefile @@ -12,6 +12,7 @@ ${PACKAGE}FILES+= d_s_output.in ${PACKAGE}FILES+= d_s_output.out ${PACKAGE}FILES+= d_vt_output.in ${PACKAGE}FILES+= d_vt_output.out +${PACKAGE}FILES+= stdin_test.out .include diff --git a/contrib/netbsd-tests/bin/cat/stdin_test.out b/contrib/netbsd-tests/bin/cat/stdin_test.out new file mode 100644 index 00000000000..7caf37d4c05 --- /dev/null +++ b/contrib/netbsd-tests/bin/cat/stdin_test.out @@ -0,0 +1 @@ +This is nothing but a cat test. diff --git a/contrib/netbsd-tests/bin/cat/t_cat.sh b/contrib/netbsd-tests/bin/cat/t_cat.sh index 10706372f87..4e88276b371 100755 --- a/contrib/netbsd-tests/bin/cat/t_cat.sh +++ b/contrib/netbsd-tests/bin/cat/t_cat.sh @@ -112,6 +112,20 @@ vt_output_body() { } # End FreeBSD +# Begin FreeBSD +atf_test_case stdin_test +stdin_test_head() { + atf_set "descr" "Test that cat(1) receives data from stdin " \ + "and outputs." +} + +stdin_test_body() { + echo "This is nothing but a cat test." | \ + atf_check -s ignore -o file:$(atf_get_srcdir)/stdin_test.out \ + cat +} +# End FreeBSD + atf_init_test_cases() { atf_add_test_case align @@ -124,5 +138,6 @@ atf_init_test_cases() atf_add_test_case s_output atf_add_test_case e_output atf_add_test_case vt_output + atf_add_test_case stdin_test # End FreeBSD }