This repository has been archived by the owner on Jul 28, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
/
test.sh
executable file
·93 lines (75 loc) · 2.44 KB
/
test.sh
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
#!/bin/bash
#
# Travis CI tests
# immediately exit if any command has a non-zero exit status
set -e
# enable xtrace
set -x
# pipeline's return status is the value of the last (rightmost) command to exit
# with a non-zero status, or zero if all commands exit successfully
set -o pipefail
# package the project
python setup.py sdist
# install the project
python setup.py install
# test for basic functionality
pyspeedtest
# test simple command line arguments
for arg in -h --help --version; do
pyspeedtest "$arg"
done
# test http connection debug levels
for level in 0 1 2 3 4 5; do
pyspeedtest -d "$level" &>/dev/null
pyspeedtest --debug "$level" &>/dev/null
pyspeedtest --debug="$level" &>/dev/null
done
# test various test modes
for mode in 1 2 4 7; do
pyspeedtest -m "$mode"
pyspeedtest --mode "$mode"
pyspeedtest --mode="$mode"
done
# use numerous test runs
for runs in 1 2 4 7; do
pyspeedtest -r "$runs"
pyspeedtest --runs "$runs"
pyspeedtest --runs="$runs"
done
# use different output formats
for format in default json xml; do
pyspeedtest -f "$format"
pyspeedtest --format "$format"
pyspeedtest --format="$format"
done
# test multiple arguments at once and verify output
pyspeedtest --debug=0 --mode=7 --runs=2 |& grep -qE $'^Using server: .*\nPing: [0-9]+ ms\nDownload speed: [0-9.]+ (bps|Kbps|Mbps|Gbps)\nUpload speed: [0-9.]+ (bps|Kbps|Mbps|Gbps)$'
# test for bad arguments
! pyspeedtest -x
! pyspeedtest --xxx
# test for bad debug levels
for arg in -d --debug; do
! output=$(pyspeedtest "${arg}" xxx 2>&1)
[[ $output = "usage: pyspeedtest [OPTION]...
pyspeedtest: error: argument -d/--debug: invalid positive int value: 'xxx'" ]]
done
# test for bad modes
for badmode in -1 0 8 9 10 11 12 13 14 15; do
for arg in -m --mode; do
! output=$(pyspeedtest "${arg}" "${badmode}" 2>&1)
[[ $output = "usage: pyspeedtest [OPTION]...
pyspeedtest: error: argument -m/--mode: invalid choice: ${badmode} (choose from 1, 2, 3, 4, 5, 6, 7)" ]]
done
done
# test for bad runs
for arg in -r --runs; do
! output=$(pyspeedtest "${arg}" xxx 2>&1)
[[ $output = "usage: pyspeedtest [OPTION]...
pyspeedtest: error: argument -r/--runs: invalid positive int value: 'xxx'" ]]
done
# test for bad output formats
for arg in -f --format; do
! output=$(pyspeedtest "${arg}" xxx 2>&1)
[[ $output = "usage: pyspeedtest [OPTION]...
pyspeedtest: error: argument -f/--format: output format not supported: 'xxx'" ]]
done