-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathconfig.source
More file actions
107 lines (100 loc) · 2.33 KB
/
config.source
File metadata and controls
107 lines (100 loc) · 2.33 KB
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Library for test helper functions
: "${PULP_API_ROOT:="/pulp/"}"
# open fd 3 as a copy of stderr
exec 3<&2
# Expects the command to succeed
# Supresses all output, which is redirected to $OUTPUT and $ERROUTPUT
# Reports verbosely on failure
expect_succ () {
if {
"$@"
} 1>log.out 2>log.err
then
echo "SUCCESS [$@]" >&3
OUTPUT="$(cat log.out)"
ERROUTPUT="$(cat log.err)"
else
echo "FAILURE [$@]" >&3
echo "=== STDOUT ===" >&3
cat log.out >&3
echo "=== STDERR ===" >&3
cat log.err >&3
echo "==============" >&3
false
fi
}
# Expects the command to fail
# Supresses all output, which is redirected to $OUTPUT and $ERROUTPUT
# Reports verbosely on failure
expect_fail () {
if {
"$@"
} 1>log.out 2>log.err
then
echo "FAILURE [! $@]" >&3
echo "=== STDOUT ===" >&3
cat log.out >&3
echo "=== STDERR ===" >&3
cat log.err >&3
false
else
echo "SUCCESS [! $@]" >&3
OUTPUT="$(cat log.out)"
ERROUTPUT="$(cat log.err)"
fi
}
# Expects the command to report access denied
# Supresses all output, which is redirected to $OUTPUT and $ERROUTPUT
# Reports verbosely on failure
expect_deny () {
if {
"$@"
} 1>log.out 2>log.err
# TODO check for access denied message
then
echo "FAILURE [! $@]" >&3
echo "=== STDOUT ===" >&3
cat log.out >&3
echo "=== STDERR ===" >&3
cat log.err >&3
false
else
if grep -q "Operation .* not authorized." log.err
then
echo "SUCCESS [! $@]" >&3
OUTPUT="$(cat log.out)"
ERROUTPUT="$(cat log.err)"
else
echo "FAILURE [! $@]" >&3
echo "=== STDOUT ===" >&3
cat log.out >&3
echo "=== STDERR ===" >&3
cat log.err >&3
false
fi
fi
}
# Expects the provided test to pass
# Supresses all output, which is redirected to ASSERTION_OUTPUT and
# ASSERTION_ERROUTPUT so as not to overwrite the latest OUTPUT and ERROUTPUT.
# That way we can test several assertions in a row.
# Reports verbosely on failure.
assert () {
if {
[[ "$@" ]]
} 1>log.out 2>log.err
then
echo "SUCCESS [$@]" >&3
ASSERTION_OUTPUT="$(cat log.out)"
ASSERTION_ERROUTPUT="$(cat log.err)"
else
echo "FAILURE [$@]" >&3
echo "=== STDOUT ===" >&3
cat log.out >&3
echo "=== STDERR ===" >&3
cat log.err >&3
echo "==============" >&3
false
fi
}
set -eu