Skip to content

Instantly share code, notes, and snippets.

@medwards
Created April 2, 2012 12:42
Show Gist options
  • Save medwards/2283172 to your computer and use it in GitHub Desktop.
Save medwards/2283172 to your computer and use it in GitHub Desktop.
An unprovable testsuite for cat
#!/bin/bash
i=0
while true
do
pass=`cat /dev/urandom | tr -dc A-Za-z0-9 | head -c $i`
echo $pass > ./testcases/length_$i.txt
i=$(($i + 1))
sleep 1
done
from subprocess import check_output, CalledProcessError
length = 0
passes = 0
while True:
try:
output = check_output(['cat', './testcases/length_%s.txt' % length])
except CalledProcessError:
print
print 'Test suite complete'
print '%s passes out of %s execution' % (passes, length)
break
testfile = open('./testcases/length_%s.txt' % length)
testdata = testfile.read()
if output == testdata:
print ".",
passes += 1
else:
print "F",
length += 1
@bct
Copy link

bct commented Apr 3, 2012

You're wasting a ton of entropy, man! There's a limited amount of that stuff.

pass=`cat /dev/urandom | base64 | head -c $i`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment