dnsping.txtar
# testscript framework tests for dnsping command line # Basic usage test!dnsping!stdout .stderr 'Exactly 2 arguments expected, got 0' # (short) versiondnsping versionstdout '^dev$'!stderr . # (long) versiondnsping buildinfostdout '^dev go'stdout 'path fortio.org/dnsping'!stderr . # bad -q type!dnsping -q foo www.google.com 8.8.8.8!stdout .stderr '\[F\] Invalid -q type name "foo", should be one of' # good -q typednsping -c 1 -q aaaa www.google.com 8.8.8.8stderr 'IN\tAAAA'stdout '0 errors' # ipv6 serverdnsping -c 1 www.google.com 2001:4860:4860::8888stderr 'Adding \[] around detected input IPv6 server ip info: \[2001:4860:4860::8888]' # -foo (bad flag)!dnsping -foo!stdout .stderr 'flag provided but not defined: -foo' # basic testdnsping -c 2 www.google.com 8.8.8.8stderr 'will query 2 times, sleeping 1s in between, the server 8\.8\.8\.8:53 for A \(1\) record for www\.google\.com\.'stdout '0 errors \(0.00%\), 2 success.' # fixed iddnsping -loglevel debug -c 1 -fixed-id 42 www.google.com 8.8.8.8stderr 'id: 42' # sequential iddnsping -loglevel debug -c 2 -sequential-id www.google.com 8.8.8.8stderr 'id: 1'stderr 'id: 2' # error (without plural)dnsping -c 1 doesnnotexist.fortio.org 8.8.8.8stdout '1 error \(100.00%\), 0 success.'stderr 'server error'!stderr '1: \[]' # json stdoutdnsping -c 1 -json - www.google.com 8.8.8.8stdout '"HowMany": 1,'stderr 'Successfully wrote .* bytes of Json data to stdout' # json can't write to file[unix] chmod 000 notwriteable.json[unix] !dnsping -c 1 -json notwriteable.json www.google.com 8.8.8.8[unix] stderr '\[F\] Unable to create notwriteable.json: open notwriteable.json: permission denied' # windows workaround for chmod etc...[windows] dnsping -c 1 -json notwriteable.json www.google.com 8.8.8.8 # how to do this without pkill?[unix] dnsping www.google.com 8.8.8.8 &[unix] exec sleep 3[unix] exec pkill -x dnsping # todo want something like kill %1 instead[unix] wait[unix] stderr 'will query until interrupted'[unix] stdout '0 errors \(0.00%\), [34] success.' # json writing to filednsping -c 1 -json ok.json www.google.com 8.8.8.8stderr 'Successfully wrote .* bytes of Json data to ok\.json'grep '"Server": "8.8.8.8:53",' ok.json -- notwriteable.json --empty