File: run

package info (click to toggle)
openmsx 21.0%2Bdfsg-3
  • links: PTS
  • area: main
  • in suites: sid
  • size: 28,132 kB
  • sloc: cpp: 244,928; xml: 54,344; tcl: 15,603; python: 5,335; perl: 281; sh: 78; makefile: 57
file content (50 lines) | stat: -rwxr-xr-x 1,387 bytes parent folder | download | duplicates (2)
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
#!/bin/bash -ex

if [ x"$AUTOPKGTEST_TMP" = x ] ; then
	# Create a temporary directory and clean it up when done.
	export AUTOPKGTEST_TMP="`mktemp -d`"
	cleanup() {
		rm -rf "$AUTOPKGTEST_TMP"
	}
	trap cleanup EXIT
fi

# Make sure we have a home during the test.
export HOME="$AUTOPKGTEST_TMP/home"
mkdir -p "$HOME"

# If there is no DISPLAY, create one for this test.
if [ x"$DISPLAY" = x ]; then
	exec xvfb-run "$0" "$@"
fi

# Run openmsx and store the (stderr) output in a file, in addition to showing it to the user.
openmsx 2>&1 | tee "$AUTOPKGTEST_TMP/output" &

# Wait for emulator to start up.
sleep 3

xwininfo -root -tree

# Find emulator window.
window="0x`xwininfo -root -tree | grep openMSX | head -n 1 | cut -f2 -dx | cut -f1 -d' '`"

# Print a string to stderr, then exit using ctrl-break.
xvkbd -xsendevent -window "$window" -text '\{F10}'
sleep 1	# Wait for console window to open.
xvkbd -xsendevent -window "$window" -text 'puts stderr "autopkgtest output"\r\D3quit\r'

# Wait for the emulator to exit.
sleep 3

# Kill the emulator if it was still running.
# Don't care if that worked; without job control this isn't reliable.
kill % || :

# Check that the expected output is produced. If not, that makes the test fail.
if ! grep '^autopkgtest output$' "$AUTOPKGTEST_TMP/output" >/dev/null ; then
	echo >&2 "Emulator did not produce expected output"
	exit 1
fi

exit 0