summaryrefslogtreecommitdiff
path: root/runtest
blob: 7e964be83b508c7b9c567c1f1c1e4ec8b987a0c7 (plain)
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
#!/bin/sh

# Test nitpicker server/client pair.

# Must be run as root, since only root can directly access the screen
# (as required by nitpicker-server)
if [ `/usr/bin/id -u` -ne 0 ]
then
 echo "FAIL: Must run as root."
 exit 1
fi

# We'll ignore the possibility of race conditions; as long as we
# check "quickly" we should be fine.  In production mode that wouldn't be
# an issue, we'd only run one nitpicker-server and that's it.
echo "Looking for existing nitpicker-server..."
if ps -f -C nitpicker-server
then
  echo "FAILURE. There's an existing nitpicker-server. If it's hung, run:"
  echo "  killall -9 nitpicker-server"
  exit 1
else
  # Clean up any leftover file.  We don't do this at the END, in case we
  # need to check this file for debugging.
  rm -f nitpicker.ref
fi

echo "Starting nitpicker-server"
./nitpicker-server &
serverpid=$!

# Poll until nitpicker.ref exists (created by nitpicker-server).
echo "Polling for nitpicker.ref"
while [ ! -e nitpicker.ref ]
do
  sleep 1
  if ! ps --pid $serverpid > /dev/null
  then
    echo "Server has failed without setting up IPC - exiting test"
    exit 1
  fi
done

echo "Found nitpicker-server, launching test client."
sleep 1
./nitpicker-test-client

sleep 5

echo "Test complete - killing nitpicker-server."
killall -q nitpicker-server