Skip to content

Commit dfd2522

Browse files
committed
tests/common.sh: exit 1 on errors
Close rootless-containers#235 Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
1 parent 4e76d97 commit dfd2522

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

tests/common.sh

+12-6
Original file line numberDiff line numberDiff line change
@@ -28,25 +28,27 @@ function wait_for_network_namespace {
2828
COUNTER=0
2929
while [ $COUNTER -lt 40 ]; do
3030
if nsenter $(nsenter_flags $1) true; then
31-
break
31+
return 0
3232
else
3333
sleep 0.5
3434
fi
3535
let COUNTER=COUNTER+1
3636
done
37+
exit 1
3738
}
3839

3940
function wait_for_network_device {
4041
# Wait that the device appears.
4142
COUNTER=0
4243
while [ $COUNTER -lt 40 ]; do
4344
if nsenter $(nsenter_flags $1) ip addr show $2; then
44-
break
45+
return 0
4546
else
4647
sleep 0.5
4748
fi
4849
let COUNTER=COUNTER+1
4950
done
51+
exit 1
5052
}
5153

5254
function wait_process_exits {
@@ -55,47 +57,51 @@ function wait_process_exits {
5557
if kill -0 $1; then
5658
sleep 0.5
5759
else
58-
break
60+
return 0
5961
fi
6062
let COUNTER=COUNTER+1
6163
done
64+
exit 1
6265
}
6366

6467
function wait_for_ping_connectivity {
6568
COUNTER=0
6669
while [ $COUNTER -lt 40 ]; do
6770
if nsenter $(nsenter_flags $1) ping -c 1 -w 1 $2; then
68-
break
71+
return 0
6972
else
7073
sleep 0.5
7174
fi
7275
let COUNTER=COUNTER+1
7376
done
77+
exit 1
7478
}
7579

7680
function wait_for_connectivity {
7781
COUNTER=0
7882
while [ $COUNTER -lt 40 ]; do
7983
if echo "wait_for_connectivity" | nsenter $(nsenter_flags $1) ncat -v $2 $3; then
80-
break
84+
return 0
8185
else
8286
sleep 0.5
8387
fi
8488
let COUNTER=COUNTER+1
8589
done
90+
exit 1
8691
}
8792

8893
function wait_for_file_content {
8994
# Wait for a file to get the specified content.
9095
COUNTER=0
9196
while [ $COUNTER -lt 20 ]; do
9297
if grep $1 $2; then
93-
break
98+
return 0
9499
else
95100
sleep 0.5
96101
fi
97102
let COUNTER=COUNTER+1
98103
done
104+
exit 1
99105
}
100106

101107
function expose_tcp() {

0 commit comments

Comments
 (0)