Created
April 2, 2012 12:42
-
-
Save medwards/2283172 to your computer and use it in GitHub Desktop.
An unprovable testsuite for cat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 '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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're wasting a ton of entropy, man! There's a limited amount of that stuff.