| Jack Palevich | bb3e9c1 | 2009-09-10 12:45:31 -0700 | [diff] [blame^] | 1 | #!/usr/bin/python | 
 | 2 | # | 
 | 3 | # Run a test on the ARM version of acc. | 
 | 4 |  | 
 | 5 | import unittest | 
 | 6 | import subprocess | 
 | 7 | import os | 
 | 8 | import sys | 
 | 9 |  | 
 | 10 | def compile(args): | 
 | 11 |     proc = subprocess.Popen(["acc"] + args, stderr=subprocess.PIPE, stdout=subprocess.PIPE) | 
 | 12 |     result = proc.communicate() | 
 | 13 |     return result | 
 | 14 |  | 
 | 15 | def runCmd(args): | 
 | 16 |     proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 
 | 17 |     result = proc.communicate() | 
 | 18 |     return result[0].strip() | 
 | 19 |  | 
 | 20 | def uname(): | 
 | 21 |     return runCmd(["uname"]) | 
 | 22 |  | 
 | 23 | def unameM(): | 
 | 24 |     return runCmd(["uname", "-m"]) | 
 | 25 |  | 
 | 26 | def which(item): | 
 | 27 |     return runCmd(["which", item]) | 
 | 28 |  | 
 | 29 | def adb(args): | 
 | 30 |     return runCmd(["adb"] + args) | 
 | 31 |  | 
 | 32 | def setupArm(file): | 
 | 33 |     print "Setting up arm" | 
 | 34 |     adb(["remount"]) | 
 | 35 |     adb(["shell", "rm", "/system/bin/acc"]) | 
 | 36 |     adb(["shell", "mkdir", "/system/bin/accdata"]) | 
 | 37 |     adb(["shell", "mkdir", "/system/bin/accdata/data"]) | 
 | 38 |  | 
 | 39 |     remoteFileName = os.path.join("/system/bin/accdata", file) | 
 | 40 |     adb(["push", file, remoteFileName]) | 
 | 41 |  | 
 | 42 |     # Copy over compiler | 
 | 43 |     adb(["sync"]) | 
 | 44 |     return remoteFileName | 
 | 45 |  | 
 | 46 | def compileArm(args): | 
 | 47 |     remoteArgs = [] | 
 | 48 |     fileName = "" | 
 | 49 |     for arg in sys.argv[1:]: | 
 | 50 |         if arg.startswith('-'): | 
 | 51 |             remoteArgs.append(arg) | 
 | 52 |         else: | 
 | 53 |             fileName = arg | 
 | 54 |  | 
 | 55 |     remoteFileName = setupArm(fileName) | 
 | 56 |     remoteArgs.append(remoteFileName) | 
 | 57 |     remoteCmdLine = ["adb", "shell", "/system/bin/acc"] + remoteArgs | 
 | 58 |     proc = subprocess.Popen(remoteCmdLine, stdout=subprocess.PIPE) | 
 | 59 |     result = proc.communicate() | 
 | 60 |     return result[0].replace("\r","") | 
 | 61 |  | 
 | 62 |  | 
 | 63 | def main(): | 
 | 64 |     print compileArm(sys.argv[1:]) | 
 | 65 |  | 
 | 66 | if __name__ == '__main__': | 
 | 67 |     main() | 
 | 68 |  | 
 | 69 |  |