From 05d06ecac32d892eafc5e8e13652324d8f5ac46a Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Thu, 20 Apr 2017 11:32:18 +0000 Subject: [PATCH] Add a regression test for diff -D --- usr.bin/diff/tests/Makefile | 3 ++- usr.bin/diff/tests/diff_test.sh | 9 +++++++++ usr.bin/diff/tests/ifdef.out | 26 ++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 usr.bin/diff/tests/ifdef.out diff --git a/usr.bin/diff/tests/Makefile b/usr.bin/diff/tests/Makefile index 4dfa372f2c4..295e3141f3d 100644 --- a/usr.bin/diff/tests/Makefile +++ b/usr.bin/diff/tests/Makefile @@ -21,7 +21,8 @@ ${PACKAGE}FILES+= \ unified_c9999.out \ unified_9999.out \ header.out \ - header_ns.out + header_ns.out \ + ifdef.out NETBSD_ATF_TESTS_SH+= netbsd_diff_test diff --git a/usr.bin/diff/tests/diff_test.sh b/usr.bin/diff/tests/diff_test.sh index c712d587148..589bc9a8603 100755 --- a/usr.bin/diff/tests/diff_test.sh +++ b/usr.bin/diff/tests/diff_test.sh @@ -4,6 +4,7 @@ atf_test_case simple atf_test_case unified atf_test_case header atf_test_case header_ns +atf_test_case ifdef simple_body() { @@ -70,10 +71,18 @@ header_ns_body() diff -u empty hello } +ifdef_body() +{ + atf_check -o file:$(atf_get_srcdir)/ifdef.out -s eq:1 \ + diff -D PLOP "$(atf_get_srcdir)/input_c1.in" \ + "$(atf_get_srcdir)/input_c2.in" +} + atf_init_test_cases() { atf_add_test_case simple atf_add_test_case unified atf_add_test_case header atf_add_test_case header_ns + atf_add_test_case ifdef } diff --git a/usr.bin/diff/tests/ifdef.out b/usr.bin/diff/tests/ifdef.out new file mode 100644 index 00000000000..cc72cac0863 --- /dev/null +++ b/usr.bin/diff/tests/ifdef.out @@ -0,0 +1,26 @@ +/* + * A comment + * +#ifndef PLOP + * And another bla +#else /* PLOP */ + * And another bla +#endif /* PLOP */ + * +#ifndef PLOP + * And yet another +#else /* PLOP */ + * and yet another +#endif /* PLOP */ + */ + +int +main(void) +{ +#ifdef PLOP + +#endif /* PLOP */ + printf("something"); + + return (0); +}