embedded-test.sh 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797
  1. #!/bin/sh
  2. # Copyright © 2014
  3. # Waldemar Brodkorb <wbx@openadk.org>
  4. #
  5. # Provided that these terms and disclaimer and all copyright notices
  6. # are retained or reproduced in an accompanying document, permission
  7. # is granted to deal in this work without restriction, including un‐
  8. # limited rights to use, publicly perform, distribute, sell, modify,
  9. # merge, give away, or sublicence.
  10. #
  11. # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
  12. # the utmost extent permitted by applicable law, neither express nor
  13. # implied; without malicious intent or gross negligence. In no event
  14. # may a licensor, author or contributor be held liable for indirect,
  15. # direct, other damage, loss, or other issues arising in any way out
  16. # of dealing in the work, even if advised of the possibility of such
  17. # damage or existence of a defect, except proven that it results out
  18. # of said person’s immediate fault when using the work as intended.
  19. #
  20. # Alternatively, this work may be distributed under the Terms of the
  21. # General Public License, any version as published by the Free Soft‐
  22. # ware Foundation.
  23. # architecture specific notes:
  24. # mips64n32/mips64eln32 produces segfaults on boot
  25. # sheb network card get no ip
  26. adk_arch_list_uclibcng="arm armhf m68k m68k-nommu mips mipsel mips64 mips64eln32 mips64n32 mips64n64 mips64el mips64el mips64eln64 ppc-nofpu sh sheb sparc x86 x86_64 xtensa"
  27. adk_arch_list_uclibc="arm armhf m68k m68k-nommu mips mipsel mips64 mips64eln32 mips64n32 mips64n64 mips64el mips64el mips64eln64 ppc-nofpu sh sheb sparc x86 x86_64"
  28. adk_arch_list_musl="arm armhf mips mipsel ppc-nofpu sh sheb x86 x86_64"
  29. adk_arch_list_glibc="aarch64 arm armhf m68k mips mipsel mips64 mips64eln32 mips64n32 mips64n64 mips64el mips64el mips64eln64 ppc-nofpu ppc64 sh sheb sparc sparc64 x86 x86_64"
  30. br_arch_list_uclibcng="arcle arcbe bfin arm mips mipsel mips64 mips64el ppc sh sparc x86 x86_64 xtensa"
  31. br_arch_list_uclibc="arcle arcbe bfin arm mips mipsel mips64 mips64el ppc sh sparc x86 x86_64 xtensa"
  32. br_arch_list_musl="arm mips mipsel ppc sh x86 x86_64"
  33. br_arch_list_glibc="aarch64 arm mips mipsel mips64 mips64el ppc sh sparc x86 x86_64"
  34. topdir=$(pwd)
  35. tools='make git wget xz cpio tar awk sed'
  36. f=0
  37. for tool in $tools; do
  38. if ! which $tool >/dev/null; then
  39. echo "Checking if $tool is installed... failed"
  40. f=1
  41. fi
  42. done
  43. if [ $f -eq 1 ];then exit 1; fi
  44. help() {
  45. cat >&2 <<EOF
  46. Syntax: $0 -v <vendor> -l <libc> -s <source> -a <arch> -t <tests>
  47. Explanation:
  48. -v: vendor for buildsystem (openadk|buildroot)
  49. -l: c library to use (uclibc-ng|musl|glibc|uclibc)
  50. -g: use latest git version
  51. -a: architecture to check
  52. -u: update vendor source via git pull
  53. -s: use directory with source for C library
  54. -d: enable debug
  55. -c: clean build directory before build
  56. -n: set NTP server for test run
  57. -t: run tests (boot|libc|ltp|native)
  58. -h: help text
  59. EOF
  60. }
  61. clean=0
  62. shell=0
  63. update=0
  64. debug=0
  65. git=0
  66. ntp=time.fu-berlin.de
  67. while getopts "hgumdcn:a:v:s:l:t:" ch; do
  68. case $ch in
  69. m)
  70. shell=1
  71. ;;
  72. g)
  73. git=1
  74. ;;
  75. c)
  76. clean=1
  77. ;;
  78. d)
  79. debug=1
  80. ;;
  81. u)
  82. update=1
  83. ;;
  84. s)
  85. source=$OPTARG
  86. ;;
  87. l)
  88. libc=$OPTARG
  89. ;;
  90. n)
  91. ntp=$OPTARG
  92. ;;
  93. a)
  94. archlist=$OPTARG
  95. ;;
  96. t)
  97. tests=$OPTARG
  98. ;;
  99. v)
  100. vendor=$OPTARG
  101. ;;
  102. h)
  103. help
  104. exit 1
  105. ;;
  106. esac
  107. done
  108. shift $((OPTIND - 1))
  109. if [ -z $vendor ];then
  110. echo "You need to provide a vendor/buildsystem"
  111. echo "Either openadk or buildroot is supported."
  112. exit 1
  113. fi
  114. if [ -z $libc ];then
  115. echo "You need to provide a C library"
  116. echo "Either uclibc-ng, musl, glibc or uclibc is supported."
  117. exit 1
  118. fi
  119. case $libc in
  120. uclibc-ng)
  121. version=1.0.0rc1
  122. gitversion=1.0.0
  123. libver=uClibc-ng-${gitversion}
  124. libdir=uClibc-ng
  125. ;;
  126. uclibc)
  127. version=0.9.33.2
  128. gitversion=0.9.34-git
  129. libver=uClibc-${gitversion}
  130. libdir=uClibc
  131. ;;
  132. glibc)
  133. version=2.19
  134. gitversion=2.19.90
  135. libver=glibc-${gitversion}
  136. libdir=glibc
  137. ;;
  138. musl)
  139. version=1.1.4
  140. gitversion=git
  141. libver=musl-${gitversion}
  142. libdir=musl
  143. ;;
  144. *)
  145. echo "c library not supported"
  146. exit 1
  147. esac
  148. if [ -z $archlist ];then
  149. if [ $vendor = "openadk" ];then
  150. case $libc in
  151. uclibc-ng)
  152. archlist=$adk_arch_list_uclibcng
  153. ;;
  154. uclibc)
  155. archlist=$adk_arch_list_uclibc
  156. ;;
  157. glibc)
  158. archlist=$adk_arch_list_glibc
  159. ;;
  160. musl)
  161. archlist=$adk_arch_list_musl
  162. ;;
  163. *)
  164. exit 1
  165. ;;
  166. esac
  167. fi
  168. if [ $vendor = "buildroot" ];then
  169. case $libc in
  170. uclibc-ng)
  171. archlist=$br_arch_list_uclibcng
  172. ;;
  173. uclibc)
  174. archlist=$br_arch_list_uclibc
  175. ;;
  176. glibc)
  177. archlist=$br_arch_list_glibc
  178. ;;
  179. musl)
  180. archlist=$br_arch_list_musl
  181. ;;
  182. *)
  183. exit 1
  184. ;;
  185. esac
  186. fi
  187. fi
  188. case $vendor in
  189. openadk)
  190. echo "Using OpenADK to check $libc on $archlist"
  191. vendor_git=http://git.openadk.org/openadk.git
  192. ;;
  193. buildroot)
  194. echo "Using buildroot to check $libc on $archlist"
  195. vendor_git=http://git.buildroot.net/git/buildroot.git
  196. ;;
  197. *)
  198. echo "Vendor $vendor not supported."
  199. exit 1
  200. ;;
  201. esac
  202. if [ ! -d $vendor ];then
  203. git clone $vendor_git
  204. if [ $? -ne 0 ];then
  205. echo "Cloning from $vendor_git failed."
  206. exit 1
  207. fi
  208. if [ "$vendor" = "buildroot" ];then
  209. wget http://downloads.uclibc-ng.org/buildroot-uClibc-ng.patch
  210. (cd buildroot && patch -p1 <../buildroot-uClibc-ng.patch)
  211. fi
  212. else
  213. if [ $update -eq 1 ];then
  214. (cd $vendor && git pull)
  215. if [ $? -ne 0 ];then
  216. echo "Updating from $vendor_git failed."
  217. exit 1
  218. fi
  219. fi
  220. fi
  221. if [ ! -z $source ];then
  222. if [ ! -d $source ];then
  223. echo "Not a directory."
  224. exit 1
  225. fi
  226. git=1
  227. usrc=$(mktemp -d /tmp/XXXX)
  228. echo "Creating source tarball $vendor/dl/${libver}.tar.xz"
  229. cp -a $source $usrc/$libver
  230. mkdir -p $topdir/$vendor/dl 2>/dev/null
  231. rm $topdir/$vendor/dl/${libver}.tar.xz 2>/dev/null
  232. (cd $usrc && tar cJf $topdir/$vendor/dl/${libver}.tar.xz ${libver} )
  233. fi
  234. runtest() {
  235. arch=$1
  236. qemu=qemu-system-${arch}
  237. qemu_args=
  238. qemu_append="ntp_server=$ntp"
  239. if [ $debug -eq 0 ];then
  240. qemu_append="$qemu_append quiet"
  241. fi
  242. if [ $shell -eq 1 ];then
  243. qemu_append="$qemu_append shell"
  244. fi
  245. suffix=
  246. psuffix=
  247. libdir=lib
  248. march=${arch}
  249. case ${arch} in
  250. arm)
  251. cpu_arch=arm
  252. qemu_machine=vexpress-a9
  253. qemu_args="${qemu_args} -cpu cortex-a9 -net user -net nic,model=lan9118"
  254. suffix=eabi
  255. psuffix=$suffix
  256. ;;
  257. armhf)
  258. cpu_arch=arm
  259. march=arm
  260. qemu=qemu-system-${cpu_arch}
  261. qemu_machine=vexpress-a9
  262. qemu_args="${qemu_args} -cpu cortex-a9 -net user -net nic,model=lan9118"
  263. suffix=eabihf
  264. psuffix=$suffix
  265. ;;
  266. mips)
  267. cpu_arch=mips
  268. qemu_machine=malta
  269. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  270. ;;
  271. mipsel)
  272. cpu_arch=mipsel
  273. march=mips
  274. qemu_machine=malta
  275. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  276. ;;
  277. mips64)
  278. cpu_arch=mips64
  279. qemu_machine=malta
  280. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  281. suffix=abi32
  282. psuffix=o32
  283. ;;
  284. mips64n32)
  285. cpu_arch=mips64
  286. march=mips64
  287. qemu=qemu-system-${cpu_arch}
  288. qemu_machine=malta
  289. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  290. suffix=abin32
  291. psuffix=n32
  292. ;;
  293. mips64n64)
  294. cpu_arch=mips64
  295. march=mips64
  296. qemu=qemu-system-${cpu_arch}
  297. qemu_machine=malta
  298. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  299. suffix=abi64
  300. psuffix=n64
  301. ;;
  302. mips64el)
  303. cpu_arch=mips64el
  304. march=mips64
  305. qemu_machine=malta
  306. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  307. suffix=abi32
  308. psuffix=o32
  309. ;;
  310. mips64eln32)
  311. cpu_arch=mips64el
  312. march=mips64
  313. qemu=qemu-system-${cpu_arch}
  314. qemu_machine=malta
  315. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  316. suffix=abin32
  317. psuffix=n32
  318. ;;
  319. mips64eln64)
  320. cpu_arch=mips64el
  321. march=mips64
  322. qemu=qemu-system-${cpu_arch}
  323. qemu_machine=malta
  324. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  325. suffix=abi64
  326. psuffix=n64
  327. ;;
  328. ppc-nofpu)
  329. cpu_arch=ppc
  330. march=ppc
  331. qemu=qemu-system-${cpu_arch}
  332. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  333. qemu_machine=bamboo
  334. ;;
  335. ppc)
  336. cpu_arch=ppc
  337. march=ppc
  338. qemu=qemu-system-${cpu_arch}
  339. qemu_args="${qemu_args} -device e1000,netdev=adk0 -netdev user,id=adk0"
  340. qemu_machine=mac99
  341. ;;
  342. powerpc64|ppc64)
  343. cpu_arch=ppc64
  344. qemu=qemu-system-${cpu_arch}
  345. qemu_machine=pseries
  346. ;;
  347. sh)
  348. cpu_arch=sh4
  349. qemu=qemu-system-${cpu_arch}
  350. qemu_machine=r2d
  351. qemu_args="${qemu_args} -monitor null -serial null -serial stdio"
  352. ;;
  353. sheb)
  354. cpu_arch=sh4eb
  355. march=sh
  356. qemu=qemu-system-${cpu_arch}
  357. qemu_machine=r2d
  358. qemu_args="${qemu_args} -monitor null -serial null -serial stdio"
  359. ;;
  360. sparc)
  361. cpu_arch=sparc
  362. qemu_machine=SS-5
  363. ;;
  364. sparc64)
  365. cpu_arch=sparc64
  366. qemu_machine=sun4u
  367. qemu_args="${qemu_args} -net nic,model=virtio -net user"
  368. ;;
  369. x86)
  370. cpu_arch=i486
  371. qemu=qemu-system-i386
  372. qemu_machine=pc
  373. qemu_args="${qemu_args}"
  374. ;;
  375. x86_64)
  376. cpu_arch=x86_64
  377. qemu_machine=pc
  378. libdir=lib64
  379. ;;
  380. x86_64_x32)
  381. cpu_arch=x86_64
  382. qemu=qemu-system-${cpu_arch}
  383. qemu_machine=pc
  384. libdir=libx32
  385. suffix=x32
  386. ;;
  387. xtensa)
  388. cpu_arch=xtensa
  389. qemu=qemu-system-${cpu_arch}
  390. qemu_machine=lx60
  391. qemu_args="${qemu_args} -cpu dc232b"
  392. ;;
  393. *)
  394. echo "architecture ${arch} not supported"; exit 1;;
  395. esac
  396. if ! which $qemu >/dev/null; then
  397. echo "Checking if $qemu is installed... failed"
  398. exit 1
  399. fi
  400. qemuver=$(${qemu} -version|awk '{ print $4 }')
  401. if [ $(echo $qemuver |sed -e "s#\.##g" -e "s#,##") -lt 210 ];then
  402. echo "Your qemu version is too old. Please update to 2.1 or greater"
  403. exit 1
  404. fi
  405. case $libc in
  406. uclibc-ng)
  407. prefix=uclibc
  408. ;;
  409. glibc)
  410. prefix=gnu
  411. ;;
  412. *)
  413. prefix=$libc
  414. ;;
  415. esac
  416. cross=${cpu_arch}-${vendor}-linux-${prefix}${suffix}
  417. if [ -z $psuffix ];then
  418. TCPATH=${topdir}/${vendor}/toolchain_qemu-${march}_${libc}_${cpu_arch}
  419. else
  420. TCPATH=${topdir}/${vendor}/toolchain_qemu-${march}_${libc}_${cpu_arch}_${psuffix}
  421. fi
  422. export PATH="${TCPATH}/usr/bin:$PATH"
  423. if ! which ${cross}-gcc >/dev/null; then
  424. echo "Checking if ${cross}-gcc is installed... failed"
  425. exit 1
  426. fi
  427. echo "Starting test for ${arch}"
  428. echo "Generating root filesystem for test run"
  429. root=$(mktemp -d /tmp/XXXX)
  430. if [ ! -f openadk/firmware/qemu-${march}_${libc}/qemu-${march}-${libc}-initramfsarchive.tar.gz ];then
  431. echo "No root filesystem available for architecture ${arch}"
  432. exit 1
  433. fi
  434. tar -xf openadk/firmware/qemu-${march}_${libc}/qemu-${march}-${libc}-initramfsarchive.tar.gz -C $root
  435. if [ $2 = "boot" ];then
  436. cat > ${root}/run.sh << EOF
  437. #!/bin/sh
  438. uname -a
  439. rdate -n \$ntp_server
  440. file /bin/busybox
  441. for i in \$(ls /lib/*.so|grep -v libgcc);do
  442. size \$i
  443. done
  444. exit
  445. EOF
  446. fi
  447. if [ $2 = "ltp" ];then
  448. cat > ${root}/run.sh << EOF
  449. #!/bin/sh
  450. uname -a
  451. rdate -n \$ntp_server
  452. /opt/ltp/runltp
  453. exit
  454. EOF
  455. fi
  456. if [ $2 = "libc" ];then
  457. case $libc in
  458. uclibc-ng|uclibc)
  459. cat > ${root}/run.sh << EOF
  460. #!/bin/sh
  461. uname -a
  462. rdate -n \$ntp_server
  463. cd /opt/$libc/test
  464. CROSS_COMPILE=": ||" make UCLIBC_ONLY=y -k run
  465. exit
  466. EOF
  467. ;;
  468. musl|glibc)
  469. cat > ${root}/run.sh << EOF
  470. #!/bin/sh
  471. uname -a
  472. rdate -n \$ntp_server
  473. cd /opt/libc-test
  474. make run
  475. exit
  476. EOF
  477. ;;
  478. esac
  479. fi
  480. chmod u+x ${root}/run.sh
  481. kernel=openadk/firmware/qemu-${march}_${libc}/qemu-${march}-initramfsarchive-kernel
  482. echo "Creating initramfs filesystem"
  483. (cd $root; find . | cpio -o -C512 -Hnewc |xz --check=crc32 --stdout > ${topdir}/initramfs.${arch})
  484. rm -rf $root
  485. echo "Now running the tests in qemu for architecture ${arch}"
  486. echo "${qemu} -M ${qemu_machine} ${qemu_args} -append ${qemu_append} -kernel ${kernel} -qmp tcp:127.0.0.1:4444,server,nowait -no-reboot -nographic -initrd initramfs.${arch}"
  487. ${qemu} -M ${qemu_machine} ${qemu_args} -append "${qemu_append}" -kernel ${kernel} -qmp tcp:127.0.0.1:4444,server,nowait -no-reboot -nographic -initrd initramfs.${arch} | tee REPORT.${arch}.${libc}
  488. if [ $? -eq 0 ];then
  489. echo "Test for ${arch} finished. See REPORT.${arch}.${libc}"
  490. echo
  491. else
  492. echo "Test failed for ${arch} with ${libc}."
  493. echo
  494. fi
  495. }
  496. create_buildroot_defconfig_arcle() {
  497. cat > configs/arcle_defconfig << EOD
  498. BR2_arcle=y
  499. BR2_TOOLCHAIN_BUILDROOT_UCLIBC_NG=y
  500. BR2_KERNEL_HEADERS_3_15=y
  501. BR2_DEFAULT_KERNEL_HEADERS="3.15.6"
  502. BR2_BINUTILS_VERSION_2_24=y
  503. BR2_GCC_VERSION_4_8_X=y
  504. BR2_TOOLCHAIN_HAS_THREADS=y
  505. EOD
  506. }
  507. create_buildroot_defconfig_arcbe() {
  508. cat > configs/arcbe_defconfig << EOD
  509. BR2_arcle=y
  510. BR2_TOOLCHAIN_BUILDROOT_UCLIBC_NG=y
  511. BR2_KERNEL_HEADERS_3_15=y
  512. BR2_DEFAULT_KERNEL_HEADERS="3.15.6"
  513. BR2_BINUTILS_VERSION_2_24=y
  514. BR2_GCC_VERSION_4_8_X=y
  515. BR2_TOOLCHAIN_HAS_THREADS=y
  516. EOD
  517. }
  518. create_buildroot_defconfig_bfin() {
  519. cat > configs/bfin_defconfig << EOD
  520. BR2_bfin=y
  521. BR2_BINFMT_FDPIC=y
  522. BR2_bf609=y
  523. BR2_TOOLCHAIN_BUILDROOT_UCLIBC_NG=y
  524. BR2_KERNEL_HEADERS_3_15=y
  525. BR2_DEFAULT_KERNEL_HEADERS="3.15.6"
  526. BR2_BINUTILS_VERSION_2_22=y
  527. BR2_GCC_VERSION_4_5_X=y
  528. BR2_TOOLCHAIN_HAS_THREADS=y
  529. EOD
  530. }
  531. build_buildroot() {
  532. cd buildroot
  533. case $1 in
  534. arcle)
  535. create_buildroot_defconfig_arcle
  536. make arcle_defconfig
  537. make clean all
  538. ;;
  539. arcbe)
  540. create_buildroot_defconfig_arcbe
  541. make arcbe_defconfig
  542. make clean all
  543. ;;
  544. arm)
  545. make qemu_arm_vexpress_defconfig
  546. make clean all
  547. ;;
  548. bfin)
  549. create_buildroot_defconfig_bfin
  550. make bfin_defconfig
  551. make clean all
  552. ;;
  553. mips)
  554. make qemu_mips_malta_defconfig
  555. make clean all
  556. ;;
  557. mipsel)
  558. make qemu_mipsel_malta_defconfig
  559. make clean all
  560. ;;
  561. mips64)
  562. make qemu_mips64_malta_defconfig
  563. make clean all
  564. ;;
  565. mips64el)
  566. make qemu_mips64el_malta_defconfig
  567. make clean all
  568. ;;
  569. ppc)
  570. make qemu_ppc_mpc8544ds_defconfig
  571. make clean all
  572. ;;
  573. sh)
  574. make qemu_sh4_r2d_defconfig
  575. make clean all
  576. ;;
  577. sparc)
  578. make qemu_sparc_ss10_defconfig
  579. make clean all
  580. ;;
  581. x86)
  582. make qemu_x86_defconfig
  583. make clean all
  584. ;;
  585. x86_64)
  586. make qemu_x86_64_defconfig
  587. make clean all
  588. ;;
  589. xtensa)
  590. make qemu_xtensa_lx60_defconfig
  591. make clean all
  592. ;;
  593. *)
  594. echo "architecture not supported in buildroot"
  595. exit 1
  596. ;;
  597. esac
  598. if [ $? -ne 0 ];then
  599. echo "build failed"
  600. exit 1
  601. fi
  602. cd ..
  603. }
  604. build_openadk() {
  605. cd openadk
  606. # always trigger regeneration of kernel config
  607. rm build_*_${libc}_${arch}*/linux/.config 2>/dev/null
  608. make package=$libc clean
  609. # start with a clean dir
  610. if [ $clean -eq 1 ];then
  611. make cleandir
  612. fi
  613. DEFAULT="ADK_TARGET_LIBC=$libc ADK_TARGET_FS=initramfsarchive ADK_TARGET_COLLECTION=test"
  614. if [ $debug -eq 1 ];then
  615. DEFAULT="$DEFAULT VERBOSE=1"
  616. fi
  617. if [ $git -eq 1 ];then
  618. DEFAULT="$DEFAULT ADK_LIBC_GIT=y"
  619. fi
  620. if [ ! -z $source ];then
  621. DEFAULT="$DEFAULT ADK_NO_CHECKSUM=y"
  622. fi
  623. if [ $2 = "boot" ];then
  624. DEFAULT="$DEFAULT ADK_TEST_BASE=y"
  625. fi
  626. if [ $2 = "ltp" ];then
  627. DEFAULT="$DEFAULT ADK_TEST_LTP=y"
  628. fi
  629. if [ $2 = "libc" ];then
  630. case $libc in
  631. uclibc-ng)
  632. DEFAULT="$DEFAULT ADK_TEST_UCLIBC_NG_TESTSUITE=y"
  633. ;;
  634. uclibc)
  635. DEFAULT="$DEFAULT ADK_TEST_UCLIBC_TESTSUITE=y"
  636. ;;
  637. glibc)
  638. DEFAULT="$DEFAULT ADK_TEST_GLIBC_TESTSUITE=y"
  639. ;;
  640. musl)
  641. DEFAULT="$DEFAULT ADK_TEST_MUSL_TESTSUITE=y"
  642. ;;
  643. *)
  644. echo "test suite not available"
  645. exit 1
  646. ;;
  647. esac
  648. fi
  649. if [ $2 = "native" ];then
  650. case $libc in
  651. uclibc-ng)
  652. DEFAULT="$DEFAULT ADK_TEST_UCLIBC_NG_NATIVE=y"
  653. ;;
  654. uclibc)
  655. DEFAULT="$DEFAULT ADK_TEST_UCLIBC_NATIVE=y"
  656. ;;
  657. musl)
  658. DEFAULT="$DEFAULT ADK_TEST_MUSL_NATIVE=y"
  659. ;;
  660. glibc)
  661. DEFAULT="$DEFAULT ADK_TEST_GLIBC_NATIVE=y"
  662. ;;
  663. *)
  664. echo "native build not available"
  665. exit 1
  666. ;;
  667. esac
  668. fi
  669. case $1 in
  670. aarch64)
  671. make $DEFAULT ADK_TARGET_ARCH=aarch64 ADK_TARGET_SYSTEM=qemu-aarch64 defconfig all
  672. ;;
  673. arm)
  674. make $DEFAULT ADK_TARGET_ARCH=arm ADK_TARGET_SYSTEM=qemu-arm ADK_TARGET_ABI=eabi ADK_TARGET_ENDIAN=little defconfig all
  675. ;;
  676. armhf)
  677. make $DEFAULT ADK_TARGET_ARCH=arm ADK_TARGET_SYSTEM=qemu-arm ADK_TARGET_ABI=eabihf ADK_TARGET_ENDIAN=little defconfig all
  678. ;;
  679. m68k-nommu)
  680. make $DEFAULT ADK_TARGET_ARCH=m68k ADK_TARGET_SYSTEM=qemu-m68k defconfig all
  681. ;;
  682. mips)
  683. make $DEFAULT ADK_TARGET_ARCH=mips ADK_TARGET_SYSTEM=qemu-mips ADK_TARGET_ENDIAN=big defconfig all
  684. ;;
  685. mipsel)
  686. make $DEFAULT ADK_TARGET_ARCH=mips ADK_TARGET_SYSTEM=qemu-mips ADK_TARGET_ENDIAN=little defconfig all
  687. ;;
  688. mips64)
  689. make $DEFAULT ADK_TARGET_ARCH=mips64 ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=big ADK_TARGET_ABI=o32 defconfig all
  690. ;;
  691. mips64n32)
  692. make $DEFAULT ADK_TARGET_ARCH=mips64 ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=big ADK_TARGET_ABI=n32 defconfig all
  693. ;;
  694. mips64n64)
  695. make $DEFAULT ADK_TARGET_ARCH=mips64 ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=big ADK_TARGET_ABI=n64 defconfig all
  696. ;;
  697. mips64el)
  698. make $DEFAULT ADK_TARGET_ARCH=mips64 ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=little ADK_TARGET_ABI=o32 defconfig all
  699. ;;
  700. mips64eln32)
  701. make $DEFAULT ADK_TARGET_ARCH=mips64 ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=little ADK_TARGET_ABI=n32 defconfig all
  702. ;;
  703. mips64eln64)
  704. make $DEFAULT ADK_TARGET_ARCH=mips64 ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=little ADK_TARGET_ABI=n64 defconfig all
  705. ;;
  706. ppc-nofpu)
  707. make $DEFAULT ADK_TARGET_ARCH=ppc ADK_TARGET_SYSTEM=qemu-ppc defconfig all
  708. ;;
  709. sh)
  710. make $DEFAULT ADK_TARGET_ARCH=sh ADK_TARGET_SYSTEM=qemu-sh ADK_TARGET_ENDIAN=little defconfig all
  711. ;;
  712. sheb)
  713. make $DEFAULT ADK_TARGET_ARCH=sh ADK_TARGET_SYSTEM=qemu-sh ADK_TARGET_ENDIAN=big defconfig all
  714. ;;
  715. *)
  716. make $DEFAULT ADK_TARGET_ARCH=$1 ADK_TARGET_SYSTEM=qemu-$1 defconfig all
  717. ;;
  718. esac
  719. if [ $? -ne 0 ];then
  720. echo "build failed"
  721. exit 1
  722. fi
  723. cd ..
  724. }
  725. echo "Compiling base system and toolchain"
  726. if [ "$vendor" = "buildroot" ];then
  727. for arch in ${archlist}; do
  728. build_buildroot $arch notest
  729. done
  730. fi
  731. if [ "$vendor" = "openadk" ];then
  732. for arch in ${archlist}; do
  733. build_openadk $arch notest
  734. if [ ! -z "$tests" ];then
  735. for test in ${tests}; do
  736. if [ $test = "boot" -o $test = "libc" -o $test = "ltp" -o $test = "native" ];then
  737. case $arch in
  738. m68k|m68k-nommu|ppc|sheb|mips64eln32|mips64n32)
  739. echo "runtime tests disabled for $arch."
  740. ;;
  741. *)
  742. build_openadk $arch $test
  743. runtest $arch $test
  744. ;;
  745. esac
  746. else
  747. echo "Test $test is not valid. Allowed tests: boot libc ltp native"
  748. fi
  749. done
  750. fi
  751. done
  752. fi
  753. echo "All tests finished."
  754. exit 0