Skip to content

Instantly share code, notes, and snippets.

@narendrans
Last active August 29, 2015 13:59
Show Gist options
  • Save narendrans/10564085 to your computer and use it in GitHub Desktop.
Save narendrans/10564085 to your computer and use it in GitHub Desktop.
Automatic grader run script for Distributed Systems project
#!/usr/bin/python
# Flow: Run grader -> store the log -> print the mark
# Run in the directory where grader is located
# Usage: run_grader.py <path to grader> <apk path> <number of times to run the grader>
# Author: Naren
# Last Modified: Sat Apr 12 21:27:44 EDT 2014
import os, sys,time
def main():
if len(sys.argv) < 2:
print 'Usage: ' + sys.argv[0] + ' <path to grader> <path to apk> <number of times to run the grader>'
print 'Run python_avd.py 5 and set_redir.py 10000 before running this tester script'
return
start_time = time.time()
pathToGrader = sys.argv[1]
pathToApk = sys.argv[2]
numberOfTimesToTest = int(sys.argv[3])
for x in range(0, numberOfTimesToTest):
print 'Run: ' + str(x+1)
command = pathToGrader + ' ' + pathToApk + ' > run_' + str(x+1) + 'log.txt'
# Uncomment below line to test
#command = 'echo testing ' + str(x+1) + ' > run_' + str(x+1) + 'log.txt'
os.system(command)
os.system('echo "Current run result" ')
os.system('awk \'/./{line=$0} END{print line}\' ' + 'run_' + str(x+1) + 'log.txt');
print "\nTime taken for this run:"+ str(start_time - time.time())
print '\nResults of all runs'
for x in range(0, numberOfTimesToTest):
os.system('echo Run ' + str(x+1) + ' result: ')
os.system('awk \'/./{line=$0} END{print line}\' ' + 'run_' + str(x+1) + 'log.txt');
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment