• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


コミットメタ情報

リビジョン59178c0a3d03294bd37a7e1ece1c6e0ef1570d90 (tree)
日時2009-07-14 06:15:18
作者Jack Palevich <jackpal@goog...>
コミッターJack Palevich

ログメッセージ

Run tests on both ARM and x86

変更サマリ

差分

--- a/libacc/tests/test.py
+++ b/libacc/tests/test.py
@@ -4,6 +4,9 @@
44 import unittest
55 import subprocess
66 import os
7+import sets
8+
9+gArmInitialized = False
710
811 def compile(args):
912 proc = subprocess.Popen(["acc"] + args, stderr=subprocess.PIPE, stdout=subprocess.PIPE)
@@ -28,9 +31,8 @@ def outputCanRun():
2831 def adb(args):
2932 return runCmd(["adb"] + args)
3033
31-gArmInitialized = False
32-
3334 def setupArm():
35+ global gArmInitialized
3436 if gArmInitialized:
3537 return
3638 print "Setting up arm"
@@ -48,7 +50,7 @@ def setupArm():
4850 adb(["push", os.path.join(root, f), os.path.join("/system/bin/accdata", root, f)])
4951 # Copy over compiler
5052 adb(["sync"])
51- gArmInitialied = True
53+ gArmInitialized = True
5254
5355 def compileArm(args):
5456 setupArm()
@@ -75,23 +77,72 @@ def firstDifference(a, b):
7577 return i
7678 return commonLen
7779
80+def compareSet(a1,a2,b1,b2):
81+ while True:
82+ totalLen = len(a1) + len(a2) + len(b1) + len(b2)
83+ a1, b1 = matchCommon(a1, b1)
84+ a1, b2 = matchCommon(a1, b2)
85+ a2, b1 = matchCommon(a2, b1)
86+ a2, b2 = matchCommon(a2, b2)
87+ newTotalLen = len(a1) + len(a2) + len(b1) + len(b2)
88+ if newTotalLen == 0:
89+ return True
90+ if newTotalLen == totalLen:
91+ print "Failed at %d %d %d %d" % (len(a1), len(a2), len(b1), len(b2))
92+ print "a1", a1
93+ print "a2", a2
94+ print "b1", b1
95+ print "b2", b2
96+ return False
97+
98+def matchCommon(a, b):
99+ while len(a) > 0 and len(b) > 0 and a[0] == b[0]:
100+ a = a[1:]
101+ b = b[1:]
102+ return a, b
103+
104+def rewritePaths(args):
105+ return [rewritePath(x) for x in args]
106+
107+def rewritePath(p):
108+ if p.startswith("data/"):
109+ p = "/system/bin/accdata/" + p
110+ return p
111+
78112 class TestACC(unittest.TestCase):
79113
80- def compileCheck(self, args, stdErrResult, stdOutResult=""):
114+ def compileCheckOld(self, args, stdErrResult, stdOutResult=""):
81115 out, err = compile(args)
82116 compare(out, stdOutResult)
83117 compare(err, stdErrResult)
84118 self.assertEqual(out, stdOutResult)
85119 self.assertEqual(err, stdErrResult)
86120
121+ def checkResult(self, out, err, stdErrResult, stdOutResult=""):
122+ a1 = out.splitlines()
123+ a2 = err.splitlines()
124+ b2 = stdErrResult.splitlines()
125+ b1 = stdOutResult.splitlines()
126+ self.assertEqual(True, compareSet(a1,a2,b1,b2))
127+
128+ def compileCheck(self, args, stdErrResult, stdOutResult="",
129+ targets=['arm', 'x86']):
130+ targetSet = sets.ImmutableSet(targets)
131+ if 'x86' in targetSet:
132+ out, err = compile(args)
133+ self.checkResult(out, err, stdErrResult, stdOutResult)
134+ if 'arm' in targetSet:
135+ out = compileArm(rewritePaths(args))
136+ self.checkResult(out, "", stdErrResult, stdOutResult)
137+
87138 def compileCheckArm(self, args, result):
88139 self.assertEqual(compileArm(args), result)
89140
90141 def testCompileReturnVal(self):
91142 self.compileCheck(["data/returnval-ansi.c"], "")
92143
93- def testCompileReturnVal(self):
94- self.compileCheck(["data/otcc-ansi.c"], "")
144+ def testCompileOTCCANSII(self):
145+ self.compileCheck(["data/otcc-ansi.c"], "", "", ['x86'])
95146
96147 def testRunReturnVal(self):
97148 self.compileCheck(["-R", "data/returnval-ansi.c"],
@@ -103,11 +154,12 @@ class TestACC(unittest.TestCase):
103154
104155 def testRunOTCCANSI(self):
105156 self.compileCheck(["-R", "data/otcc-ansi.c", "data/returnval.c"],
106- "Executing compiled code:\notcc-ansi.c: About to execute compiled code:\natcc-ansi.c: result: 42\nresult: 42\n")
157+ "Executing compiled code:\notcc-ansi.c: About to execute compiled code:\natcc-ansi.c: result: 42\nresult: 42\n", "",
158+ ['x86'])
107159
108160 def testRunOTCCANSI2(self):
109161 self.compileCheck(["-R", "data/otcc-ansi.c", "data/otcc.c", "data/returnval.c"],
110- "Executing compiled code:\notcc-ansi.c: About to execute compiled code:\notcc.c: about to execute compiled code.\natcc-ansi.c: result: 42\nresult: 42\n")
162+ "Executing compiled code:\notcc-ansi.c: About to execute compiled code:\notcc.c: about to execute compiled code.\natcc-ansi.c: result: 42\nresult: 42\n", "",['x86'])
111163
112164 def testRunConstants(self):
113165 self.compileCheck(["-R", "data/constants.c"],
@@ -178,7 +230,7 @@ class TestACC(unittest.TestCase):
178230 "testpassidf: 1 2 3\n"
179231 )
180232
181- def testArmRunReturnVal(self):
233+ def oldtestArmRunReturnVal(self):
182234 self.compileCheckArm(["-R", "/system/bin/accdata/data/returnval-ansi.c"],
183235 "Executing compiled code:\nresult: 42\n")
184236