embedded-test.sh 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943
  1. #!/usr/bin/env mksh
  2. #
  3. # Copyright © 2014-2015
  4. # Waldemar Brodkorb <wbx@embedded-test.org>
  5. #
  6. # Provided that these terms and disclaimer and all copyright notices
  7. # are retained or reproduced in an accompanying document, permission
  8. # is granted to deal in this work without restriction, including un‐
  9. # limited rights to use, publicly perform, distribute, sell, modify,
  10. # merge, give away, or sublicence.
  11. #
  12. # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
  13. # the utmost extent permitted by applicable law, neither express nor
  14. # implied; without malicious intent or gross negligence. In no event
  15. # may a licensor, author or contributor be held liable for indirect,
  16. # direct, other damage, loss, or other issues arising in any way out
  17. # of dealing in the work, even if advised of the possibility of such
  18. # damage or existence of a defect, except proven that it results out
  19. # of said person’s immediate fault when using the work as intended.
  20. #
  21. # Alternatively, this work may be distributed under the Terms of the
  22. # General Public License, any version as published by the Free Soft‐
  23. # ware Foundation.
  24. # architecture specific notes:
  25. # sheb network card get no ip
  26. # uClibc-ng
  27. arch_list_uclibcng="armv5 armv7 armeb arcv1 arcv2 arcv1-be arcv2-be avr32 bfin c6x crisv10 crisv32 m68k m68k-nommu metag microblazeel microblazebe mips mipssf mipsel mipselsf mips64 mips64eln32 mips64n32 mips64n64 mips64el mips64el mips64eln64 or1k ppc ppcsf sh2 sh3 sh4 sh4eb sparc x86 x86_64 xtensa"
  28. # musl
  29. arch_list_musl="aarch64 armv5 armv7 armeb microblazeel microblazebe mips mipssf mipsel mipselsf or1k ppc sh4 sh4eb x86 x86_64"
  30. # glibc
  31. arch_list_glibc="aarch64 armv5 armv7 armeb ia64 microblazeel microblazebe mips mipssf mipsel mipselsf mips64 mips64eln32 mips64n32 mips64n64 mips64el mips64eln32 mips64eln64 nios2 ppc ppcsf ppc64 s390 sh4 sh4eb sparc sparc64 tile x86 x86_64"
  32. # newlib
  33. arch_list_newlib="armv5 armeb bfin crisv10 crisv32 frv lm32 m68k microblazeel mips mipsel or1k ppc sparc x86"
  34. topdir=$(pwd)
  35. giturl=http://git.openadk.org/openadk.git
  36. valid_libc="uclibc-ng musl glibc newlib"
  37. valid_tests="boot libc ltp mksh native"
  38. tools='make git wget xz cpio tar awk sed'
  39. f=0
  40. for tool in $tools; do
  41. if ! which $tool >/dev/null; then
  42. echo "Checking if $tool is installed... failed"
  43. f=1
  44. fi
  45. done
  46. if [ $f -eq 1 ];then exit 1; fi
  47. help() {
  48. cat >&2 <<EOF
  49. Syntax: $0 [ --libc=<libc> --arch=<arch> --tests=<tests> ]
  50. Explanation:
  51. --libc=<libc> c library to use (${valid_libc})
  52. --arch=<arch> architecture to check (otherwise all supported)
  53. --skiparch=<arch> architectures to skip when all choosen
  54. --tests=<tests> run tests (${valid_tests})
  55. --source=<dir> use directory with source for C library
  56. --ntp=<ntpserver> set NTP server for test run
  57. --packages=<packagelist> add extra packages to the build
  58. --update update OpenADK source via git pull, before building
  59. --continue continue on a broken build
  60. --cleandir clean OpenADK build directories before build
  61. --clean clean OpenADK build directory for single arch
  62. --debug enable debug output from OpenADK
  63. --shell start a shell instead auf autorun of test
  64. --help this help text
  65. EOF
  66. exit 1
  67. }
  68. cont=0
  69. clean=0
  70. cleandir=0
  71. shell=0
  72. update=0
  73. debug=0
  74. piggyback=0
  75. ntp=""
  76. libc=""
  77. while [[ $1 != -- && $1 = -* ]]; do case $1 {
  78. (--cleandir) cleandir=1; shift ;;
  79. (--clean) clean=1; shift ;;
  80. (--debug) debug=1; shift ;;
  81. (--update) update=1; shift ;;
  82. (--continue) cont=1; shift ;;
  83. (--shell) shell=1 shift ;;
  84. (--libc=*) libc=${1#*=}; shift ;;
  85. (--arch=*) archs=${1#*=}; shift ;;
  86. (--skiparch=*) skiparchs=${1#*=}; shift ;;
  87. (--tests=*) tests=${1#*=}; shift ;;
  88. (--source=*) source=${1#*=}; shift ;;
  89. (--ntp=*) ntp=${1#*=}; shift ;;
  90. (--help) help; shift ;;
  91. (--*) echo "unknown option $1"; exit 1 ;;
  92. (-*) help ;;
  93. }; done
  94. if [ -z "$libc" ];then
  95. libc="uclibc-ng musl glibc newlib"
  96. fi
  97. if [ ! -d openadk ];then
  98. git clone $giturl
  99. if [ $? -ne 0 ];then
  100. echo "Cloning from $giturl failed."
  101. exit 1
  102. fi
  103. else
  104. if [ $update -eq 1 ];then
  105. (cd openadk && git pull)
  106. if [ $? -ne 0 ];then
  107. echo "Updating from $giturl failed."
  108. exit 1
  109. fi
  110. fi
  111. fi
  112. runtest() {
  113. lib=$1
  114. arch=$2
  115. test=$3
  116. emulator=qemu
  117. qemu=qemu-system-${arch}
  118. qemu_args=-nographic
  119. if [ $ntp ]; then
  120. qemu_append="-append ntpserver=$ntp"
  121. fi
  122. if [ $shell -eq 1 ]; then
  123. qemu_append="-append shell"
  124. fi
  125. noappend=0
  126. piggyback=0
  127. suffix=
  128. libdir=lib
  129. march=${arch}
  130. case ${arch} in
  131. aarch64)
  132. cpu_arch=aarch64
  133. qemu_machine=virt
  134. qemu_args="${qemu_args} -cpu cortex-a57 -netdev user,id=eth0 -device virtio-net-device,netdev=eth0"
  135. ;;
  136. armv5)
  137. cpu_arch=arm
  138. march=arm-versatilepb
  139. qemu=qemu-system-${cpu_arch}
  140. qemu_machine=versatilepb
  141. suffix=soft_eabi
  142. dtbdir=openadk/firmware/qemu-${march}_${lib}_${cpu_arch}_${suffix}
  143. qemu_args="${qemu_args} -cpu arm926 -net user -net nic,model=smc91c111"
  144. ;;
  145. armv7)
  146. cpu_arch=arm
  147. march=arm-vexpress-a9
  148. qemu=qemu-system-${cpu_arch}
  149. qemu_machine=vexpress-a9
  150. suffix=hard_eabihf
  151. dtbdir=openadk/firmware/qemu-${march}_${lib}_${cpu_arch}_${suffix}
  152. qemu_args="${qemu_args} -cpu cortex-a9 -net user -net nic,model=lan9118 -dtb ${dtbdir}/vexpress-v2p-ca9.dtb"
  153. ;;
  154. arcv1|arcv2)
  155. emulator=nsim
  156. cpu_arch=arc
  157. piggyback=1
  158. ;;
  159. arcv1-be)
  160. emulator=nsim
  161. cpu_arch=arceb
  162. march=arcv1
  163. piggyback=1
  164. ;;
  165. arcv2-be)
  166. emulator=nsim
  167. cpu_arch=arceb
  168. march=arcv2
  169. piggyback=1
  170. ;;
  171. crisv32)
  172. cpu_arch=crisv32
  173. march=cris
  174. qemu=qemu-system-${march}
  175. qemu_machine=axis-dev88
  176. piggyback=1
  177. ;;
  178. metag)
  179. cpu_arch=metag
  180. qemu=qemu-system-meta
  181. qemu_args="-display none -device da,exit_threads=1 -chardev stdio,id=chan1 -chardev pty,id=chan2"
  182. qemu_machine=01sp
  183. piggyback=1
  184. ;;
  185. microblazeel)
  186. cpu_arch=microblazeel
  187. march=microblaze-ml605
  188. qemu_machine=petalogix-s3adsp1800
  189. ;;
  190. microblazebe)
  191. cpu_arch=microblaze
  192. march=microblaze-ml605
  193. qemu=qemu-system-${cpu_arch}
  194. qemu_machine=petalogix-s3adsp1800
  195. ;;
  196. mips)
  197. cpu_arch=mips
  198. qemu=qemu-system-${cpu_arch}
  199. qemu_machine=malta
  200. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  201. suffix=hard
  202. ;;
  203. mipssf)
  204. cpu_arch=mips
  205. march=mips
  206. qemu=qemu-system-${cpu_arch}
  207. qemu_machine=malta
  208. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  209. suffix=soft
  210. ;;
  211. mipsel)
  212. cpu_arch=mipsel
  213. march=mips
  214. qemu=qemu-system-${cpu_arch}
  215. qemu_machine=malta
  216. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  217. suffix=hard
  218. ;;
  219. mipselsf)
  220. cpu_arch=mipsel
  221. march=mips
  222. qemu=qemu-system-${cpu_arch}
  223. qemu_machine=malta
  224. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  225. suffix=soft
  226. ;;
  227. mips64)
  228. cpu_arch=mips64
  229. qemu_machine=malta
  230. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  231. suffix=o32
  232. ;;
  233. mips64n32)
  234. cpu_arch=mips64
  235. march=mips64
  236. qemu=qemu-system-${cpu_arch}
  237. qemu_machine=malta
  238. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  239. suffix=n32
  240. ;;
  241. mips64n64)
  242. cpu_arch=mips64
  243. march=mips64
  244. qemu=qemu-system-${cpu_arch}
  245. qemu_machine=malta
  246. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  247. suffix=n64
  248. ;;
  249. mips64el)
  250. cpu_arch=mips64el
  251. march=mips64
  252. qemu_machine=malta
  253. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  254. suffix=o32
  255. ;;
  256. mips64eln32)
  257. cpu_arch=mips64el
  258. march=mips64
  259. qemu=qemu-system-${cpu_arch}
  260. qemu_machine=malta
  261. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  262. suffix=n32
  263. ;;
  264. mips64eln64)
  265. cpu_arch=mips64el
  266. march=mips64
  267. qemu=qemu-system-${cpu_arch}
  268. qemu_machine=malta
  269. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  270. suffix=n64
  271. ;;
  272. ppcsf)
  273. cpu_arch=ppc
  274. march=ppc-bamboo
  275. qemu=qemu-system-${cpu_arch}
  276. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  277. qemu_machine=bamboo
  278. suffix=soft
  279. ;;
  280. ppc)
  281. cpu_arch=ppc
  282. march=ppc-macppc
  283. qemu=qemu-system-${cpu_arch}
  284. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  285. qemu_machine=mac99
  286. suffix=hard
  287. noappend=1
  288. ;;
  289. ppc64)
  290. cpu_arch=ppc64
  291. qemu=qemu-system-${cpu_arch}
  292. qemu_machine=pseries
  293. ;;
  294. s390)
  295. cpu_arch=s390x
  296. qemu=qemu-system-${cpu_arch}
  297. qemu_machine=s390-ccw-virtio-2.4
  298. ;;
  299. sh4)
  300. cpu_arch=sh4
  301. march=sh
  302. qemu=qemu-system-${cpu_arch}
  303. qemu_machine=r2d
  304. qemu_args="${qemu_args} -monitor null -serial null -serial stdio"
  305. ;;
  306. sh4eb)
  307. cpu_arch=sh4eb
  308. march=sh
  309. qemu=qemu-system-${cpu_arch}
  310. qemu_machine=r2d
  311. qemu_args="${qemu_args} -monitor null -serial null -serial stdio"
  312. ;;
  313. sparc)
  314. cpu_arch=sparc
  315. qemu_machine=SS-5
  316. ;;
  317. sparc64)
  318. cpu_arch=sparc64
  319. qemu_machine=sun4u
  320. qemu_args="${qemu_args} -net nic,model=e1000 -net user"
  321. ;;
  322. x86)
  323. cpu_arch=i686
  324. qemu=qemu-system-i386
  325. qemu_machine=pc
  326. qemu_args="${qemu_args}"
  327. ;;
  328. x86_64)
  329. cpu_arch=x86_64
  330. qemu_machine=pc
  331. libdir=lib64
  332. ;;
  333. x86_64_x32)
  334. cpu_arch=x86_64
  335. qemu=qemu-system-${cpu_arch}
  336. qemu_machine=pc
  337. libdir=libx32
  338. ;;
  339. xtensa)
  340. cpu_arch=xtensa
  341. qemu=qemu-system-${cpu_arch}
  342. qemu_machine=lx60
  343. qemu_args="${qemu_args} -cpu dc233c"
  344. ;;
  345. *)
  346. echo "architecture ${arch} not supported"; exit 1;;
  347. esac
  348. case $emulator in
  349. qemu)
  350. echo "Using QEMU as emulator"
  351. if ! which $qemu >/dev/null; then
  352. echo "Checking if $qemu is installed... failed"
  353. exit 1
  354. fi
  355. qemuver=$(${qemu} -version|awk '{ print $4 }')
  356. if [ "$arch" != "metag" ]; then
  357. if [ $(echo $qemuver |sed -e "s#\.##g" -e "s#,##") -lt 210 ];then
  358. echo "Your qemu version is too old. Please update to 2.1 or greater"
  359. exit 1
  360. fi
  361. fi
  362. ;;
  363. nsim)
  364. echo "Using Synopsys NSIM as simulator"
  365. if ! which nsimdrv >/dev/null; then
  366. echo "Checking if $emulator is installed... failed"
  367. exit 1
  368. fi
  369. ;;
  370. *)
  371. echo "emulator/simulator not supported"; exit 1;;
  372. esac
  373. echo "Starting test for $lib and $arch"
  374. # check if initramfs or piggyback is used
  375. if [ $piggyback -eq 1 ]; then
  376. echo "Using extra directory for test image creation"
  377. root=openadk/extra
  378. rm -rf openadk/extra 2>/dev/null
  379. mkdir openadk/extra 2>/dev/null
  380. if [ ! -z $suffix ]; then
  381. kernel=openadk/firmware/${emulator}-${march}_${lib}_${cpu_arch}_${suffix}/${emulator}-${march}-initramfspiggyback-kernel
  382. else
  383. kernel=openadk/firmware/${emulator}-${march}_${lib}_${cpu_arch}/${emulator}-${march}-initramfspiggyback-kernel
  384. fi
  385. else
  386. echo "Generating root filesystem for test run"
  387. root=$(mktemp -d /tmp/XXXX)
  388. if [ ! -z $suffix ]; then
  389. archive=openadk/firmware/${emulator}-${march}_${lib}_${cpu_arch}_${suffix}/qemu-${march}-${lib}-initramfsarchive.tar.xz
  390. kernel=openadk/firmware/${emulator}-${march}_${lib}_${cpu_arch}_${suffix}/qemu-${march}-initramfsarchive-kernel
  391. else
  392. archive=openadk/firmware/${emulator}-${march}_${lib}_${cpu_arch}/${emulator}-${march}-${lib}-initramfsarchive.tar.xz
  393. kernel=openadk/firmware/${emulator}-${march}_${lib}_${cpu_arch}/${emulator}-${march}-initramfsarchive-kernel
  394. fi
  395. if [ ! -f $archive ];then
  396. echo "No root filesystem available for architecture ${arch} tried $archive"
  397. exit 1
  398. fi
  399. tar -xf $archive -C $root
  400. fi
  401. # creating test script to be run on boot
  402. cat > ${root}/run.sh << EOF
  403. #!/bin/sh
  404. uname -a
  405. if [ \$ntpserver ]; then
  406. rdate \$ntpserver
  407. else
  408. rdate time.fu-berlin.de
  409. fi
  410. EOF
  411. if [ $test = "boot" ];then
  412. cat >> ${root}/run.sh << EOF
  413. file /bin/busybox
  414. size /bin/busybox
  415. for i in \$(ls /lib/*.so|grep -v libgcc);do
  416. size \$i
  417. done
  418. exit
  419. EOF
  420. fi
  421. if [ $test = "ltp" ];then
  422. cat >> ${root}/run.sh << EOF
  423. /opt/ltp/runltp
  424. exit
  425. EOF
  426. fi
  427. if [ $test = "mksh" ];then
  428. cat >> ${root}/run.sh << EOF
  429. mksh /opt/mksh/test.sh
  430. exit
  431. EOF
  432. fi
  433. if [ $test = "libc" ];then
  434. case $lib in
  435. uclibc-ng)
  436. cat >> ${root}/run.sh << EOF
  437. cd /opt/uclibc-ng/test
  438. sh ./uclibcng-testrunner.sh
  439. exit
  440. EOF
  441. ;;
  442. musl|glibc)
  443. cat >> ${root}/run.sh << EOF
  444. cd /opt/libc-test
  445. CC=: make run
  446. exit
  447. EOF
  448. ;;
  449. esac
  450. fi
  451. chmod u+x ${root}/run.sh
  452. if [ $piggyback -eq 1 ]; then
  453. (cd openadk && make v)
  454. else
  455. echo "Creating initramfs filesystem"
  456. (cd $root; find . | cpio -o -C512 -Hnewc |xz --check=crc32 --stdout > ${topdir}/initramfs.${arch})
  457. rm -rf $root
  458. qemu_args="$qemu_args -initrd initramfs.${arch}"
  459. fi
  460. # qemu-ppc overwrites existing commandline
  461. if [ $noappend -eq 0 ]; then
  462. qemu_args="$qemu_args ${qemu_append}"
  463. fi
  464. echo "Now running the test ${test} in ${emulator} for architecture ${arch} and ${lib}"
  465. case $emulator in
  466. qemu)
  467. echo "${qemu} -M ${qemu_machine} ${qemu_args} -kernel ${kernel} -qmp tcp:127.0.0.1:4444,server,nowait -no-reboot"
  468. ${qemu} -M ${qemu_machine} ${qemu_args} -kernel ${kernel} -qmp tcp:127.0.0.1:4444,server,nowait -no-reboot | tee REPORT.${arch}.${test}.${libver}
  469. ;;
  470. nsim)
  471. echo "./openadk/scripts/nsim.sh ${arch} ${kernel}"
  472. ./openadk/scripts/nsim.sh ${arch} ${kernel} | tee REPORT.${arch}.${test}.${libver}
  473. ;;
  474. esac
  475. if [ $? -eq 0 ];then
  476. echo "Test ${test} for ${arch} finished. See REPORT.${arch}.${test}.${libver}"
  477. echo
  478. else
  479. echo "Test ${test} failed for ${arch} with ${lib} ${libver}."
  480. echo
  481. fi
  482. }
  483. compile() {
  484. rm .config* .defconfig 2>/dev/null
  485. make $1 defconfig
  486. for pkg in $pkgs; do p=$(echo $pkg|tr '[:lower:]' '[:upper:]');printf "ADK_COMPILE_$p=y\nADK_PACKAGE_$p=y" >> .config;done
  487. make $1 all
  488. }
  489. build() {
  490. lib=$1
  491. arch=$2
  492. test=$3
  493. cd openadk
  494. make prereq
  495. # rebuild uClibc-ng package to get test-suite
  496. if [ "$lib" = "uclibc-ng" ]; then
  497. make package=$lib clean
  498. fi
  499. DEFAULT="ADK_TARGET_LIBC=$lib"
  500. if [ $debug -eq 1 ];then
  501. DEFAULT="$DEFAULT ADK_VERBOSE=1"
  502. fi
  503. if [ $test = "boot" ];then
  504. DEFAULT="$DEFAULT ADK_TEST_BASE=y"
  505. fi
  506. if [ $test = "ltp" ];then
  507. DEFAULT="$DEFAULT ADK_TEST_LTP=y"
  508. fi
  509. if [ $test = "mksh" ];then
  510. DEFAULT="$DEFAULT ADK_TEST_MKSH=y"
  511. fi
  512. if [ $test = "libc" ];then
  513. case $lib in
  514. uclibc-ng)
  515. DEFAULT="$DEFAULT ADK_TEST_UCLIBC_NG_TESTSUITE=y"
  516. ;;
  517. glibc)
  518. DEFAULT="$DEFAULT ADK_TEST_GLIBC_TESTSUITE=y"
  519. ;;
  520. musl)
  521. DEFAULT="$DEFAULT ADK_TEST_MUSL_TESTSUITE=y"
  522. ;;
  523. esac
  524. fi
  525. if [ $test = "native" ];then
  526. case $lib in
  527. uclibc-ng)
  528. DEFAULT="$DEFAULT ADK_TEST_UCLIBC_NG_NATIVE=y"
  529. ;;
  530. musl)
  531. DEFAULT="$DEFAULT ADK_TEST_MUSL_NATIVE=y"
  532. ;;
  533. glibc)
  534. DEFAULT="$DEFAULT ADK_TEST_GLIBC_NATIVE=y"
  535. ;;
  536. esac
  537. fi
  538. case $arch in
  539. aarch64)
  540. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=aarch64 ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-aarch64"
  541. compile "$DEFAULT"
  542. ;;
  543. arcv1)
  544. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=arc ADK_TARGET_FS=initramfspiggyback ADK_TARGET_SYSTEM=nsim-arcv1 ADK_TARGET_ENDIAN=little"
  545. compile "$DEFAULT"
  546. ;;
  547. arcv2)
  548. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=arc ADK_TARGET_FS=initramfspiggyback ADK_TARGET_SYSTEM=nsim-arcv2 ADK_TARGET_ENDIAN=little"
  549. compile "$DEFAULT"
  550. ;;
  551. arcv1-be)
  552. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=arc ADK_TARGET_FS=initramfspiggyback ADK_TARGET_SYSTEM=nsim-arcv1 ADK_TARGET_ENDIAN=big"
  553. compile "$DEFAULT"
  554. ;;
  555. arcv2-be)
  556. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=arc ADK_TARGET_FS=initramfspiggyback ADK_TARGET_SYSTEM=nsim-arcv2 ADK_TARGET_ENDIAN=big"
  557. compile "$DEFAULT"
  558. ;;
  559. armv5)
  560. if [ "$lib" = "newlib" ]; then
  561. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=arm ADK_TARGET_ENDIAN=little ADK_TARGET_SYSTEM=toolchain-arm"
  562. else
  563. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=arm ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-arm-versatilepb"
  564. fi
  565. compile "$DEFAULT"
  566. ;;
  567. armeb)
  568. if [ "$lib" = "newlib" ]; then
  569. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=arm ADK_TARGET_ENDIAN=big ADK_TARGET_SYSTEM=toolchain-arm"
  570. else
  571. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=arm ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=toolchain-arm ADK_TARGET_FLOAT=soft ADK_TARGET_ENDIAN=big"
  572. fi
  573. compile "$DEFAULT"
  574. ;;
  575. armv7)
  576. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=arm ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-arm-vexpress-a9"
  577. compile "$DEFAULT"
  578. ;;
  579. avr32)
  580. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=avr32 ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=toolchain-avr32"
  581. compile "$DEFAULT"
  582. ;;
  583. bfin)
  584. if [ "$lib" = "newlib" ]; then
  585. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=bfin ADK_TARGET_SYSTEM=toolchain-bfin"
  586. else
  587. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=bfin ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=toolchain-bfin"
  588. fi
  589. compile "$DEFAULT"
  590. ;;
  591. c6x)
  592. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=c6x ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=toolchain-c6x"
  593. compile "$DEFAULT"
  594. ;;
  595. crisv10)
  596. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=cris ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=toolchain-cris ADK_TARGET_CPU=crisv10"
  597. compile "$DEFAULT"
  598. ;;
  599. crisv32)
  600. if [ "$lib" = "newlib" ]; then
  601. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=cris ADK_TARGET_ENDIAN=little ADK_TARGET_SYSTEM=toolchain-cris ADK_TARGET_CPU=crisv32"
  602. else
  603. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=cris ADK_TARGET_FS=initramfspiggyback ADK_TARGET_SYSTEM=qemu-cris"
  604. fi
  605. compile "$DEFAULT"
  606. ;;
  607. ia64)
  608. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=ia64 ADK_TARGET_SYSTEM=toolchain-ia64"
  609. compile "$DEFAULT"
  610. ;;
  611. h8300)
  612. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=h8300 ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=toolchain-h8300"
  613. compile "$DEFAULT"
  614. ;;
  615. lm32)
  616. if [ "$lib" = "newlib" ]; then
  617. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=$arch ADK_TARGET_SYSTEM=toolchain-$arch"
  618. else
  619. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=$arch ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-$arch"
  620. fi
  621. compile "$DEFAULT"
  622. ;;
  623. m68k)
  624. if [ "$lib" = "newlib" ]; then
  625. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=m68k ADK_TARGET_SYSTEM=toolchain-m68k"
  626. else
  627. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=m68k ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-m68k-q800"
  628. fi
  629. compile "$DEFAULT"
  630. ;;
  631. m68k-nommu)
  632. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=m68k ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-m68k-mcf5208"
  633. compile "$DEFAULT"
  634. ;;
  635. metag)
  636. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=metag ADK_TARGET_FS=initramfspiggyback ADK_TARGET_SYSTEM=qemu-metag"
  637. compile "$DEFAULT"
  638. ;;
  639. microblazebe)
  640. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=microblaze ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-microblaze-ml605 ADK_TARGET_ENDIAN=big"
  641. compile "$DEFAULT"
  642. ;;
  643. microblazeel)
  644. if [ "$lib" = "newlib" ]; then
  645. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=microblaze ADK_TARGET_SYSTEM=toolchain-microblaze ADK_TARGET_ENDIAN=little"
  646. else
  647. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=microblaze ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-microblaze-ml605 ADK_TARGET_ENDIAN=little"
  648. fi
  649. compile "$DEFAULT"
  650. ;;
  651. mips)
  652. if [ "$lib" = "newlib" ]; then
  653. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=mips ADK_TARGET_SYSTEM=toolchain-mips ADK_TARGET_ENDIAN=big"
  654. else
  655. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=mips ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-mips ADK_TARGET_ENDIAN=big ADK_TARGET_FLOAT=hard"
  656. fi
  657. compile "$DEFAULT"
  658. ;;
  659. mipssf)
  660. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=mips ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-mips ADK_TARGET_ENDIAN=big ADK_TARGET_FLOAT=soft"
  661. compile "$DEFAULT"
  662. ;;
  663. mipsel)
  664. if [ "$lib" = "newlib" ]; then
  665. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=mips ADK_TARGET_SYSTEM=toolchain-mips ADK_TARGET_ENDIAN=little"
  666. else
  667. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=mips ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-mips ADK_TARGET_ENDIAN=little ADK_TARGET_FLOAT=hard"
  668. fi
  669. compile "$DEFAULT"
  670. ;;
  671. mipselsf)
  672. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=mips ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-mips ADK_TARGET_ENDIAN=little ADK_TARGET_FLOAT=soft"
  673. compile "$DEFAULT"
  674. ;;
  675. mips64)
  676. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=mips64 ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=big ADK_TARGET_ABI=o32"
  677. compile "$DEFAULT"
  678. ;;
  679. mips64n32)
  680. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=mips64 ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=big ADK_TARGET_ABI=n32"
  681. compile "$DEFAULT"
  682. ;;
  683. mips64n64)
  684. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=mips64 ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=big ADK_TARGET_ABI=n64"
  685. compile "$DEFAULT"
  686. ;;
  687. mips64el)
  688. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=mips64 ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=little ADK_TARGET_ABI=o32"
  689. compile "$DEFAULT"
  690. ;;
  691. mips64eln32)
  692. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=mips64 ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=little ADK_TARGET_ABI=n32"
  693. compile "$DEFAULT"
  694. ;;
  695. mips64eln64)
  696. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=mips64 ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=little ADK_TARGET_ABI=n64"
  697. compile "$DEFAULT"
  698. ;;
  699. nios2)
  700. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=nios2 ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=toolchain-nios2"
  701. compile "$DEFAULT"
  702. ;;
  703. or1k)
  704. if [ "$lib" = "newlib" ]; then
  705. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=$arch ADK_TARGET_SYSTEM=toolchain-$arch"
  706. else
  707. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=or1k ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=toolchain-or1k"
  708. fi
  709. compile "$DEFAULT"
  710. ;;
  711. ppc)
  712. if [ "$lib" = "newlib" ]; then
  713. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=ppc ADK_TARGET_SYSTEM=toolchain-ppc"
  714. else
  715. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=ppc ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-ppc-macppc ADK_TARGET_FLOAT=hard"
  716. fi
  717. compile "$DEFAULT"
  718. ;;
  719. ppcsf)
  720. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=ppc ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-ppc-bamboo ADK_TARGET_FLOAT=soft"
  721. compile "$DEFAULT"
  722. ;;
  723. ppc64)
  724. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=ppc64 ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-ppc64 ADK_TARGET_ENDIAN=big"
  725. compile "$DEFAULT"
  726. ;;
  727. s390)
  728. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=s390 ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-s390"
  729. compile "$DEFAULT"
  730. ;;
  731. sh2)
  732. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=sh ADK_TARGET_SYSTEM=toolchain-sh ADK_TARGET_CPU=sh2"
  733. compile "$DEFAULT"
  734. ;;
  735. sh3)
  736. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=sh ADK_TARGET_SYSTEM=toolchain-sh ADK_TARGET_CPU=sh3"
  737. compile "$DEFAULT"
  738. ;;
  739. sh4)
  740. if [ "$lib" = "newlib" ]; then
  741. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=sh ADK_TARGET_SYSTEM=toolchain-sh ADK_TARGET_CPU=sh4"
  742. else
  743. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=sh ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-sh ADK_TARGET_ENDIAN=little"
  744. fi
  745. compile "$DEFAULT"
  746. ;;
  747. sh4eb)
  748. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=sh ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-sh ADK_TARGET_ENDIAN=big"
  749. compile "$DEFAULT"
  750. ;;
  751. sparc|sparc64)
  752. if [ "$lib" = "newlib" ]; then
  753. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=$arch ADK_TARGET_SYSTEM=toolchain-$arch"
  754. else
  755. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=$arch ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-$arch"
  756. fi
  757. compile "$DEFAULT"
  758. ;;
  759. tile)
  760. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=tile ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=toolchain-tile"
  761. compile "$DEFAULT"
  762. ;;
  763. x86|x86_64)
  764. if [ "$lib" = "newlib" ]; then
  765. DEFAULT="$DEFAULT ADK_APPLIANCE=new ADK_TARGET_ARCH=$arch ADK_TARGET_SYSTEM=toolchain-$arch"
  766. else
  767. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=$arch ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-$arch"
  768. fi
  769. compile "$DEFAULT"
  770. ;;
  771. *)
  772. DEFAULT="$DEFAULT ADK_APPLIANCE=test ADK_TARGET_ARCH=$arch ADK_TARGET_FS=initramfsarchive ADK_TARGET_SYSTEM=qemu-$arch"
  773. compile "$DEFAULT"
  774. ;;
  775. esac
  776. if [ $? -ne 0 ];then
  777. echo "build failed"
  778. exit 1
  779. fi
  780. cd ..
  781. }
  782. for lib in ${libc}; do
  783. case $lib in
  784. uclibc-ng)
  785. archlist=$arch_list_uclibcng
  786. version=1.0.9
  787. libver=uClibc-ng-${version}
  788. libdir=uClibc-ng
  789. ;;
  790. glibc)
  791. archlist=$arch_list_glibc
  792. version=2.22
  793. libver=glibc-${version}
  794. libdir=glibc
  795. ;;
  796. musl)
  797. archlist=$arch_list_musl
  798. version=1.1.12
  799. libver=musl-${version}
  800. libdir=musl
  801. ;;
  802. newlib)
  803. archlist=$arch_list_newlib
  804. version=2.2.0
  805. libver=newlib-${version}
  806. libdir=newlib
  807. ;;
  808. *)
  809. echo "$lib not supported"
  810. exit 1
  811. ;;
  812. esac
  813. if [ ! -z $archs ]; then
  814. archlist="$archs"
  815. fi
  816. if [ ! -z $source ]; then
  817. if [ ! -d $source ]; then
  818. echo "Not a directory."
  819. exit 1
  820. fi
  821. usrc=$(mktemp -d /tmp/XXXX)
  822. echo "Creating source tarball openadk/dl/${libver}.tar.xz"
  823. cp -a $source $usrc/$libver
  824. mkdir -p $topdir/openadk/dl 2>/dev/null
  825. rm $topdir/openadk/dl/${libver}.tar.xz 2>/dev/null
  826. (cd $usrc && tar cJf $topdir/openadk/dl/${libver}.tar.xz ${libver} )
  827. touch $topdir/openadk/dl/${libver}.tar.xz.nohash
  828. fi
  829. # start with a clean dir
  830. if [ $cleandir -eq 1 ]; then
  831. echo "completely cleaning openadk build directory"
  832. (cd openadk && make cleandir)
  833. fi
  834. if [ ! -z "$tests" ];then
  835. testinfo="$tests testing"
  836. else
  837. testinfo="toolchain testing"
  838. fi
  839. echo "Summary: testing $archlist with C library $lib and $testinfo"
  840. sleep 2
  841. for arch in ${archlist}; do
  842. if [ $cont -eq 1 ]; then
  843. if [ -f "REPORT.${arch}.${tests}.${libver}" -o -f "REPORT.${arch}.toolchain.${libver}" ]; then
  844. echo "Skipping already run test for $arch"
  845. continue
  846. fi
  847. fi
  848. if [ "$arch" = "$skiparchs" ];then
  849. echo "Skipping $skiparchs"
  850. continue
  851. fi
  852. if [ $clean -eq 1 ]; then
  853. echo "cleaning openadk build directory"
  854. (cd openadk && make cleansystem)
  855. fi
  856. echo "Compiling base system and toolchain for $lib and $arch"
  857. build $lib $arch notest
  858. echo "$arch with $lib successfully build" > REPORT.${arch}.toolchain.${libver}
  859. if [ ! -z "$tests" ];then
  860. for test in ${tests}; do
  861. if [ $test = "boot" -o $test = "libc" -o $test = "ltp" -o $test = "native" -o $test = "mksh" ];then
  862. case $lib in
  863. uclibc-ng)
  864. case $arch in
  865. armeb|avr32|bfin|c6x|crisv10|h8300|ia64|lm32|microblazeel|microblazebe|m68k|m68k-nommu|nios2|or1k|sh2|sh3|sh4eb)
  866. echo "runtime tests disabled for $arch."
  867. ;;
  868. *)
  869. build $lib $arch $test
  870. runtest $lib $arch $test
  871. ;;
  872. esac
  873. ;;
  874. musl)
  875. case $arch in
  876. armeb|or1k|sh4eb)
  877. echo "runtime tests disabled for $arch."
  878. ;;
  879. *)
  880. build $lib $arch $test
  881. runtest $lib $arch $test
  882. ;;
  883. esac
  884. ;;
  885. glibc)
  886. case $arch in
  887. armeb|ia64|m68k|nios2|s390|sh4eb|tile)
  888. echo "runtime tests disabled for $arch."
  889. ;;
  890. *)
  891. build $lib $arch $test
  892. runtest $lib $arch $test
  893. ;;
  894. esac
  895. ;;
  896. newlib)
  897. echo "runtime tests disabled for newlib."
  898. ;;
  899. esac
  900. else
  901. echo "Test $test is not valid. Allowed tests: $valid_tests"
  902. exit 1
  903. fi
  904. done
  905. fi
  906. done
  907. done
  908. echo "All tests finished."
  909. exit 0