summaryrefslogtreecommitdiffstats
path: root/tests/ts/script/replay
blob: 384c5b3b133c9f8cc3bf57b74185094847c2e9b3 (plain)
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
#!/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