@@ -10,19 +10,22 @@ function test_ping_parsec() {
10
10
usermod -a -G parsec-clients test-user-1
11
11
12
12
su test-user-1 << ' EOSU '
13
- cd $HOME
13
+ set -eu
14
+ cd ${HOME}
14
15
curl https://sh.rustup.rs -sSf | bash -s -- -y
15
- export PATH="$HOME/.cargo/bin:$PATH"
16
+ export PATH="${ HOME} /.cargo/bin:$PATH"
16
17
17
18
git clone https://github.com/parallaxsecond/parsec-tool.git
18
19
cd parsec-tool
19
20
cargo build
21
+
22
+ set +e
20
23
cargo run -- ping
21
- exit $?
22
- EOSU
23
24
24
- TEST_PASSED=$([[ $? -eq 0 ]])
25
- return ${TEST_PASSED}
25
+ # This test passes if the above command pinged the Parsec service
26
+ # successfully.
27
+ [ $? -eq 0 ]
28
+ EOSU
26
29
}
27
30
28
31
function test_ping_parsec_not_in_group() {
@@ -32,19 +35,21 @@ function test_ping_parsec_not_in_group() {
32
35
useradd -m test-user-2
33
36
34
37
su test-user-2 <<' EOSU'
35
- cd $HOME
38
+ set -eu
39
+ cd ${HOME}
36
40
curl https://sh.rustup.rs -sSf | bash -s -- -y
37
- export PATH="$HOME/.cargo/bin:$PATH"
41
+ export PATH="${ HOME} /.cargo/bin:$PATH"
38
42
39
43
git clone https://github.com/parallaxsecond/parsec-tool.git
40
44
cd parsec-tool
41
45
cargo build
46
+
47
+ set +e
42
48
cargo run -- ping
43
- exit $?
44
- EOSU
45
49
46
- TEST_PASSED=$([[ $? -ne 0 ]])
47
- return ${TEST_PASSED}
50
+ # This test passes if the above command failed to ping the Parsec service.
51
+ [ $? -ne 0 ]
52
+ EOSU
48
53
}
49
54
50
55
function init_parsec() {
@@ -54,11 +59,6 @@ function init_parsec() {
54
59
55
60
# Start the Parsec service as user parsec.
56
61
su parsec -c 'systemctl --user start parsec'
57
- if [[ $? -ne 0 ]]; then
58
- echo "Failed to start Parsec service, cannot continue."
59
- exit 1
60
- fi
61
-
62
62
}
63
63
64
64
function main() {
@@ -73,12 +73,14 @@ function main() {
73
73
NUM_FAILED=0
74
74
for i in "${!TESTS[@]}"; do
75
75
TEST_NAME="${TESTS[$i]}"
76
+ echo "=== RUNNING TEST ${TEST_NAME} ==="
76
77
if ${TESTS[$i]}; then
77
78
echo "${TEST_NAME} passed."
78
79
else
79
80
echo "${TEST_NAME} failed!"
80
81
NUM_FAILED=$((NUM_FAILED + 1))
81
82
fi
83
+ echo "" # spacing
82
84
done
83
85
84
86
if [[ ${NUM_FAILED} -eq 0 ]]; then
0 commit comments