1#!/bin/bash 2 3[ -f testing.sh ] && . testing.sh 4 5testing "cmp not enough arguments [fail]" "cmp input 2>/dev/null || echo yes" "yes\n" "foo" "" 6testing "cmp missing file1 [fail]" "cmp file1 input 2>/dev/null || echo yes" "yes\n" "foo" "" 7 8#mkdir dir 9#testing "cmp directory [fail]" "cmp dir dir 2>/dev/null || echo yes" \ 10 #"yes\n" "" "" 11#rmdir dir 12 13echo "ab 14c" > input2 15 16testing "cmp identical files, stdout" "cmp input input2" "" "ab\nc\n" "" 17testing "cmp identical files, return code" "cmp input input2 && echo yes" "yes\n" "ab\nc\n" "" 18 19testing "cmp EOF, stderr" "cmp input input2 2>&1" "cmp: EOF on input2\n" "ab\nc\nx" "" 20testing "cmp EOF, return code" "cmp input input2 2>/dev/null || echo yes" "yes\n" "ab\nc\nx" "" 21# The gnu/dammit version fails this because posix says "char" and they don't. 22testing "cmp diff, stdout" "cmp input input2" "input input2 differ: char 4, line 2\n" "ab\nx\nx" "" 23testing "cmp diff, return code" "cmp input input2 > /dev/null || echo yes" "yes\n" "ab\nx\nx" "" 24 25testing "cmp -s EOF, return code" "cmp -s input input2 || echo yes" "yes\n" "ab\nc\nx" "" 26testing "cmp -s diff, return code" "cmp -s input input2 || echo yes" "yes\n" "ab\nx\nx" "" 27 28testing "cmp -l EOF, stderr" "cmp -l input input2 2>&1" "cmp: EOF on input2\n" "ab\nc\nx" "" 29testing "cmp -l diff and EOF, stdout and stderr" "cmp -l input input2 2>&1 | sort" "4 170 143\ncmp: EOF on input2\n" "ab\nx\nx" "" 30 31rm input2 32 33testing "cmp stdin and file" "cmp input -" "input - differ: char 4, line 2\n" "ab\nc\n" "ab\nx\n" 34#testing "cmp stdin and stdin" "cmp input -" "" "" "ab\nc\n" 35 36