4 # set detach key explicitly in case it was changed in config.h
7 [ ! -z "$1" ] && ABDUCO
="$1"
8 [ ! -x "$ABDUCO" ] && echo "usage: $0 /path/to/abduco" && exit 1
33 expected_abduco_prolog
() {
34 printf "\e[?1049h\e[H"
37 # $1 => session-name, $2 => exit status
38 expected_abduco_epilog
() {
39 echo "\e[?1049labduco: $1: session terminated with exit status $2"
42 # $1 => session-name, $2 => cmd to run
43 expected_abduco_attached_output
() {
44 expected_abduco_prolog
46 expected_abduco_epilog
"$1" $?
49 # $1 => session-name, $2 => cmd to run
50 expected_abduco_detached_output
() {
51 expected_abduco_prolog
53 expected_abduco_epilog
"$1" $?
57 [ "`$ABDUCO | wc -l`" -gt 1 ] && echo Abduco session exists
&& exit 1;
58 pgrep abduco
&& echo Abduco process exists
&& exit 1;
62 test_non_existing_command
() {
63 check_environment ||
return 1;
64 $ABDUCO -c test .
/non-existing-command
&> /dev
/null
65 check_environment ||
return 1;
68 # $1 => session-name, $2 => command to execute
70 check_environment ||
return 1;
74 local output
="$name.out"
75 local output_expected
="$name.expected"
77 echo -n "Running test attached: $name "
78 expected_abduco_attached_output
"$name" "$cmd" &> "$output_expected"
79 $ABDUCO -c "$name" $cmd 2>&1 |
sed 's/.$//' > "$output"
81 if diff -u "$output_expected" "$output" && check_environment
; then
82 rm "$output" "$output_expected"
91 # $1 => session-name, $2 => command to execute
93 check_environment ||
return 1;
97 local output
="$name.out"
98 local output_expected
="$name.expected"
100 echo -n "Running test detached: $name "
101 expected_abduco_detached_output
"$name" "$cmd" &> "$output_expected"
103 if $ABDUCO -n "$name" $cmd &> /dev
/null
&& sleep 1 &&
104 $ABDUCO -a "$name" 2>&1 |
sed 's/.$//' > "$output" &&
105 diff -u "$output_expected" "$output" && check_environment
; then
106 rm "$output" "$output_expected"
115 # $1 => session-name, $2 => command to execute
116 run_test_attached_detached
() {
117 check_environment ||
return 1;
121 local output
="$name.out"
122 local output_expected
="$name.expected"
124 echo -n "Running test: $name "
126 expected_abduco_epilog
"$name" $?
&> "$output_expected"
128 if detach |
$ABDUCO $ABDUCO_OPTS -c "$name" $cmd &> /dev
/null
&& sleep 3 &&
129 $ABDUCO -a "$name" 2>&1 |
tail -1 |
sed 's/.$//' > "$output" &&
130 diff -u "$output_expected" "$output" && check_environment
; then
131 rm "$output" "$output_expected"
141 echo -n "Running dvtm test: "
142 if ! which dvtm
&> /dev
/null
; then
148 local output
="$name.out"
149 local output_expected
="$name.expected"
151 echo exit | dvtm
&> /dev
/null
152 expected_abduco_epilog
"$name" $?
> "$output_expected"
153 local len
=`wc -c "$output_expected" | awk '{ print $1 }'`
155 if dvtm_session |
$ABDUCO -c "$name" 2>&1 |
tail -c $len |
sed 's/.$//' > "$output" &&
156 diff -u "$output_expected" "$output" && check_environment
; then
157 rm "$output" "$output_expected"
166 test_non_existing_command ||
echo "Execution of non existing command FAILED"
168 run_test_attached
"seq" "seq 1 1000"
169 run_test_detached
"seq" "seq 1 1000"
171 run_test_attached
"false" "false"
172 run_test_detached
"false" "false"
174 run_test_attached
"true" "true"
175 run_test_detached
"true" "true"
177 cat > exit-status.sh
<<-EOT
181 chmod +x exit-status.sh
183 run_test_attached
"exit-status" "./exit-status.sh"
184 run_test_detached
"exit-status" "./exit-status.sh"
188 cat > long-running.sh
<<-EOT
199 chmod +x long-running.sh
201 run_test_attached_detached
"attach-detach" "./long-running.sh"