open-vault/vendor/github.com/ugorji/go/codec/tests.sh

103 lines
3.5 KiB
Bash
Raw Normal View History

2015-09-22 15:44:21 +00:00
#!/bin/bash
# Run all the different permutations of all the tests.
# This helps ensure that nothing gets broken.
_run() {
2015-10-30 22:07:00 +00:00
# 1. VARIATIONS: regular (t), canonical (c), IO R/W (i),
# binc-nosymbols (n), struct2array (s), intern string (e),
2016-04-26 00:18:04 +00:00
# json-indent (d), circular (l)
2015-10-30 22:07:00 +00:00
# 2. MODE: reflection (r), external (x), codecgen (g), unsafe (u), notfastpath (f)
# 3. OPTIONS: verbose (v), reset (z), must (m),
2015-09-22 15:44:21 +00:00
#
2015-10-30 22:07:00 +00:00
# Use combinations of mode to get exactly what you want,
# and then pass the variations you need.
2015-09-22 15:44:21 +00:00
ztags=""
2015-10-30 22:07:00 +00:00
zargs=""
2015-09-22 15:44:21 +00:00
local OPTIND
OPTIND=1
2016-04-26 00:18:04 +00:00
while getopts "_xurtcinsvgzmefdl" flag
2015-09-22 15:44:21 +00:00
do
case "x$flag" in
'xr') ;;
2015-10-30 22:07:00 +00:00
'xf') ztags="$ztags notfastpath" ;;
2015-09-22 15:44:21 +00:00
'xg') ztags="$ztags codecgen" ;;
'xx') ztags="$ztags x" ;;
'xu') ztags="$ztags unsafe" ;;
2015-10-30 22:07:00 +00:00
'xv') zargs="$zargs -tv" ;;
'xz') zargs="$zargs -tr" ;;
'xm') zargs="$zargs -tm" ;;
2016-04-26 00:18:04 +00:00
'xl') zargs="$zargs -tl" ;;
2015-09-22 15:44:21 +00:00
*) ;;
esac
done
# shift $((OPTIND-1))
2015-10-07 20:10:00 +00:00
printf '............. TAGS: %s .............\n' "$ztags"
# echo ">>>>>>> TAGS: $ztags"
2015-09-22 15:44:21 +00:00
OPTIND=1
2016-04-26 00:18:04 +00:00
while getopts "_xurtcinsvgzmefdl" flag
2015-09-22 15:44:21 +00:00
do
case "x$flag" in
2015-10-30 22:07:00 +00:00
'xt') printf ">>>>>>> REGULAR : "; go test "-tags=$ztags" $zargs ; sleep 2 ;;
'xc') printf ">>>>>>> CANONICAL : "; go test "-tags=$ztags" $zargs -tc; sleep 2 ;;
'xi') printf ">>>>>>> I/O : "; go test "-tags=$ztags" $zargs -ti; sleep 2 ;;
2016-04-26 00:18:04 +00:00
'xn') printf ">>>>>>> NO_SYMBOLS : "; go test "-tags=$ztags" -run=Binc $zargs -tn; sleep 2 ;;
2015-10-30 22:07:00 +00:00
'xs') printf ">>>>>>> TO_ARRAY : "; go test "-tags=$ztags" $zargs -ts; sleep 2 ;;
'xe') printf ">>>>>>> INTERN : "; go test "-tags=$ztags" $zargs -te; sleep 2 ;;
2016-04-26 00:18:04 +00:00
'xd') printf ">>>>>>> INDENT : ";
go test "-tags=$ztags" -run=JsonCodecsTable -td=-1 $zargs;
go test "-tags=$ztags" -run=JsonCodecsTable -td=8 $zargs;
sleep 2 ;;
2015-09-22 15:44:21 +00:00
*) ;;
esac
done
shift $((OPTIND-1))
OPTIND=1
}
2015-10-07 20:10:00 +00:00
# echo ">>>>>>> RUNNING VARIATIONS OF TESTS"
2017-01-13 14:06:34 +00:00
if [[ "x$@" = "x" || "x$@" = "x-A" ]]; then
2015-10-30 22:07:00 +00:00
# All: r, x, g, gu
2016-04-26 00:18:04 +00:00
_run "-_tcinsed_ml" # regular
_run "-_tcinsed_ml_z" # regular with reset
_run "-_tcinsed_ml_f" # regular with no fastpath (notfastpath)
_run "-x_tcinsed_ml" # external
_run "-gx_tcinsed_ml" # codecgen: requires external
_run "-gxu_tcinsed_ml" # codecgen + unsafe
2015-10-30 22:07:00 +00:00
elif [[ "x$@" = "x-Z" ]]; then
# Regular
2016-04-26 00:18:04 +00:00
_run "-_tcinsed_ml" # regular
_run "-_tcinsed_ml_z" # regular with reset
2015-10-30 22:07:00 +00:00
elif [[ "x$@" = "x-F" ]]; then
# regular with notfastpath
2016-04-26 00:18:04 +00:00
_run "-_tcinsed_ml_f" # regular
_run "-_tcinsed_ml_zf" # regular with reset
2017-01-13 14:06:34 +00:00
elif [[ "x$@" = "x-C" ]]; then
# codecgen
_run "-gx_tcinsed_ml" # codecgen: requires external
_run "-gxu_tcinsed_ml" # codecgen + unsafe
elif [[ "x$@" = "x-X" ]]; then
# external
_run "-x_tcinsed_ml" # external
elif [[ "x$@" = "x-h" || "x$@" = "x-?" ]]; then
cat <<EOF
Usage: tests.sh [options...]
-A run through all tests (regular, external, codecgen)
-Z regular tests only
-F regular tests only (without fastpath, so they run quickly)
-C codecgen only
-X external only
-h show help (usage)
-? same as -h
(no options)
same as -A
(unrecognized options)
just pass on the options from the command line
EOF
2015-09-22 15:44:21 +00:00
else
_run "$@"
fi