embedded-test.sh 19 KB

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