blob: 0914e104d790ad62c98338aed20e43d1e238871c [file] [log] [blame]
Shih-wei Liao77ed6142010-04-07 12:21:42 -07001#!/usr/bin/python
2#
3# Run a test on the ARM version of bcc.
4
5import unittest
6import subprocess
7import os
8import sys
9
10def compile(args):
11 proc = subprocess.Popen(["bcc"] + 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/bcc"])
36 adb(["shell", "mkdir", "/system/bin/bccdata"])
37 adb(["shell", "mkdir", "/system/bin/bccdata/data"])
38
39 remoteFileName = os.path.join("/system/bin/bccdata", 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/bcc"] + 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