/
0011-munged-cmdline.t
executable file
·74 lines (61 loc) · 1.74 KB
/
0011-munged-cmdline.t
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/sh
test_description='Check munged command-line options'
. "$(dirname "$0")/sharness.sh"
# Setup the test environment.
##
test_expect_success 'setup' '
munged_setup_env &&
munged_create_key
'
test_expect_success 'munged invalid option' '
test_must_fail "${MUNGED}" --invalid-option
'
for OPT_HELP in '-h' '--help'; do
test_expect_success "munged ${OPT_HELP}" '
"${MUNGED}" "${OPT_HELP}" |
grep -q "^Usage:"
'
done
for OPT_LICENSE in '-L' '--license'; do
test_expect_success "munged ${OPT_LICENSE}" '
"${MUNGED}" "${OPT_LICENSE}" |
grep -q "GNU General Public License"
'
done
for OPT_VERSION in '-V' '--version'; do
test_expect_success "munged ${OPT_VERSION}" '
"${MUNGED}" "${OPT_VERSION}" |
grep -q "^munge-[0-9.]*"
'
done
# Check if the stop option succeeds in stopping the process and removing the
# socket and pidfile from the filesystem.
##
for OPT_STOP in '-s' '--stop'; do
test_expect_success "munged ${OPT_STOP}" '
munged_start_daemon &&
"${MUNGED}" "${OPT_STOP}" --socket="${MUNGE_SOCKET}"
'
done
# Check if the stop option properly fails to stop a daemon on a non-existent
# socket.
##
test_expect_success 'munged --stop for missing socket' '
test_must_fail "${MUNGED}" --stop --socket=missing.socket.$$
'
for OPT_VERBOSE in '-v' '--verbose'; do
test_expect_success "munged ${OPT_VERBOSE}" '
munged_start_daemon &&
"${MUNGED}" "${OPT_VERBOSE}" --stop --socket="${MUNGE_SOCKET}" 2>&1 |
grep -q "Terminated daemon"
'
done
test_expect_failure 'finish writing tests' '
false
'
# Clean up after a munged process that may not have terminated.
##
test_expect_success 'cleanup' '
munged_cleanup
'
test_done