2 # Copyright 2008, Google Inc.
5 # Redistribution and use in source and binary forms, with or without
6 # modification, are permitted provided that the following conditions are
9 # * Redistributions of source code must retain the above copyright
10 # notice, this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above
12 # copyright notice, this list of conditions and the following disclaimer
13 # in the documentation and/or other materials provided with the
15 # * Neither the name of Google Inc. nor the names of its
16 # contributors may be used to endorse or promote products derived from
17 # this software without specific prior written permission.
19 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 """Simple testing harness for native client modulers running under sel_ldr
34 The tool expects 5 arguments (in this order):
37 * path to sel_ldr executable
38 * the native client module
39 * a sequence of rpc calls in plain text (e.g. tests/mandel/test.stdin)
40 * the expected out put (e.g. tests/mandel/test.stdout)
41 * a regex to filter the actual output (NYI)
43 The tool reports failure if the native client module exits with
44 an nonzero exit code or if actual and expected output do not match
58 print "Using sel_ldr at ", sel_ldr
67 short_exe
= os
.path
.abspath(exe
)
68 fail_msg
= short_exe
+ ' ' + 'FAILED'
69 pass_msg
= short_exe
+ ' ' + 'PASSED'
72 if stdin_data
!= "None":
73 input_data
= open(stdin_data
).read()
76 if stdout_data
!= "None":
77 output_data
= open(stdout_data
).read()
79 cmd
= [sel_ldr
, '-d', '-f', exe
] + flags
.split()
81 dur
, retcode
, failed
, stdout
, stderr
= test_lib
.RunTestWithInputOutput(
84 # TODO: add filter code for stdout here
87 print "command retuned nonzero exitcode ", retcode
96 print "command failed"
100 diff
= list(test_lib
.DiffStringsIgnoringWhiteSpace(stdout
, output_data
))
101 diff
= "\n".join(diff
)
104 print "Error Diff found"
108 print "Potentential New Golden Output"
116 if __name__
== '__main__':
117 sys
.exit(main(sys
.argv
[1:]))