imagetest-qemu.bbclass, qemuimage-testlib: add support for more FSTYPES

qemuimage-testlib hardcodes ext3 as fs type. This adds support for more
images types which are supported by runqemu: ext[234]/jffs2/btrfs.

I've skipped (for now) vmdk (which qemu can boot) because:
 - we don't have network on images without connman because of the way
runqemu starts vmdk images (can't pass kernel args for network config)
 - qemuimage-testlib-pythonhelper relies on '192.168' being in the output of
ps to return the pid

(From OE-Core rev: 95b7cafafcaa4dda7328632475003f5778ab95bd)

Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Stefan Stanacar 2013-05-10 19:06:26 +03:00 committed by Richard Purdie
parent 2c2dd5be3e
commit cef2446eb3
2 changed files with 24 additions and 21 deletions

View File

@ -37,6 +37,8 @@ def qemuimagetest_main(d):
resultstr = re.compile(r'\s*(?P<case>\w+)\s*(?P<pass>\d+)\s*(?P<fail>\d+)\s*(?P<noresult>\d+)') resultstr = re.compile(r'\s*(?P<case>\w+)\s*(?P<pass>\d+)\s*(?P<fail>\d+)\s*(?P<noresult>\d+)')
machine = d.getVar('MACHINE', True) machine = d.getVar('MACHINE', True)
pname = d.getVar('PN', True) pname = d.getVar('PN', True)
allfstypes = d.getVar("IMAGE_FSTYPES", True).split()
testfstypes = [ "ext2", "ext3", "ext4", "jffs2", "btrfs" ]
"""function to save test cases running status""" """function to save test cases running status"""
def teststatus(test, status, index, length): def teststatus(test, status, index, length):
@ -50,7 +52,7 @@ def qemuimagetest_main(d):
f.close() f.close()
"""funtion to run each case under scenario""" """funtion to run each case under scenario"""
def runtest(scen, case, fulltestpath): def runtest(scen, case, fulltestpath, fstype):
resultpath = d.getVar('TEST_RESULT', True) resultpath = d.getVar('TEST_RESULT', True)
tmppath = d.getVar('TEST_TMP', True) tmppath = d.getVar('TEST_TMP', True)
@ -75,6 +77,7 @@ def qemuimagetest_main(d):
os.environ["TEST_SERIALIZE"] = d.getVar("TEST_SERIALIZE", True) os.environ["TEST_SERIALIZE"] = d.getVar("TEST_SERIALIZE", True)
os.environ["SDK_NAME"] = d.getVar("SDK_NAME", True) os.environ["SDK_NAME"] = d.getVar("SDK_NAME", True)
os.environ["RUNQEMU_LOGFILE"] = d.expand("${T}/log.runqemutest.%s" % os.getpid()) os.environ["RUNQEMU_LOGFILE"] = d.expand("${T}/log.runqemutest.%s" % os.getpid())
os.environ["ROOTFS_EXT"] = fstype
# Add in all variables from the user's original environment which # Add in all variables from the user's original environment which
# haven't subsequntly been set/changed # haven't subsequntly been set/changed
@ -193,21 +196,22 @@ def qemuimagetest_main(d):
os.remove(sresultfile) os.remove(sresultfile)
subprocess.call("touch %s" % resultfile, shell=True) subprocess.call("touch %s" % resultfile, shell=True)
os.symlink(resultfile, sresultfile) os.symlink(resultfile, sresultfile)
f = open(sresultfile, "a")
f.write("\tTest Result for %s %s\n" % (machine, pname))
f.write("\t%-15s%-15s%-15s%-15s\n" % ("Testcase", "PASS", "FAIL", "NORESULT"))
f.close()
"""generate pre-defined testcase list""" """generate pre-defined testcase list"""
testlist = d.getVar('TEST_SCEN', True) testlist = d.getVar('TEST_SCEN', True)
fulllist = generate_list(testlist) fulllist = generate_list(testlist)
"""Begin testing""" """Begin testing"""
for index,test in enumerate(fulllist): for fstype in allfstypes:
(scen, case, fullpath) = test if fstype in testfstypes:
teststatus(case, "running", index, (len(fulllist) - 1)) with open(sresultfile, "a") as f:
runtest(scen, case, fullpath) f.write("\tTest Result for %s %s %s\n" % (machine, pname, fstype))
teststatus(case, "finished", index, (len(fulllist) - 1)) f.write("\t%-15s%-15s%-15s%-15s\n" % ("Testcase", "PASS", "FAIL", "NORESULT"))
for index,test in enumerate(fulllist):
(scen, case, fullpath) = test
teststatus(case, "running", index, (len(fulllist) - 1))
runtest(scen, case, fullpath, fstype)
teststatus(case, "finished", index, (len(fulllist) - 1))
"""Print Test Result""" """Print Test Result"""
ret = 0 ret = 0
@ -230,5 +234,5 @@ def qemuimagetest_main(d):
clean_tmp() clean_tmp()
if ret != 0: if ret != 0:
raise bb.build.FuncFailed("Some testcases fail, pls. check test result and test log!!!") raise bb.build.FuncFailed("Some tests failed. Please check the results file: %s and the log files found in: %s." % (resultfile, d.getVar('TEST_LOG', True)))

View File

@ -14,8 +14,6 @@
# Version 2. # Version 2.
# #
TYPE="ext3"
# The folder to hold all scripts running on targets # The folder to hold all scripts running on targets
TOOLS="$COREBASE/scripts/qemuimage-tests/tools" TOOLS="$COREBASE/scripts/qemuimage-tests/tools"
@ -306,18 +304,18 @@ Test_Find_Image()
extension="" extension=""
rootfs="" rootfs=""
while getopts "l:k:a:t:" Option while getopts "l:k:a:t:e:" Option
do do
case $Option in case $Option in
l) where="$OPTARG" l) where="$OPTARG"
;; ;;
k) kernel="$OPTARG" k) kernel="$OPTARG"
extension="bin"
;; ;;
a) arch="$OPTARG" a) arch="$OPTARG"
;; ;;
t) target="$OPTARG" t) target="$OPTARG"
extension="ext3" ;;
e) extension="$OPTARG"
;; ;;
*) echo "invalid option: -$Option" && return 1 *) echo "invalid option: -$Option" && return 1
;; ;;
@ -396,11 +394,11 @@ Test_Create_Qemu()
fi fi
if [ "$QEMUARCH" = "qemux86" -o "$QEMUARCH" = "qemux86-64" ]; then if [ "$QEMUARCH" = "qemux86" -o "$QEMUARCH" = "qemux86-64" ]; then
KERNEL=$(Test_Find_Image -l ${DEPLOY_DIR}/images -k bzImage -a ${QEMUARCH}) KERNEL=$(Test_Find_Image -l ${DEPLOY_DIR}/images -k bzImage -a ${QEMUARCH} -e "bin")
elif [ "$QEMUARCH" = "qemuarm" -o "$QEMUARCH" = "spitz" -o "$QEMUARCH" = "borzoi" -o "$QEMUARCH" = "akita" -o "$QEMUARCH" = "nokia800" ]; then elif [ "$QEMUARCH" = "qemuarm" -o "$QEMUARCH" = "spitz" -o "$QEMUARCH" = "borzoi" -o "$QEMUARCH" = "akita" -o "$QEMUARCH" = "nokia800" ]; then
KERNEL=$(Test_Find_Image -l ${DEPLOY_DIR}/images -k zImage -a ${QEMUARCH}) KERNEL=$(Test_Find_Image -l ${DEPLOY_DIR}/images -k zImage -a ${QEMUARCH})
elif [ "$QEMUARCH" = "qemumips" -o "$QEMUARCH" = "qemuppc" ]; then elif [ "$QEMUARCH" = "qemumips" -o "$QEMUARCH" = "qemuppc" ]; then
KERNEL=$(Test_Find_Image -l ${DEPLOY_DIR}/images -k vmlinux -a ${QEMUARCH}) KERNEL=$(Test_Find_Image -l ${DEPLOY_DIR}/images -k vmlinux -a ${QEMUARCH} -e "bin")
fi fi
# If there is no kernel image found, return failed directly # If there is no kernel image found, return failed directly
@ -409,7 +407,8 @@ Test_Create_Qemu()
return 1 return 1
fi fi
ROOTFS_IMAGE=$(Test_Find_Image -l ${DEPLOY_DIR}/images -t ${QEMUTARGET} -a ${QEMUARCH}) Test_Info "rootfs image extension selected: $ROOTFS_EXT"
ROOTFS_IMAGE=$(Test_Find_Image -l ${DEPLOY_DIR}/images -t ${QEMUTARGET} -a ${QEMUARCH} -e "$ROOTFS_EXT")
# If there is no rootfs image found, return failed directly # If there is no rootfs image found, return failed directly
if [ $? -eq 1 ]; then if [ $? -eq 1 ]; then
@ -417,7 +416,7 @@ Test_Create_Qemu()
return 1 return 1
fi fi
TEST_ROOTFS_IMAGE="${TEST_TMP}/${QEMUTARGET}-${QEMUARCH}-test.ext3" TEST_ROOTFS_IMAGE="${TEST_TMP}/${QEMUTARGET}-${QEMUARCH}-test.${ROOTFS_EXT}"
CP=`which cp` CP=`which cp`
@ -751,4 +750,4 @@ Test_Display_Syslog()
echo "System logs:" echo "System logs:"
cat $tmplog cat $tmplog
rm -f $tmplog rm -f $tmplog
} }