summaryrefslogtreecommitdiffstats
path: root/scripts/qemuimage-testlib
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/qemuimage-testlib')
-rwxr-xr-xscripts/qemuimage-testlib760
1 files changed, 0 insertions, 760 deletions
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 @@
1#!/bin/bash
2# Common function for test
3# Expect should be installed for SSH Testing
4# To execute `runqemu`, NOPASSWD needs to be set in /etc/sudoers for user
5# For example, for user "builder", /etc/sudoers can be like following:
6# #########
7# #Members of the admin group may gain root privileges
8# %builder ALL=(ALL) NOPASSWD: NOPASSWD: ALL
9# #########
10#
11# Author: Jiajun Xu <jiajun.xu@intel.com>
12#
13# This file is licensed under the GNU General Public License,
14# Version 2.
15#
16
17# The folder to hold all scripts running on targets
18TOOLS="$COREBASE/scripts/qemuimage-tests/tools"
19
20# The folder to hold all projects for toolchain testing
21TOOLCHAIN_PROJECTS="$COREBASE/scripts/qemuimage-tests/toolchain_projects"
22
23# Test Directory on target for testing
24TARGET_TEST_DIR="/tmp/test"
25
26# Global variables for process id
27XTERMPID=0
28QEMUPID=0
29
30# Global variable for target ip address
31TARGET_IPADDR=0
32
33# Global variable for test project version during toolchain test
34# Version of cvs is 1.12.13
35# Version of iptables is 1.4.11
36# Version of sudoku-savant is 1.3
37PROJECT_PV=0
38
39# Global variable for test project download URL during toolchain test
40# URL of cvs is http://ftp.gnu.org/non-gnu/cvs/source/feature/1.12.13/cvs-1.12.13.tar.bz2
41# URL of iptables is http://netfilter.org/projects/iptables/files/iptables-1.4.11.tar.bz2
42# URL of sudoku-savant is http://downloads.sourceforge.net/project/sudoku-savant/sudoku-savant/sudoku-savant-1.3/sudoku-savant-1.3.tar.bz2
43PROJECT_DOWNLOAD_URL=0
44
45# SDK folder to hold toolchain tarball
46TOOLCHAIN_DIR="${DEPLOY_DIR}/sdk"
47
48# Toolchain test folder to hold extracted toolchain tarball
49TOOLCHAIN_TEST="/opt"
50
51# common function for information print
52Test_Error()
53{
54 echo -e "\tTest_Error: $*"
55}
56
57Test_Info()
58{
59 echo -e "\tTest_Info: $*"
60}
61
62# function to update target ip address
63# $1 is the process id of the process, which starts the qemu target
64# $2 is the ip address of the target
65Test_Update_IPSAVE()
66{
67 local pid=$1
68 local ip_addr=$2
69
70 if [ "$TEST_SERIALIZE" -eq 1 -a "$pid" != "0" -a "$pid" != "" -a "$ip_addr" != "" -a "$ip_addr" != "" ]; then
71 echo "Saving $pid $ip_addr to $TARGET_IPSAVE"
72 echo "$pid $ip_addr" > $TARGET_IPSAVE
73 fi
74}
75
76# function to copy files from host into target
77# $1 is the ip address of target
78# $2 is the files, which need to be copied into target
79# $3 is the path on target, where files are copied into
80Test_SCP()
81{
82 local ip_addr=$1
83 local src=$2
84 local des=$3
85 local time_out=60
86 local ret=0
87
88 # We use expect to interactive with target by ssh
89 local exp_cmd=`cat << EOF
90eval spawn scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "$src" root@$ip_addr:"$des"
91set timeout $time_out
92expect {
93 "*assword:" { send "\r"; exp_continue}
94 "*(yes/no)?" { send "yes\r"; exp_continue }
95 eof { exit [ lindex [wait] 3 ] }
96}
97EOF`
98
99 expect=`which expect`
100 if [ ! -x "$expect" ]; then
101 Test_Error "ERROR: Please install expect"
102 return 1
103 fi
104
105 expect -c "$exp_cmd"
106 ret=$?
107 return $ret
108}
109
110# function to copy files from target to host
111# $1 is the ip address of target
112# $2 is the files, which need to be copied into target
113# $3 is the path on target, where files are copied into
114Test_SCP_From()
115{
116 local ip_addr=$1
117 local src=$2
118 local des=$3
119 local time_out=60
120 local ret=0
121
122 # We use expect to interactive with target by ssh
123 local exp_cmd=`cat << EOF
124eval spawn scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$ip_addr:"$src" "$des"
125set timeout $time_out
126expect {
127 "*assword:" { send "\r"; exp_continue}
128 "*(yes/no)?" { send "yes\r"; exp_continue }
129 eof { exit [ lindex [wait] 3 ] }
130}
131EOF`
132
133 expect=`which expect`
134 if [ ! -x "$expect" ]; then
135 Test_Error "ERROR: Please install expect"
136 return 1
137 fi
138
139 expect -c "$exp_cmd"
140 ret=$?
141 return $ret
142}
143
144# function to run command in $ip_addr via ssh
145Test_SSH()
146{
147 local ip_addr="$1"
148 local command="$2"
149
150 if [ $# -eq 3 ]; then
151 local time_out=$3
152 else
153 local time_out=60
154 fi
155
156 local ret=0
157 local exp_cmd=`cat << EOF
158eval spawn ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@$ip_addr "$command"
159set timeout $time_out
160expect {
161 "*assword:" { send "\r"; exp_continue}
162 "*(yes/no)?" { send "yes\r"; exp_continue }
163 eof { exit [ lindex [wait] 3 ] }
164}
165EOF`
166
167 expect=`which expect`
168 if [ ! -x "$expect" ]; then
169 Test_Error "ERROR: Please install expect"
170 return 1
171 fi
172
173 expect -c "$exp_cmd"
174 ret=$?
175 return $ret
176}
177
178# function to check if ssh is up in $ip_addr
179Test_SSH_UP()
180{
181 local ip_addr=$1
182 local timeout=$2
183 local interval=0
184
185 # If TEST_SERIALIZE is set, use existing running qemu for testing
186 if [ ${TEST_SERIALIZE} -eq 1 -a -e ${TARGET_IPSAVE} ]; then
187 timeout=50
188 fi
189
190 while [ ${interval} -lt ${timeout} ]
191 do
192 Test_SSH ${ip_addr} "hostname"
193 if [ $? -ne 0 ]; then
194 interval=`expr $interval + 10`
195 sleep 10
196 else
197 Test_Info "We can ssh on ${ip_addr} within ${interval} seconds"
198 return 0
199 fi
200
201 done
202
203 Test_Info "We can not ssh on ${ip_addr} in ${timeout} seconds"
204 return 1
205}
206
207# function to prepare target test environment
208# $1 is the ip address of target system
209# $2 is the files, which needs to be copied into target
210Test_Target_Pre()
211{
212 local ip_addr=$1
213 local testscript=$2
214
215 # Create a pre-defined folder for test scripts
216 Test_SSH $ip_addr "mkdir -p $TARGET_TEST_DIR"
217 if [ $? -eq 0 ]; then
218 # Copy test scripts into target
219 Test_SCP $ip_addr $testscript $TARGET_TEST_DIR && return 0
220 else
221 Test_Error "Fail to create $TARGET_TEST_DIR on target"
222 return 1
223 fi
224
225 return 1
226}
227
228# function to record test result in $TEST_RESULT/testresult.log
229Test_Print_Result()
230{
231 local PASS=0
232 local FAIL=0
233 local NORESULT=0
234 if [ $2 -eq 0 ]; then
235 PASS=1
236 elif [ $2 -eq 1 ]; then
237 FAIL=1
238 else
239 NORESULT=1
240 fi
241
242 # Format the output of the test result
243 echo -e "$1 $PASS $FAIL $NORESULT" | awk '{printf("\t"); for(i=1;i<=NF;i++) printf("%-15s",$i); printf("\n");}' >> $TEST_RESULT/testresult.log
244}
245
246# Test_Kill_Qemu to kill child pid with parent pid given
247# $1 is qemu process id, which needs to be killed
248Test_Kill_Qemu()
249{
250 local index=0
251 local total=0
252 local k=0
253
254 # When TEST_SERIALIZE is set, qemu process will not be
255 # killed until all the cases are finished
256 if [ ${TEST_SERIALIZE} -eq 1 -a -e ${TEST_STATUS} ]; then
257 index=`sed -n 2p ${TEST_STATUS} | awk '{print $3}'`
258 total=`sed -n 2p ${TEST_STATUS} | awk '{print $4}'`
259 if [ ${index} != ${total} ]; then
260 Test_Info "Do not kill the qemu process and use it for later testing (step $index of $total)"
261 Test_Update_IPSAVE $XTERMPID $TARGET_IPADDR
262 else
263 k=1
264 fi
265 else
266 k=1
267 fi
268
269 if [ $k -eq 1 ]; then
270 if [ "$QEMUPID" != "0" -a "$QEMUPID" != "" ]; then
271 running=`ps -wwfp $QEMUPID`
272 if [ $? -eq 0 ]; then
273 echo "killing $QEMUPID"
274 kill $QEMUPID
275 fi
276 fi
277 if [ "$XTERMPID" != "0" -a "$XTERMPID" != "" ]; then
278 running=`ps -wwfp $XTERMPID`
279 if [ $? -eq 0 ]; then
280 echo "killing $XTERMPID"
281 kill $XTERMPID
282 fi
283 fi
284 fi
285
286 return
287}
288
289# function to check if network is up
290Test_Check_IP_UP()
291{
292 ping -c1 $1 1> /dev/null
293 if [ $? -ne 0 ]; then
294 Test_Info "IP $1 is not up"
295 return 1
296 else
297 Test_Info "IP $1 is up"
298 return 0
299 fi
300}
301
302# function to find kernel/rootfs image
303Test_Find_Image()
304{
305 where=""
306 kernel=""
307 arch=""
308 target=""
309 extension=""
310 rootfs=""
311
312 while getopts "l:k:a:t:e:" Option
313 do
314 case $Option in
315 l) where="$OPTARG"
316 ;;
317 k) kernel="$OPTARG"
318 ;;
319 a) arch="$OPTARG"
320 ;;
321 t) target="$OPTARG"
322 ;;
323 e) extension="$OPTARG"
324 ;;
325 *) echo "invalid option: -$Option" && return 1
326 ;;
327 esac
328 done
329
330 if [ ! -z $kernel ]; then
331 if [ -L ${where}/${kernel}-${arch}.${extension} ]; then
332 echo ${where}/${kernel}-${arch}.${extension}
333 return 0
334 else
335 for i in `dir ${where}`
336 do
337 # Exclude qemux86-64 when target is qemux86
338 echo $i | grep "${kernel}.*${arch}.*\.${extension}" | grep -qv "${kernel}.*${arch}-64.*\.${extension}"
339 if [ $? -eq 0 ]; then
340 echo ${where}/${i}
341 return 0
342 fi
343 done
344 return 1
345 fi
346 fi
347
348 if [ ! -z $target ]; then
349 if [ -L ${where}/${target}-${arch}.${extension} ]; then
350 rootfs=`readlink -f ${where}/${target}-${arch}.${extension}`
351 echo ${rootfs}
352 return 0
353 else
354 for i in `dir ${where}`
355 do
356 # Exclude qemux86-64 when target is qemux86
357 echo $i | grep "${target}-${arch}.*\.${extension}" | grep -qv "${target}-${arch}-64.*\.${extension}"
358 if [ $? -eq 0 ]; then
359 echo ${where}/${i}
360 return 0
361 fi
362 done
363 return 1
364 fi
365 fi
366 return 1
367}
368
369# function to parse IP address of target
370# $1 is the pid of qemu startup process
371Test_Fetch_Target_IP()
372{
373 local opid=$1
374 local ip_addr=0
375
376 if [ "$opid" = "0" -o "$opid" = "" ]; then
377 echo ""
378 return
379 fi
380
381 # Check if $1 pid exists and contains ipaddr of target
382 ip_addr=`ps -wwfp $opid | grep -o "192\.168\.7\.[0-9]*::" | awk -F":" '{print $1}'`
383
384 echo $ip_addr
385
386 return
387}
388
389# function to check if qemu and its network
390Test_Create_Qemu()
391{
392 local timeout=$1
393 shift
394 local extraargs="$@"
395 local up_time=0
396
397 RUNQEMU=`which runqemu`
398 if [ $? -ne 0 ]; then
399 Test_Error "Can not find runqemu in \$PATH, return fail"
400 return 1
401 fi
402
403 if [ "$QEMUARCH" = "qemux86" -o "$QEMUARCH" = "qemux86-64" ]; then
404 KERNEL=$(Test_Find_Image -l ${DEPLOY_DIR}/images -k bzImage -a ${QEMUARCH} -e "bin")
405 elif [ "$QEMUARCH" = "qemuarm" -o "$QEMUARCH" = "spitz" -o "$QEMUARCH" = "borzoi" -o "$QEMUARCH" = "akita" -o "$QEMUARCH" = "nokia800" ]; then
406 KERNEL=$(Test_Find_Image -l ${DEPLOY_DIR}/images -k zImage -a ${QEMUARCH})
407 elif [ "$QEMUARCH" = "qemumips" -o "$QEMUARCH" = "qemuppc" ]; then
408 KERNEL=$(Test_Find_Image -l ${DEPLOY_DIR}/images -k vmlinux -a ${QEMUARCH} -e "bin")
409 fi
410
411 # If there is no kernel image found, return failed directly
412 if [ $? -eq 1 ]; then
413 Test_Info "No kernel image file found under ${DEPLOY_DIR}/images for ${QEMUARCH}, pls. have a check"
414 return 1
415 fi
416
417 Test_Info "rootfs image extension selected: $ROOTFS_EXT"
418 ROOTFS_IMAGE=$(Test_Find_Image -l ${DEPLOY_DIR}/images -t ${QEMUTARGET} -a ${QEMUARCH} -e "$ROOTFS_EXT")
419
420 # If there is no rootfs image found, return failed directly
421 if [ $? -eq 1 ]; then
422 Test_Info "No ${QEMUTARGET} rootfs image file found under ${DEPLOY_DIR}/images for ${QEMUARCH}, pls. have a check"
423 return 1
424 fi
425
426 TEST_ROOTFS_IMAGE="${TEST_TMP}/${QEMUTARGET}-${QEMUARCH}-test.${ROOTFS_EXT}"
427
428 CP=`which cp`
429
430 # When TEST_SERIALIZE is set, we use the existing image under tmp folder
431 if [ ${TEST_SERIALIZE} -eq 1 -a -e "$TARGET_IPSAVE" ]; then
432 # If TARGET_IPSAVE exists, check PID of the qemu process from it
433 XTERMPID=`awk '{print $1}' $TARGET_IPSAVE`
434 timeout=50
435 else
436 rm -rf $TEST_ROOTFS_IMAGE
437 echo "Copying rootfs $ROOTFS_IMAGE to $TEST_ROOTFS_IMAGE"
438 $CP $ROOTFS_IMAGE $TEST_ROOTFS_IMAGE
439 if [ $? -ne 0 ]; then
440 Test_Info "Image ${ROOTFS_IMAGE} copy to ${TEST_ROOTFS_IMAGE} failed, return fail"
441 return 1
442 fi
443
444 export MACHINE=$QEMUARCH
445
446 # Create Qemu in localhost VNC Port 1
447 echo "Running xterm -display ${DISPLAY} -e 'OE_TMPDIR=${OE_TMPDIR} ${RUNQEMU} ${KERNEL} ${TEST_ROOTFS_IMAGE} ${extraargs} 2>&1 | tee ${RUNQEMU_LOGFILE} || /bin/sleep 60' &"
448 xterm -display ${DISPLAY} -e "OE_TMPDIR=${OE_TMPDIR} ${RUNQEMU} ${KERNEL} ${TEST_ROOTFS_IMAGE} ${extraargs} 2>&1 | tee ${RUNQEMU_LOGFILE} || /bin/sleep 60" &
449
450 # Get the pid of the xterm processor, which will be used in Test_Kill_Qemu
451 XTERMPID=$!
452 echo "XTERMPID is $XTERMPID"
453 # When starting, qemu can reexecute itself and change PID so wait a short while for things to settle
454 sleep 5
455 fi
456
457 while [ ${up_time} -lt 30 ]
458 do
459 QEMUPID=`qemuimage-testlib-pythonhelper --findqemu $XTERMPID 2>/dev/null`
460 if [ $? -ne 0 ]; then
461 Test_Info "Wait for qemu up..."
462 up_time=`expr $up_time + 5`
463 sleep 5
464 else
465 Test_Info "Begin to check if qemu network is up"
466 echo "QEMUPID is $QEMUPID"
467 break
468 fi
469 done
470
471 if [ ${up_time} == 30 ]; then
472 Test_Info "No qemu process appeared to start, exiting"
473 ps axww -O ppid
474 Test_Info "Process list dumped for debugging purposes"
475 Test_Info "runqemu output log:"
476 cat ${RUNQEMU_LOGFILE}
477 echo
478 return 1
479 fi
480
481 up_time=0
482 # Parse IP address of target from the qemu command line
483 TARGET_IPADDR=`Test_Fetch_Target_IP $QEMUPID`
484 echo "Target IP is ${TARGET_IPADDR}"
485 if [ "${TARGET_IPADDR}" = "" -o "${TARGET_IPADDR}" = "0" ]; then
486 Test_Info "There is no qemu process or qemu ip address found, return failed"
487 ps -wwf
488 ps axww -O ppid
489 Test_Info "runqemu output log:"
490 cat ${RUNQEMU_LOGFILE}
491 echo
492 return 1
493 fi
494
495 while [ ${up_time} -lt ${timeout} ]
496 do
497 Test_Check_IP_UP ${TARGET_IPADDR}
498 if [ $? -eq 0 ]; then
499 Test_Info "Qemu Network is up, ping with ${TARGET_IPADDR} is OK within ${up_time} seconds"
500 return 0
501 else
502 Test_Info "Wait for Qemu Network up"
503 up_time=`expr $up_time + 5`
504 sleep 5
505 fi
506 done
507
508 Test_Info "Process list dumped for debugging purposes:"
509 ps axww -O ppid
510 Test_Info "runqemu output log:"
511 cat ${RUNQEMU_LOGFILE}
512 Test_Info "Qemu or its network is not up in ${timeout} seconds"
513 Test_Update_IPSAVE $XTERMPID $TARGET_IPADDR
514 return 1
515}
516
517# Function to prepare test project for toolchain test
518# $1 is the folder holding test project file
519# $2 is the test project name
520Test_Project_Prepare()
521{
522 local toolchain_dir=$1
523
524 if [ ! -d ${toolchain_dir} ]; then
525 mkdir -p ${toolchain_dir}
526 if [ $? -ne 0 ]; then
527 ret=$?
528 Test_Info "Create ${toolchain_dir} fail, return"
529 return $ret
530 fi
531 fi
532
533 # Download test project tarball if it does not exist
534 if [ ! -f ${toolchain_dir}/${2}-${PROJECT_PV}.${suffix} ]; then
535 wget -c -t 5 $PROJECT_DOWNLOAD_URL -O ${toolchain_dir}/${2}-${PROJECT_PV}.${suffix}
536 if [ $? -ne 0 ]; then
537 ret=$?
538 Test_Info "Fail to download ${2}-${PROJECT_PV}.${suffix} from $PROJECT_DOWNLOAD_URL"
539 rm -rf ${toolchain_dir}/${2}-${PROJECT_PV}.${suffix}
540 return $ret
541 fi
542 fi
543
544 # Extract the test project into ${TEST_TMP}
545 tar jxf ${toolchain_dir}/${2}-${PROJECT_PV}.${suffix} -C ${TEST_TMP}
546 if [ $? -ne 0 ]; then
547 ret=$?
548 Test_Info "Fail to extract ${2}-${PROJECT_PV}.${suffix} into ${TEST_TMP}"
549 return $ret
550 fi
551 Test_Info "Extract ${2}-${PROJECT_PV}.${suffix} into ${TEST_TMP} successfully"
552 return 0
553}
554
555# Function to prepare toolchain environment
556# $1 is toolchain directory to hold toolchain tarball
557# $2 is prefix name for toolchain tarball
558Test_Toolchain_Prepare()
559{
560 local toolchain_dir=$1
561 local sdk_name=$2
562 local ret=1
563
564 if [ ! -d ${toolchain_dir} ]; then
565 Test_Info "No directory ${toolchain_dir}, which holds toolchain tarballs"
566 return 1
567 fi
568
569 # Check if there is any toolchain tarball under $toolchain_dir with prefix $sdk_name
570 for i in `dir ${toolchain_dir}`
571 do
572 echo $i | grep "${sdk_name}-toolchain-gmae"
573 if [ $? -eq 0 ]; then
574 rm -rf ${TEST_TMP}/opt
575 tar jxf ${toolchain_dir}/${i} -C ${TEST_TMP}
576 ret=$?
577 break
578 fi
579 done
580
581 if [ $ret -eq 0 ]; then
582 Test_Info "Check if /opt is accessible for non-root user"
583
584 # Check if the non-root test user has write access of $TOOLCHAIN_TEST
585 if [ -d ${TOOLCHAIN_TEST} ]; then
586 touch ${TOOLCHAIN_TEST}
587 if [ $? -ne 0 ]; then
588 Test_Info "Has no right to modify folder $TOOLCHAIN_TEST, pls. chown it to test user"
589 return 2
590 fi
591 else
592 mkdir -p ${TOOLCHAIN_TEST}
593 if [ $? -ne 0 ]; then
594 Test_Info "Has no right to create folder $TOOLCHAIN_TEST, pls. create it and chown it to test user"
595 return 2
596 fi
597 fi
598
599 # If there is a toolchain folder under $TOOLCHAIN_TEST, let's remove it
600 if [ -d ${TOOLCHAIN_TEST}/poky ]; then
601 rm -rf ${TOOLCHAIN_TEST}/poky
602 fi
603
604 # Copy toolchain into $TOOLCHAIN_TEST
605 cp -r ${TEST_TMP}/opt/poky ${TOOLCHAIN_TEST}
606 ret=$?
607
608 if [ $ret -eq 0 ]; then
609 Test_Info "Successfully copy toolchain into $TOOLCHAIN_TEST"
610 return $ret
611 else
612 Test_Info "Meet error when copy toolchain into $TOOLCHAIN_TEST"
613 return $ret
614 fi
615 else
616 Test_Info "No tarball named ${sdk_name}-toolchain-gmae under ${toolchain_dir}"
617 return $ret
618 fi
619}
620
621# Function to execute command and exit if run out of time
622# $1 is timeout value
623# $2 is the command to be executed
624Test_Time_Out()
625{
626 local timeout=$1
627 shift
628 local command=$*
629 local date=0
630 local tmp=`mktemp`
631 local ret=1
632 local pid=0
633 local ppid=0
634 local i=0
635 declare local pid_l
636
637 # Run command in background
638 ($command; echo $? > $tmp) &
639 pid=$!
640 while ps -e -o pid | grep -qw $pid; do
641 if [ $date -ge $timeout ]; then
642 Test_Info "$timeout Timeout when running command $command"
643 rm -rf $tmp
644
645 # Find all child processes of pid and kill them
646 ppid=$pid
647 ps -f --ppid $ppid
648 ret=$?
649
650 while [ $ret -eq 0 ]
651 do
652 # If yes, get the child pid and check if the child pid has other child pid
653 # Continue the while loop until there is no child pid found
654 pid_l[$i]=`ps -f --ppid $ppid | awk '{if ($2 != "PID") print $2}'`
655 ppid=${pid_l[$i]}
656 i=$((i+1))
657 ps -f --ppid $ppid
658 ret=$?
659 done
660
661 # Kill these children pids from the last one
662 while [ $i -ne 0 ]
663 do
664 i=$((i-1))
665 kill ${pid_l[$i]}
666 sleep 2
667 done
668
669 # Kill the parent id
670 kill $pid
671 return 1
672 fi
673 sleep 5
674 date=`expr $date + 5`
675 done
676 ret=`cat $tmp`
677 rm -rf $tmp
678 return $ret
679}
680
681# Function to test toolchain
682# $1 is test project name
683# $2 is the timeout value
684Test_Toolchain()
685{
686 local test_project=$1
687 local timeout=$2
688 local ret=1
689 local suffix="tar.bz2"
690 local env_setup=""
691 local pro_install="${TEST_TMP}/pro_install"
692
693 # Set value for PROJECT_PV and PROJECT_DOWNLOAD_URL accordingly
694 if [ $test_project == "cvs" ]; then
695 PROJECT_PV=1.12.13
696 PROJECT_DOWNLOAD_URL="http://ftp.gnu.org/non-gnu/cvs/source/feature/1.12.13/cvs-1.12.13.tar.bz2"
697 elif [ $test_project == "iptables" ]; then
698 PROJECT_PV=1.4.11
699 PROJECT_DOWNLOAD_URL="http://netfilter.org/projects/iptables/files/iptables-1.4.11.tar.bz2"
700 elif [ $test_project == "sudoku-savant" ]; then
701 PROJECT_PV=1.3
702 PROJECT_DOWNLOAD_URL="http://downloads.sourceforge.net/project/sudoku-savant/sudoku-savant/sudoku-savant-1.3/sudoku-savant-1.3.tar.bz2"
703 else
704 Test_Info "Unknown test project name $test_project"
705 return 1
706 fi
707
708 # Download test project and extract it
709 Test_Project_Prepare $TOOLCHAIN_PROJECTS $test_project
710 if [ $? -ne 0 ]; then
711 Test_Info "Prepare test project file failed"
712 return 1
713 fi
714
715 # Extract toolchain tarball into ${TEST_TMP}
716 Test_Toolchain_Prepare $TOOLCHAIN_DIR $SDK_NAME
717 ret=$?
718 if [ $ret -ne 0 ]; then
719 Test_Info "Prepare toolchain test environment failed"
720 return $ret
721 fi
722
723 if [ ! -d ${pro_install} ]; then
724 mkdir -p ${pro_install}
725 fi
726
727 # Begin to build test project in toolchain environment
728 env_setup=`find ${TOOLCHAIN_TEST}/poky -name "environment-setup*"`
729
730 source $env_setup
731
732 if [ $test_project == "cvs" -o $test_project == "iptables" ]; then
733 cd ${TEST_TMP}/${test_project}-${PROJECT_PV}
734 Test_Time_Out $timeout ./configure ${CONFIGURE_FLAGS} || { Test_Info "configure failed with $test_project"; return 1; }
735 Test_Time_Out $timeout make -j4 || { Test_Info "make failed with $test_project"; return 1; }
736 Test_Time_Out $timeout make install DESTDIR=${pro_install} || { Test_Info "make failed with $test_project"; return 1; }
737 cd -
738 ret=0
739 elif [ $test_project == "sudoku-savant" ]; then
740 cd ${TEST_TMP}/${test_project}-${PROJECT_PV}
741 Test_Time_Out $timeout ./configure ${CONFIGURE_FLAGS} || { Test_Info "configure failed with $test_project"; return 1; }
742 Test_Time_Out $timeout make -j4 || { Test_Info "make failed with $test_project"; return 1; }
743 cd -
744 ret=0
745 else
746 Test_Info "Unknown test project $test_project"
747 ret=1
748 fi
749
750 return $ret
751}
752
753Test_Display_Syslog()
754{
755 local tmplog=`mktemp`
756 Test_SCP_From ${TARGET_IPADDR} /var/log/messages $tmplog
757 echo "System logs:"
758 cat $tmplog
759 rm -f $tmplog
760}