Contents of /tags/mkinitrd-6_1_6/busybox/testsuite/diff.tests
Parent Directory | Revision Log
Revision 903 -
(show annotations)
(download)
Wed Aug 5 19:21:45 2009 UTC (15 years, 1 month ago) by niro
File size: 2287 byte(s)
Wed Aug 5 19:21:45 2009 UTC (15 years, 1 month ago) by niro
File size: 2287 byte(s)
tagged 'mkinitrd-6_1_6'
1 | #!/bin/sh |
2 | # Copyright 2008 by Denys Vlasenko |
3 | # Licensed under GPL v2, see file LICENSE for details. |
4 | |
5 | . testing.sh |
6 | |
7 | # testing "test name" "options" "expected result" "file input" "stdin" |
8 | |
9 | # diff outputs date/time in the header, which should not be analysed |
10 | # NB: sed has tab character in s command! |
11 | TRIM_TAB="sed 's/ .*//'" |
12 | |
13 | testing "diff of stdin" \ |
14 | "diff -u - input | $TRIM_TAB" \ |
15 | "\ |
16 | --- - |
17 | +++ input |
18 | @@ -1 +1,3 @@ |
19 | +qwe |
20 | asd |
21 | +zxc |
22 | " \ |
23 | "qwe\nasd\nzxc\n" \ |
24 | "asd\n" |
25 | |
26 | testing "diff of stdin, no newline in the file" \ |
27 | "diff -u - input | $TRIM_TAB" \ |
28 | "\ |
29 | --- - |
30 | +++ input |
31 | @@ -1 +1,3 @@ |
32 | +qwe |
33 | asd |
34 | +zxc |
35 | \\ No newline at end of file |
36 | " \ |
37 | "qwe\nasd\nzxc" \ |
38 | "asd\n" |
39 | |
40 | # we also test that stdin is in fact NOT read |
41 | testing "diff of stdin, twice" \ |
42 | "diff - -; echo $?; wc -c" \ |
43 | "0\n5\n" \ |
44 | "" \ |
45 | "stdin" |
46 | |
47 | # testing "test name" "options" "expected result" "file input" "stdin" |
48 | |
49 | rm -rf diff1 diff2 |
50 | mkdir diff1 diff2 diff2/subdir |
51 | echo qwe >diff1/- |
52 | echo asd >diff2/subdir/- |
53 | testing "diff diff1 diff2/subdir" \ |
54 | "diff -ur diff1 diff2/subdir | $TRIM_TAB" \ |
55 | "\ |
56 | --- diff1/- |
57 | +++ diff2/subdir/- |
58 | @@ -1 +1 @@ |
59 | -qwe |
60 | +asd |
61 | " \ |
62 | "" "" |
63 | |
64 | # using directory structure from prev test... |
65 | testing "diff dir dir2/file/-" \ |
66 | "diff -ur diff1 diff2/subdir/- | $TRIM_TAB" \ |
67 | "\ |
68 | --- diff1/- |
69 | +++ diff2/subdir/- |
70 | @@ -1 +1 @@ |
71 | -qwe |
72 | +asd |
73 | " \ |
74 | "" "" |
75 | |
76 | # using directory structure from prev test... |
77 | mkdir diff1/test |
78 | mkfifo diff2/subdir/test |
79 | testing "diff of dir and fifo" \ |
80 | "diff -ur diff1 diff2/subdir | $TRIM_TAB" \ |
81 | "\ |
82 | --- diff1/- |
83 | +++ diff2/subdir/- |
84 | @@ -1 +1 @@ |
85 | -qwe |
86 | +asd |
87 | Only in diff2/subdir: test |
88 | " \ |
89 | "" "" |
90 | |
91 | # using directory structure from prev test... |
92 | rmdir diff1/test |
93 | echo >diff1/test |
94 | testing "diff of file and fifo" \ |
95 | "diff -ur diff1 diff2/subdir | $TRIM_TAB" \ |
96 | "\ |
97 | --- diff1/- |
98 | +++ diff2/subdir/- |
99 | @@ -1 +1 @@ |
100 | -qwe |
101 | +asd |
102 | File diff2/subdir/test is not a regular file or directory and was skipped |
103 | " \ |
104 | "" "" |
105 | |
106 | # using directory structure from prev test... |
107 | mkfifo diff1/test2 |
108 | testing "diff -rN does not read non-regular files" \ |
109 | "diff -urN diff1 diff2/subdir | $TRIM_TAB" \ |
110 | "\ |
111 | --- diff1/- |
112 | +++ diff2/subdir/- |
113 | @@ -1 +1 @@ |
114 | -qwe |
115 | +asd |
116 | File diff2/subdir/test is not a regular file or directory and was skipped |
117 | File diff1/test2 is not a regular file or directory and was skipped |
118 | " \ |
119 | "" "" |
120 | |
121 | # clean up |
122 | rm -rf diff1 diff2 |
123 | |
124 | exit $FAILCOUNT |