19f07849eSopenharmony_ci#!/bin/sh 29f07849eSopenharmony_ci 39f07849eSopenharmony_cirun() { 49f07849eSopenharmony_ci prog=$1; shift 59f07849eSopenharmony_ci name=$1; shift 69f07849eSopenharmony_ci answer=$1; shift 79f07849eSopenharmony_ci 89f07849eSopenharmony_ci result=`HOME=$builddir $builddir/$prog $*` 99f07849eSopenharmony_ci if [ "$answer" != "$result" ]; then 109f07849eSopenharmony_ci echo "FAIL: $name: \"$result\" != \"$answer\" " 119f07849eSopenharmony_ci else 129f07849eSopenharmony_ci echo "PASS: $name" 139f07849eSopenharmony_ci fi 149f07849eSopenharmony_ci} 159f07849eSopenharmony_ci 169f07849eSopenharmony_cirun_diff() { 179f07849eSopenharmony_ci prog=$1; shift 189f07849eSopenharmony_ci name=$1; shift 199f07849eSopenharmony_ci in_file=$1; shift 209f07849eSopenharmony_ci answer_file=$1; shift 219f07849eSopenharmony_ci 229f07849eSopenharmony_ci out=$builddir/tmp.out 239f07849eSopenharmony_ci diff_file=$builddir/tmp.diff 249f07849eSopenharmony_ci 259f07849eSopenharmony_ci $builddir/$prog $in_file > $out 269f07849eSopenharmony_ci ret=$? 279f07849eSopenharmony_ci diff $out $answer_file > $diff_file 289f07849eSopenharmony_ci diff_ret=$? 299f07849eSopenharmony_ci 309f07849eSopenharmony_ci if [ "$diff_ret" != "0" ]; then 319f07849eSopenharmony_ci echo "FAIL $name: failed output is in $out, diff is:" 329f07849eSopenharmony_ci cat $diff_file 339f07849eSopenharmony_ci else 349f07849eSopenharmony_ci echo "PASS $name" 359f07849eSopenharmony_ci fi 369f07849eSopenharmony_ci rm $out $diff_file 379f07849eSopenharmony_ci} 389f07849eSopenharmony_ci 399f07849eSopenharmony_cibuilddir=`pwd` 409f07849eSopenharmony_cicd ${builddir} 419f07849eSopenharmony_ciecho "Running tests in ${builddir}" 429f07849eSopenharmony_ci 439f07849eSopenharmony_ci#make -q testcases 449f07849eSopenharmony_ci 459f07849eSopenharmony_cirun test1 "test1 - 1" "arg1: 1 arg2: (none)" --arg1 469f07849eSopenharmony_cirun test1 "test1 - 2" "arg1: 0 arg2: foo" --arg2 foo 479f07849eSopenharmony_cirun test1 "test1 - 3" "arg1: 1 arg2: something" --arg1 --arg2 something 489f07849eSopenharmony_cirun test1 "test1 - 4" "arg1: 0 arg2: another" --simple another 499f07849eSopenharmony_cirun test1 "test1 - 5" "arg1: 1 arg2: alias" --two 509f07849eSopenharmony_cirun test1 "test1 - 6" "arg1: 1 arg2: (none) rest: --arg2" --arg1 -- --arg2 519f07849eSopenharmony_cirun test1 "test1 - 7" "arg1: 0 arg2: abcd rest: --arg1" --simple abcd -- --arg1 529f07849eSopenharmony_cirun test1 "test1 - 8" "arg1: 1 arg2: (none) rest: --arg2" --arg1 --takerest --arg2 539f07849eSopenharmony_cirun test1 "test1 - 9" "arg1: 0 arg2: foo" -2 foo 549f07849eSopenharmony_cirun test1 "test1 - 10" "arg1: 0 arg2: (none) arg3: 50" -3 50 559f07849eSopenharmony_cirun test1 "test1 - 11" "arg1: 0 arg2: bar" -T bar 569f07849eSopenharmony_cirun test1 "test1 - 12" "arg1: 1 arg2: (none)" -O 579f07849eSopenharmony_cirun test1 "test1 - 13" "arg1: 1 arg2: foo" -OT foo 589f07849eSopenharmony_cirun test1 "test1 - 14" "arg1: 0 arg2: (none) inc: 1" --inc 599f07849eSopenharmony_cirun test1 "test1 - 15" "arg1: 0 arg2: foo inc: 1" -I --arg2 foo 609f07849eSopenharmony_ciPOSIX_ME_HARDER=1 ; export POSIX_ME_HARDER 619f07849eSopenharmony_cirun test1 "test1 - 16" "arg1: 1 arg2: (none) rest: foo --arg2 something" --arg1 foo --arg2 something 629f07849eSopenharmony_ciunset POSIX_ME_HARDER 639f07849eSopenharmony_ciPOSIXLY_CORRECT=1 ; export POSIXLY_CORRECT 649f07849eSopenharmony_cirun test1 "test1 - 17" "arg1: 1 arg2: (none) rest: foo --arg2 something" --arg1 foo --arg2 something 659f07849eSopenharmony_ciunset POSIXLY_CORRECT 669f07849eSopenharmony_cirun test1 "test1 - 18" "callback: c sampledata bar arg1: 1 arg2: (none)" --arg1 --cb bar 679f07849eSopenharmony_cirun test1 "test1 - 19" "" --echo-args 689f07849eSopenharmony_cirun test1 "test1 - 20" "--arg1" --echo-args --arg1 699f07849eSopenharmony_cirun test1 "test1 - 21" "--arg2 something" -T something -e 709f07849eSopenharmony_cirun test1 "test1 - 22" "--arg2 something more args" -T something -a more args 719f07849eSopenharmony_cirun test1 "test1 - 23" "--echo-args -a" --echo-args -e -a 729f07849eSopenharmony_cirun test1 "test1 - 24" "arg1: 0 arg2: (none) short: 1" -onedash 739f07849eSopenharmony_cirun test1 "test1 - 25" "arg1: 0 arg2: (none) short: 1" --onedash 749f07849eSopenharmony_cirun test1 "test1 - 26" "callback: c arg for cb2 foo arg1: 0 arg2: (none)" --cb2 foo 759f07849eSopenharmony_cirun test1 "test1 - 27" "arg1: 0 arg2: (none) rest: -" - 769f07849eSopenharmony_cirun test1 "test1 - 28" "arg1: 0 arg2: foo rest: -" - -2 foo 779f07849eSopenharmony_cirun test1 "test1 - 29" "arg1: 0 arg2: bbbb" --arg2=aaaa -2 bbbb 789f07849eSopenharmony_cirun test1 "test1 - 30" "arg1: 0 arg2: 'foo bingo' rest: boggle" --grab bingo boggle 799f07849eSopenharmony_cirun test1 "test1 - 31" "arg1: 0 arg2: 'foo bar' rest: boggle" --grabbar boggle 809f07849eSopenharmony_ci 819f07849eSopenharmony_cirun test1 "test1 - 32" "arg1: 0 arg2: (none) aInt: 123456789" -i 123456789 829f07849eSopenharmony_cirun test1 "test1 - 33" "arg1: 0 arg2: (none) aInt: 123456789" --int 123456789 839f07849eSopenharmony_cirun test1 "test1 - 34" "arg1: 0 arg2: (none) aShort: 12345" -s 12345 849f07849eSopenharmony_cirun test1 "test1 - 35" "arg1: 0 arg2: (none) aShort: 12345" --short 12345 859f07849eSopenharmony_cirun test1 "test1 - 36" "arg1: 0 arg2: (none) aLong: 1123456789" -l 1123456789 869f07849eSopenharmony_cirun test1 "test1 - 37" "arg1: 0 arg2: (none) aLong: 1123456789" --long 1123456789 879f07849eSopenharmony_cirun test1 "test1 - 38" "arg1: 0 arg2: (none) aLongLong: 1111123456789" -L 1111123456789 889f07849eSopenharmony_cirun test1 "test1 - 39" "arg1: 0 arg2: (none) aLongLong: 1111123456789" --longlong 1111123456789 899f07849eSopenharmony_ci 909f07849eSopenharmony_cirun test1 "test1 - 40" "arg1: 0 arg2: (none) aFloat: 10.1" -f 10.1 919f07849eSopenharmony_cirun test1 "test1 - 41" "arg1: 0 arg2: (none) aFloat: 10.1" --float 10.1 929f07849eSopenharmony_cirun test1 "test1 - 42" "arg1: 0 arg2: (none) aDouble: 10.1" -d 10.1 939f07849eSopenharmony_cirun test1 "test1 - 43" "arg1: 0 arg2: (none) aDouble: 10.1" --double 10.1 949f07849eSopenharmony_ci 959f07849eSopenharmony_cirun test1 "test1 - 44" "arg1: 0 arg2: (none) oStr: (none)" --optional 969f07849eSopenharmony_cirun test1 "test1 - 45" "arg1: 0 arg2: (none) oStr: yadda" --optional=yadda 979f07849eSopenharmony_cirun test1 "test1 - 46" "arg1: 0 arg2: (none) oStr: yadda" --optional yadda 989f07849eSopenharmony_cirun test1 "test1 - 47" "arg1: 0 arg2: (none) oStr: ping rest: pong" --optional=ping pong 999f07849eSopenharmony_cirun test1 "test1 - 48" "arg1: 0 arg2: (none) oStr: ping rest: pong" --optional ping pong 1009f07849eSopenharmony_cirun test1 "test1 - 49" "arg1: 0 arg2: (none) aArgv: A B rest: C" --argv A --argv B C 1019f07849eSopenharmony_ci 1029f07849eSopenharmony_cirun test1 "test1 - 50" "arg1: 0 arg2: foo=bar" -2foo=bar 1039f07849eSopenharmony_cirun test1 "test1 - 51" "arg1: 0 arg2: foo=bar" -2=foo=bar 1049f07849eSopenharmony_ci 1059f07849eSopenharmony_cirun test1 "test1 - 52" "arg1: 0 arg2: (none) aFlag: 0xfeed" --bitxor 1069f07849eSopenharmony_cirun test1 "test1 - 53" "arg1: 0 arg2: (none) aFlag: 0xffff" --bitset 1079f07849eSopenharmony_cirun test1 "test1 - 54" "arg1: 0 arg2: (none) aFlag: 0x28c" --bitclr 1089f07849eSopenharmony_cirun test1 "test1 - 55" "arg1: 0 arg2: (none) aFlag: 0x8888" --nobitset 1099f07849eSopenharmony_cirun test1 "test1 - 56" "arg1: 0 arg2: (none) aFlag: 0xface" --nobitclr 1109f07849eSopenharmony_ci 1119f07849eSopenharmony_cirun test1 "test1 - 57" "arg1: 0 arg2: (none) aBits: foo,baz" --bits foo,bar,baz,!bar 1129f07849eSopenharmony_ci 1139f07849eSopenharmony_cirun test1 "test1 - 58" "\ 1149f07849eSopenharmony_ciUsage: test1 [-I?] [-c|--cb2=STRING] [--arg1] [-2|--arg2=ARG] 1159f07849eSopenharmony_ci [-3|--arg3=ANARG] [-onedash] [--optional=STRING] [--val] 1169f07849eSopenharmony_ci [-i|--int=INT] [-s|--short=SHORT] [-l|--long=LONG] 1179f07849eSopenharmony_ci [-L|--longlong=LONGLONG] [-f|--float=FLOAT] [-d|--double=DOUBLE] 1189f07849eSopenharmony_ci [--randint=INT] [--randshort=SHORT] [--randlong=LONG] 1199f07849eSopenharmony_ci [--randlonglong=LONGLONG] [--argv=STRING] [--bitset] [--bitclr] 1209f07849eSopenharmony_ci [-x|--bitxor] [--nstr=STRING] [--lstr=STRING] [-I|--inc] 1219f07849eSopenharmony_ci [-c|--cb=STRING] [--longopt] [-?|--help] [--usage] [--simple=ARG]" --usage 1229f07849eSopenharmony_cirun test1 "test1 - 59" "\ 1239f07849eSopenharmony_ciUsage: test1 [OPTION...] 1249f07849eSopenharmony_ci --arg1 First argument with a really long 1259f07849eSopenharmony_ci description. After all, we have to test 1269f07849eSopenharmony_ci argument help wrapping somehow, right? 1279f07849eSopenharmony_ci -2, --arg2=ARG Another argument (default: \"(none)\") 1289f07849eSopenharmony_ci -3, --arg3=ANARG A third argument 1299f07849eSopenharmony_ci -onedash POPT_ARGFLAG_ONEDASH: Option takes a single - 1309f07849eSopenharmony_ci --optional[=STRING] POPT_ARGFLAG_OPTIONAL: Takes an optional 1319f07849eSopenharmony_ci string argument 1329f07849eSopenharmony_ci --val POPT_ARG_VAL: 125992 141421 1339f07849eSopenharmony_ci -i, --int=INT POPT_ARG_INT: 271828 (default: 271828) 1349f07849eSopenharmony_ci -s, --short=SHORT POPT_ARG_SHORT: 4523 (default: 4523) 1359f07849eSopenharmony_ci -l, --long=LONG POPT_ARG_LONG: 738905609 (default: 738905609) 1369f07849eSopenharmony_ci -L, --longlong=LONGLONG POPT_ARG_LONGLONG: 738905609 (default: 1379f07849eSopenharmony_ci 738905609) 1389f07849eSopenharmony_ci -f, --float=FLOAT POPT_ARG_FLOAT: 3.14159 (default: 3.14159) 1399f07849eSopenharmony_ci -d, --double=DOUBLE POPT_ARG_DOUBLE: 9.8696 (default: 9.8696) 1409f07849eSopenharmony_ci --randint=INT POPT_ARGFLAG_RANDOM: experimental 1419f07849eSopenharmony_ci --randshort=SHORT POPT_ARGFLAG_RANDOM: experimental 1429f07849eSopenharmony_ci --randlong=LONG POPT_ARGFLAG_RANDOM: experimental 1439f07849eSopenharmony_ci --randlonglong=LONGLONG POPT_ARGFLAG_RANDOM: experimental 1449f07849eSopenharmony_ci --argv STRING POPT_ARG_ARGV: append string to argv array 1459f07849eSopenharmony_ci (can be used multiple times) 1469f07849eSopenharmony_ci --[no]bitset POPT_BIT_SET: |= 0x7777 1479f07849eSopenharmony_ci --[no]bitclr POPT_BIT_CLR: &= ~0xf842 1489f07849eSopenharmony_ci -x, --bitxor POPT_ARGFLAG_XOR: ^= (0x8ace^0xfeed) 1499f07849eSopenharmony_ci --nstr=STRING POPT_ARG_STRING: (null) (default: null) 1509f07849eSopenharmony_ci --lstr=STRING POPT_ARG_STRING: \"123456789...\" (default: 1519f07849eSopenharmony_ci \"This tests default strings and exceeds the 1529f07849eSopenharmony_ci ... limit. 1539f07849eSopenharmony_ci 123456789+123456789+123456789+123456789+123456789+ 123456789+123456789+123456789+123456789+123456789+ 1234567...\") 1549f07849eSopenharmony_ci 1559f07849eSopenharmony_ciarg for cb2 1569f07849eSopenharmony_ci -c, --cb2=STRING Test argument callbacks 1579f07849eSopenharmony_ci -I, --inc An included argument 1589f07849eSopenharmony_ci 1599f07849eSopenharmony_ciCallback arguments 1609f07849eSopenharmony_ci -c, --cb=STRING Test argument callbacks 1619f07849eSopenharmony_ci --longopt Unused option for help testing 1629f07849eSopenharmony_ci 1639f07849eSopenharmony_ciOptions implemented via popt alias/exec: 1649f07849eSopenharmony_ci --simple=ARG simple description 1659f07849eSopenharmony_ci 1669f07849eSopenharmony_ciHelp options: 1679f07849eSopenharmony_ci -?, --help Show this help message 1689f07849eSopenharmony_ci --usage Display brief usage message" --help 1699f07849eSopenharmony_ci 1709f07849eSopenharmony_cirun test1 "test1 - 60" "" --val=foo 1719f07849eSopenharmony_cirun test1 "test1 - 61" "" -x=f1 1729f07849eSopenharmony_ci 1739f07849eSopenharmony_cirun test1 "test1 - 62" "arg1: 0 arg2: (none) aInt: 1" --randint=-1 1749f07849eSopenharmony_ci 1759f07849eSopenharmony_ciif ! [ -e test3-data ]; then 1769f07849eSopenharmony_ci # create symlink for running during 'make distcheck' 1779f07849eSopenharmony_ci ln -s "${srcdir}/test3-data" test3-data 1789f07849eSopenharmony_cifi 1799f07849eSopenharmony_cirun_diff test3 "test3 - 1" test3-data/01.input test3-data/01.answer 1809f07849eSopenharmony_cirun_diff test3 "test3 - 2" test3-data/02.input test3-data/02.answer 1819f07849eSopenharmony_cirun_diff test3 "test3 - 3" test3-data/03.input test3-data/03.answer 1829f07849eSopenharmony_ci 1839f07849eSopenharmony_ciecho "" 1849f07849eSopenharmony_ciecho "Passed." 185