Annotation of embedaddon/arping/extra/testing.exp, revision 1.1

1.1     ! misho       1: #!/usr/bin/expect -f
        !             2: #
        !             3: # Usage: testing.exp <path to arping> <ifname> <ip address> <mac address>
        !             4: #
        !             5: # Test all cases against a "normal" machine:
        !             6: # * Responds to ARP
        !             7: # * Responds to ping
        !             8: # * Doesn't respond to broadcast pings.
        !             9: #
        !            10: # Abnormal machines, to be tested elsewhere:
        !            11: # * Proxy ARP
        !            12: # * Respond to broadcast pings
        !            13: # * Lost packets
        !            14: # * Duplicated replies
        !            15: #
        !            16: # Tested here:
        !            17: # * -a
        !            18: # * -c
        !            19: # * -D
        !            20: # * -e
        !            21: # * -h
        !            22: # * -q (soon)
        !            23: # * -r
        !            24: # * -R
        !            25: # * -s (soon)
        !            26: # * -S (soon)
        !            27: # * -t
        !            28: # * -T
        !            29: # * -u (soon)
        !            30: # * -v (soon)
        !            31: # * -w (soon)
        !            32: # * -W (soon)
        !            33: #
        !            34: # Not tested here:
        !            35: # * -0
        !            36: # * -A (forced on with mac ping)
        !            37: # * -b
        !            38: # * -B
        !            39: # * -d
        !            40: # * -p
        !            41: # * -P
        !            42: # * -U
        !            43: # * Mac ping without -T.
        !            44: #
        !            45: set bin [lindex $argv 0]
        !            46: set ifname [lindex $argv 1]
        !            47: set ip [lindex $argv 2]
        !            48: set mac [lindex $argv 3]
        !            49: set bad_ip "1.2.4.3"
        !            50: set bad_mac "00:11:22:33:44:55"
        !            51: 
        !            52: # Check if "stty -oxtabs" is a thing.
        !            53: # It is on OpenBSD, but not Linux.
        !            54: spawn tty
        !            55: expect eof
        !            56: spawn "stty" "-oxtabs"
        !            57: catch wait result
        !            58: if {[lindex $result 3] == 0} {
        !            59:     set stty_init "-oxtabs"
        !            60: }
        !            61: 
        !            62: send_user -- "--------------- No options ------------------\n"
        !            63: spawn $bin
        !            64: expect -re "ARPing 2\.\d+, by Thomas Habets <thomas@habets.se>\r
        !            65: usage: arping \\\[ -0aAbdDeFpqrRuUv \\\] \\\[ -w <us> \\\] \\\[ -S <host/ip> \\\]\r
        !            66: \\\[ -T <host/ip \\\] \\\[ -s <MAC> \\\] \\\[ -t <MAC> \\\] \\\[ -c <count> \\\]\r
        !            67: \\\[ -i <interface> \\\] <host/ip/MAC | -B>\r
        !            68: For complete usage info, use --help or check the manpage.\r
        !            69: "
        !            70: expect eof
        !            71: 
        !            72: send_user -- "--------------- -h ------------------\n"
        !            73: spawn $bin -h
        !            74: expect -re "ARPing 2\.\d+, by Thomas Habets <thomas@habets.se>\r
        !            75: usage: arping \\\[ -0aAbdDeFpqrRuUv \\\] \\\[ -w <us> \\\] \\\[ -S <host/ip> \\\]\r
        !            76: \\\[ -T <host/ip \\\] \\\[ -s <MAC> \\\] \\\[ -t <MAC> \\\] \\\[ -c <count> \\\]\r
        !            77: \\\[ -i <interface> \\\] <host/ip/MAC | -B>\r
        !            78: For complete usage info, use --help or check the manpage.\r
        !            79: "
        !            80: expect eof
        !            81: 
        !            82: send_user -- "--------------- --help ------------------\n"
        !            83: spawn $bin --help
        !            84: expect -re "ARPing 2\.\d+, by Thomas Habets <thomas@habets.se>\r
        !            85: usage: arping \\\[ -0aAbdDeFpqrRuUv \\\] \\\[ -w <us> \\\] \\\[ -S <host/ip> \\\]\r
        !            86: \\\[ -T <host/ip \\\] \\\[ -s <MAC> \\\] \\\[ -t <MAC> \\\] \\\[ -c <count> \\\]\r
        !            87: \\\[ -i <interface> \\\] <host/ip/MAC | -B>\r
        !            88: \r
        !            89: "
        !            90: expect "Report bugs to: thomas@habets.se\r
        !            91: Arping home page: <http://www.habets.pp.se/synscan/>\r
        !            92: Development repo: http://github.com/ThomasHabets/arping\r
        !            93: "
        !            94: expect eof
        !            95: 
        !            96: send_user -- "--------------- Bad interface ------------------\n"
        !            97: spawn $bin -i uhtaonuhoes $ip
        !            98: expect -re "arping: libnet_init.*\r"
        !            99: expect "\r" {
        !           100:     # Make sure double-endline is stripped.
        !           101:     exit 1
        !           102: }
        !           103: 
        !           104: send_user -- "--------------- Ping IP Simple ------------------\n"
        !           105: spawn $bin -c 1 $ip
        !           106: expect -re "ARPING $ip\r
        !           107: \(42|60\) bytes from $mac \\($ip\\): index=0 time=(.*)sec\r
        !           108: \r
        !           109: --- $ip statistics ---\r
        !           110: 1 packets transmitted, 1 packets received,   0% unanswered \\(0 extra\\)\r
        !           111: rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/0.000 ms\r
        !           112: "
        !           113: expect eof
        !           114: 
        !           115: send_user -- "--------------- Ping IP Raw (-r) ------------------\n"
        !           116: spawn $bin -c 2 -r $ip
        !           117: expect -re "$mac\r
        !           118: $mac\r
        !           119: "
        !           120: expect eof
        !           121: 
        !           122: send_user -- "--------------- Ping IP Raw audio (-r -a) ------------------\n"
        !           123: spawn $bin -c 2 -r -a $ip
        !           124: expect -re "\a$mac\r
        !           125: \a$mac\r
        !           126: "
        !           127: expect eof
        !           128: 
        !           129: send_user -- "--------------- Ping IP Raw audio bad dest (-r -e) ------------------\n"
        !           130: spawn $bin -c 2 -r -i "$ifname" -e $bad_ip
        !           131: expect -re "\a\a"
        !           132: expect eof
        !           133: 
        !           134: send_user -- "--------------- Ping IP reverse raw (-R) ------------------\n"
        !           135: spawn $bin -c 2 -R $ip
        !           136: expect -re "$ip\r
        !           137: $ip\r
        !           138: "
        !           139: expect eof
        !           140: 
        !           141: send_user -- "--------------- Ping IP double raw (-R) ------------------\n"
        !           142: spawn $bin -c 2 -R -r $ip
        !           143: expect -re "$mac $ip\r
        !           144: $mac $ip\r
        !           145: "
        !           146: expect eof
        !           147: 
        !           148: send_user -- "--------------- Ping IP max 2 (-C) ------------------\n"
        !           149: spawn $bin -C 2 -c 10 $ip
        !           150: expect -re "ARPING $ip\r
        !           151: \(42|60\) bytes from $mac \\($ip\\): index=0 time=(.*)sec\r
        !           152: \(42|60\) bytes from $mac \\($ip\\): index=1 time=(.*)sec\r
        !           153: \r
        !           154: --- $ip statistics ---\r
        !           155: 2 packets transmitted, 2 packets received,   0% unanswered \\(0 extra\\)\r
        !           156: rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/\[0-9.\]+ ms\r
        !           157: "
        !           158: expect eof
        !           159: 
        !           160: send_user -- "--------------- Ping IP x 3 (-c) ------------------\n"
        !           161: spawn $bin -c 3 $ip
        !           162: expect -re "ARPING $ip\r
        !           163: \(42|60\) bytes from $mac \\($ip\\): index=0 time=\[0-9.\]+ \[mu\]?sec\r
        !           164: \(42|60\) bytes from $mac \\($ip\\): index=1 time=\[0-9.\]+ \[mu\]?sec\r
        !           165: \(42|60\) bytes from $mac \\($ip\\): index=2 time=\[0-9.\]+ \[mu\]?sec\r
        !           166: \r
        !           167: --- $ip statistics ---\r
        !           168: 3 packets transmitted, 3 packets received,   0% unanswered \\(0 extra\\)\r
        !           169: rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/\[0-9.\]+ ms\r
        !           170: "
        !           171: expect eof
        !           172: 
        !           173: send_user -- "--------------- Ping IP x 3 with audio (-a)  ------------------\n"
        !           174: spawn $bin -c 3 -a $ip
        !           175: expect -re "ARPING $ip\r
        !           176: \a\(42|60\) bytes from $mac \\($ip\\): index=0 time=\[0-9.\]+ \[mu\]?sec\r
        !           177: \a\(42|60\) bytes from $mac \\($ip\\): index=1 time=\[0-9.\]+ \[mu\]?sec\r
        !           178: \a\(42|60\) bytes from $mac \\($ip\\): index=2 time=\[0-9.\]+ \[mu\]?sec\r
        !           179: \r
        !           180: --- $ip statistics ---\r
        !           181: 3 packets transmitted, 3 packets received,   0% unanswered \\(0 extra\\)\r
        !           182: rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/\[0-9.\]+ ms\r
        !           183: "
        !           184: expect eof
        !           185: 
        !           186: send_user -- "--------- Ping IP x 2 with inverted audio (-e)  ------------\n"
        !           187: spawn $bin -c 2 -e $ip
        !           188: expect -re "ARPING $ip\r
        !           189: \(42|60\) bytes from $mac \\($ip\\): index=0 time=\[0-9.\]+ \[mu\]?sec\r
        !           190: \(42|60\) bytes from $mac \\($ip\\): index=1 time=\[0-9.\]+ \[mu\]?sec\r
        !           191: \r
        !           192: --- $ip statistics ---\r
        !           193: 2 packets transmitted, 2 packets received,   0% unanswered \\(0 extra\\)\r
        !           194: rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/\[0-9.\]+ ms\r
        !           195: "
        !           196: expect eof
        !           197: 
        !           198: send_user -- "--------- Ping IP x 2 with inverted audio, bad IP (-e)  ------------\n"
        !           199: spawn $bin -c 2 -i "$ifname" -e "$bad_ip"
        !           200: expect -re "ARPING $bad_ip\r
        !           201: \aTimeout\r
        !           202: \aTimeout\r
        !           203: \r
        !           204: --- $bad_ip statistics ---\r
        !           205: 2 packets transmitted, 0 packets received, 100% unanswered \\(0 extra\\)\r
        !           206: \r
        !           207: "
        !           208: expect eof
        !           209: 
        !           210: send_user -- "--------- Ping IP x 2 with inverted audio (-e -D)  ------------\n"
        !           211: spawn $bin -c 2 -e -D $ip
        !           212: expect "!!\t  0% packet loss (0 extra)\r\n"
        !           213: expect eof
        !           214: 
        !           215: send_user -- "--------- Ping IP x 2 with inverted audio, bad IP (-e -D)  ------------\n"
        !           216: spawn $bin -c 2 -e -i $ifname -D "$bad_ip"
        !           217: expect "\a.\a.\t100% packet loss (0 extra)\r\n"
        !           218: expect eof
        !           219: 
        !           220: send_user -- "--------------- Ping IP cisco style (-D) ------------------\n"
        !           221: spawn $bin -c 3 -D $ip
        !           222: expect "!!!\t  0% packet loss (0 extra)\r\n"
        !           223: expect eof
        !           224: 
        !           225: send_user -- "--------------- Ping IP cisco style with audio (-D -a) -----------\n"
        !           226: spawn $bin -c 3 -D -a $ip
        !           227: expect "\a!\a!\a!\t  0% packet loss (0 extra)\r\n"
        !           228: expect eof
        !           229: 
        !           230: send_user -- "--------------- Ping IP Targeted (-t) ------------------\n"
        !           231: spawn $bin -c 1 -t $mac $ip
        !           232: expect -re "ARPING $ip\r
        !           233: \(42|60\) bytes from $mac \\($ip\\): index=0 time=(.*)sec\r
        !           234: \r
        !           235: --- $ip statistics ---\r
        !           236: 1 packets transmitted, 1 packets received,   0% unanswered \\(0 extra\\)\r
        !           237: rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/0.000 ms\r
        !           238: "
        !           239: expect eof
        !           240: 
        !           241: send_user -- "--------------- Ping IP Mistargeted (-t) ------------------\n"
        !           242: spawn $bin -c 1 -t $bad_mac $ip
        !           243: expect "ARPING $ip\r
        !           244: Timeout\r
        !           245: \r
        !           246: --- $ip statistics ---\r
        !           247: 1 packets transmitted, 0 packets received, 100% unanswered \\(0 extra\\)\r
        !           248: "
        !           249: expect eof
        !           250: 
        !           251: send_user -- "--------------- Ping MAC with IP destination ------------------\n"
        !           252: spawn $bin -A -c 1 -T $ip $mac
        !           253: expect -re "ARPING $mac\r
        !           254: \(42|60\) bytes from $ip \\($mac\\): icmp_seq=0 time=(.*)sec\r
        !           255: \r
        !           256: --- $mac statistics ---\r
        !           257: 1 packets transmitted, 1 packets received,   0% unanswered \\(0 extra\\)\r
        !           258: rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/0.000 ms\r
        !           259: "
        !           260: expect eof
        !           261: 
        !           262: send_user -- "--------------- Ping MAC Raw (-r) ------------------\n"
        !           263: spawn $bin -c 2 -r -T $ip $mac
        !           264: expect -re "$ip\r
        !           265: $ip\r
        !           266: "
        !           267: expect eof
        !           268: 
        !           269: send_user -- "--------------- Ping MAC Raw audio (-r -a) ------------------\n"
        !           270: spawn $bin -c 2 -a -r -T $ip $mac
        !           271: expect -re "\a$ip\r
        !           272: \a$ip\r
        !           273: "
        !           274: expect eof
        !           275: 
        !           276: send_user -- "--------------- Ping MAC Raw audio bad dest (-r -e) ------------------\n"
        !           277: spawn $bin -c 2 -r -e -T $ip $bad_mac
        !           278: expect -re "\a\a"
        !           279: expect eof
        !           280: 
        !           281: send_user -- "--------------- Ping MAC reverse raw (-R) ------------------\n"
        !           282: spawn $bin -c 2 -R -T $ip $mac
        !           283: expect -re "$mac\r
        !           284: $mac\r
        !           285: "
        !           286: expect eof
        !           287: 
        !           288: send_user -- "--------------- Ping MAC double raw (-a -R) ------------------\n"
        !           289: spawn $bin -c 2 -R -r -T $ip $mac
        !           290: expect -re "$mac $ip\r
        !           291: $mac $ip\r
        !           292: "
        !           293: expect eof
        !           294: 
        !           295: 
        !           296: send_user -- "--------------- Ping MAC max 2 (-C) ------------------\n"
        !           297: spawn $bin -A -C 2 -c 10 -T $ip $mac
        !           298: expect -re "ARPING $mac\r
        !           299: \(42|60\) bytes from $ip \\($mac\\): icmp_seq=0 time=(.*)sec\r
        !           300: \(42|60\) bytes from $ip \\($mac\\): icmp_seq=1 time=(.*)sec\r
        !           301: \r
        !           302: --- $mac statistics ---\r
        !           303: 2 packets transmitted, 2 packets received,   0% unanswered \\(0 extra\\)\r
        !           304: rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/\[0-9.\]+ ms\r
        !           305: "
        !           306: expect eof
        !           307: 
        !           308: send_user -- "--------------- Ping MAC cisco style (-D) ------------------\n"
        !           309: spawn $bin -A -c 3 -D -T $ip $mac
        !           310: expect "!!!\t  0% packet loss (0 extra)\r\n"
        !           311: expect eof
        !           312: 
        !           313: send_user -- "--------------- Ping MAC cisco style with audio (-D -a) -----------\n"
        !           314: spawn $bin -A -c 3 -D -a -T $ip $mac
        !           315: expect "\a!\a!\a!\t  0% packet loss (0 extra)\r\n"
        !           316: expect eof
        !           317: 
        !           318: send_user -- "--------- Ping MAC x 2 with inverted audio (-e)  ------------\n"
        !           319: spawn $bin -c 2 -T $ip "$mac"
        !           320: expect -re "ARPING $mac\r
        !           321: \(42|60\) bytes from $ip \\($mac\\): icmp_seq=0 time=(.*)sec\r
        !           322: \(42|60\) bytes from $ip \\($mac\\): icmp_seq=1 time=(.*)sec\r
        !           323: \r
        !           324: --- $mac statistics ---\r
        !           325: 2 packets transmitted, 2 packets received,   0% unanswered \\(0 extra\\)\r
        !           326: rtt min/avg/max/std-dev = \[0-9.\]+/\[0-9.\]+/\[0-9.\]+/\[0-9.\]+ ms\r
        !           327: "
        !           328: expect eof
        !           329: 
        !           330: send_user -- "--------- Ping MAC x 2 with inverted audio, bad dest (-e)  ------------\n"
        !           331: spawn $bin -e -c 2 -T $ip "$bad_mac"
        !           332: expect -re "ARPING $bad_mac\r
        !           333: \aTimeout\r
        !           334: \aTimeout\r
        !           335: \r
        !           336: --- $bad_mac statistics ---\r
        !           337: 2 packets transmitted, 0 packets received, 100% unanswered \\(0 extra\\)\r
        !           338: \r
        !           339: "
        !           340: expect eof
        !           341: 
        !           342: send_user -- "--------- Ping MAC x 2 with inverted audio (-e -D)  ------------\n"
        !           343: spawn $bin -A -e -c 2 -D -T $ip $mac
        !           344: expect "!!\t  0% packet loss (0 extra)\r\n"
        !           345: expect eof
        !           346: 
        !           347: send_user -- "--------- Ping MAC x 2 with inverted audio, bad dest (-e -D)  ------------\n"
        !           348: spawn $bin -A -c 2 -e -i $ifname -D -T $ip $bad_mac
        !           349: expect "\a.\a.\t100% packet loss (0 extra)\r\n"
        !           350: expect eof
        !           351: 
        !           352: send_user -- "---------------------------------------------------------\n"
        !           353: send_user -- "All tests passed\n"

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>