summaryrefslogtreecommitdiffstats
path: root/scripts/qemuimage-tests/tools
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/qemuimage-tests/tools')
-rw-r--r--scripts/qemuimage-tests/tools/compiler_test.sh137
-rw-r--r--scripts/qemuimage-tests/tools/connman_test.sh55
-rw-r--r--scripts/qemuimage-tests/tools/rpm_test.sh45
-rw-r--r--scripts/qemuimage-tests/tools/zypper_test.sh45
4 files changed, 282 insertions, 0 deletions
diff --git a/scripts/qemuimage-tests/tools/compiler_test.sh b/scripts/qemuimage-tests/tools/compiler_test.sh
new file mode 100644
index 0000000000..9c30d6d78b
--- /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
diff --git a/scripts/qemuimage-tests/tools/connman_test.sh b/scripts/qemuimage-tests/tools/connman_test.sh
new file mode 100644
index 0000000000..d7e63e7dba
--- /dev/null
+++ b/scripts/qemuimage-tests/tools/connman_test.sh
@@ -0,0 +1,55 @@
1#!/bin/bash
2# connman 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
10Target_Info()
11{
12 echo -e "\tTARGET: $*"
13}
14
15Target_Err()
16{
17 echo -e "\tTARGET: connman has issue when running, Pls. check the error log"
18 echo -e "\tTARGET: ##### Error Log #####"
19 $1
20 echo -e "\tTARGET: ##### End #####"
21}
22
23# Check if connmand is in target
24if [ ! -f /usr/sbin/connmand ]; then
25 Target_Info "No connmand command found"
26 exit 1
27fi
28
29# Check if connmand is running in background
30count=`ps -eo cmd | cut -d " " -f 1 | grep -c connmand`
31
32if [ $count -ne 1 ]; then
33 Target_Info "connmand has issue when running in background, Pls, check the output of ps"
34 ps -ef cmd | grep connmand
35 exit 1
36fi
37
38# Check if there is always only one connmand running in background
39if [ connmand > /dev/null 2>&1 ]; then
40 Target_Info "connmand command run without problem"
41 count=`ps -eo cmd | cut -d " " -f 1 | grep -c connmand`
42 if [ $count -ne 1 ]; then
43 Target_Info "There are more than one connmand running in background, Pls, check the output of ps"
44 ps -ef cmd | grep connmand
45 exit 1
46 else
47 Target_Info "There is always one connmand running in background, test pass"
48 exit 0
49 fi
50else
51 Target_Err connmand
52 exit 1
53fi
54
55exit 0
diff --git a/scripts/qemuimage-tests/tools/rpm_test.sh b/scripts/qemuimage-tests/tools/rpm_test.sh
new file mode 100644
index 0000000000..6e6f9112ca
--- /dev/null
+++ b/scripts/qemuimage-tests/tools/rpm_test.sh
@@ -0,0 +1,45 @@
1#!/bin/bash
2# rpm 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
10Target_Info()
11{
12 echo -e "\tTARGET: $*"
13}
14
15Target_Err()
16{
17 echo -e "\tTARGET: rpm command has issue when running, Pls. check the error log"
18 echo -e "\tTARGET: ##### Error Log #####"
19 $1
20 echo -e "\tTARGET: ##### End #####"
21}
22
23which rpm
24if [ $? -ne 0 ]; then
25 Target_Info "No rpm command found"
26 exit 1
27fi
28
29if [ rpm > /dev/null 2>&1 ]; then
30 Target_Info "rpm command run without problem"
31else
32 Target_Err rpm
33 exit 1
34fi
35
36# run rpm with specific command parsed to rpm_test.sh
37rpm $* > /dev/null 2>&1
38
39if [ $? -eq 0 ]; then
40 Target_Info "rpm $* work without problem"
41 exit 0
42else
43 Target_Err rpm $*
44 exit 1
45fi
diff --git a/scripts/qemuimage-tests/tools/zypper_test.sh b/scripts/qemuimage-tests/tools/zypper_test.sh
new file mode 100644
index 0000000000..5e8e7aaacf
--- /dev/null
+++ b/scripts/qemuimage-tests/tools/zypper_test.sh
@@ -0,0 +1,45 @@
1#!/bin/bash
2# zypper 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
10Target_Info()
11{
12 echo -e "\tTARGET: $*"
13}
14
15Target_Err()
16{
17 echo -e "\tTARGET: zypper command has issue when running, Pls. check the error log"
18 echo -e "\tTARGET: ##### Error Log #####"
19 $1
20 echo -e "\tTARGET: ##### End #####"
21}
22
23which zypper
24if [ $? -ne 0 ]; then
25 Target_Info "No zypper command found"
26 exit 1
27fi
28
29if [ zypper > /dev/null 2>&1 ]; then
30 Target_Info "zypper command run without problem"
31else
32 Target_Err zypper
33 exit 1
34fi
35
36# run zypper with specific command parsed to zypper_test.sh
37zypper $* > /dev/null 2>&1
38
39if [ $? -eq 0 ]; then
40 Target_Info "zypper $* work without problem"
41 exit 0
42else
43 Target_Err zypper $*
44 exit 1
45fi