blob: 6a57943b9250d1a11db0b2a406e47665012dc7a9 [file] [log] [blame]
Ruben Brunk370e2432014-10-14 18:33:23 -07001# Copyright 2014 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import os
16import os.path
17import tempfile
18import subprocess
19import time
20import sys
21import its.device
22
23def main():
24 """Run all the automated tests, saving intermediate files, and producing
25 a summary/report of the results.
26
27 Script should be run from the top-level CameraITS directory.
28 """
29
Yin-Chia Yeh665dda42014-10-20 11:23:48 -070030 # Not yet mandated tests
31 NOT_YET_MANDATED = {
32 "scene0":[
33 "test_jitter"
34 ],
35 "scene1":[
36 "test_ae_precapture_trigger",
37 "test_black_white",
38 "test_burst_sameness_manual",
39 "test_crop_region_raw",
40 "test_crop_regions",
41 "test_exposure",
42 "test_locked_burst",
43 "test_param_exposure_time",
44 "test_param_flash_mode",
45 "test_yuv_plus_jpeg",
46 "test_yuv_plus_raw",
47 "test_yuv_plus_raw10"
48 ]
49 }
50
Ruben Brunk370e2432014-10-14 18:33:23 -070051 # Get all the scene0 and scene1 tests, which can be run using the same
52 # physical setup.
53 scenes = ["scene0", "scene1"]
54 tests = []
55 for d in scenes:
56 tests += [(d,s[:-3],os.path.join("tests", d, s))
57 for s in os.listdir(os.path.join("tests",d))
58 if s[-3:] == ".py"]
59 tests.sort()
60
61 # Make output directories to hold the generated files.
62 topdir = tempfile.mkdtemp()
63 for d in scenes:
64 os.mkdir(os.path.join(topdir, d))
65 print "Saving output files to:", topdir, "\n"
66
67 # Run each test, capturing stdout and stderr.
68 numpass = 0
Yin-Chia Yeh665dda42014-10-20 11:23:48 -070069 numnotmandatedfail = 0
Ruben Brunk370e2432014-10-14 18:33:23 -070070 for (scene,testname,testpath) in tests:
71 cmd = ['python', os.path.join(os.getcwd(),testpath)] + sys.argv[1:]
72 outdir = os.path.join(topdir,scene)
73 outpath = os.path.join(outdir,testname+"_stdout.txt")
74 errpath = os.path.join(outdir,testname+"_stderr.txt")
75 t0 = time.time()
76 with open(outpath,"w") as fout, open(errpath,"w") as ferr:
77 retcode = subprocess.call(cmd,stderr=ferr,stdout=fout,cwd=outdir)
78 t1 = time.time()
Yin-Chia Yeh665dda42014-10-20 11:23:48 -070079 retstr = "PASS "
80 if retcode != 0:
81 retstr = "FAIL*" if testname in NOT_YET_MANDATED[scene] else "FAIL "
82
83 if retstr == "FAIL*":
84 numnotmandatedfail += 1
85
86 print "%s %s/%s [%.1fs]" % (retstr, scene, testname, t1-t0)
87 if retcode == 0 or testname in NOT_YET_MANDATED[scene]:
Ruben Brunk370e2432014-10-14 18:33:23 -070088 numpass += 1
Ruben Brunk370e2432014-10-14 18:33:23 -070089
90 print "\n%d / %d tests passed (%.1f%%)" % (
91 numpass, len(tests), 100.0*float(numpass)/len(tests))
Yin-Chia Yeh665dda42014-10-20 11:23:48 -070092 if numnotmandatedfail > 0:
93 print "(*) tests are not yet mandated"
94 its.device.ItsSession.report_result(numpass == len(tests))
Ruben Brunk370e2432014-10-14 18:33:23 -070095
96if __name__ == '__main__':
97 main()
98