summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiajun Xu <jiajun.xu@intel.com>2011-05-03 10:07:30 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-05-04 00:56:33 +0100
commitea4857a98b500e0b73d875b28c43e2d1d0f740b6 (patch)
tree23cbe4dab67160a869b2689949720b10de1a3c99
parent49e2fcc60458853d7ff7f2908e695b11a95f3061 (diff)
downloadpoky-ea4857a98b500e0b73d875b28c43e2d1d0f740b6.tar.gz
qemuimagetest: Enable toolchain automation tests in qemuimagetest
Enable toolchain automation tests in qemuimagetest framework. 3 C/C++ test projects are added to test toolchain - cvs, iptables and sudoku-savant. User needs to set TEST_SCEN to "toolchain" in local.conf to enable tests. Test case will check if toolchain tarball exists under "${DEPLOY_DIR}/sdk". And it will extract toolchain tarball into /opt. It requires user to chown /opt to non-root user, who will run qemuimagetest. Signed-off-by Jiajun Xu <jiajun.xu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta-yocto/conf/local.conf.sample2
-rw-r--r--meta/classes/imagetest-qemu.bbclass9
-rw-r--r--meta/recipes-core/meta/meta-toolchain.bb3
-rwxr-xr-xscripts/qemuimage-testlib232
-rw-r--r--scripts/qemuimage-tests/scenario/qemuarm/meta-toolchain-gmae3
-rw-r--r--scripts/qemuimage-tests/scenario/qemumips/meta-toolchain-gmae3
-rw-r--r--scripts/qemuimage-tests/scenario/qemuppc/meta-toolchain-gmae3
-rw-r--r--scripts/qemuimage-tests/scenario/qemux86-64/meta-toolchain-gmae3
-rw-r--r--scripts/qemuimage-tests/scenario/qemux86/meta-toolchain-gmae3
-rw-r--r--scripts/qemuimage-tests/toolchain/cvs31
-rw-r--r--scripts/qemuimage-tests/toolchain/iptables31
-rw-r--r--scripts/qemuimage-tests/toolchain/sudoku-savant31
12 files changed, 349 insertions, 5 deletions
diff --git a/meta-yocto/conf/local.conf.sample b/meta-yocto/conf/local.conf.sample
index 740f54202b..5cf3b26080 100644
--- a/meta-yocto/conf/local.conf.sample
+++ b/meta-yocto/conf/local.conf.sample
@@ -175,7 +175,7 @@ ENABLE_BINARY_LOCALE_GENERATION = "1"
175# By default test cases in sanity suite will be ran. If you want to run other 175# By default test cases in sanity suite will be ran. If you want to run other
176# test suite or specific test case(e.g. bat or boot test case under sanity suite), 176# test suite or specific test case(e.g. bat or boot test case under sanity suite),
177# list them like following. 177# list them like following.
178#TEST_SCEN = "sanity bat sanity:boot" 178#TEST_SCEN = "sanity bat sanity:boot toolchain"
179 179
180#Because of the QEMU booting slowness issue(see bug #646 and #618), autobuilder 180#Because of the QEMU booting slowness issue(see bug #646 and #618), autobuilder
181#may suffer a timeout issue when running sanity test. We introduce variable 181#may suffer a timeout issue when running sanity test. We introduce variable
diff --git a/meta/classes/imagetest-qemu.bbclass b/meta/classes/imagetest-qemu.bbclass
index daeb8d8c9c..e259ae9baa 100644
--- a/meta/classes/imagetest-qemu.bbclass
+++ b/meta/classes/imagetest-qemu.bbclass
@@ -27,6 +27,7 @@ def qemuimagetest_main(d):
27 import sys 27 import sys
28 import re 28 import re
29 import os 29 import os
30 import shutil
30 31
31 """ 32 """
32 Test Controller for automated testing. 33 Test Controller for automated testing.
@@ -72,6 +73,7 @@ def qemuimagetest_main(d):
72 os.environ["TEST_STATUS"] = bb.data.getVar("TEST_STATUS", d, True) 73 os.environ["TEST_STATUS"] = bb.data.getVar("TEST_STATUS", d, True)
73 os.environ["TARGET_IPSAVE"] = bb.data.getVar("TARGET_IPSAVE", d, True) 74 os.environ["TARGET_IPSAVE"] = bb.data.getVar("TARGET_IPSAVE", d, True)
74 os.environ["TEST_SERIALIZE"] = bb.data.getVar("TEST_SERIALIZE", d, True) 75 os.environ["TEST_SERIALIZE"] = bb.data.getVar("TEST_SERIALIZE", d, True)
76 os.environ["SDK_NAME"] = bb.data.getVar("SDK_NAME", d, True)
75 77
76 """run Test Case""" 78 """run Test Case"""
77 bb.note("Run %s test in scenario %s" % (case, scen)) 79 bb.note("Run %s test in scenario %s" % (case, scen))
@@ -120,7 +122,10 @@ def qemuimagetest_main(d):
120 if os.path.isdir(tmppath): 122 if os.path.isdir(tmppath):
121 for f in os.listdir(tmppath): 123 for f in os.listdir(tmppath):
122 tmpfile = os.path.join(tmppath, f) 124 tmpfile = os.path.join(tmppath, f)
123 os.remove(tmpfile) 125 if os.path.isfile(tmpfile):
126 os.remove(tmpfile)
127 elif os.path.isdir(tmpfile):
128 shutil.rmtree(tmpfile, True)
124 129
125 """Before running testing, clean temp folder first""" 130 """Before running testing, clean temp folder first"""
126 clean_tmp() 131 clean_tmp()
@@ -154,7 +159,7 @@ def qemuimagetest_main(d):
154 os.system("touch %s" % resultfile) 159 os.system("touch %s" % resultfile)
155 os.symlink(resultfile, sresultfile) 160 os.symlink(resultfile, sresultfile)
156 f = open(sresultfile, "a") 161 f = open(sresultfile, "a")
157 f.write("\tTest Result for %s\n" % machine) 162 f.write("\tTest Result for %s %s\n" % (machine, pname))
158 f.write("\t%-15s%-15s%-15s%-15s\n" % ("Testcase", "PASS", "FAIL", "NORESULT")) 163 f.write("\t%-15s%-15s%-15s%-15s\n" % ("Testcase", "PASS", "FAIL", "NORESULT"))
159 f.close() 164 f.close()
160 165
diff --git a/meta/recipes-core/meta/meta-toolchain.bb b/meta/recipes-core/meta/meta-toolchain.bb
index 94c8a91a72..ab98bf99b2 100644
--- a/meta/recipes-core/meta/meta-toolchain.bb
+++ b/meta/recipes-core/meta/meta-toolchain.bb
@@ -6,6 +6,7 @@ PR = "r4"
6LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58 \ 6LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58 \
7 file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" 7 file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
8 8
9inherit populate_sdk 9IMAGETEST ?= "dummy"
10inherit populate_sdk imagetest-${IMAGETEST}
10 11
11CONFIG_SITE := "${@siteinfo_get_files(d)}" 12CONFIG_SITE := "${@siteinfo_get_files(d)}"
diff --git a/scripts/qemuimage-testlib b/scripts/qemuimage-testlib
index 5318ca636c..c39fb7ae21 100755
--- a/scripts/qemuimage-testlib
+++ b/scripts/qemuimage-testlib
@@ -19,6 +19,9 @@ TYPE="ext3"
19# The folder to hold all scripts running on targets 19# The folder to hold all scripts running on targets
20TOOLS="$COREBASE/scripts/qemuimage-tests/tools" 20TOOLS="$COREBASE/scripts/qemuimage-tests/tools"
21 21
22# The folder to hold all projects for toolchain testing
23TOOLCHAIN_PROJECTS="$COREBASE/scripts/qemuimage-tests/toolchain_projects"
24
22# Test Directory on target for testing 25# Test Directory on target for testing
23TARGET_TEST_DIR="/opt/test" 26TARGET_TEST_DIR="/opt/test"
24 27
@@ -28,6 +31,24 @@ PID=0
28# Global variable for target ip address 31# Global variable for target ip address
29TARGET_IPADDR=0 32TARGET_IPADDR=0
30 33
34# Global variable for test project version during toolchain test
35# Version of cvs is 1.11.23
36# Version of iptables is 1.4.9
37# Version of sudoku-savant is 1.3
38PROJECT_PV=0
39
40# Global variable for test project download URL during toolchain test
41# URL of cvs is http://ftp.gnu.org/non-gnu/cvs/source/stable/1.11.23/cvs-1.11.23.tar.bz2
42# URL of iptables is http://netfilter.org/projects/iptables/files/iptables-1.4.9.tar.bz2
43# URL of sudoku-savant is http://downloads.sourceforge.net/project/sudoku-savant/sudoku-savant/sudoku-savant-1.3/sudoku-savant-1.3.tar.bz2
44PROJECT_DOWNLOAD_URL=0
45
46# SDK folder to hold toolchain tarball
47TOOLCHAIN_DIR="${DEPLOY_DIR}/sdk"
48
49# Toolchain test folder to hold extracted toolchain tarball
50TOOLCHAIN_TEST="/opt"
51
31# common function for information print 52# common function for information print
32Test_Error() 53Test_Error()
33{ 54{
@@ -400,7 +421,7 @@ Test_Create_Qemu()
400 RUNQEMU=`which runqemu` 421 RUNQEMU=`which runqemu`
401 else 422 else
402 Test_Error "Can not find runqemu in \$PATH, return fail" 423 Test_Error "Can not find runqemu in \$PATH, return fail"
403 exit 1 424 return 1
404 fi 425 fi
405 426
406 if [ "$QEMUARCH" = "qemux86" -o "$QEMUARCH" = "qemux86-64" ]; then 427 if [ "$QEMUARCH" = "qemux86" -o "$QEMUARCH" = "qemux86-64" ]; then
@@ -499,3 +520,212 @@ Test_Create_Qemu()
499 return $ret 520 return $ret
500 fi 521 fi
501} 522}
523
524# Function to prepare test project for toolchain test
525# $1 is the folder holding test project file
526# $2 is the test project name
527Test_Project_Prepare()
528{
529 local toolchain_dir=$1
530 local ret=1
531
532 if [ ! -d ${toolchain_dir} ]; then
533 mkdir -p ${toolchain_dir}
534 ret=$?
535
536 if [ $ret -ne 0 ]; then
537 Test_Info "Create ${toolchain_dir} fail, return"
538 return $ret
539 fi
540 fi
541
542 ret=0
543 # Download test project tarball if it does not exist
544 if [ ! -f ${toolchain_dir}/${2}-${PROJECT_PV}.${suffix} ]; then
545 wget -c -t 5 $PROJECT_DOWNLOAD_URL -O ${toolchain_dir}/${2}-${PROJECT_PV}.${suffix}
546 ret=$?
547 fi
548
549 # Extract the test project into ${TEST_TMP}
550 if [ $ret -eq 0 ]; then
551 tar jxf ${toolchain_dir}/${2}-${PROJECT_PV}.${suffix} -C ${TEST_TMP}
552 ret=$?
553 if [ $ret -eq 0 ]; then
554 Test_Info "Extract ${2}-${PROJECT_PV}.${suffix} into ${TEST_TMP} successfully"
555 return $ret
556 else
557 Test_Info "Fail to extract ${2}-${PROJECT_PV}.${suffix} into ${TEST_TMP}"
558 return $ret
559 fi
560 else
561 Test_Info "Fail to download ${2}-${PROJECT_PV}.${suffix} from $PROJECT_DOWNLOAD_URL"
562 rm -rf ${toolchain_dir}/${2}-${PROJECT_PV}.${suffix}
563 return $ret
564 fi
565}
566
567# Function to prepare toolchain environment
568# $1 is toolchain directory to hold toolchain tarball
569# $2 is prefix name for toolchain tarball
570Test_Toolchain_Prepare()
571{
572 local toolchain_dir=$1
573 local sdk_name=$2
574 local ret=1
575
576 if [ ! -d ${toolchain_dir} ]; then
577 Test_Info "No directory ${toolchain_dir}, which holds toolchain tarballs"
578 return 1
579 fi
580
581 # Check if there is any toolchain tarball under $toolchain_dir with prefix $sdk_name
582 for i in `dir ${toolchain_dir}`
583 do
584 echo $i | grep "${sdk_name}-toolchain-gmae"
585 if [ $? -eq 0 ]; then
586 rm -rf ${TEST_TMP}/opt
587 tar jxf ${toolchain_dir}/${i} -C ${TEST_TMP}
588 ret=$?
589 break
590 fi
591 done
592
593 if [ $ret -eq 0 ]; then
594 Test_Info "Check if /opt is accessible for non-root user"
595
596 # Check if the non-root test user has write access of $TOOLCHAIN_TEST
597 if [ -d ${TOOLCHAIN_TEST} ]; then
598 touch ${TOOLCHAIN_TEST}
599 if [ $? -ne 0 ]; then
600 Test_Info "Has no right to modify folder $TOOLCHAIN_TEST, pls. chown it to test user"
601 return 2
602 fi
603 else
604 mkdir -p ${TOOLCHAIN_TEST}
605 if [ $? -ne 0 ]; then
606 Test_Info "Has no right to create folder $TOOLCHAIN_TEST, pls. create it and chown it to test user"
607 return 2
608 fi
609 fi
610
611 # If there is a toolchain folder under $TOOLCHAIN_TEST, let's remove it
612 if [ -d ${TOOLCHAIN_TEST}/poky ]; then
613 rm -rf ${TOOLCHAIN_TEST}/poky
614 fi
615
616 # Copy toolchain into $TOOLCHAIN_TEST
617 cp -r ${TEST_TMP}/opt/poky ${TOOLCHAIN_TEST}
618 ret=$?
619
620 if [ $ret -eq 0 ]; then
621 Test_Info "Successfully copy toolchain into $TOOLCHAIN_TEST"
622 return $ret
623 else
624 Test_Info "Meet error when copy toolchain into $TOOLCHAIN_TEST"
625 return $ret
626 fi
627 else
628 Test_Info "No tarball named ${sdk_name}-toolchain-gmae under ${toolchain_dir}"
629 return $ret
630 fi
631}
632
633# Function to execute command and exit if run out of time
634# $1 is timeout value
635# $2 is the command to be executed
636Test_Time_Out()
637{
638 local timeout=$1
639 shift
640 local command=$*
641 local date=0
642 local tmp=`mktemp`
643 local ret=1
644
645 # Run command in background
646 ($command; echo $? > $tmp) &
647 while ps -e -o pid | grep -qw $!; do
648 if [ $date -ge $timeout ]; then
649 Test_Info "$timeout Timeout when running command $command"
650 rm -rf $tmp
651 return 1
652 fi
653 sleep 5
654 date=`expr $date + 5`
655 done
656 ret=`cat $tmp`
657 rm -rf $tmp
658 return $ret
659}
660
661# Function to test toolchain
662# $1 is test project name
663# $2 is the timeout value
664Test_Toolchain()
665{
666 local test_project=$1
667 local timeout=$2
668 local ret=1
669 local suffix="tar.bz2"
670 local env_setup=""
671 local pro_install="${TEST_TMP}/pro_install"
672
673 # Set value for PROJECT_PV and PROJECT_DOWNLOAD_URL accordingly
674 if [ $test_project == "cvs" ]; then
675 PROJECT_PV=1.11.23
676 PROJECT_DOWNLOAD_URL="http://ftp.gnu.org/non-gnu/cvs/source/stable/1.11.23/cvs-1.11.23.tar.bz2"
677 elif [ $test_project == "iptables" ]; then
678 PROJECT_PV=1.4.9
679 PROJECT_DOWNLOAD_URL="http://netfilter.org/projects/iptables/files/iptables-1.4.9.tar.bz2"
680 elif [ $test_project == "sudoku-savant" ]; then
681 PROJECT_PV=1.3
682 PROJECT_DOWNLOAD_URL="http://downloads.sourceforge.net/project/sudoku-savant/sudoku-savant/sudoku-savant-1.3/sudoku-savant-1.3.tar.bz2"
683 else
684 Test_Info "Unknown test project name $test_project"
685 return 1
686 fi
687
688 # Download test project and extract it
689 Test_Project_Prepare $TOOLCHAIN_PROJECTS $test_project
690 if [ $? -ne 0 ]; then
691 Test_Info "Prepare test project file failed"
692 return 1
693 fi
694
695 # Extract toolchain tarball into ${TEST_TMP}
696 Test_Toolchain_Prepare $TOOLCHAIN_DIR $SDK_NAME
697 ret=$?
698 if [ $ret -ne 0 ]; then
699 Test_Info "Prepare toolchain test environment failed"
700 return $ret
701 fi
702
703 if [ ! -d ${pro_install} ]; then
704 mkdir -p ${pro_install}
705 fi
706
707 # Begin to build test project in toolchain environment
708 env_setup=`find ${TOOLCHAIN_TEST}/poky -name "environment-setup*"`
709
710 source $env_setup
711
712 if [ $test_project == "cvs" -o $test_project == "iptables" ]; then
713 cd ${TEST_TMP}/${test_project}-${PROJECT_PV}
714 Test_Time_Out $timeout ./configure ${CONFIGURE_FLAGS} || { Test_Info "configure failed with $test_project"; return 1; }
715 Test_Time_Out $timeout make -j4 || { Test_Info "make failed with $test_project"; return 1; }
716 Test_Time_Out $timeout make install DESTDIR=${pro_install} || { Test_Info "make failed with $test_project"; return 1; }
717 cd -
718 ret=0
719 elif [ $test_project == "sudoku-savant" ]; then
720 cd ${TEST_TMP}/${test_project}-${PROJECT_PV}
721 Test_Time_Out $timeout ./configure ${CONFIGURE_FLAGS} || { Test_Info "configure failed with $test_project"; return 1; }
722 Test_Time_Out $timeout make -j4 || { Test_Info "make failed with $test_project"; return 1; }
723 cd -
724 ret=0
725 else
726 Test_Info "Unknown test project $test_project"
727 ret=1
728 fi
729
730 return $ret
731}
diff --git a/scripts/qemuimage-tests/scenario/qemuarm/meta-toolchain-gmae b/scripts/qemuimage-tests/scenario/qemuarm/meta-toolchain-gmae
new file mode 100644
index 0000000000..199176efc8
--- /dev/null
+++ b/scripts/qemuimage-tests/scenario/qemuarm/meta-toolchain-gmae
@@ -0,0 +1,3 @@
1toolchain cvs
2toolchain iptables
3toolchain sudoku-savant
diff --git a/scripts/qemuimage-tests/scenario/qemumips/meta-toolchain-gmae b/scripts/qemuimage-tests/scenario/qemumips/meta-toolchain-gmae
new file mode 100644
index 0000000000..199176efc8
--- /dev/null
+++ b/scripts/qemuimage-tests/scenario/qemumips/meta-toolchain-gmae
@@ -0,0 +1,3 @@
1toolchain cvs
2toolchain iptables
3toolchain sudoku-savant
diff --git a/scripts/qemuimage-tests/scenario/qemuppc/meta-toolchain-gmae b/scripts/qemuimage-tests/scenario/qemuppc/meta-toolchain-gmae
new file mode 100644
index 0000000000..199176efc8
--- /dev/null
+++ b/scripts/qemuimage-tests/scenario/qemuppc/meta-toolchain-gmae
@@ -0,0 +1,3 @@
1toolchain cvs
2toolchain iptables
3toolchain sudoku-savant
diff --git a/scripts/qemuimage-tests/scenario/qemux86-64/meta-toolchain-gmae b/scripts/qemuimage-tests/scenario/qemux86-64/meta-toolchain-gmae
new file mode 100644
index 0000000000..199176efc8
--- /dev/null
+++ b/scripts/qemuimage-tests/scenario/qemux86-64/meta-toolchain-gmae
@@ -0,0 +1,3 @@
1toolchain cvs
2toolchain iptables
3toolchain sudoku-savant
diff --git a/scripts/qemuimage-tests/scenario/qemux86/meta-toolchain-gmae b/scripts/qemuimage-tests/scenario/qemux86/meta-toolchain-gmae
new file mode 100644
index 0000000000..199176efc8
--- /dev/null
+++ b/scripts/qemuimage-tests/scenario/qemux86/meta-toolchain-gmae
@@ -0,0 +1,3 @@
1toolchain cvs
2toolchain iptables
3toolchain sudoku-savant
diff --git a/scripts/qemuimage-tests/toolchain/cvs b/scripts/qemuimage-tests/toolchain/cvs
new file mode 100644
index 0000000000..871d99110f
--- /dev/null
+++ b/scripts/qemuimage-tests/toolchain/cvs
@@ -0,0 +1,31 @@
1#!/bin/bash
2#
3# CVS compile Test for toolchain test
4# The case extract toolchain tarball into temp folder
5# Then compile CVS with the toolchain environment
6#
7# Author: Jiajun Xu <jiajun.xu@intel.com>
8#
9# This file is licensed under the GNU General Public License,
10# Version 2.
11#
12. $COREBASE/scripts/qemuimage-testlib
13
14TIMEOUT=120
15
16# Extract and test toolchain tarball
17Test_Toolchain cvs ${TIMEOUT}
18
19if [ $? -eq 0 ]; then
20 Test_Info "CVS Test PASS"
21 Test_Print_Result "CVS" 0
22 exit 0
23elif [ $? -eq 1 ]; then
24 Test_Info "CVS Test FAIL"
25 Test_Print_Result "CVS" 1
26 exit 1
27else
28 Test_Info "Skip CVS Test due to some configuration problem"
29 Test_Print_Result "CVS" 2
30 exit 2
31fi
diff --git a/scripts/qemuimage-tests/toolchain/iptables b/scripts/qemuimage-tests/toolchain/iptables
new file mode 100644
index 0000000000..af89bbe7b3
--- /dev/null
+++ b/scripts/qemuimage-tests/toolchain/iptables
@@ -0,0 +1,31 @@
1#!/bin/bash
2#
3# iptables compile Test for toolchain test
4# The case extract toolchain tarball into temp folder
5# Then compile iptables with the toolchain environment
6#
7# Author: Jiajun Xu <jiajun.xu@intel.com>
8#
9# This file is licensed under the GNU General Public License,
10# Version 2.
11#
12. $COREBASE/scripts/qemuimage-testlib
13
14TIMEOUT=120
15
16# Extract and test toolchain tarball
17Test_Toolchain iptables ${TIMEOUT}
18
19if [ $? -eq 0 ]; then
20 Test_Info "iptables Test PASS"
21 Test_Print_Result "iptables" 0
22 exit 0
23elif [ $? -eq 1 ]; then
24 Test_Info "iptables Test FAIL"
25 Test_Print_Result "iptables" 1
26 exit 1
27else
28 Test_Info "Skip iptables Test due to some configuration problem"
29 Test_Print_Result "iptables" 2
30 exit 2
31fi
diff --git a/scripts/qemuimage-tests/toolchain/sudoku-savant b/scripts/qemuimage-tests/toolchain/sudoku-savant
new file mode 100644
index 0000000000..603afe63ee
--- /dev/null
+++ b/scripts/qemuimage-tests/toolchain/sudoku-savant
@@ -0,0 +1,31 @@
1#!/bin/bash
2#
3# sudoku-savant compile Test for toolchain test
4# The case extract toolchain tarball into temp folder
5# Then compile sudoku-savant with the toolchain environment
6#
7# Author: Jiajun Xu <jiajun.xu@intel.com>
8#
9# This file is licensed under the GNU General Public License,
10# Version 2.
11#
12. $COREBASE/scripts/qemuimage-testlib
13
14TIMEOUT=120
15
16# Extract and test toolchain tarball
17Test_Toolchain sudoku-savant ${TIMEOUT}
18
19if [ $? -eq 0 ]; then
20 Test_Info "sudoku-savant Test PASS"
21 Test_Print_Result "sudoku-savant" 0
22 exit 0
23elif [ $? -eq 1 ]; then
24 Test_Info "sudoku-savant Test FAIL"
25 Test_Print_Result "sudoku-savant" 1
26 exit 1
27else
28 Test_Info "Skip sudoku-savant Test due to some configuration problem"
29 Test_Print_Result "sudoku-savant" 2
30 exit 2
31fi