1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
|
# environment variables:
# GREP - if set, can be used to use alternative grep version
# Most important use case is to use GNU grep (ggrep)
# on Solaris. If unset, use "grep".
set -e
if [ "x$debug" == "xon" ]; then #get core-dump on crash
ulimit -c unlimited
fi
#cmd="../src/ln_test -v" # case to get debug info (add -vvv for more verbosity)
cmd=../src/ln_test # regular case
. ./options.sh
no_solaris10() {
if (uname -a | grep -q "SunOS.*5.10"); then
printf 'platform: %s\n' "$(uname -a)"
printf 'This looks like solaris 10, we disable known-failing tests to\n'
printf 'permit OpenCSW to build packages. However, this are real failures\n'
printf 'and so a fix should be done as soon as time permits.\n'
exit 77
fi
}
test_def() {
test_file=$(basename $1)
test_name=$(echo $test_file | sed -e 's/\..*//g')
echo ===============================================================================
echo "[${test_file}]: test for ${2}"
}
execute() {
if [ "x$debug" == "xon" ]; then
echo "======rulebase======="
cat tmp.rulebase
echo "====================="
set -x
fi
if [ "$1" == "file" ]; then
$cmd $ln_opts -r tmp.rulebase -e json > test.out < $2
else
echo "$1" | $cmd $ln_opts -r tmp.rulebase -e json > test.out
fi
echo "Out:"
cat test.out
if [ "x$debug" == "xon" ]; then
set +x
fi
}
execute_with_string() {
# $1 must be rulebase string
# $2 must be sample string
if [ "x$debug" == "xon" ]; then
echo "======rulebase======="
cat tmp.rulebase
echo "====================="
set -x
fi
echo "$2" | $cmd $ln_opts -R "$1" -e json > test.out
echo "Out:"
cat test.out
if [ "x$debug" == "xon" ]; then
set +x
fi
}
assert_output_contains() {
${GREP:-grep} -F "$1" < test.out
}
assert_output_json_eq() {
./json_eq "$1" "$(cat test.out)"
}
rulebase_file_name() {
if [ "x$1" == "x" ]; then
echo tmp.rulebase
else
echo $1.rulebase
fi
}
reset_rules() {
rb_file=$(rulebase_file_name $1)
rm -f $rb_file
}
add_rule() {
rb_file=$(rulebase_file_name $2)
echo $1 >> $rb_file
}
add_rule_no_LF() {
rb_file=$(rulebase_file_name $2)
echo -n $1 >> $rb_file
}
cleanup_tmp_files() {
rm -f -- test.out *.rulebase
}
reset_rules
|