Revision 571b34f8

b/Makefile.am
342 342
	test/tempfile_fork_unittest.py
343 343

  
344 344
dist_TESTS = \
345
	test/daemon-util_unittest.bash \
345 346
	$(python_tests)
346 347

  
347 348
nodist_TESTS =
......
369 370

  
370 371
srclink_files = \
371 372
	man/footer.sgml \
373
	test/daemon-util_unittest.bash \
372 374
	$(all_python_code)
373 375

  
374 376
check_python_code = \
......
381 383
	$(dist_tools_SCRIPTS) \
382 384
	$(BUILD_BASH_COMPLETION)
383 385

  
386
test/daemon-util_unittest.bash: daemons/daemon-util
387

  
384 388
devel/upload: devel/upload.in $(REPLACE_VARS_SED)
385 389
	sed -f $(REPLACE_VARS_SED) < $< > $@
386 390
	chmod u+x $@
b/autotools/run-in-tempdir
5 5
tmpdir=$(mktemp -d -t gntbuild.XXXXXXXX)
6 6
trap "rm -rf $tmpdir" EXIT
7 7

  
8
cp -r scripts lib tools test $tmpdir
8
cp -r daemons scripts lib tools test $tmpdir
9 9
mv $tmpdir/lib $tmpdir/ganeti
10 10

  
11 11
cd $tmpdir && "$@"
b/test/daemon-util_unittest.bash
1
#!/bin/bash
2
#
3

  
4
# Copyright (C) 2010 Google Inc.
5
#
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
10
#
11
# This program is distributed in the hope that it will be useful, but
12
# WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
# General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19
# 02110-1301, USA.
20

  
21
set -e
22

  
23
daemon_util=daemons/daemon-util
24

  
25
err() {
26
  echo "$@"
27
  echo 'Aborting'
28
  exit 1
29
}
30

  
31
$daemon_util >/dev/null 2>&1 &&
32
  err "daemon-util succeeded without command"
33

  
34
$daemon_util this-is-an-unimplemented-command >/dev/null 2>&1 &&
35
  err "daemon-util accepted unimplemented command"
36

  
37
$daemon_util list_start_daemons >/dev/null 2>&1 &&
38
  err "daemon-util accepted command with underscores"
39

  
40
$daemon_util check-exitcode 0 ||
41
  err "check-exitcode 0 failed"
42

  
43
for i in 1 2 3 4 20 25 33; do
44
  $daemon_util check-exitcode $i >/dev/null 2>&1 && rc=0 || rc=$?
45
  test "$rc" == 1 || err "check-exitcode $i didn't return 1"
46
done
47

  
48
$daemon_util check-exitcode 11 >/dev/null 2>&1 ||
49
  err "check-exitcode 11 (not master) didn't return 0"
50

  
51
tmp=$(echo $($daemon_util list-start-daemons))
52
test "$tmp" == "$(echo ganeti-{noded,masterd,rapi,confd})" ||
53
  err "list-start-daemons didn't return correct list of daemons"
54

  
55
tmp=$(echo $($daemon_util list-stop-daemons))
56
test "$tmp" == "$(echo ganeti-{confd,rapi,masterd,noded})" ||
57
  err "list-stop-daemons didn't return correct list of daemons"
58

  
59
$daemon_util is-daemon-name >/dev/null 2>&1 &&
60
  err "is-daemon-name didn't require daemon name"
61

  
62
for i in '' '.' '..' '-' 'not-a-daemon'; do
63
  $daemon_util is-daemon-name "$i" >/dev/null 2>&1 &&
64
    err "is-daemon-name thinks '$i' is a daemon name"
65
done
66

  
67
for i in ganeti-{confd,rapi,masterd,noded}; do
68
  $daemon_util is-daemon-name $i >/dev/null 2>&1 ||
69
    err "is-daemon-name doesn't think '$i' is a daemon name"
70
done

Also available in: Unified diff