blob: 3d5842aea8462b2fa1609b682e23e2f48ca5b041 [file] [log] [blame]
Rob Landleyac9c5922008-05-04 15:35:04 -05001#!/bin/bash
2
3[ -f testing.sh ] && . testing.sh
4
5#testing "name" "command" "result" "infile" "stdin"
6
Elie De Brauwer6c576282012-12-08 13:28:40 +01007echo "one" > file1
8echo "two" > file2
Rob Landleyac9c5922008-05-04 15:35:04 -05009testing "cat" "cat && echo yes" "oneyes\n" "" "one"
Elie De Brauwer6c576282012-12-08 13:28:40 +010010testing "cat -" "cat - && echo yes" "oneyes\n" "" "one"
11testing "cat file1 file2" "cat file1 file2" "one\ntwo\n" "" ""
12testing "cat - file" "cat - file1" "zero\none\n" "" "zero\n"
13testing "cat file -" "cat file1 -" "one\nzero\n" "" "zero\n"
14
15testing "cat file1 notfound file2" \
16 "cat file1 notfound file2 2>stderr && echo ok ; cat stderr; rm stderr" \
17 "one\ntwo\ncat: notfound: No such file or directory\n" "" ""
18
Rob Landleyac9c5922008-05-04 15:35:04 -050019testing "cat file1" \
Elie De Brauwer6c576282012-12-08 13:28:40 +010020 "cat /proc/self/exe > file1 && cmp /proc/self/exe file1 && echo yes" \
21 "yes\n" "" ""
Rob Landleyac9c5922008-05-04 15:35:04 -050022
23testing "cat - file1" \
Elie De Brauwer6c576282012-12-08 13:28:40 +010024 "cat - file1 | diff -a -U 0 - file1 | tail -n 1" \
25 "-hello\n" "" "hello\n"
Rob Landleyac9c5922008-05-04 15:35:04 -050026
Elie De Brauwer6c576282012-12-08 13:28:40 +010027testing "cat > /dev/full" \
28 "cat - > /dev/full 2>stderr && echo ok; cat stderr; rm stderr" \
29 "cat: xwrite: No space left on device\n" "" "zero\n"
30
31rm file1 file2