~nabijaczleweli/voreutils

ref: 5a4de15fa57068c5e4fe56192c37c3bcc069990c voreutils/tests/tac/test -rwxr-xr-x 5.3 KiB
5a4de15fнаб Add sleep 7 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/bin/sh
# SPDX-License-Identifier: 0BSD

IFS="
"

tmpdir="$(mktemp -dt "tac.XXXXXXXXXX")/"
tac="${CMDDIR}tac"
# tac="tac"
data="$(realpath data)/"
files="$(for f in "$data"*; do [ -f "$f" ] && echo "${f##*/}"; done)"

mkdir "${tmpdir}singlef/"
for f in $files; do
	cp "$data$f" "${tmpdir}singlef/"
done
cp -r "${tmpdir}singlef/" "${tmpdir}withnull/"
cp -r "${tmpdir}singlef/" "${tmpdir}with-/"
cp -r "${tmpdir}singlef/" "${tmpdir}just-/"
cp -r "${tmpdir}singlef/" "${tmpdir}nothing/"

cd "${tmpdir}singlef/" && for f in $files; do
  mkdir "$f.d"
  "$tac"     "$f" > "$f.d/$f"    2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
  "$tac" -b  "$f" > "$f.d/$f-b"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
  "$tac" -r  "$f" > "$f.d/$f-r"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
  "$tac" -br "$f" > "$f.d/$f-br" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  for s in '' ' ' '  ' 'a ' ' ' '\s' '.' '..' 'a $'; do
    "$tac" -s   "$s" "$f" > "$f.d/$f-s'$s'"   2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
    "$tac" -bs  "$s" "$f" > "$f.d/$f-bs'$s'"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
    "$tac" -rs  "$s" "$f" > "$f.d/$f-rs'$s'"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
    "$tac" -brs "$s" "$f" > "$f.d/$f-brs'$s'" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  done
done
diff -r -u "$data" "${tmpdir}singlef/" >&3 2>&1 && echo "Single-file ok"

cd "${tmpdir}withnull/" && for f in $files; do
  mkdir "$f.d"
  "$tac"     /dev/null "$f" /dev/null > "$f.d/$f"    2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
  "$tac" -b  /dev/null "$f" /dev/null > "$f.d/$f-b"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
  "$tac" -r  /dev/null "$f" /dev/null > "$f.d/$f-r"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
  "$tac" -br /dev/null "$f" /dev/null > "$f.d/$f-br" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  for s in '' ' ' '  ' 'a ' ' ' '\s' '.' '..' 'a $'; do
    "$tac" -s   "$s" /dev/null "$f" /dev/null > "$f.d/$f-s'$s'"   2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
    "$tac" -bs  "$s" /dev/null "$f" /dev/null > "$f.d/$f-bs'$s'"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
    "$tac" -rs  "$s" /dev/null "$f" /dev/null > "$f.d/$f-rs'$s'"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
    "$tac" -brs "$s" /dev/null "$f" /dev/null > "$f.d/$f-brs'$s'" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  done
done
diff -r -u "$data" "${tmpdir}withnull/" >&3 2>&1 && echo "Interposed null ok"

cd "${tmpdir}with-/" && for f in $files; do
  mkdir "$f.d"
  printf "" | "$tac"     - "$f" - > "$f.d/$f"    2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
  printf "" | "$tac" -b  - "$f" - > "$f.d/$f-b"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
  printf "" | "$tac" -r  - "$f" - > "$f.d/$f-r"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
  printf "" | "$tac" -br - "$f" - > "$f.d/$f-br" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  for s in '' ' ' '  ' 'a ' ' ' '\s' '.' '..' 'a $'; do
    printf "" | "$tac" -s   "$s" - "$f" - > "$f.d/$f-s'$s'"   2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
    printf "" | "$tac" -bs  "$s" - "$f" - > "$f.d/$f-bs'$s'"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
    printf "" | "$tac" -rs  "$s" - "$f" - > "$f.d/$f-rs'$s'"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
    printf "" | "$tac" -brs "$s" - "$f" - > "$f.d/$f-brs'$s'" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  done
done
diff -r -u "$data" "${tmpdir}with-/" >&3 2>&1 && echo "Interposed - ok"

cd "${tmpdir}just-/" && for f in $files; do
  mkdir "$f.d"
  "$tac"     - < "$f" > "$f.d/$f"    2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
  "$tac" -b  - < "$f" > "$f.d/$f-b"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
  "$tac" -r  - < "$f" > "$f.d/$f-r"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
  "$tac" -br - < "$f" > "$f.d/$f-br" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  for s in '' ' ' '  ' 'a ' ' ' '\s' '.' '..' 'a $'; do
    "$tac" -s   "$s" - < "$f" > "$f.d/$f-s'$s'"   2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
    "$tac" -bs  "$s" - < "$f" > "$f.d/$f-bs'$s'"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
    "$tac" -rs  "$s" - < "$f" > "$f.d/$f-rs'$s'"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
    "$tac" -brs "$s" - < "$f" > "$f.d/$f-brs'$s'" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  done
done
diff -r -u "$data" "${tmpdir}just-/" >&3 2>&1 && echo "stdin ok"

cd "${tmpdir}nothing/" && for f in $files; do
  mkdir "$f.d"
  "$tac"     < "$f" > "$f.d/$f"    2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
  "$tac" -b  < "$f" > "$f.d/$f-b"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
  "$tac" -r  < "$f" > "$f.d/$f-r"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
  "$tac" -br < "$f" > "$f.d/$f-br" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  for s in '' ' ' '  ' 'a ' ' ' '\s' '.' '..' 'a $'; do
    "$tac" -s   "$s" < "$f" > "$f.d/$f-s'$s'"   2>/dev/null || echo yes > "$f.d/$f-s'$s'.error"
    "$tac" -bs  "$s" < "$f" > "$f.d/$f-bs'$s'"  2>/dev/null || echo yes > "$f.d/$f-bs'$s'.error"
    "$tac" -rs  "$s" < "$f" > "$f.d/$f-rs'$s'"  2>/dev/null || echo yes > "$f.d/$f-rs'$s'.error"
    "$tac" -brs "$s" < "$f" > "$f.d/$f-brs'$s'" 2>/dev/null || echo yes > "$f.d/$f-brs'$s'.error"
  done
done
diff -r -u "$data" "${tmpdir}nothing/" >&3 2>&1 && echo "Default ok"

rm -rf "$tmpdir" >&3