summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorJiajun Xu <jiajun.xu@intel.com>2010-08-18 22:02:08 +0800
committerRichard Purdie <rpurdie@linux.intel.com>2010-08-27 13:04:37 +0100
commit7303807ef13c0a02434941852530fecce8778619 (patch)
treeb7e0db2a3f1a8dbace7e1069fc87a09b5b406094 /meta
parent192d6994cb56ca3d1e93780d8d2544e54440d356 (diff)
downloadpoky-7303807ef13c0a02434941852530fecce8778619.tar.gz
test: Add scenario file for each target and support single case running
Different test cases are needed for different targets. A folder "scenario" is created under scripts/qemuimage-tests to hold scenario files for different targets. Single case running is supported now. User can run single case together with a whole test suite by setting variable TEST_SCEN in local.conf. By default test cases in sanity suite will be ran. If you want to run other test suite or specific test case(e.g. bat or boot test case under sanity suite), list them like following. TEST_SCEN = "sanity bat sanity:boot" Signed-off-by Jiajun Xu <jiajun.xu@intel.com>
Diffstat (limited to 'meta')
-rw-r--r--meta/classes/imagetest-qemu.bbclass59
-rw-r--r--meta/conf/local.conf.sample7
2 files changed, 36 insertions, 30 deletions
diff --git a/meta/classes/imagetest-qemu.bbclass b/meta/classes/imagetest-qemu.bbclass
index feab868476..5742644e02 100644
--- a/meta/classes/imagetest-qemu.bbclass
+++ b/meta/classes/imagetest-qemu.bbclass
@@ -8,7 +8,6 @@ do_qemuimagetest[depends] += "qemu-native:do_populate_sysroot"
8TEST_DIR ?= "${WORKDIR}/qemuimagetest" 8TEST_DIR ?= "${WORKDIR}/qemuimagetest"
9TEST_LOG ?= "${LOG_DIR}/qemuimagetests" 9TEST_LOG ?= "${LOG_DIR}/qemuimagetests"
10TEST_RESULT ?= "${TEST_DIR}/result" 10TEST_RESULT ?= "${TEST_DIR}/result"
11TEST_LIST ?= "${TEST_DIR}/list"
12TEST_TMP ?= "${TEST_DIR}/tmp" 11TEST_TMP ?= "${TEST_DIR}/tmp"
13TEST_SCEN ?= "sanity" 12TEST_SCEN ?= "sanity"
14 13
@@ -21,15 +20,14 @@ python do_qemuimagetest() {
21 Test Controller for Poky Testing. 20 Test Controller for Poky Testing.
22 """ 21 """
23 22
24 casestr = re.compile(r'(?P<scen>\w+\b)\s*(?P<case>\w+$)') 23 casestr = re.compile(r'(?P<scen>\w+\b):(?P<case>\w+$)')
25 resultstr = re.compile(r'\s*(?P<case>\w+)\s*(?P<pass>\d+)\s*(?P<fail>\d+)\s*(?P<noresult>\d+)') 24 resultstr = re.compile(r'\s*(?P<case>\w+)\s*(?P<pass>\d+)\s*(?P<fail>\d+)\s*(?P<noresult>\d+)')
25 machine = bb.data.getVar('MACHINE', d, 1)
26 pname = bb.data.getVar('PN', d, 1)
26 27
27 """funtion to run each case under scenario""" 28 """funtion to run each case under scenario"""
28 def runtest(scen, case, fulltestpath): 29 def runtest(scen, case, fulltestpath):
29 resultpath = bb.data.getVar('TEST_RESULT', d, 1) 30 resultpath = bb.data.getVar('TEST_RESULT', d, 1)
30 machine = bb.data.getVar('MACHINE', d, 1)
31 pname = bb.data.getVar('PN', d, 1)
32
33 testpath = bb.data.getVar('TEST_DIR', d, 1) 31 testpath = bb.data.getVar('TEST_DIR', d, 1)
34 32
35 """initialize log file for testcase""" 33 """initialize log file for testcase"""
@@ -54,31 +52,39 @@ python do_qemuimagetest() {
54 os.system("%s | tee -a %s" % (fulltestpath, caselog)) 52 os.system("%s | tee -a %s" % (fulltestpath, caselog))
55 53
56 """Generate testcase list in runtime""" 54 """Generate testcase list in runtime"""
57 def generate_list(testfile, testlist): 55 def generate_list(testlist):
58 list = [] 56 list = []
59 if len(testlist) == 0: 57 if len(testlist) == 0:
60 raise bb.build.FuncFailed("No testcase defined in TEST_SCEN") 58 raise bb.build.FuncFailed("No testcase defined in TEST_SCEN")
61 59
62 """remove old testcase list file""" 60 """check testcase folder and add case list according to TEST_SCEN"""
63 if os.path.exists(testfile):
64 os.remove(testfile)
65 os.system("touch %s" % testfile)
66
67 """check testcase folder and add case to TEST_LIST"""
68 for item in testlist.split(" "): 61 for item in testlist.split(" "):
69 found = False 62 n = casestr.match(item)
70 for dir in bb.data.getVar("QEMUIMAGETESTS", d, True).split(): 63 if n:
71 casepath = os.path.join(dir, item) 64 item = n.group('scen')
72 if not os.path.isdir(casepath): 65 casefile = n.group('case')
73 continue 66 for dir in bb.data.getVar("QEMUIMAGETESTS", d, True).split():
74 files = os.listdir(casepath) 67 fulltestcase = os.path.join(dir, item, casefile)
75 for casefile in files: 68 if not os.path.isfile(fulltestcase):
76 fulltestcase = "%s/%s" % (casepath, casefile) 69 raise bb.build.FuncFailed("Testcase %s not found" % fulltestcase)
77 if os.path.isfile(fulltestcase): 70 list.append((item, casefile, fulltestcase))
78 list.append((item, casefile, fulltestcase)) 71 else:
79 found = True 72 for dir in bb.data.getVar("QEMUIMAGETESTS", d, True).split():
80 if not found: 73 scenlist = os.path.join(dir, "scenario", machine, pname)
81 raise bb.build.FuncFailed("Testcase folder not found for test %s" % item) 74 if not os.path.isfile(scenlist):
75 raise bb.build.FuncFailed("No scenario list file named %s found" % scenlist)
76
77 f = open(scenlist, "r")
78 for line in f:
79 if item != line.split()[0]:
80 continue
81 else:
82 casefile = line.split()[1]
83
84 fulltestcase = os.path.join(dir, item, casefile)
85 if not os.path.isfile(fulltestcase):
86 raise bb.build.FuncFailed("Testcase %s not found" % fulltestcase)
87 list.append((item, casefile, fulltestcase))
82 return list 88 return list
83 89
84 """check testcase folder and create test log folder""" 90 """check testcase folder and create test log folder"""
@@ -109,9 +115,8 @@ python do_qemuimagetest() {
109 f.close() 115 f.close()
110 116
111 """generate pre-defined testcase list""" 117 """generate pre-defined testcase list"""
112 testfile = bb.data.getVar('TEST_LIST', d, 1)
113 testlist = bb.data.getVar('TEST_SCEN', d, 1) 118 testlist = bb.data.getVar('TEST_SCEN', d, 1)
114 fulllist = generate_list(testfile, testlist) 119 fulllist = generate_list(testlist)
115 120
116 """Begin testing""" 121 """Begin testing"""
117 for test in fulllist: 122 for test in fulllist:
diff --git a/meta/conf/local.conf.sample b/meta/conf/local.conf.sample
index 66acaa49a7..a06c7555c9 100644
--- a/meta/conf/local.conf.sample
+++ b/meta/conf/local.conf.sample
@@ -146,6 +146,7 @@ ENABLE_BINARY_LOCALE_GENERATION = "1"
146# testing in qemu after do_rootfs. 146# testing in qemu after do_rootfs.
147#IMAGETEST = "qemu" 147#IMAGETEST = "qemu"
148 148
149# By default testing will run the sanitytest suite. If you want to run other tests 149# By default test cases in sanity suite will be ran. If you want to run other
150# (e.g. bat), list them here 150# test suite or specific test case(e.g. bat or boot test case under sanity suite),
151#TEST_SCEN = "sanitytest bat" 151# list them like following.
152#TEST_SCEN = "sanity bat sanity:boot"