1# $FreeBSD$ 2 3atf_test_case simple 4atf_test_case unified 5atf_test_case header 6atf_test_case header_ns 7atf_test_case ifdef 8atf_test_case group_format 9atf_test_case side_by_side 10atf_test_case brief_format 11 12simple_body() 13{ 14 atf_check -o file:$(atf_get_srcdir)/simple.out -s eq:1 \ 15 diff "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input2.in" 16 17 atf_check -o file:$(atf_get_srcdir)/simple_e.out -s eq:1 \ 18 diff -e "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input2.in" 19 20 atf_check -o file:$(atf_get_srcdir)/simple_u.out -s eq:1 \ 21 diff -u -L input1 -L input2 "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input2.in" 22 23 atf_check -o file:$(atf_get_srcdir)/simple_n.out -s eq:1 \ 24 diff -n "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input2.in" 25 26 atf_check -o inline:"Files $(atf_get_srcdir)/input1.in and $(atf_get_srcdir)/input2.in differ\n" -s eq:1 \ 27 diff -q "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input2.in" 28 29 atf_check \ 30 diff -q "$(atf_get_srcdir)/input1.in" "$(atf_get_srcdir)/input1.in" 31 32 atf_check -o file:$(atf_get_srcdir)/simple_i.out -s eq:1 \ 33 diff -i "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" 34 35 atf_check -o file:$(atf_get_srcdir)/simple_w.out -s eq:1 \ 36 diff -w "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" 37 38 atf_check -o file:$(atf_get_srcdir)/simple_b.out -s eq:1 \ 39 diff -b "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" 40 41 atf_check -o file:$(atf_get_srcdir)/simple_p.out -s eq:1 \ 42 diff --label input_c1.in --label input_c2.in -p "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" 43} 44 45unified_body() 46{ 47 atf_check -o file:$(atf_get_srcdir)/unified_p.out -s eq:1 \ 48 diff -up -L input_c1.in -L input_c2.in "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" 49 atf_check -o file:$(atf_get_srcdir)/unified_c9999.out -s eq:1 \ 50 diff -u -c9999 -L input_c1.in -L input_c2.in "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" 51 atf_check -o file:$(atf_get_srcdir)/unified_9999.out -s eq:1 \ 52 diff -u9999 -L input_c1.in -L input_c2.in "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" 53} 54 55header_body() 56{ 57 export TZ=UTC 58 : > empty 59 echo hello > hello 60 touch -d 2015-04-03T01:02:03 empty 61 touch -d 2016-12-22T11:22:33 hello 62 atf_check -o "file:$(atf_get_srcdir)/header.out" -s eq:1 \ 63 diff -u empty hello 64} 65 66header_ns_body() 67{ 68 export TZ=UTC 69 : > empty 70 echo hello > hello 71 touch -d 2015-04-03T01:02:03.123456789 empty 72 touch -d 2016-12-22T11:22:33.987654321 hello 73 atf_check -o "file:$(atf_get_srcdir)/header_ns.out" -s eq:1 \ 74 diff -u empty hello 75} 76 77ifdef_body() 78{ 79 atf_check -o file:$(atf_get_srcdir)/ifdef.out -s eq:1 \ 80 diff -D PLOP "$(atf_get_srcdir)/input_c1.in" \ 81 "$(atf_get_srcdir)/input_c2.in" 82} 83 84group_format_body() 85{ 86 atf_check -o file:$(atf_get_srcdir)/group-format.out -s eq:1 \ 87 diff --changed-group-format='<<<<<<< (local) 88%<======= 89%>>>>>>>> (stock) 90' "$(atf_get_srcdir)/input_c1.in" "$(atf_get_srcdir)/input_c2.in" 91} 92 93side_by_side_body() 94{ 95 atf_expect_fail "--side-by-side not currently implemented (bug # 219933)" 96 97 atf_check -o save:A printf "A\nB\nC\n" 98 atf_check -o save:B printf "D\nB\nE\n" 99 100 exp_output="A[[:space:]]+|[[:space:]]+D\nB[[:space:]]+B\nC[[:space:]]+|[[:space:]]+E" 101 exp_output_suppressed="A[[:space:]]+|[[:space:]]+D\nC[[:space:]]+|[[:space:]]+E" 102 103 atf_check -o match:"$exp_output" -s exit:1 \ 104 diff --side-by-side A B 105 atf_check -o match:"$exp_output" -s exit:1 \ 106 diff -y A B 107 atf_check -o match:"$exp_output_suppressed" -s exit:1 \ 108 diff -y --suppress-common-lines A B 109 atf_check -o match:"$exp_output_suppressed" -s exit:1 \ 110 diff -W 65 -y --suppress-common-lines A B 111} 112 113brief_format_body() 114{ 115 atf_check mkdir A B 116 117 atf_check -x "echo 1 > A/test-file" 118 atf_check -x "echo 2 > B/test-file" 119 120 atf_check cp -Rf A C 121 atf_check cp -Rf A D 122 123 atf_check -x "echo 3 > D/another-test-file" 124 125 atf_check \ 126 -s exit:1 \ 127 -o inline:"Files A/test-file and B/test-file differ\n" \ 128 diff -rq A B 129 130 atf_check diff -rq A C 131 132 atf_check \ 133 -s exit:1 \ 134 -o inline:"Only in D: another-test-file\n" \ 135 diff -rq A D 136 137 atf_check \ 138 -s exit:1 \ 139 -o inline:"Files A/another-test-file and D/another-test-file differ\n" \ 140 diff -Nrq A D 141} 142 143atf_init_test_cases() 144{ 145 atf_add_test_case simple 146 atf_add_test_case unified 147 atf_add_test_case header 148 atf_add_test_case header_ns 149 atf_add_test_case ifdef 150 atf_add_test_case group_format 151 atf_add_test_case side_by_side 152 atf_add_test_case brief_format 153} 154