Debian Codegraph @

test/runinx

raw
1 #! /bin/sh
2 # gtk-engines - a collection of drawing engines for GTK+
3 # Copyright (C) 2007 Benjamin Berg <[email protected]>
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License, or (at your option) any later version.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 #
19 # Project contact: <[email protected]>
20 #
21
22
23 # This script is a wrapper to start an X server for tests.
24 # there may be better ways to do this, but I don't know any ...
25
26 if [ "$DISPLAY" != "" ]; then
27 # Just start everything, and exit after that
28 "$@"
29 exit $?
30 fi
31
32 for port in `seq 20 1000`; do
33 # Check if there is a lock file, if yes test if the server is running
34 if [ -f /tmp/.X$port-lock ]; then
35 # Test if there is anything running with the PID
36 pid="`cat /tmp/.X$port-lock | sed 's/ //g'`"
37
38 if [ "`ps -e | grep -c ^\\ *$pid`" = "0" ]; then
39 # Remove the stale lock file
40 rm -f /tmp/.X$port-lock
41 break
42 fi
43 else
44 break
45 fi
46 done
47
48
49 export DISPLAY=:$port
50
51 # Start the Xvfb server -- try to ...
52 # We need 24bpp as cairo does not support everything
53 Xvfb $DISPLAY -ac -screen 0 1280x1024x24 & 2>/dev/null >/dev/null
54 xvfb_pid=$!
55
56 "$@"
57 result="$?"
58
59 kill $xvfb_pid 2>/dev/null >/dev/null
60
61 exit $result
62