File: test-scan-interface.sh

package info (click to toggle)
xlbiff 4.6.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 248 kB
  • sloc: ansic: 754; sh: 609; python: 389; xml: 67; perl: 45; makefile: 44
file content (66 lines) | stat: -rwxr-xr-x 1,679 bytes parent folder | download
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
#! /bin/bash
# Test that xlbiff can run "scan" from nmh.
# The "scan" program needs some setup; this tests that
# xlbiff does it if needed.

# Usage: test-scan-interface.sh [--logdir dirname] [--as-installed]

. "$(dirname "$0")"/utilities.sh

parse_command_line "$@"

scan_binary=/usr/bin/mh/scan

util_check_dependencies "$scan_binary" nmh

create_test_tmpdir

# Create "scan" program wrapper

# This wrapper touches a file to let us know when scan runs successfully.
cat > "$test_tmpdir"/scan <<EOF
#! /bin/sh
HOME=/xlbiff-scan-test-nonexistent
echo "\$@" > "$test_tmpdir"/scan.args
"$scan_binary" "\$@" > "$logdir/scan.\$\$.stdout" 2> "$logdir/scan.\$\$.stderr"
status=\$?
cat -- "$logdir/scan.\$\$.stdout"
cat -- "$logdir/scan.\$\$.stderr" >&2
if [ "\$status" -eq 0 ]; then
    touch -- "$test_tmpdir"/scan.success
fi 
exit "\$status"
EOF
chmod -- 755 "$test_tmpdir"/scan

# Change the "scan" program used in the installed X resources
# file to point to our wrapper instead.

printf -v xrm_sed_sub 's|mailbox-preview|& --scanproc %q/scan|p' "$test_tmpdir"
xrm_scan=$(sed -n "/^[^:!]*scanCommand:/$xrm_sed_sub" "$resource_file")

# Create the mail file
cat > "$test_tmpdir"/mailbox <<EOF
From: Test Harness <tester@localhost>
Subject: your scan interface test
Date: Sat, 26 Sep 2020 21:10:55 -0700

The scan program should be called on this message.
EOF

start_test scan
util_logv "$("$scan_binary" -version 2>&1)"
start_xlbiff_under_xvfb -file "$test_tmpdir/mailbox" -xrm "$xrm_scan"

scan_success_file_exists() {
    [[ -f "$test_tmpdir"/scan.success ]]
}

# wait for xlbiff to run "scan"
loop_for 100 scan_success_file_exists

end_test_with_status pass

kill_xvfb

exit 0