summaryrefslogtreecommitdiffstats
path: root/tests/ts/script
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xtests/ts/script/buffering-race27
-rwxr-xr-xtests/ts/script/options66
-rwxr-xr-xtests/ts/script/race48
-rwxr-xr-xtests/ts/script/replay98
4 files changed, 239 insertions, 0 deletions
diff --git a/tests/ts/script/buffering-race b/tests/ts/script/buffering-race
new file mode 100755
index 0000000..b720383
--- /dev/null
+++ b/tests/ts/script/buffering-race
@@ -0,0 +1,27 @@
+#!/bin/bash
+
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="buffering race"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_SCRIPT"
+
+#SCRIPT_DEBUG=all ULPTY_DEBUG=all
+$TS_CMD_SCRIPT -c "echo Hallo World" /dev/null </dev/null >$TS_OUTPUT
+
+ts_finalize
+
diff --git a/tests/ts/script/options b/tests/ts/script/options
new file mode 100755
index 0000000..9b5f9d5
--- /dev/null
+++ b/tests/ts/script/options
@@ -0,0 +1,66 @@
+#!/bin/bash
+
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="options"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+export SCRIPT_TEST_SECOND_SINCE_EPOCH=1432489398
+export TZ="GMT"
+
+ts_check_test_command "$TS_HELPER_SCRIPT"
+
+ts_init_subtest "append"
+$TS_HELPER_SCRIPT --command "echo append1" $TS_OUTPUT </dev/null >/dev/null 2>&1
+$TS_HELPER_SCRIPT --append -c "echo append2" $TS_OUTPUT </dev/null >/dev/null 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "force"
+ln -s $TS_OUTPUT typescript
+$TS_HELPER_SCRIPT --command "echo no force" </dev/null >/dev/null 2>> $TS_OUTPUT
+echo $? >> $TS_OUTPUT
+$TS_HELPER_SCRIPT -a --force --command "echo with force" </dev/null >/dev/null
+echo $? >> $TS_OUTPUT
+rm -f typescript
+ln -s $TS_OUTPUT tpircsepyt
+$TS_HELPER_SCRIPT -a --command "echo not typescript" tpircsepyt </dev/null >/dev/null
+echo $? >> $TS_OUTPUT
+rm -f tpircsepyt
+ts_finalize_subtest
+
+ts_init_subtest "quiet"
+$TS_HELPER_SCRIPT --quiet --command "echo quiet1" $TS_OUTPUT </dev/null >/dev/null 2>&1
+$TS_HELPER_SCRIPT -a -q --command "echo quiet2" $TS_OUTPUT </dev/null >/dev/null 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "return"
+$TS_HELPER_SCRIPT --command "exit 1" $TS_OUTPUT </dev/null >/dev/null 2>&1
+echo $? >> $TS_OUTPUT
+$TS_HELPER_SCRIPT -a --command "exit 0" $TS_OUTPUT </dev/null >/dev/null 2>&1
+echo $? >> $TS_OUTPUT
+$TS_HELPER_SCRIPT -e --append -c "exit 42" $TS_OUTPUT </dev/null >/dev/null 2>&1
+echo $? >> $TS_OUTPUT
+$TS_HELPER_SCRIPT --return --append -c "exit 127" $TS_OUTPUT </dev/null >/dev/null 2>&1
+echo $? >> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_init_subtest "size"
+$TS_HELPER_SCRIPT --output-limit 9 --command "echo 1:1234567890" $TS_OUTPUT </dev/null >/dev/null 2>&1
+$TS_HELPER_SCRIPT -a -o 9 --command "echo 2:1234567890" $TS_OUTPUT </dev/null >/dev/null 2>&1
+echo $? >> $TS_OUTPUT
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/script/race b/tests/ts/script/race
new file mode 100755
index 0000000..6ef5309
--- /dev/null
+++ b/tests/ts/script/race
@@ -0,0 +1,48 @@
+#!/bin/bash
+
+#
+# Copyright (C) 2007 Karel Zak <kzak@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="race conditions"
+
+. $TS_TOPDIR/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_SCRIPT"
+
+# this test may fail on systems with very heavy load
+# https://github.com/util-linux/util-linux/issues/296
+TS_KNOWN_FAIL="yes"
+
+bingofile="$TS_OUTDIR/${TS_TESTNAME}-bingo"
+
+count=1000
+for i in `seq 1 $count`; do
+ $TS_CMD_SCRIPT -q -c "printf 'Bingo\n'" $bingofile
+done | grep -c Bingo >> $TS_OUTPUT
+
+seen=$(<$TS_OUTPUT)
+if [ "$seen" = "$count" ]; then
+ echo "all bingos seen" > $TS_OUTPUT
+else
+ echo "only $seen of $count bingos seen" > $TS_OUTPUT
+fi
+
+rm -f $bingofile
+
+ts_finalize
+
diff --git a/tests/ts/script/replay b/tests/ts/script/replay
new file mode 100755
index 0000000..384c5b3
--- /dev/null
+++ b/tests/ts/script/replay
@@ -0,0 +1,98 @@
+#!/bin/bash
+
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="replay"
+
+. "$TS_TOPDIR/functions.sh"
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_SCRIPT"
+ts_check_test_command "$TS_CMD_SCRIPTREPLAY"
+ts_check_test_command "$TS_CMD_SCRIPTLIVE"
+
+LOG_OUT_FILE="${TS_OUTDIR}/${TS_TESTNAME}-logfile-out"
+LOG_IN_FILE="${TS_OUTDIR}/${TS_TESTNAME}-logfile-in"
+LOG_IO_FILE="${TS_OUTDIR}/${TS_TESTNAME}-logfile-io"
+TIMING_FILE="${TS_OUTDIR}/${TS_TESTNAME}-logfile-tm"
+
+rm -f $TIMING_FILE $LOG_IN_FILE $LOG_OUT_FILE $LOG_IO_FILE
+
+
+#
+# Old command line format
+#
+ts_init_subtest "basic"
+echo "===recording" >"$TS_OUTPUT"
+$TS_CMD_SCRIPT \
+ --command "echo hello world; sleep 0.5; echo all done" \
+ --timing="$TIMING_FILE" \
+ "$LOG_OUT_FILE" >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+echo "===replaying" >>"$TS_OUTPUT"
+$TS_CMD_SCRIPTREPLAY "$TIMING_FILE" "$LOG_OUT_FILE" 1.5 >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+sed -i "s|$TIMING_FILE|timingfile|g; s|$LOG_OUT_FILE|outlog|g" $TS_OUTPUT $TS_ERRLOG
+ts_finalize_subtest
+
+
+#
+# New command line format
+#
+ts_init_subtest "output"
+echo "===recording" >"$TS_OUTPUT"
+NUMBER=1 $TS_CMD_SCRIPT \
+ --command 'echo "result is $(($NUMBER + 1))"' \
+ --log-out "$LOG_OUT_FILE" \
+ --log-timing "$TIMING_FILE" >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+echo "===replaying" >>"$TS_OUTPUT"
+$TS_CMD_SCRIPTREPLAY \
+ --log-out "$LOG_OUT_FILE" \
+ --log-timing "$TIMING_FILE" >> $TS_OUTPUT 2>> $TS_ERRLOG
+
+sed -i "s|$TIMING_FILE|timingfile|g; s|$LOG_OUT_FILE|outlog|g" $TS_OUTPUT $TS_ERRLOG
+ts_finalize_subtest
+
+
+#
+# Log input
+#
+ts_init_subtest "input"
+echo "===recording" >"$TS_OUTPUT"
+echo 'echo "result is $(($NUMBER + 1))"' | $TS_CMD_SCRIPT \
+ --command 'sh' \
+ --log-in "$LOG_IN_FILE" \
+ --log-timing "$TIMING_FILE" >> /dev/null 2>> $TS_ERRLOG
+
+echo "===replaying" >>"$TS_OUTPUT"
+$TS_CMD_SCRIPTREPLAY \
+ --log-in "$LOG_IN_FILE" \
+ --log-timing "$TIMING_FILE" >> $TS_OUTPUT 2>> $TS_ERRLOG
+ts_finalize_subtest
+
+
+#
+# Live replay
+#
+ts_init_subtest "live"
+TS_KNOWN_FAIL="yes"
+NUMBER=123 $TS_CMD_SCRIPTLIVE \
+ --command 'sh' \
+ --log-in "$LOG_IN_FILE" \
+ --log-timing "$TIMING_FILE" >> $TS_OUTPUT 2>> $TS_ERRLOG
+sed -i 's/^[[:alnum:][:punct:][:blank:]]*[\$\#] /prompt> /g' $TS_OUTPUT
+ts_finalize_subtest
+
+ts_finalize