From 7303807ef13c0a02434941852530fecce8778619 Mon Sep 17 00:00:00 2001 From: Jiajun Xu Date: Wed, 18 Aug 2010 22:02:08 +0800 Subject: 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 --- meta/classes/imagetest-qemu.bbclass | 59 ++++++++++++---------- meta/conf/local.conf.sample | 7 +-- .../scenario/qemuarm/poky-image-minimal | 1 + .../scenario/qemuarm/poky-image-sato | 2 + .../scenario/qemuarm/poky-image-sdk | 2 + .../scenario/qemumips/poky-image-minimal | 1 + .../scenario/qemumips/poky-image-sato | 2 + .../scenario/qemumips/poky-image-sdk | 2 + .../scenario/qemuppc/poky-image-minimal | 1 + .../scenario/qemuppc/poky-image-sato | 2 + .../scenario/qemuppc/poky-image-sdk | 2 + .../scenario/qemux86/poky-image-minimal | 1 + .../scenario/qemux86/poky-image-sato | 2 + .../scenario/qemux86/poky-image-sdk | 2 + 14 files changed, 56 insertions(+), 30 deletions(-) create mode 100644 scripts/qemuimage-tests/scenario/qemuarm/poky-image-minimal create mode 100644 scripts/qemuimage-tests/scenario/qemuarm/poky-image-sato create mode 100644 scripts/qemuimage-tests/scenario/qemuarm/poky-image-sdk create mode 100644 scripts/qemuimage-tests/scenario/qemumips/poky-image-minimal create mode 100644 scripts/qemuimage-tests/scenario/qemumips/poky-image-sato create mode 100644 scripts/qemuimage-tests/scenario/qemumips/poky-image-sdk create mode 100644 scripts/qemuimage-tests/scenario/qemuppc/poky-image-minimal create mode 100644 scripts/qemuimage-tests/scenario/qemuppc/poky-image-sato create mode 100644 scripts/qemuimage-tests/scenario/qemuppc/poky-image-sdk create mode 100644 scripts/qemuimage-tests/scenario/qemux86/poky-image-minimal create mode 100644 scripts/qemuimage-tests/scenario/qemux86/poky-image-sato create mode 100644 scripts/qemuimage-tests/scenario/qemux86/poky-image-sdk 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" TEST_DIR ?= "${WORKDIR}/qemuimagetest" TEST_LOG ?= "${LOG_DIR}/qemuimagetests" TEST_RESULT ?= "${TEST_DIR}/result" -TEST_LIST ?= "${TEST_DIR}/list" TEST_TMP ?= "${TEST_DIR}/tmp" TEST_SCEN ?= "sanity" @@ -21,15 +20,14 @@ python do_qemuimagetest() { Test Controller for Poky Testing. """ - casestr = re.compile(r'(?P\w+\b)\s*(?P\w+$)') + casestr = re.compile(r'(?P\w+\b):(?P\w+$)') resultstr = re.compile(r'\s*(?P\w+)\s*(?P\d+)\s*(?P\d+)\s*(?P\d+)') + machine = bb.data.getVar('MACHINE', d, 1) + pname = bb.data.getVar('PN', d, 1) """funtion to run each case under scenario""" def runtest(scen, case, fulltestpath): resultpath = bb.data.getVar('TEST_RESULT', d, 1) - machine = bb.data.getVar('MACHINE', d, 1) - pname = bb.data.getVar('PN', d, 1) - testpath = bb.data.getVar('TEST_DIR', d, 1) """initialize log file for testcase""" @@ -54,31 +52,39 @@ python do_qemuimagetest() { os.system("%s | tee -a %s" % (fulltestpath, caselog)) """Generate testcase list in runtime""" - def generate_list(testfile, testlist): + def generate_list(testlist): list = [] if len(testlist) == 0: raise bb.build.FuncFailed("No testcase defined in TEST_SCEN") - """remove old testcase list file""" - if os.path.exists(testfile): - os.remove(testfile) - os.system("touch %s" % testfile) - - """check testcase folder and add case to TEST_LIST""" + """check testcase folder and add case list according to TEST_SCEN""" for item in testlist.split(" "): - found = False - for dir in bb.data.getVar("QEMUIMAGETESTS", d, True).split(): - casepath = os.path.join(dir, item) - if not os.path.isdir(casepath): - continue - files = os.listdir(casepath) - for casefile in files: - fulltestcase = "%s/%s" % (casepath, casefile) - if os.path.isfile(fulltestcase): - list.append((item, casefile, fulltestcase)) - found = True - if not found: - raise bb.build.FuncFailed("Testcase folder not found for test %s" % item) + n = casestr.match(item) + if n: + item = n.group('scen') + casefile = n.group('case') + for dir in bb.data.getVar("QEMUIMAGETESTS", d, True).split(): + fulltestcase = os.path.join(dir, item, casefile) + if not os.path.isfile(fulltestcase): + raise bb.build.FuncFailed("Testcase %s not found" % fulltestcase) + list.append((item, casefile, fulltestcase)) + else: + for dir in bb.data.getVar("QEMUIMAGETESTS", d, True).split(): + scenlist = os.path.join(dir, "scenario", machine, pname) + if not os.path.isfile(scenlist): + raise bb.build.FuncFailed("No scenario list file named %s found" % scenlist) + + f = open(scenlist, "r") + for line in f: + if item != line.split()[0]: + continue + else: + casefile = line.split()[1] + + fulltestcase = os.path.join(dir, item, casefile) + if not os.path.isfile(fulltestcase): + raise bb.build.FuncFailed("Testcase %s not found" % fulltestcase) + list.append((item, casefile, fulltestcase)) return list """check testcase folder and create test log folder""" @@ -109,9 +115,8 @@ python do_qemuimagetest() { f.close() """generate pre-defined testcase list""" - testfile = bb.data.getVar('TEST_LIST', d, 1) testlist = bb.data.getVar('TEST_SCEN', d, 1) - fulllist = generate_list(testfile, testlist) + fulllist = generate_list(testlist) """Begin testing""" 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" # testing in qemu after do_rootfs. #IMAGETEST = "qemu" -# By default testing will run the sanitytest suite. If you want to run other tests -# (e.g. bat), list them here -#TEST_SCEN = "sanitytest bat" +# 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" diff --git a/scripts/qemuimage-tests/scenario/qemuarm/poky-image-minimal b/scripts/qemuimage-tests/scenario/qemuarm/poky-image-minimal new file mode 100644 index 0000000000..0fcc7bba84 --- /dev/null +++ b/scripts/qemuimage-tests/scenario/qemuarm/poky-image-minimal @@ -0,0 +1 @@ +sanity boot diff --git a/scripts/qemuimage-tests/scenario/qemuarm/poky-image-sato b/scripts/qemuimage-tests/scenario/qemuarm/poky-image-sato new file mode 100644 index 0000000000..95a091b741 --- /dev/null +++ b/scripts/qemuimage-tests/scenario/qemuarm/poky-image-sato @@ -0,0 +1,2 @@ +sanity boot +sanity ssh diff --git a/scripts/qemuimage-tests/scenario/qemuarm/poky-image-sdk b/scripts/qemuimage-tests/scenario/qemuarm/poky-image-sdk new file mode 100644 index 0000000000..95a091b741 --- /dev/null +++ b/scripts/qemuimage-tests/scenario/qemuarm/poky-image-sdk @@ -0,0 +1,2 @@ +sanity boot +sanity ssh diff --git a/scripts/qemuimage-tests/scenario/qemumips/poky-image-minimal b/scripts/qemuimage-tests/scenario/qemumips/poky-image-minimal new file mode 100644 index 0000000000..0fcc7bba84 --- /dev/null +++ b/scripts/qemuimage-tests/scenario/qemumips/poky-image-minimal @@ -0,0 +1 @@ +sanity boot diff --git a/scripts/qemuimage-tests/scenario/qemumips/poky-image-sato b/scripts/qemuimage-tests/scenario/qemumips/poky-image-sato new file mode 100644 index 0000000000..95a091b741 --- /dev/null +++ b/scripts/qemuimage-tests/scenario/qemumips/poky-image-sato @@ -0,0 +1,2 @@ +sanity boot +sanity ssh diff --git a/scripts/qemuimage-tests/scenario/qemumips/poky-image-sdk b/scripts/qemuimage-tests/scenario/qemumips/poky-image-sdk new file mode 100644 index 0000000000..95a091b741 --- /dev/null +++ b/scripts/qemuimage-tests/scenario/qemumips/poky-image-sdk @@ -0,0 +1,2 @@ +sanity boot +sanity ssh diff --git a/scripts/qemuimage-tests/scenario/qemuppc/poky-image-minimal b/scripts/qemuimage-tests/scenario/qemuppc/poky-image-minimal new file mode 100644 index 0000000000..0fcc7bba84 --- /dev/null +++ b/scripts/qemuimage-tests/scenario/qemuppc/poky-image-minimal @@ -0,0 +1 @@ +sanity boot diff --git a/scripts/qemuimage-tests/scenario/qemuppc/poky-image-sato b/scripts/qemuimage-tests/scenario/qemuppc/poky-image-sato new file mode 100644 index 0000000000..95a091b741 --- /dev/null +++ b/scripts/qemuimage-tests/scenario/qemuppc/poky-image-sato @@ -0,0 +1,2 @@ +sanity boot +sanity ssh diff --git a/scripts/qemuimage-tests/scenario/qemuppc/poky-image-sdk b/scripts/qemuimage-tests/scenario/qemuppc/poky-image-sdk new file mode 100644 index 0000000000..95a091b741 --- /dev/null +++ b/scripts/qemuimage-tests/scenario/qemuppc/poky-image-sdk @@ -0,0 +1,2 @@ +sanity boot +sanity ssh diff --git a/scripts/qemuimage-tests/scenario/qemux86/poky-image-minimal b/scripts/qemuimage-tests/scenario/qemux86/poky-image-minimal new file mode 100644 index 0000000000..0fcc7bba84 --- /dev/null +++ b/scripts/qemuimage-tests/scenario/qemux86/poky-image-minimal @@ -0,0 +1 @@ +sanity boot diff --git a/scripts/qemuimage-tests/scenario/qemux86/poky-image-sato b/scripts/qemuimage-tests/scenario/qemux86/poky-image-sato new file mode 100644 index 0000000000..95a091b741 --- /dev/null +++ b/scripts/qemuimage-tests/scenario/qemux86/poky-image-sato @@ -0,0 +1,2 @@ +sanity boot +sanity ssh diff --git a/scripts/qemuimage-tests/scenario/qemux86/poky-image-sdk b/scripts/qemuimage-tests/scenario/qemux86/poky-image-sdk new file mode 100644 index 0000000000..95a091b741 --- /dev/null +++ b/scripts/qemuimage-tests/scenario/qemux86/poky-image-sdk @@ -0,0 +1,2 @@ +sanity boot +sanity ssh -- cgit v1.2.3-54-g00ecf