2 # Copyright (C) 2012 Red Hat Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 # Run the test script using the real daemon and tools.
24 libdir=$(cd ../../lib; pwd)
25 toolsdir=$(cd ../../tools; pwd)
26 daemondir=$(cd ../../daemon; pwd)
33 rm -rf "$testdir/.whenjobs"
34 mkdir "$testdir/.whenjobs"
35 rm -f "$testdir/test_output"
37 PATH="$toolsdir:$daemondir:$PATH"
40 # Kill the daemon and clean up when the script exits.
42 kill `cat "$testdir/.whenjobs/daemon_pid"`
43 rm -rf "$testdir/.whenjobs"
45 trap cleanup INT TERM QUIT EXIT
50 # Copy the job into the directory.
51 cp "$1" "$testdir/.whenjobs/jobs.ml"
53 # Upload it to the daemon.
54 whenjobs --upload --lib "$libdir"
56 # Now wait until the test completes. Note we cannot use 'wait'
57 # because the daemon is not a direct child of the script.
58 while [ -e /proc/`cat "$testdir/.whenjobs/daemon_pid"` ]; do
62 trap - INT TERM QUIT EXIT
63 rm -rf "$testdir/.whenjobs"
65 # Sort the output by job serial number, so that jobs that happened to
66 # fire off in parallel are still recorded in order.
67 sort -n -o "$testdir/test_output" "$testdir/test_output"
69 # Check the test output matches the expected output.
70 if ! cmp -s "$testdir/test_output" "$1.expected"; then
71 echo "$0: $1: test output did not match expected output"
72 echo "test output was:"
74 cat "$testdir/test_output"
79 rm -f "$testdir/test_output"