blob: 6b1bf663f6c62704028297e1ec615057cb97f1f8 [file] [log] [blame]
Jack Palevichbb3e9c12009-09-10 12:45:31 -07001#!/usr/bin/python
2#
3# Run a test on the ARM version of acc.
4
5import unittest
6import subprocess
7import os
8import sys
9
10def compile(args):
11 proc = subprocess.Popen(["acc"] + args, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
12 result = proc.communicate()
13 return result
14
15def runCmd(args):
16 proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
17 result = proc.communicate()
18 return result[0].strip()
19
20def uname():
21 return runCmd(["uname"])
22
23def unameM():
24 return runCmd(["uname", "-m"])
25
26def which(item):
27 return runCmd(["which", item])
28
29def adb(args):
30 return runCmd(["adb"] + args)
31
32def 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
46def 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
63def main():
64 print compileArm(sys.argv[1:])
65
66if __name__ == '__main__':
67 main()
68
69