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 # $1 => session-name, $2 => exit status
34 expected_abduco_output
() {
35 echo "\e[?25h\e[999Habduco: $1: session terminated with exit status $2"
39 [ "`$ABDUCO | wc -l`" -gt 1 ] && echo Abduco session exists
&& exit 1;
40 pgrep abduco
&& echo Abduco process exists
&& exit 1;
44 test_non_existing_command
() {
45 check_environment ||
return 1;
46 $ABDUCO -c test .
/non-existing-command
&> /dev
/null
47 check_environment ||
return 1;
50 # $1 => session-name, $2 => command to execute
52 check_environment ||
return 1;
56 local output
="$name.out"
57 local output_expected
="$name.expected"
59 echo -n "Running test attached: $name "
60 $cmd &> "$output_expected"
61 expected_abduco_output
"$name" $?
>> "$output_expected"
62 $ABDUCO -c "$name" $cmd 2>&1 |
head -n -1 |
sed 's/.$//' > "$output"
63 if diff -u "$output_expected" "$output" && check_environment
; then
64 rm "$output" "$output_expected"
73 # $1 => session-name, $2 => command to execute
75 check_environment ||
return 1;
79 local output
="$name.out"
80 local output_expected
="$name.expected"
82 echo -n "Running test detached: $name "
84 expected_abduco_output
"$name" $?
> "$output_expected"
86 if $ABDUCO -n "$name" $cmd &> /dev
/null
&& sleep 1 &&
87 $ABDUCO -a "$name" 2>&1 |
head -n -1 |
sed 's/.$//' > "$output" &&
88 diff -u "$output_expected" "$output" && check_environment
; then
89 rm "$output" "$output_expected"
98 # $1 => session-name, $2 => command to execute
99 run_test_attached_detached
() {
100 check_environment ||
return 1;
104 local output
="$name.out"
105 local output_expected
="$name.expected"
107 echo -n "Running test: $name "
109 expected_abduco_output
"$name" $?
> "$output_expected"
111 if detach |
$ABDUCO $ABDUCO_OPTS -c "$name" $cmd &> /dev
/null
&& sleep 3 &&
112 $ABDUCO -a "$name" 2>&1 |
head -n -1 |
tail -1 |
sed 's/.$//' > "$output" &&
113 diff -u "$output_expected" "$output" && check_environment
; then
114 rm "$output" "$output_expected"
124 echo -n "Running dvtm test: "
125 if ! which dvtm
&> /dev
/null
; then
131 local output
="$name.out"
132 local output_expected
="$name.expected"
134 echo exit | dvtm
&> /dev
/null
135 expected_abduco_output
"$name" $?
> "$output_expected"
136 local len
=`wc -c "$output_expected" | awk '{ print $1 }'`
138 if dvtm_session |
$ABDUCO -c "$name" 2>&1 |
head -n -1 |
tail -c $len |
sed 's/.$//' > "$output" &&
139 diff -u "$output_expected" "$output" && check_environment
; then
140 rm "$output" "$output_expected"
149 test_non_existing_command ||
echo "Execution of non existing command FAILED"
151 run_test_attached
"seq" "seq 1 1000"
152 run_test_detached
"seq" "seq 1 1000"
154 run_test_attached
"false" "false"
155 run_test_detached
"false" "false"
157 run_test_attached
"true" "true"
158 run_test_detached
"true" "true"
160 cat > exit-status.sh
<<-EOT
164 chmod +x exit-status.sh
166 run_test_attached
"exit-status" "./exit-status.sh"
167 run_test_detached
"exit-status" "./exit-status.sh"
171 cat > long-running.sh
<<-EOT
182 chmod +x long-running.sh
184 run_test_attached_detached
"attach-detach" "./long-running.sh"