5 # Permission is hereby granted, free of charge, to any person obtaining
6 # a copy of this software and associated documentation files (the
7 # "Software"), to deal in the Software without restriction, including
8 # without limitation the rights to use, copy, modify, merge, publish,
9 # distribute, sublicense, and/or sell copies of the Software, and to
10 # permit persons to whom the Software is furnished to do so, subject to
11 # the following conditions:
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
17 # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18 # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
28 Verify execution of custom test cases.
35 _python_ = TestSCons._python_
37 test = TestSCons.TestSCons()
39 NCR = test.NCR # non-cached rebuild
40 CR = test.CR # cached rebuild (up to date)
41 NCF = test.NCF # non-cached build failure
42 CF = test.CF # cached build failure
44 compileOK = '#include <stdio.h>\\nint main() {printf("Hello");return 0;}'
45 compileFAIL = "syntax error"
47 linkFAIL = "void myFunc(); int main() { myFunc(); }"
49 runFAIL = "int main() { return 1; }"
51 test.write('pyAct.py', """\
54 sys.exit(int(sys.argv[1]))
57 test.write('SConstruct', """\
58 def CheckCustom(test):
59 test.Message( 'Executing MyTest ... ' )
60 retCompileOK = test.TryCompile( '%(compileOK)s', '.c' )
61 retCompileFAIL = test.TryCompile( '%(compileFAIL)s', '.c' )
62 retLinkOK = test.TryLink( '%(linkOK)s', '.c' )
63 retLinkFAIL = test.TryLink( '%(linkFAIL)s', '.c' )
64 (retRunOK, outputRunOK) = test.TryRun( '%(runOK)s', '.c' )
65 (retRunFAIL, outputRunFAIL) = test.TryRun( '%(runFAIL)s', '.c' )
66 (retActOK, outputActOK) = test.TryAction( '%(_python_)s pyAct.py 0 > $TARGET' )
67 (retActFAIL, outputActFAIL) = test.TryAction( '%(_python_)s pyAct.py 1 > $TARGET' )
68 resOK = retCompileOK and retLinkOK and retRunOK and outputRunOK=="Hello"
69 resOK = resOK and retActOK and int(outputActOK)==0
70 resFAIL = retCompileFAIL or retLinkFAIL or retRunFAIL or outputRunFAIL!=""
71 resFAIL = resFAIL or retActFAIL or outputActFAIL!=""
72 test.Result( int(resOK and not resFAIL) )
73 return resOK and not resFAIL
77 env.AppendENVPath('PATH', os.environ['PATH'])
78 conf = Configure( env, custom_tests={'CheckCustom' : CheckCustom} )
85 test.checkLogAndStdout(["Executing MyTest ... "],
87 [[(('.c', NCR), (_obj, NCR)),
88 (('.c', NCR), (_obj, NCF)),
89 (('.c', NCR), (_obj, NCR), (_exe, NCR)),
90 (('.c', NCR), (_obj, NCR), (_exe, NCF)),
91 (('.c', NCR), (_obj, NCR), (_exe, NCR), (_exe + '.out', NCR)),
92 (('.c', NCR), (_obj, NCR), (_exe, NCR), (_exe + '.out', NCF)),
95 "config.log", ".sconf_temp", "SConstruct")
99 test.checkLogAndStdout(["Executing MyTest ... "],
101 [[(('.c', CR), (_obj, CR)),
102 (('.c', CR), (_obj, CF)),
103 (('.c', CR), (_obj, CR), (_exe, CR)),
104 (('.c', CR), (_obj, CR), (_exe, CF)),
105 (('.c', CR), (_obj, CR), (_exe, CR), (_exe + '.out', CR)),
106 (('.c', CR), (_obj, CR), (_exe, CR), (_exe + '.out', CF)),
109 "config.log", ".sconf_temp", "SConstruct")
115 # indent-tabs-mode:nil
117 # vim: set expandtab tabstop=4 shiftwidth=4: