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
|
#!/bin/sh
# vim: set filetype=sh :
# file: special.test.mylib
# warning: mylib and example.mylib are not official part of shellia
# copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2021)
# license: GNU General Public License, version 3
# description: test example library mylib
# example.mylib needs ssh to localhost without password
# see also: mylib, example.mylib
# The following tests are included:
# (1) Run with -i
# (2) check logfile
# (3) Run without options
# (4) check logfile
#
# the following test only run on developers machine, because
# they will only work if "ssh localhost" works without password
. ./tstlib
quote="'"
shell="dash"
while [ $# -ne 0 ]; do
if [ "$1" = "-s" ]; then
shell="$2"
shift 2
else
echo "ERROR $0: unknown option <$1>" >&2
exit 1
fi
done
[ "$shell" = "bash" ] && set -- "$@" -u "$UNIFY_mktemp"
[ "$shell" = "posh" ] && set -- "$@" -u "$UNIFY_mktemp"
[ "$shell" = "mksh" ] && set -- "$@" -u "$UNIFY_mktemp"
[ "$shell" = "dash" ] && set -- "$@" -u "$UNIFY_mktemp"
[ "$shell" = "busybox sh" ] && set -- "$@" -u "$UNIFY_mktemp"
cmd="$(dirname $0)/example.mylib-2"
ia_logfile="$(mktemp)"
export ia_logfile
rm -f $ia_logfile
check "(1) Run with -i" --sshd2222-opts -i "/bin/echo \"c
c
\"" "$@" "$cmd -a -i" \
"=== example.mylib-2 ===
1 answer=\"\$(ia_ssh $<ssh_options> localhost \"cd $<PWD_DIR>; $<SCRIPT_DIR>/example.mylib-2 -i --local-run\")\"
2 echo \"answer=<\$answer>\"
d ... change dbg: 0
i toggle -i flag
c continue without questions
q quit
? [1]
=== example.mylib-2/localhost:example.mylib-2 ===
1 echo 42
d ... change dbg: 0
q quit
? [1] answer=<42>"
check "(2) check logfile" --sshd2222 "$@" "cat $ia_logfile" \
"|=== example.mylib-2 ===
|1 answer=\"\$(ia_ssh $<ssh_options> localhost \"cd $<PWD_DIR>; $<SCRIPT_DIR>/example.mylib-2 -i --local-run\")\"
|2 echo \"answer=<\$answer>\"
|d ... change dbg: 0
|i toggle -i flag
|c continue without questions
|q quit
|? [1] c<RETURN>
||=== example.mylib-2/localhost:example.mylib-2 ===
||1 echo 42
||d ... change dbg: 0
||q quit
||? [1] c<RETURN>
||s:42
|s:answer=<42>"
rm -f $ia_logfile
check "(3) Run without option" --sshd2222-opts "$@" "$cmd -a" \
"answer=<42>"
check "(4) check logfile" --sshd2222 "$@" "cat $ia_logfile" \
"|example.mylib-2
||example.mylib-2/localhost:example.mylib-2
||s:42
|s:answer=<42>"
rm -f $ia_logfile
|