make: move tests to external script
This commit is contained in:
parent
111135ae0e
commit
93911e51d8
2 changed files with 67 additions and 41 deletions
43
Makefile
43
Makefile
|
|
@ -7,47 +7,8 @@ LIBS ::=
|
|||
shinyr: shinyr.c
|
||||
$(CC) $(BASE_CFLAGS) $(CFLAGS) -o $@ $< $(LIBS)
|
||||
|
||||
test: shinyr
|
||||
res="$$(./shinyr api2db AwnW35HP3S0ADNCM76)"; \
|
||||
[ "$$res" = "00000198-70ad-868e-8d3a-6d2726850000" ] \
|
||||
|| { echo "FAIL TEST 1"; exit 1; } ; \
|
||||
\
|
||||
res="$$(./shinyr db2api 00000198-70ad-868e-8d3a-6d2726850000)"; \
|
||||
[ "$$res" = "AwnW35HP3S0ADNCM76" ] \
|
||||
|| { echo "FAIL TEST 2"; exit 1; } ; \
|
||||
\
|
||||
res="$$(./shinyr api2db 123)"; \
|
||||
[ "$$res" = "00000000-0000-0000-0000-00000000007b" ] \
|
||||
|| { echo "FAIL TEST 3"; exit 1; } ; \
|
||||
\
|
||||
res="$$(./shinyr db2api 00000000-0000-0000-0000-00000000007b)"; \
|
||||
[ "$$res" = "123" ] \
|
||||
|| { echo "FAIL TEST 4"; exit 1; } ; \
|
||||
\
|
||||
res="$$(./shinyr db2api FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 2>&1)"; \
|
||||
[ "$$res" = "7n42DGM5Tflk9n8mt7Fhc7" ] \
|
||||
|| { echo "FAIL TEST 5"; exit 1; } ; \
|
||||
\
|
||||
res="$$(./shinyr db2api 100000000000000000000000000000000 2>&1)"; \
|
||||
( [ "$$?" -eq 1 ] && echo "$$res" | grep -q 'too big' ) \
|
||||
|| { echo "FAIL TEST 6"; exit 1; } ; \
|
||||
\
|
||||
res="$$(./shinyr db2api 3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 2>&1)"; \
|
||||
( [ "$$?" -eq 1 ] && echo "$$res" | grep -q 'too big' ) \
|
||||
|| { echo "FAIL TEST 7"; exit 1; } ; \
|
||||
\
|
||||
res="$$(./shinyr api2db 7n42DGM5Tflk9n8mt7Fhc7 2>&1)"; \
|
||||
[ "$$res" = "ffffffff-ffff-ffff-ffff-ffffffffffff" ] \
|
||||
|| { echo "FAIL TEST 8 (got $$res)"; exit 1; } ; \
|
||||
\
|
||||
res="$$(./shinyr api2db 7n42DGM5Tflk9n8mt7Fhc8 2>&1)"; \
|
||||
( [ "$$?" -eq 1 ] && echo "$$res" | grep -q 'too big' ) \
|
||||
|| { echo "FAIL TEST 9"; exit 1; } ; \
|
||||
\
|
||||
res="$$(./shinyr api2db 17n42DGM5Tflk9n8mt7Fhc9 2>&1)"; \
|
||||
( [ "$$?" -eq 1 ] && echo "$$res" | grep -q 'too big' ) \
|
||||
|| { echo "FAIL TEST 10"; exit 1; } ; \
|
||||
echo "ALL GOOD"
|
||||
test: shinyr test.sh
|
||||
bash test.sh shinyr
|
||||
|
||||
clean:
|
||||
rm -f shinyr
|
||||
|
|
|
|||
65
test.sh
Normal file
65
test.sh
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
if [ "$#" -ne 1 ] || [ \! -x "$1" ] ; then
|
||||
echo "Wrong arguments! Must supply path to shinyr executeable!"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
SHINYR="$1"
|
||||
|
||||
TCUR=-1
|
||||
|
||||
fail_msg() {
|
||||
echo "FAILED on test: $TCUR"
|
||||
exit 1
|
||||
}
|
||||
|
||||
trap fail_msg EXIT
|
||||
|
||||
TCUR="api2db"
|
||||
res="$("$SHINYR" api2db AwnW35HP3S0ADNCM76)"
|
||||
[ "$res" = "00000198-70ad-868e-8d3a-6d2726850000" ]
|
||||
|
||||
TCUR="db2api"
|
||||
res="$("$SHINYR" db2api 00000198-70ad-868e-8d3a-6d2726850000)"
|
||||
[ "$res" = "AwnW35HP3S0ADNCM76" ]
|
||||
|
||||
TCUR="api2db legacy id"
|
||||
res="$("$SHINYR" api2db 123)"
|
||||
[ "$res" = "00000000-0000-0000-0000-00000000007b" ]
|
||||
|
||||
TCUR="db2api legacy id"
|
||||
res="$("$SHINYR" db2api 00000000-0000-0000-0000-00000000007b)"
|
||||
[ "$res" = "123" ]
|
||||
|
||||
TCUR="db2api max value"
|
||||
res="$("$SHINYR" db2api FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 2>&1)"
|
||||
[ "$res" = "7n42DGM5Tflk9n8mt7Fhc7" ]
|
||||
|
||||
TCUR="db2api too large (just barely)"
|
||||
exc=0
|
||||
res="$("$SHINYR" db2api 100000000000000000000000000000000 2>&1)" || exc="$?"
|
||||
[ "$exc" -eq 1 ] && echo "$res" | grep -q 'too big'
|
||||
|
||||
TCUR="db2api too large (a lot)"
|
||||
exc=0
|
||||
res="$("$SHINYR" db2api 3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF 2>&1)" || exc="$?"
|
||||
[ "$exc" -eq 1 ] && echo "$res" | grep -q 'too big'
|
||||
|
||||
TCUR="api2db max value"
|
||||
res="$("$SHINYR" api2db 7n42DGM5Tflk9n8mt7Fhc7 2>&1)"
|
||||
[ "$res" = "ffffffff-ffff-ffff-ffff-ffffffffffff" ]
|
||||
|
||||
TCUR="api2db too large (just barely)"
|
||||
exc=0
|
||||
res="$("$SHINYR" api2db 7n42DGM5Tflk9n8mt7Fhc8 2>&1)" || exc="$?"
|
||||
[ "$exc" -eq 1 ] && echo "$res" | grep -q 'too big'
|
||||
|
||||
TCUR="api2db too large (a lot)"
|
||||
exc=0
|
||||
res="$("$SHINYR" api2db 17n42DGM5Tflk9n8mt7Fhc9 2>&1)" || exc="$?"
|
||||
[ "$exc" -eq 1 ] && echo "$res" | grep -q 'too big'
|
||||
|
||||
trap - EXIT
|
||||
echo "ALL GOOD"
|
||||
Loading…
Add table
Add a link
Reference in a new issue