diff options
| author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2013-09-19 13:18:06 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-09-20 12:14:32 +0100 |
| commit | d469c92394a1a95ae7a45b8b80dc4c2918e0e9a6 (patch) | |
| tree | bf46541bf207a6e4f5470b59feac7de9fcb67a1a | |
| parent | a68b4c6ee780c0efe6c877595d0c10b3192ad80b (diff) | |
| download | openembedded-core-d469c92394a1a95ae7a45b8b80dc4c2918e0e9a6.tar.gz openembedded-core-d469c92394a1a95ae7a45b8b80dc4c2918e0e9a6.tar.bz2 openembedded-core-d469c92394a1a95ae7a45b8b80dc4c2918e0e9a6.zip | |
classes/imagetest-qemu: remove old image testing class
This has now been superseded by testimage.
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
54 files changed, 0 insertions, 2411 deletions
diff --git a/meta/classes/imagetest-qemu.bbclass b/meta/classes/imagetest-qemu.bbclass deleted file mode 100644 index 7083a99381..0000000000 --- a/meta/classes/imagetest-qemu.bbclass +++ /dev/null @@ -1,238 +0,0 @@ -# Test related variables -# By default, TEST_DIR is created under WORKDIR -TEST_DIR ?= "${WORKDIR}/qemuimagetest" -TEST_LOG ?= "${LOG_DIR}/qemuimagetests" -TEST_RESULT ?= "${TEST_DIR}/result" -TEST_TMP ?= "${TEST_DIR}/tmp" -TEST_SCEN ?= "sanity" -TEST_STATUS ?= "${TEST_TMP}/status" -TARGET_IPSAVE ?= "${TEST_TMP}/target_ip" -TEST_SERIALIZE ?= "1" - -python do_qemuimagetest() { - qemuimagetest_main(d) -} -addtask qemuimagetest before do_build after do_rootfs -do_qemuimagetest[nostamp] = "1" -do_qemuimagetest[depends] += "qemu-native:do_populate_sysroot" - -python do_qemuimagetest_standalone() { - qemuimagetest_main(d) -} -addtask qemuimagetest_standalone -do_qemuimagetest_standalone[nostamp] = "1" -do_qemuimagetest_standalone[depends] += "qemu-native:do_populate_sysroot" - -def qemuimagetest_main(d): - import sys - import re - import shutil - import subprocess - - """ - Test Controller for automated testing. - """ - - casestr = re.compile(r'(?P<scen>\w+\b):(?P<case>\S+$)') - 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) - 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""" - def teststatus(test, status, index, length): - test_status = d.getVar('TEST_STATUS', True) - if not os.path.exists(test_status): - raise bb.build.FuncFailed("No test status file existing under TEST_TMP") - - f = open(test_status, "w") - f.write("\t%-15s%-15s%-15s%-15s\n" % ("Case", "Status", "Number", "Total")) - f.write("\t%-15s%-15s%-15s%-15s\n" % (case, status, index, length)) - f.close() - - """funtion to run each case under scenario""" - def runtest(scen, case, fulltestpath, fstype): - resultpath = d.getVar('TEST_RESULT', True) - tmppath = d.getVar('TEST_TMP', True) - - """initialize log file for testcase""" - logpath = d.getVar('TEST_LOG', True) - bb.utils.mkdirhier("%s/%s" % (logpath, scen)) - caselog = os.path.join(logpath, "%s/log_%s.%s" % (scen, case, d.getVar('DATETIME', True))) - subprocess.call("touch %s" % caselog, shell=True) - - """export TEST_TMP, TEST_RESULT, DEPLOY_DIR and QEMUARCH""" - os.environ["PATH"] = d.getVar("PATH", True) - os.environ["TEST_TMP"] = tmppath - os.environ["TEST_RESULT"] = resultpath - os.environ["DEPLOY_DIR"] = d.getVar("DEPLOY_DIR", True) - os.environ["QEMUARCH"] = machine - os.environ["QEMUTARGET"] = pname - os.environ["COREBASE"] = d.getVar("COREBASE", True) - os.environ["TOPDIR"] = d.getVar("TOPDIR", True) - os.environ["OE_TMPDIR"] = d.getVar("TMPDIR", True) - os.environ["TEST_STATUS"] = d.getVar("TEST_STATUS", True) - os.environ["TARGET_IPSAVE"] = d.getVar("TARGET_IPSAVE", True) - os.environ["TEST_SERIALIZE"] = d.getVar("TEST_SERIALIZE", True) - os.environ["SDK_NAME"] = d.getVar("SDK_NAME", True) - 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 - # haven't subsequntly been set/changed - origbbenv = d.getVar("BB_ORIGENV", False) or {} - for key in origbbenv: - if key in os.environ: - continue - value = origbbenv.getVar(key, True) - if value is not None: - os.environ[key] = str(value) - - """run Test Case""" - bb.note("Run %s test in scenario %s" % (case, scen)) - subprocess.call("%s" % fulltestpath, shell=True) - - """function to check testcase list and remove inappropriate cases""" - def check_list(list): - final_list = [] - for test in list: - (scen, case, fullpath) = test - - """Skip rpm/smart if package_rpm not set for PACKAGE_CLASSES""" - if case.find("smart") != -1 or case.find("rpm") != -1: - if d.getVar("PACKAGE_CLASSES", True).find("rpm", 0, 11) == -1: - bb.note("skip rpm/smart cases since package_rpm not set in PACKAGE_CLASSES") - continue - else: - final_list.append((scen, case, fullpath)) - else: - final_list.append((scen, case, fullpath)) - - if not final_list: - raise bb.build.FuncFailed("There is no suitable testcase for this target") - - return final_list - - """Generate testcase list in runtime""" - def generate_list(testlist): - list = [] - final_list = [] - if len(testlist) == 0: - raise bb.build.FuncFailed("No testcase defined in TEST_SCEN") - - """check testcase folder and add case list according to TEST_SCEN""" - for item in testlist.split(" "): - n = casestr.match(item) - if n: - item = n.group('scen') - casefile = n.group('case') - for dir in d.getVar("QEMUIMAGETESTS", 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 d.getVar("QEMUIMAGETESTS", 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)) - f.close() - final_list = check_list(list) - return final_list - - """Clean tmp folder for testing""" - def clean_tmp(): - tmppath = d.getVar('TEST_TMP', True) - - if os.path.isdir(tmppath): - for f in os.listdir(tmppath): - tmpfile = os.path.join(tmppath, f) - if os.path.isfile(tmpfile): - os.remove(tmpfile) - elif os.path.isdir(tmpfile): - shutil.rmtree(tmpfile, True) - - """Before running testing, clean temp folder first""" - clean_tmp() - - """check testcase folder and create test log folder""" - testpath = d.getVar('TEST_DIR', True) - bb.utils.mkdirhier(testpath) - - logpath = d.getVar('TEST_LOG', True) - bb.utils.mkdirhier(logpath) - - tmppath = d.getVar('TEST_TMP', True) - bb.utils.mkdirhier(tmppath) - - """initialize test status file""" - test_status = d.getVar('TEST_STATUS', True) - if os.path.exists(test_status): - os.remove(test_status) - subprocess.call("touch %s" % test_status, shell=True) - - """initialize result file""" - resultpath = d.getVar('TEST_RESULT', True) - bb.utils.mkdirhier(resultpath) - resultfile = os.path.join(resultpath, "testresult.%s" % d.getVar('DATETIME', True)) - sresultfile = os.path.join(resultpath, "testresult.log") - - machine = d.getVar('MACHINE', True) - - if os.path.exists(sresultfile): - os.remove(sresultfile) - subprocess.call("touch %s" % resultfile, shell=True) - os.symlink(resultfile, sresultfile) - - """generate pre-defined testcase list""" - testlist = d.getVar('TEST_SCEN', True) - fulllist = generate_list(testlist) - - """Begin testing""" - for fstype in allfstypes: - if fstype in testfstypes: - with open(sresultfile, "a") as f: - f.write("\tTest Result for %s %s %s\n" % (machine, pname, fstype)) - 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""" - ret = 0 - f = open(sresultfile, "r") - for line in f: - m = resultstr.match(line) - if m: - if m.group('fail') == "1": - ret = 1 - elif m.group('noresult') == "1": - ret = 2 - line = line.strip('\n') - bb.note(line) - else: - line = line.strip('\n') - bb.note(line) - f.close() - - """Clean temp files for testing""" - clean_tmp() - - if ret != 0: - 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))) - diff --git a/meta/classes/populate_sdk_base.bbclass b/meta/classes/populate_sdk_base.bbclass index bddcf6213b..b7ea85159c 100644 --- a/meta/classes/populate_sdk_base.bbclass +++ b/meta/classes/populate_sdk_base.bbclass @@ -1,9 +1,6 @@ inherit meta toolchain-scripts inherit populate_sdk_${IMAGE_PKGTYPE} -IMAGETESTCLASS = "${@oe.utils.ifelse(d.getVar('IMAGETEST'),'imagetest-' + (d.getVar('IMAGETEST') or ""),'')}" -inherit ${IMAGETESTCLASS} - SDK_DIR = "${WORKDIR}/sdk" SDK_OUTPUT = "${SDK_DIR}/image" SDK_DEPLOY = "${TMPDIR}/deploy/sdk" diff --git a/meta/conf/layer.conf b/meta/conf/layer.conf index 31c095c2cb..e249a6a43e 100644 --- a/meta/conf/layer.conf +++ b/meta/conf/layer.conf @@ -14,9 +14,6 @@ LAYERVERSION_core = "3" # Set a variable to get to the top of the metadata location COREBASE = '${@os.path.normpath("${LAYERDIR}/../")}' -# Set path to qemu image tests included in this layer -QEMUIMAGETESTS = "${COREBASE}/scripts/qemuimage-tests" - SIGGEN_EXCLUDERECIPES_ABISAFE += " \ sysvinit-inittab \ shadow-securetty \ diff --git a/scripts/qemuimage-testlib b/scripts/qemuimage-testlib deleted file mode 100755 index adcdf6bfef..0000000000 --- a/scripts/qemuimage-testlib +++ /dev/null @@ -1,760 +0,0 @@ -#!/bin/bash -# Common function for test -# Expect should be installed for SSH Testing -# To execute `runqemu`, NOPASSWD needs to be set in /etc/sudoers for user -# For example, for user "builder", /etc/sudoers can be like following: -# ######### -# #Members of the admin group may gain root privileges -# %builder ALL=(ALL) NOPASSWD: NOPASSWD: ALL -# ######### -# -# Author: Jiajun Xu <jiajun.xu@intel.com> -# -# This file is licensed under the GNU General Public License, -# Version 2. -# - -# The folder to hold all scripts running on targets -TOOLS="$COREBASE/scripts/qemuimage-tests/tools" - -# The folder to hold all projects for toolchain testing -TOOLCHAIN_PROJECTS="$COREBASE/scripts/qemuimage-tests/toolchain_projects" - -# Test Directory on target for testing -TARGET_TEST_DIR="/tmp/test" - -# Global variables for process id -XTERMPID=0 -QEMUPID=0 - -# Global variable for target ip address -TARGET_IPADDR=0 - -# Global variable for test project version during toolchain test -# Version of cvs is 1.12.13 -# Version of iptables is 1.4.11 -# Version of sudoku-savant is 1.3 -PROJECT_PV=0 - -# Global variable for test project download URL during toolchain test -# URL of cvs is http://ftp.gnu.org/non-gnu/cvs/source/feature/1.12.13/cvs-1.12.13.tar.bz2 -# URL of iptables is http://netfilter.org/projects/iptables/files/iptables-1.4.11.tar.bz2 -# URL of sudoku-savant is http://downloads.sourceforge.net/project/sudoku-savant/sudoku-savant/sudoku-savant-1.3/sudoku-savant-1.3.tar.bz2 -PROJECT_DOWNLOAD_URL=0 - -# SDK folder to hold toolchain tarball -TOOLCHAIN_DIR="${DEPLOY_DIR}/sdk" - -# Toolchain test folder to hold extracted toolchain tarball -TOOLCHAIN_TEST="/opt" - -# common function for information print -Test_Error() -{ - echo -e "\tTest_Error: $*" -} - -Test_Info() -{ - echo -e "\tTest_Info: $*" -} - -# function to update target ip address -# $1 is the process id of the process, which starts the qemu target -# $2 is the ip address of the target -Test_Update_IPSAVE() -{ - local pid=$1 - local ip_addr=$2 - - if [ "$TEST_SERIALIZE" -eq 1 -a "$pid" != "0" -a "$pid" != "" -a "$ip_addr" != "" -a "$ip_addr" != "" ]; then - echo "Saving $pid $ip_addr to $TARGET_IPSAVE" - echo "$pid $ip_addr" > $TARGET_IPSAVE - fi -} - -# function to copy files from host into target -# $1 is the ip address of target -# $2 is the files, which need to be copied into target -# $3 is the path on target, where files are copied into -Test_SCP() -{ - local ip_addr=$1 - local src=$2 - local des=$3 - local time_out=60 - local ret=0 - - # We use expect to interactive with target by ssh - local exp_cmd=`cat << EOF -eval spawn scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$src" root@$ip_addr:"$des" -set timeout $time_out -expect { - "*assword:" { send "\r"; exp_continue} - "*(yes/no)?" { send "yes\r"; exp_continue } - eof { exit [ lindex [wait] 3 ] } -} -EOF` - - expect=`which expect` - if [ ! -x "$expect" ]; then - Test_Error "ERROR: Please install expect" - return 1 - fi - - expect -c "$exp_cmd" - ret=$? - return $ret -} - -# function to copy files from target to host -# $1 is the ip address of target -# $2 is the files, which need to be copied into target -# $3 is the path on target, where files are copied into -Test_SCP_From() -{ - local ip_addr=$1 - local src=$2 - local des=$3 - local time_out=60 - local ret=0 - - # We use expect to interactive with target by ssh - local exp_cmd=`cat << EOF -eval spawn scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$ip_addr:"$src" "$des" -set timeout $time_out -expect { - "*assword:" { send "\r"; exp_continue} - "*(yes/no)?" { send "yes\r"; exp_continue } - eof { exit [ lindex [wait] 3 ] } -} -EOF` - - expect=`which expect` - if [ ! -x "$expect" ]; then - Test_Error "ERROR: Please install expect" - return 1 - fi - - expect -c "$exp_cmd" - ret=$? - return $ret -} - -# function to run command in $ip_addr via ssh -Test_SSH() -{ - local ip_addr="$1" - local command="$2" - - if [ $# -eq 3 ]; then - local time_out=$3 - else - local time_out=60 - fi - - local ret=0 - local exp_cmd=`cat << EOF -eval spawn ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$ip_addr "$command" -set timeout $time_out -expect { - "*assword:" { send "\r"; exp_continue} - "*(yes/no)?" { send "yes\r"; exp_continue } - eof { exit [ lindex [wait] 3 ] } -} -EOF` - - expect=`which expect` - if [ ! -x "$expect" ]; then - Test_Error "ERROR: Please install expect" - return 1 - fi - - expect -c "$exp_cmd" - ret=$? - return $ret -} - -# function to check if ssh is up in $ip_addr -Test_SSH_UP() -{ - local ip_addr=$1 - local timeout=$2 - local interval=0 - - # If TEST_SERIALIZE is set, use existing running qemu for testing - if [ ${TEST_SERIALIZE} -eq 1 -a -e ${TARGET_IPSAVE} ]; then - timeout=50 - fi - - while [ ${interval} -lt ${timeout} ] - do - Test_SSH ${ip_addr} "hostname" - if [ $? -ne 0 ]; then - interval=`expr $interval + 10` - sleep 10 - else - Test_Info "We can ssh on ${ip_addr} within ${interval} seconds" - return 0 - fi - - done - - Test_Info "We can not ssh on ${ip_addr} in ${timeout} seconds" - return 1 -} - -# function to prepare target test environment -# $1 is the ip address of target system -# $2 is the files, which needs to be copied into target -Test_Target_Pre() -{ - local ip_addr=$1 - local testscript=$2 - - # Create a pre-defined folder for test scripts - Test_SSH $ip_addr "mkdir -p $TARGET_TEST_DIR" - if [ $? -eq 0 ]; then - # Copy test scripts into target - Test_SCP $ip_addr $testscript $TARGET_TEST_DIR && return 0 - else - Test_Error "Fail to create $TARGET_TEST_DIR on target" - return 1 - fi - - return 1 -} - -# function to record test result in $TEST_RESULT/testresult.log -Test_Print_Result() -{ - local PASS=0 - local FAIL=0 - local NORESULT=0 - if [ $2 -eq 0 ]; then - PASS=1 - elif [ $2 -eq 1 ]; then - FAIL=1 - else - NORESULT=1 - fi - - # Format the output of the test result - echo -e "$1 $PASS $FAIL $NORESULT" | awk '{printf("\t"); for(i=1;i<=NF;i++) printf("%-15s",$i); printf("\n");}' >> $TEST_RESULT/testresult.log -} - -# Test_Kill_Qemu to kill child pid with parent pid given -# $1 is qemu process id, which needs to be killed -Test_Kill_Qemu() -{ - local index=0 - local total=0 - local k=0 - - # When TEST_SERIALIZE is set, qemu process will not be - # killed until all the cases are finished - if [ ${TEST_SERIALIZE} -eq 1 -a -e ${TEST_STATUS} ]; then - index=`sed -n 2p ${TEST_STATUS} | awk '{print $3}'` - total=`sed -n 2p ${TEST_STATUS} | awk '{print $4}'` - if [ ${index} != ${total} ]; then - Test_Info "Do not kill the qemu process and use it for later testing (step $index of $total)" - Test_Update_IPSAVE $XTERMPID $TARGET_IPADDR - else - k=1 - fi - else - k=1 - fi - - if [ $k -eq 1 ]; then - if [ "$QEMUPID" != "0" -a "$QEMUPID" != "" ]; then - running=`ps -wwfp $QEMUPID` - if [ $? -eq 0 ]; then - echo "killing $QEMUPID" - kill $QEMUPID - fi - fi - if [ "$XTERMPID" != "0" -a "$XTERMPID" != "" ]; then - running=`ps -wwfp $XTERMPID` - if [ $? -eq 0 ]; then - echo "killing $XTERMPID" - kill $XTERMPID - fi - fi - fi - - return -} - -# function to check if network is up -Test_Check_IP_UP() -{ - ping -c1 $1 1> /dev/null - if [ $? -ne 0 ]; then - Test_Info "IP $1 is not up" - return 1 - else - Test_Info "IP $1 is up" - return 0 - fi -} - -# function to find kernel/rootfs image -Test_Find_Image() -{ - where="" - kernel="" - arch="" - target="" - extension="" - rootfs="" - - while getopts "l:k:a:t:e:" Option - do - case $Option in - l) where="$OPTARG" - ;; - k) kernel="$OPTARG" - ;; - a) arch="$OPTARG" - ;; - t) target="$OPTARG" - ;; - e) extension="$OPTARG" - ;; - *) echo "invalid option: -$Option" && return 1 - ;; - esac - done - - if [ ! -z $kernel ]; then - if [ -L ${where}/${kernel}-${arch}.${extension} ]; then - echo ${where}/${kernel}-${arch}.${extension} - return 0 - else - for i in `dir ${where}`< |
