diff options
| author | Baptiste Daroussin <bapt@FreeBSD.org> | 2017-03-11 05:01:29 +0000 |
|---|---|---|
| committer | Baptiste Daroussin <bapt@FreeBSD.org> | 2017-03-11 05:01:29 +0000 |
| commit | 3bbe3f672e37e4f609adb3be3a6476edce2243ec (patch) | |
| tree | d0c4281aad22341ee2dcefb6bcad582cedd9d7a0 /usr.bin/diff/tests | |
| parent | 719498102c3367e9ac84da335e3da4bc261f93cd (diff) | |
Notes
Diffstat (limited to 'usr.bin/diff/tests')
| -rw-r--r-- | usr.bin/diff/tests/Makefile | 24 | ||||
| -rwxr-xr-x | usr.bin/diff/tests/diff.sh | 53 | ||||
| -rw-r--r-- | usr.bin/diff/tests/input1.in | 2 | ||||
| -rw-r--r-- | usr.bin/diff/tests/input2.in | 3 | ||||
| -rw-r--r-- | usr.bin/diff/tests/input_c1.in | 15 | ||||
| -rw-r--r-- | usr.bin/diff/tests/input_c2.in | 16 | ||||
| -rw-r--r-- | usr.bin/diff/tests/simple.out | 5 | ||||
| -rw-r--r-- | usr.bin/diff/tests/simple_b.out | 6 | ||||
| -rw-r--r-- | usr.bin/diff/tests/simple_e.out | 4 | ||||
| -rw-r--r-- | usr.bin/diff/tests/simple_i.out | 6 | ||||
| -rw-r--r-- | usr.bin/diff/tests/simple_n.out | 4 | ||||
| -rw-r--r-- | usr.bin/diff/tests/simple_p.out | 34 | ||||
| -rw-r--r-- | usr.bin/diff/tests/simple_u.out | 7 | ||||
| -rw-r--r-- | usr.bin/diff/tests/simple_w.out | 6 | ||||
| -rw-r--r-- | usr.bin/diff/tests/unified_9999.out | 21 | ||||
| -rw-r--r-- | usr.bin/diff/tests/unified_c9999.out | 36 | ||||
| -rw-r--r-- | usr.bin/diff/tests/unified_p.out | 20 |
17 files changed, 262 insertions, 0 deletions
diff --git a/usr.bin/diff/tests/Makefile b/usr.bin/diff/tests/Makefile new file mode 100644 index 0000000000000..e19f804b98fed --- /dev/null +++ b/usr.bin/diff/tests/Makefile @@ -0,0 +1,24 @@ +# $FreeBSD$ + +PACKAGE= tests + +ATF_TESTS_SH= diff + +${PACKAGE}FILES+= \ + input1.in \ + input2.in \ + input_c1.in \ + input_c2.in \ + simple.out \ + simple_e.out \ + simple_n.out \ + simple_u.out \ + simple_i.out \ + simple_w.out \ + simple_b.out \ + simple_p.out \ + unified_p.out \ + unified_c9999.out \ + unified_9999.out + +.include <bsd.test.mk> diff --git a/usr.bin/diff/tests/diff.sh b/usr.bin/diff/tests/diff.sh new file mode 100755 index 0000000000000..cd2c470637740 --- /dev/null +++ b/usr.bin/diff/tests/diff.sh @@ -0,0 +1,53 @@ +# $FreeBSD$ + +atf_test_case simple +atf_test_case unified + +simple_body() +{ + atf_check -o file:$(atf_get_srcdir)/simple.out -s eq:1 \ + diff "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input2.in" + + atf_check -o file:$(atf_get_srcdir)/simple_e.out -s eq:1 \ + diff -e "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input2.in" + + atf_check -o file:$(atf_get_srcdir)/simple_u.out -s eq:1 \ + diff -u -L input1 -L input2 "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input2.in" + + atf_check -o file:$(atf_get_srcdir)/simple_n.out -s eq:1 \ + diff -n "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input2.in" + + atf_check -o inline:"Files $(atf_get_srcdir)/input1.in and $(atf_get_srcdir)/input2.in differ\n" -s eq:1 \ + diff -q "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input2.in" + + atf_check \ + diff -q "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input1.in" + + atf_check -o file:$(atf_get_srcdir)/simple_i.out -s eq:1 \ + diff -i "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" + + atf_check -o file:$(atf_get_srcdir)/simple_w.out -s eq:1 \ + diff -w "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" + + atf_check -o file:$(atf_get_srcdir)/simple_b.out -s eq:1 \ + diff -b "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" + + atf_check -o file:$(atf_get_srcdir)/simple_p.out -s eq:1 \ + diff --label input_c1.in --label input_c2.in -p "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" +} + +unified_body() +{ + atf_check -o file:$(atf_get_srcdir)/unified_p.out -s eq:1 \ + diff -up -L input_c1.in -L input_c2.in "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" + atf_check -o file:$(atf_get_srcdir)/unified_c9999.out -s eq:1 \ + diff -u -c9999 -L input_c1.in -L input_c2.in "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" + atf_check -o file:$(atf_get_srcdir)/unified_9999.out -s eq:1 \ + diff -u9999 -L input_c1.in -L input_c2.in "$(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 +} diff --git a/usr.bin/diff/tests/input1.in b/usr.bin/diff/tests/input1.in new file mode 100644 index 0000000000000..3892e8400f86f --- /dev/null +++ b/usr.bin/diff/tests/input1.in @@ -0,0 +1,2 @@ +Simple input file designed +to be able to test diff diff --git a/usr.bin/diff/tests/input2.in b/usr.bin/diff/tests/input2.in new file mode 100644 index 0000000000000..c38b487353a70 --- /dev/null +++ b/usr.bin/diff/tests/input2.in @@ -0,0 +1,3 @@ +Simple input file designed +and written +to be able to test diff utility diff --git a/usr.bin/diff/tests/input_c1.in b/usr.bin/diff/tests/input_c1.in new file mode 100644 index 0000000000000..d39dfbdc511b2 --- /dev/null +++ b/usr.bin/diff/tests/input_c1.in @@ -0,0 +1,15 @@ +/* + * A comment + * + * And another bla + * + * And yet another + */ + +int +main(void) +{ + printf("something"); + + return (0); +} diff --git a/usr.bin/diff/tests/input_c2.in b/usr.bin/diff/tests/input_c2.in new file mode 100644 index 0000000000000..933ec67dc175b --- /dev/null +++ b/usr.bin/diff/tests/input_c2.in @@ -0,0 +1,16 @@ +/* + * A comment + * + * And another bla + * + * and yet another + */ + +int +main(void) +{ + + printf("something"); + + return (0); +} diff --git a/usr.bin/diff/tests/simple.out b/usr.bin/diff/tests/simple.out new file mode 100644 index 0000000000000..fcbcaa041e8c3 --- /dev/null +++ b/usr.bin/diff/tests/simple.out @@ -0,0 +1,5 @@ +2c2,3 +< to be able to test diff +--- +> and written +> to be able to test diff utility diff --git a/usr.bin/diff/tests/simple_b.out b/usr.bin/diff/tests/simple_b.out new file mode 100644 index 0000000000000..704be9d621a88 --- /dev/null +++ b/usr.bin/diff/tests/simple_b.out @@ -0,0 +1,6 @@ +6c6 +< * And yet another +--- +> * and yet another +11a12 +> diff --git a/usr.bin/diff/tests/simple_e.out b/usr.bin/diff/tests/simple_e.out new file mode 100644 index 0000000000000..0c7e2b5c752b0 --- /dev/null +++ b/usr.bin/diff/tests/simple_e.out @@ -0,0 +1,4 @@ +2c +and written +to be able to test diff utility +. diff --git a/usr.bin/diff/tests/simple_i.out b/usr.bin/diff/tests/simple_i.out new file mode 100644 index 0000000000000..9edc1f98d72d7 --- /dev/null +++ b/usr.bin/diff/tests/simple_i.out @@ -0,0 +1,6 @@ +4c4 +< * And another bla +--- +> * And another bla +11a12 +> diff --git a/usr.bin/diff/tests/simple_n.out b/usr.bin/diff/tests/simple_n.out new file mode 100644 index 0000000000000..33ca7090cf97a --- /dev/null +++ b/usr.bin/diff/tests/simple_n.out @@ -0,0 +1,4 @@ +d2 1 +a2 2 +and written +to be able to test diff utility diff --git a/usr.bin/diff/tests/simple_p.out b/usr.bin/diff/tests/simple_p.out new file mode 100644 index 0000000000000..f5aebb0d1199b --- /dev/null +++ b/usr.bin/diff/tests/simple_p.out @@ -0,0 +1,34 @@ +*** input_c1.in +--- input_c2.in +*************** +*** 1,14 **** + /* + * A comment + * +! * And another bla + * +! * And yet another + */ + + int + main(void) + { + printf("something"); + + return (0); +--- 1,15 ---- + /* + * A comment + * +! * And another bla + * +! * and yet another + */ + + int + main(void) + { ++ + printf("something"); + + return (0); diff --git a/usr.bin/diff/tests/simple_u.out b/usr.bin/diff/tests/simple_u.out new file mode 100644 index 0000000000000..f341987ebec6f --- /dev/null +++ b/usr.bin/diff/tests/simple_u.out @@ -0,0 +1,7 @@ +--- input1 ++++ input2 +@@ -1,2 +1,3 @@ + Simple input file designed +-to be able to test diff ++and written ++to be able to test diff utility diff --git a/usr.bin/diff/tests/simple_w.out b/usr.bin/diff/tests/simple_w.out new file mode 100644 index 0000000000000..704be9d621a88 --- /dev/null +++ b/usr.bin/diff/tests/simple_w.out @@ -0,0 +1,6 @@ +6c6 +< * And yet another +--- +> * and yet another +11a12 +> diff --git a/usr.bin/diff/tests/unified_9999.out b/usr.bin/diff/tests/unified_9999.out new file mode 100644 index 0000000000000..0f9303fbdc7c0 --- /dev/null +++ b/usr.bin/diff/tests/unified_9999.out @@ -0,0 +1,21 @@ +--- input_c1.in ++++ input_c2.in +@@ -1,15 +1,16 @@ + /* + * A comment + * +- * And another bla ++ * And another bla + * +- * And yet another ++ * and yet another + */ + + int + main(void) + { ++ + printf("something"); + + return (0); + } diff --git a/usr.bin/diff/tests/unified_c9999.out b/usr.bin/diff/tests/unified_c9999.out new file mode 100644 index 0000000000000..87f439463e5df --- /dev/null +++ b/usr.bin/diff/tests/unified_c9999.out @@ -0,0 +1,36 @@ +*** input_c1.in +--- input_c2.in +*************** +*** 1,15 **** + /* + * A comment + * +! * And another bla + * +! * And yet another + */ + + int + main(void) + { + printf("something"); + + return (0); + } +--- 1,16 ---- + /* + * A comment + * +! * And another bla + * +! * and yet another + */ + + int + main(void) + { ++ + printf("something"); + + return (0); + } diff --git a/usr.bin/diff/tests/unified_p.out b/usr.bin/diff/tests/unified_p.out new file mode 100644 index 0000000000000..938b07890fbcf --- /dev/null +++ b/usr.bin/diff/tests/unified_p.out @@ -0,0 +1,20 @@ +--- input_c1.in ++++ input_c2.in +@@ -1,14 +1,15 @@ + /* + * A comment + * +- * And another bla ++ * And another bla + * +- * And yet another ++ * and yet another + */ + + int + main(void) + { ++ + printf("something"); + + return (0); |
