summaryrefslogtreecommitdiffstats
path: root/scripts/qemuimage-tests
diff options
context:
space:
mode:
authorJiajun Xu <jiajun.xu@intel.com>2010-12-31 07:15:31 (GMT)
committerSaul Wold <sgw@linux.intel.com>2011-01-02 09:25:40 (GMT)
commit62caed8237baabd2b51d8f216f555880ae4a23c8 (patch)
treeca8d7e3230921912777781adce08de5f97a09af2 /scripts/qemuimage-tests
parentbcf8853e457f7ec43dfcaa91c66c0ae159565b53 (diff)
downloadpoky-62caed8237baabd2b51d8f216f555880ae4a23c8.tar.gz
qemuimagetest: Add basic function check for gcc/g++/make command in target
Add one case for compile tools sanity test in target, including gcc/g++/make. Signed-off-by Jiajun Xu <jiajun.xu@intel.com>
Diffstat (limited to 'scripts/qemuimage-tests')
-rwxr-xr-xscripts/qemuimage-tests/sanity/compiler52
-rw-r--r--scripts/qemuimage-tests/scenario/qemuarm/poky-image-sdk1
-rw-r--r--scripts/qemuimage-tests/scenario/qemumips/poky-image-sdk1
-rw-r--r--scripts/qemuimage-tests/scenario/qemuppc/poky-image-sdk1
-rw-r--r--scripts/qemuimage-tests/scenario/qemux86-64/poky-image-sdk1
-rw-r--r--scripts/qemuimage-tests/scenario/qemux86/poky-image-sdk1
-rw-r--r--scripts/qemuimage-tests/tools/compiler_test.sh137
7 files changed, 194 insertions, 0 deletions
diff --git a/scripts/qemuimage-tests/sanity/compiler b/scripts/qemuimage-tests/sanity/compiler
new file mode 100755
index 0000000..0290540
--- /dev/null
+++ b/scripts/qemuimage-tests/sanity/compiler
@@ -0,0 +1,52 @@
1#!/bin/bash
2# Compiler Test Case for Sanity Test
3# The case boot up the Qemu target with `poky-qemu qemuxxx`.
4# Then check if gcc/g++/make command can work in target.
5#
6# Author: Jiajun Xu <jiajun.xu@intel.com>
7#
8# This file is licensed under the GNU General Public License,
9# Version 2.
10#
11
12. $POKYBASE/scripts/qemuimage-testlib
13
14TIMEOUT=360
15RET=1
16
17# Start qemu and check its network
18Test_Create_Qemu ${TIMEOUT}
19
20# If qemu network is up, check ssh service in qemu
21if [ $? -eq 0 ]; then
22 Test_Info "Begin to Test SSH Service in Qemu"
23 Test_SSH_UP ${TARGET_IPADDR} ${TIMEOUT}
24 RET=$?
25else
26 RET=1
27fi
28
29# Check if gcc/g++/make can work in target
30if [ $RET -eq 0 -a -f $TOOLS/compiler_test.sh ]; then
31 # Copy compiler_test.sh into target
32 Test_Target_Pre ${TARGET_IPADDR} $TOOLS/compiler_test.sh
33 if [ $? -eq 0 ]; then
34 # Run compiler_test.sh to check if gcc/g++/make can work in target
35 Test_SSH ${TARGET_IPADDR} "sh $TARGET_TEST_DIR/compiler_test.sh"
36 RET=$?
37 else
38 RET=1
39 fi
40fi
41
42if [ ${RET} -eq 0 ]; then
43 Test_Info "Compiler Test PASS"
44 Test_Kill_Qemu
45 Test_Print_Result "compiler" 0
46 exit 0
47else
48 Test_Info "Compiler FAIL, Pls. check above error log"
49 Test_Kill_Qemu
50 Test_Print_Result "compiler" 1
51 exit 1
52fi
diff --git a/scripts/qemuimage-tests/scenario/qemuarm/poky-image-sdk b/scripts/qemuimage-tests/scenario/qemuarm/poky-image-sdk
index 32d2bd1..d18a9f7 100644
--- a/scripts/qemuimage-tests/scenario/qemuarm/poky-image-sdk
+++ b/scripts/qemuimage-tests/scenario/qemuarm/poky-image-sdk
@@ -6,3 +6,4 @@ sanity shutdown
6sanity zypper_help 6sanity zypper_help
7sanity zypper_search 7sanity zypper_search
8sanity rpm_query 8sanity rpm_query
9sanity compiler
diff --git a/scripts/qemuimage-tests/scenario/qemumips/poky-image-sdk b/scripts/qemuimage-tests/scenario/qemumips/poky-image-sdk
index 32d2bd1..d18a9f7 100644
--- a/scripts/qemuimage-tests/scenario/qemumips/poky-image-sdk
+++ b/scripts/qemuimage-tests/scenario/qemumips/poky-image-sdk
@@ -6,3 +6,4 @@ sanity shutdown
6sanity zypper_help 6sanity zypper_help
7sanity zypper_search 7sanity zypper_search
8sanity rpm_query 8sanity rpm_query
9sanity compiler
diff --git a/scripts/qemuimage-tests/scenario/qemuppc/poky-image-sdk b/scripts/qemuimage-tests/scenario/qemuppc/poky-image-sdk
index 32d2bd1..d18a9f7 100644
--- a/scripts/qemuimage-tests/scenario/qemuppc/poky-image-sdk
+++ b/scripts/qemuimage-tests/scenario/qemuppc/poky-image-sdk
@@ -6,3 +6,4 @@ sanity shutdown
6sanity zypper_help 6sanity zypper_help
7sanity zypper_search 7sanity zypper_search
8sanity rpm_query 8sanity rpm_query
9sanity compiler
diff --git a/scripts/qemuimage-tests/scenario/qemux86-64/poky-image-sdk b/scripts/qemuimage-tests/scenario/qemux86-64/poky-image-sdk
index 32d2bd1..d18a9f7 100644
--- a/scripts/qemuimage-tests/scenario/qemux86-64/poky-image-sdk
+++ b/scripts/qemuimage-tests/scenario/qemux86-64/poky-image-sdk
@@ -6,3 +6,4 @@ sanity shutdown
6sanity zypper_help 6sanity zypper_help
7sanity zypper_search 7sanity zypper_search
8sanity rpm_query 8sanity rpm_query
9sanity compiler
diff --git a/scripts/qemuimage-tests/scenario/qemux86/poky-image-sdk b/scripts/qemuimage-tests/scenario/qemux86/poky-image-sdk
index 32d2bd1..d18a9f7 100644
--- a/scripts/qemuimage-tests/scenario/qemux86/poky-image-sdk
+++ b/scripts/qemuimage-tests/scenario/qemux86/poky-image-sdk
@@ -6,3 +6,4 @@ sanity shutdown
6sanity zypper_help 6sanity zypper_help
7sanity zypper_search 7sanity zypper_search
8sanity rpm_query 8sanity rpm_query
9sanity compiler
diff --git a/scripts/qemuimage-tests/tools/compiler_test.sh b/scripts/qemuimage-tests/tools/compiler_test.sh
new file mode 100644
index 0000000..9c30d6d
--- /dev/null
+++ b/scripts/qemuimage-tests/tools/compiler_test.sh
@@ -0,0 +1,137 @@
1#!/bin/bash
2# compiler test script running in target
3#
4# Author: Jiajun Xu <jiajun.xu@intel.com>
5#
6# This file is licensed under the GNU General Public License,
7# Version 2.
8#
9
10# Prepare test folder for compiler test
11COMPILE_FOLDER="/opt/test/compile_test"
12TEST_FILE="$COMPILE_FOLDER/compile_test.c"
13EXECUTE_FILE="$COMPILE_FOLDER/compile_test"
14TEST_MAKEFILE="$COMPILE_FOLDER/makefile"
15TEST_LIST="gcc g++ make"
16
17if [ ! -d $COMPILE_FOLDER ]; then
18 mkdir -p $COMPILE_FOLDER
19fi
20
21Target_Info()
22{
23 echo -e "\tTARGET: $*"
24}
25
26Target_Err()
27{
28 echo -e "\tTARGET: ##### Error Log #####"
29 $@
30 echo -e "\tTARGET: ##### End #####"
31}
32
33# Function to generate a c test file for compiler testing
34Gen_File()
35{
36 temp=`mktemp`
37
38 # Generate c/c++ test file for compiler testing
39 echo "#include <stdio.h>" >> $temp
40 echo "#include <math.h>" >> $temp
41 echo "" >> $temp
42 echo "double" >> $temp
43 echo "convert(long long l)" >> $temp
44 echo "{" >> $temp
45 echo " return (double)l; // or double(l)" >> $temp
46 echo "}" >> $temp
47 echo "" >> $temp
48 echo "int" >> $temp
49 echo "main(int argc, char * argv[])" >> $temp
50 echo "{" >> $temp
51 echo " long long l = 10;" >> $temp
52 echo " double f;" >> $temp
53 echo "" >> $temp
54 echo " f = convert(l);" >> $temp
55 echo " printf(\"convert: %lld => %f\n\", l, f);" >> $temp
56 echo "" >> $temp
57 echo " f = 1234.67;" >> $temp
58 echo " printf(\"floorf(%f) = %f\n\", f, floorf(f));" >> $temp
59 echo " return 0;" >> $temp
60 echo "}" >> $temp
61 echo $temp
62}
63
64# Function to generate a makefile for compiler testing
65Gen_Makefile()
66{
67 temp=`mktemp`
68 basename=`basename $EXECUTE_FILE`
69
70 echo -e "$basename: $basename.o" >> $temp
71 echo -e "\tgcc -o $basename $basename.o -lm" >> $temp
72 echo -e "$basename.o: $basename.c" >> $temp
73 echo -e "\tgcc -c $basename.c" >> $temp
74
75 echo $temp
76}
77
78# Generate a c test file for compiler testing
79test_file=`Gen_File`
80
81MOVE=`which mv`
82$MOVE $test_file $TEST_FILE
83
84# Begin compiler test in target
85for cmd in $TEST_LIST
86do
87 which $cmd
88 if [ $? -ne 0 ]; then
89 Target_Info "No $cmd command found"
90 exit 1
91 fi
92
93 if [ "$cmd" == "make" ]; then
94 rm -rf $EXECUTE_FILE
95
96 # For makefile test, we need to generate a makefile and run with a c file
97 makefile=`Gen_Makefile`
98 $MOVE $makefile $TEST_MAKEFILE
99
100 cd `dirname $TEST_MAKEFILE`
101 make
102
103 if [ $? -ne 0 ]; then
104 Target_Info "$cmd running with error, Pls. check error in following"
105 Target_Err make
106 exit 1
107 fi
108 else
109 rm -rf $EXECUTE_FILE
110
111 # For gcc/g++, we compile a c test file and check the output
112 $cmd $TEST_FILE -o $EXECUTE_FILE -lm
113
114 if [ $? -ne 0 ]; then
115 Target_Info "$cmd running with error, Pls. check error in following"
116 Target_Err $cmd $TEST_FILE -o $EXECUTE_FILE -lm
117 exit 1
118 fi
119 fi
120
121 # Check if the binary file generated by $cmd can work without error
122 if [ -f $EXECUTE_FILE ]; then
123 $EXECUTE_FILE
124 if [ $? -ne 0 ]; then
125 Target_Info "$EXECUTE_FILE running with error, Pls. check error in following"
126 Target_Err $EXECUTE_FILE
127 exit 1
128 else
129 Target_Info "$cmd can work without problem in target"
130 fi
131 else
132 Target_Info "No executalbe file $EXECUTE_FILE found, Pls. check the error log"
133 exit 1
134 fi
135done
136
137exit 0