Skip to content

Instantly share code, notes, and snippets.

@s25g5d4
Created April 10, 2016 09:56
Show Gist options
  • Save s25g5d4/863a5905a7fcb42e023e91d48ffd9728 to your computer and use it in GitHub Desktop.
Save s25g5d4/863a5905a7fcb42e023e91d48ffd9728 to your computer and use it in GitHub Desktop.
$ cat ./test
#!/bin/bash
echo "a
b
3
4
-1
-2
c
d
-c
-d" > /tmp/testinput
echo "test case is:"
cat /tmp/testinput
echo
let i=1
while [ $# -ge 2 ]; do
echo "test $i: login: $1, password: $2"
./B023040011.csh $1 $2 > /tmp/myoutput < /tmp/testinput
let exitcode=$?
./login $1 $2 > /tmp/correctoutput < /tmp/testinput
if [[ $exitcode != $? ]]; then
echo "Correct exit code is $?, while your script exits with exit code $exitcode"
fi
diff -u /tmp/myoutput /tmp/correctoutput && echo "correct!"
let i=i+1
shift
shift
done
echo
echo "Size of your script: `fgrep -v '#!' B023040011.csh | tr -d '\r\n\t "' | wc -c`"
$ ./test a b 3 4 1 2 -1 -2 c d -c -d
test case is:
a
b
3
4
-1
-2
c
d
-c
-d
test 1: login: a, password: b
correct!
test 2: login: 3, password: 4
correct!
test 3: login: 1, password: 2
correct!
test 4: login: -1, password: -2
correct!
test 5: login: c, password: d
correct!
test 6: login: -c, password: -d
correct!
Size of your script: 399
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment