File: testscript

package info (click to toggle)
netmask 2.5.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,328 kB
  • sloc: sh: 5,181; ansic: 876; makefile: 22
file content (111 lines) | stat: -rwxr-xr-x 3,519 bytes parent folder | download
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/bin/sh
netmask="${NETMASK_PATH:-./netmask}"

if [ "$srcdir" ]
then base="$srcdir/"
else base=""
fi

RET=0

case "$1"
in
  '')
    i=0
    check () {
      i=$(expr $i + 1)
      eval $3 | diff -au "$base$2" -
      if test $? -eq 0
      then echo "ok $i - $1"
      else echo "not ok $i - $1" ; RET=1
      fi
    }
    ;;
  update)
    check () {
      if test -e "$base$2"
      then echo "skip $2, file exists"
      else
        echo -n "make $base$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 2" tests/bounds_dq2 \
    "$netmask 192.168.0.1/255.0.0.0"
check "boundary dottedq 3" tests/bounds_dq3 \
    "$netmask 192.168.0.1/255.255.0.0"
check "boundary dottedq 4" tests/bounds_dq4 \
    "$netmask 192.168.0.1/255.255.255.0"
check "boundary dottedq 5" tests/bounds_dq5 \
    "$netmask 192.168.0.1/255.255.255.255"
check "boundary dottedq 6" 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"
check "v6 simple" tests/ipv6_simple \
    "$netmask ::0 ::2 ::4 ::6 ::8"
check "v6 cisco" tests/v6_cisco \
    "$netmask -i 2000::/32"
check "v6 hex" tests/v6_hex \
    "$netmask -x 2000::/32"
check "v6 octal" tests/v6_octal \
    "$netmask -o 2000::/32"
check "v6 binary" tests/v6_binary \
    "$netmask -b 2000::/32"
check "file input" tests/file_input \
    "echo 1.2.3.4 | $netmask -f -"
check "coverage 1" tests/coverage1 \
    "$netmask -r 12 12/24 12/16 2000::/64 2001::/::ffff"
# this is a little odd, make sure we don't change what happens when a
# non-cidr range walks into or out of the IPv4-mapped section
check "v4 edge" tests/v4_edge \
    "$netmask ::fffe:ffff:ffff,+1 255.255.255.255:+1"

exit $RET