3 # Start an X session, fire up some xterms and GL apps, then bounce them
6 # Copyright (C) 2003-2006 IBM
8 # This program is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License as
10 # published by the Free Software Foundation; either version 2 of the
11 # License, or (at your option) any later version.
13 # This program is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 # X11 testing -- this is a daemon test!
30 #if [ -z "$DISPLAY" ]; then
34 # Kill test if we don't want it.
35 if [ $DO_X_TESTS -eq 0 ]; then
36 echo "X11 testing is off."
40 # Can we find the startx script?
42 XSERVER_FILE
=`which startx 2> /dev/null`
43 if [ -z "$XSERVER_FILE" -o ! -x "$XSERVER_FILE" ]; then
45 XSERVER_FILE
=`which X 2> /dev/null`
46 if [ -z "$XSERVER_FILE" -o ! -x "$XSERVER_FILE" ]; then
47 echo "startx script not found."
53 OLD_XSERVERS
=`pgrep -l X | grep -v Xprt | wc -l`
56 if [ $NEED_TO_START_X -eq 1 ]; then
57 echo "xterm_stress: Starting X..."
59 rm -rf /var
/log
/Xorg
.2.log
/var
/log
/XFree86.2.log
62 if [ $RAW_X_SERVER -eq 0 ]; then
63 $XSERVER_FILE -- $DISPLAY -ac vt9
&
65 $POUNDER_HOME/timed_loop
$TEST_DURATION $XSERVER_FILE $DISPLAY -ac vt9
&
69 NEW_XSERVERS
=`pgrep -l X | grep -v Xprt | wc -l`
70 if [ $NEW_XSERVERS -gt $OLD_XSERVERS ]; then
71 export XPID
=`pgrep -l X -n | grep -v Xprt | awk -F " " '{print $1}'`
72 echo -n " -$XPID" >> $POUNDER_PIDFILE
78 trap 'kill -4 $XPID' 15
80 # Did we see any failures?
81 LOGFILE
=`ls /var/log/X*.2.log`
82 ERRORS
=`egrep -ic "(fatal)" $LOGFILE`
83 if [ $ERRORS -gt 0 ]; then
84 if [ $ERRORS -eq 255 ]; then
87 cp $LOGFILE $POUNDER_TMPDIR/x-log-
$XPID
92 # Now start the window manager if we couldn't find startx.
93 if [ $NEED_TO_START_X -eq 1 -a $RAW_X_SERVER -eq 1 ]; then
95 echo "xterm_stress: Starting twm - 5s"
99 # Sleep a little more so that the session can start before
100 # we start flooding X with crud.
103 # sets the list delimiter to :
105 # Add some screensavers to the path (OpenGL testing)
106 export PATH
=$PATH:/usr
/lib
/xscreensaver
:/usr
/X11R
6/lib
/xscreensaver
109 cmd
="dmesg:ls -l:cat /var/log/messages:dmesg:ls -l:cat /var/log/messages"
110 xcmd
="sproingies -fps -delay 0:flyingtoasters -fps -delay 0:glmatrix -fps -delay 0"
113 xterm
-geom 80x25
+0+0 -e "bash -c $POUNDER_SRCDIR/dump_xserver_statm" &
115 #start text-based programs
118 exe
="while true; do $i; done"
119 xterm
-geometry 80x25
`$POUNDER_SRCDIR/randacoords/coords 600 400` -e "bash -c '$exe'" &
130 # Put up a top window for top monitoring.
131 xterm
-geom 100x9
+0+0 -e top
&
132 echo "xterm_stress: Test started"
134 # Now make the windows go bonkers!
135 $POUNDER_SRCDIR/xbonkers
/xbonkers
-i 500 -s 10000 &
137 # If we started X via startx, we need to wait 1200s and then
139 if [ $RAW_X_SERVER -eq 0 ]; then
144 # Track the number of times we wait for X server to die.
147 # Loop until the X server goes away
149 XSERVERS
=`pgrep -l X | grep -v Xprt | wc -l`
150 if [ $XSERVERS -lt $OLD_XSERVERS ]; then
151 # Did we see any failures?
152 LOGFILE
=`ls /var/log/X*.2.log`
153 ERRORS
=`egrep -ic "(fatal)" $LOGFILE`
155 # There will always be one fatal error--we killed X.
158 if [ $DIE_TIMEOUT_LOOPS -gt 180 ]; then
159 # Three minutes; try something stronger.
160 echo "First attempt to kill X server failed; trying -9."
163 if [ $DIE_TIMEOUT_LOOPS -gt 360 ]; then
164 # Six minutes. Still not dead? Abort script.
165 echo "Second attempt to kill X server failed. Aborting."
169 OLD_XSERVERS
=$XSERVERS
170 DIE_TIMEOUT_LOOPS
=$
((DIE_TIMEOUT_LOOPS
+ 1))
174 echo "ERROR: Jumped to somewhere where we should never be."
175 # We're not supposed to get here.