-
Notifications
You must be signed in to change notification settings - Fork 10
/
testscript
executable file
·88 lines (83 loc) · 2.66 KB
/
testscript
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
#!/bin/sh
netmask="./netmask"
RET=0
case "$1"
in
'')
i=0
check () {
i=$(expr $i + 1)
eval $3 | diff -au $2 -
if test $? -eq 0
then echo "ok $i - $1"
else echo "not ok $i - $1" ; RET=1
fi
}
;;
update)
check () {
if test -e "$2"
then echo "skip $2, file exists"
else
echo -n "make $2..."
eval $3 > "$2"
echo " done"
fi
}
;;
*) echo "Usage: $0 [ update ]" ;;
esac
echo "1..23"
check "simple one element" tests/simple \
"$netmask 0"
check "simple multi element" tests/simple2 \
"$netmask 0 2 4 6 8"
check "input formats" tests/inputs \
"$netmask 0 02 0x4 0.0.0.6"
check "simple ranges" tests/range \
"$netmask 100:200"
check "CIDR ranges" tests/range_cidr \
"$netmask 12.34.56.78/20"
check "large ranges" tests/range_large \
"$netmask 1:0x7ffffffe 0x80000001:0xfffffffe"
check "output format standard" tests/output_std \
"$netmask --standard 0 2 4 6 8"
check "output format cidr" tests/output_cidr \
"$netmask --cidr 0 2 4 6 8 077777777 0xffffffff"
check "output format cisco" tests/output_cisco \
"$netmask --cisco 0 2 4 6 8 077777777 0xffffffff"
check "output format range" tests/output_range \
"$netmask --range 0 2 4 6 8 077777777 0xffffffff"
check "output format hex" tests/output_hex \
"$netmask --hex 0 2 4 6 8 077777777 0xffffffff"
check "output format octal" tests/output_octal \
"$netmask --octal 0 2 4 6 8 077777777 0xffffffff"
check "output format binary" tests/output_binary \
"$netmask --binary 0 2 4 6 8 077777777 0xffffffff"
check "subset skipping" tests/subset_skip \
"$netmask 345 100:200 105 45 200"
check "subset clean" tests/subset_clean \
"$netmask 105 45 200 100:200 345"
check "range joining" tests/range_join \
"$netmask 10.1.0.0/16 10.2.0.0/16 10.3.0.0/16 10.4.0.0/16"
check "entire range joining" tests/range_join2 \
"$netmask 10.0.0.0/16 10.1.0.0/16 10.2.0.0/16 10.3.0.0/16"
check "boundary dottedq 1" tests/bounds_dq1 \
"$netmask 192.168.0.1/0.0.0.0"
check "boundary dottedq 1" tests/bounds_dq2 \
"$netmask 192.168.0.1/255.0.0.0"
check "boundary dottedq 1" tests/bounds_dq3 \
"$netmask 192.168.0.1/255.255.0.0"
check "boundary dottedq 1" tests/bounds_dq4 \
"$netmask 192.168.0.1/255.255.255.0"
check "boundary dottedq 1" tests/bounds_dq5 \
"$netmask 192.168.0.1/255.255.255.255"
check "boundary dottedq 1" tests/bounds_dq6 \
"$netmask 192.168.0.1/0.255.255.255"
check "range adds" tests/range_adds \
"$netmask 10.0.0.1,+5 172.16.29.1:+7"
check "range order" tests/range_order \
"$netmask 200:100"
check "range special" tests/range_special \
"$netmask 0.0.0.5:+-2"
exit $RET