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)
31 rm -rf "$testdir/.whenjobs"
32 mkdir "$testdir/.whenjobs"
33 rm -f "$testdir/test_output"
35 PATH="$toolsdir:$daemondir:$PATH"
38 # Kill the daemon and clean up when the script exits.
40 kill `cat "$testdir/.whenjobs/daemon_pid"`
41 rm -rf "$testdir/.whenjobs"
43 trap cleanup INT TERM QUIT EXIT
48 # Copy the job into the directory.
49 cp "$1" "$testdir/.whenjobs/jobs.ml"
51 # Upload it to the daemon.
52 whenjobs --upload --lib "$libdir"
54 # Now wait until the test completes. Note we cannot use 'wait'
55 # because the daemon is not a direct child of the script.
56 while [ -e /proc/`cat "$testdir/.whenjobs/daemon_pid"` ]; do
60 trap - INT TERM QUIT EXIT
61 rm -rf "$testdir/.whenjobs"
63 # Sort the output by job serial number, so that jobs that happened to
64 # fire off in parallel are still recorded in order.
65 sort -n -o "$testdir/test_output" "$testdir/test_output"
67 # Check the test output matches the expected output.
68 if ! cmp -s "$testdir/test_output" "$1.expected"; then
69 echo "$0: $1: test output did not match expected output"
70 echo "test output was:"
72 cat "$testdir/test_output"
77 rm -f "$testdir/test_output"