-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·69 lines (51 loc) · 1.15 KB
/
test.sh
File metadata and controls
executable file
·69 lines (51 loc) · 1.15 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
#!/bin/bash
set +e
DATA="FOO"
RESULT=0
usage() {
cat << EOF
Usage: $0 [OPTIONS]
Options:
--no-memcheck: Disable memory checking
EOF
exit 1
}
for opt in "$@"; do
shift
case "${opt}" in
--no-memcheck)
NO_MEMCHECK=true
;;
*)
usage
;;
esac
done
if [ -z ${NO_MEMCHECK} ]; then
COMMAND+="valgrind --error-exitcode=1 --leak-check=full --show-leak-kinds=all --track-origins=yes --trace-children=yes"
fi
docker run \
--name tcp-echo-test \
--rm \
tcp-echo-test \
/bin/bash -c "${COMMAND} ./tcp-echo" &
for i in {1..30}; do
RETURNED_DATA=$(docker exec tcp-echo-test /bin/bash -c "echo ${DATA}| nc -w 1 localhost 8090" 2> /dev/null)
EXIT_CODE=$?
if [ ${EXIT_CODE} -eq 0 ]; then
echo "Received (${RETURNED_DATA})"
break;
fi
sleep 1
done
docker kill -s SIGTERM tcp-echo-test > /dev/null 2>&1
if [ ${EXIT_CODE} -ne 0 ]; then
echo "Could not connect"
RESULT=1
fi
if [ "${RETURNED_DATA}" != "${DATA}" ] ; then
echo "Data received (${RETURNED_DATA}) did not match (${DATA})"
RESULT=1
fi
wait $!
exit $(($? + ${RESULT}))