system/corennnnn
修訂 | bf2d557b0a2a780967e68f4bf978ab35cd37564f (tree) |
---|---|
時間 | 2009-08-19 09:20:08 |
作者 | Jack Palevich <jackpal@goog...> |
Commiter | Android Git Automerger |
am 29f34260: Merge change 21812 into eclair
Merge commit '29f3426016116678c122b37cf6d5d40bdfec7749'
* commit '29f3426016116678c122b37cf6d5d40bdfec7749':
@@ -3812,9 +3812,6 @@ class Compiler : public ErrorSink { | ||
3812 | 3812 | next(); |
3813 | 3813 | tokenid_t name = tok; |
3814 | 3814 | String* pName = new String(); |
3815 | - while (isspace(ch)) { | |
3816 | - inp(); | |
3817 | - } | |
3818 | 3815 | if (ch == '(') { |
3819 | 3816 | delete pName; |
3820 | 3817 | error("Defines with arguments not supported"); |
@@ -0,0 +1,7 @@ | ||
1 | +// Simple tests of the C preprocessor | |
2 | + | |
3 | +#define A (1 + 2) | |
4 | + | |
5 | +int main() { | |
6 | + return A; | |
7 | +} |
@@ -2,5 +2,5 @@ | ||
2 | 2 | |
3 | 3 | SCRIPT_DIR=`dirname $BASH_SOURCE` |
4 | 4 | cd $SCRIPT_DIR |
5 | -python test.py | |
5 | +python test.py "$@" | |
6 | 6 |
@@ -4,9 +4,28 @@ | ||
4 | 4 | import unittest |
5 | 5 | import subprocess |
6 | 6 | import os |
7 | -import sets | |
7 | +import sys | |
8 | 8 | |
9 | 9 | gArmInitialized = False |
10 | +gUseArm = True | |
11 | +gUseX86 = True | |
12 | +gRunOTCCOutput = True | |
13 | + | |
14 | + | |
15 | +def parseArgv(): | |
16 | + global gUseArm | |
17 | + global gRunOTCCOutput | |
18 | + for arg in sys.argv[1:]: | |
19 | + if arg == "--noarm": | |
20 | + print "--noarm detected, not testing on ARM" | |
21 | + gUseArm = False | |
22 | + elif arg == "--norunotcc": | |
23 | + print "--norunotcc detected, not running OTCC output" | |
24 | + gRunOTCCOutput = False | |
25 | + else: | |
26 | + print "Unknown parameter: ", arg | |
27 | + raise "Unknown parameter" | |
28 | + sys.argv = sys.argv[0:1] | |
10 | 29 | |
11 | 30 | def compile(args): |
12 | 31 | proc = subprocess.Popen(["acc"] + args, stderr=subprocess.PIPE, stdout=subprocess.PIPE) |
@@ -131,11 +150,13 @@ class TestACC(unittest.TestCase): | ||
131 | 150 | |
132 | 151 | def compileCheck(self, args, stdErrResult, stdOutResult="", |
133 | 152 | targets=['arm', 'x86']): |
134 | - targetSet = sets.ImmutableSet(targets) | |
135 | - if False and 'x86' in targetSet: | |
153 | + global gUseArm | |
154 | + global gUseX86 | |
155 | + targetSet = frozenset(targets) | |
156 | + if gUseX86 and 'x86' in targetSet: | |
136 | 157 | out, err = compile(args) |
137 | 158 | self.checkResult(out, err, stdErrResult, stdOutResult) |
138 | - if 'arm' in targetSet: | |
159 | + if gUseArm and 'arm' in targetSet: | |
139 | 160 | out = compileArm(rewritePaths(args)) |
140 | 161 | self.checkResult(out, "", stdErrResult, stdOutResult) |
141 | 162 |
@@ -157,13 +178,17 @@ class TestACC(unittest.TestCase): | ||
157 | 178 | "Executing compiled code:\nresult: 13\n", "Hello, world\n") |
158 | 179 | |
159 | 180 | def testRunOTCCANSI(self): |
160 | - self.compileCheck(["-R", "data/otcc-ansi.c", "data/returnval.c"], | |
161 | - "Executing compiled code:\notcc-ansi.c: About to execute compiled code:\natcc-ansi.c: result: 42\nresult: 42\n", "", | |
162 | - ['x86']) | |
181 | + global gRunOTCCOutput | |
182 | + if gRunOTCCOutput: | |
183 | + self.compileCheck(["-R", "data/otcc-ansi.c", "data/returnval.c"], | |
184 | + "Executing compiled code:\notcc-ansi.c: About to execute compiled code:\natcc-ansi.c: result: 42\nresult: 42\n", "", | |
185 | + ['x86']) | |
163 | 186 | |
164 | 187 | def testRunOTCCANSI2(self): |
165 | - self.compileCheck(["-R", "data/otcc-ansi.c", "data/otcc.c", "data/returnval.c"], | |
166 | - "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']) | |
188 | + global gRunOTCCOutput | |
189 | + if gRunOTCCOutput: | |
190 | + self.compileCheck(["-R", "data/otcc-ansi.c", "data/otcc.c", "data/returnval.c"], | |
191 | + "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']) | |
167 | 192 | |
168 | 193 | def testRunConstants(self): |
169 | 194 | self.compileCheck(["-R", "data/constants.c"], |
@@ -409,8 +434,17 @@ lmnopabcdefghijklmno | ||
409 | 434 | result: 0 |
410 | 435 | ""","""""") |
411 | 436 | |
412 | -if __name__ == '__main__': | |
437 | + def testDefines(self): | |
438 | + self.compileCheck(["-R", "data/defines.c"], """Executing compiled code: | |
439 | +result: 3 | |
440 | +""","""""") | |
441 | + | |
442 | +def main(): | |
443 | + parseArgv() | |
413 | 444 | if not outputCanRun(): |
414 | - print "Many tests are expected to fail, because acc is not a 32-bit x86 Linux executable." | |
445 | + print "Can't run output of acc compiler." | |
415 | 446 | unittest.main() |
416 | 447 | |
448 | +if __name__ == '__main__': | |
449 | + main() | |
450 | + |