embedded-test.sh 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  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 for uClibc/uClibc-ng
  25. # sheb network card get no ip
  26. adk_arch_list_uclibcng="arm armhf bfin 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 bfin 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 mips64eln32 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. aarch64)
  251. cpu_arch=aarch64
  252. qemu_machine=virt
  253. qemu_args="${qemu_args} -cpu cortex-a57 -netdev user,id=eth0 -device virtio-net-device,netdev=eth0"
  254. ;;
  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=i486
  376. qemu=qemu-system-i386
  377. qemu_machine=pc
  378. qemu_args="${qemu_args}"
  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 = "boot" ];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 = "ltp" ];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 = "libc" ];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}.$2
  493. if [ $? -eq 0 ];then
  494. echo "Test for ${arch} finished. See REPORT.${arch}.${libc}.$2"
  495. echo
  496. else
  497. echo "Test $2 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. make prereq
  612. # always trigger regeneration of kernel config
  613. rm build_*_${libc}_${arch}*/linux/.config 2>/dev/null
  614. make package=$libc clean 2>/dev/null
  615. # start with a clean dir
  616. if [ $clean -eq 1 ];then
  617. make cleandir
  618. fi
  619. DEFAULT="ADK_TARGET_LIBC=$libc ADK_TARGET_FS=initramfsarchive ADK_TARGET_COLLECTION=test"
  620. if [ $debug -eq 1 ];then
  621. DEFAULT="$DEFAULT VERBOSE=1"
  622. fi
  623. if [ $git -eq 1 ];then
  624. DEFAULT="$DEFAULT ADK_LIBC_GIT=y"
  625. fi
  626. if [ ! -z $source ];then
  627. DEFAULT="$DEFAULT ADK_NO_CHECKSUM=y"
  628. fi
  629. if [ $2 = "boot" ];then
  630. DEFAULT="$DEFAULT ADK_TEST_BASE=y"
  631. fi
  632. if [ $2 = "ltp" ];then
  633. DEFAULT="$DEFAULT ADK_TEST_LTP=y"
  634. fi
  635. if [ $2 = "libc" ];then
  636. case $libc in
  637. uclibc-ng)
  638. DEFAULT="$DEFAULT ADK_TEST_UCLIBC_NG_TESTSUITE=y"
  639. ;;
  640. uclibc)
  641. DEFAULT="$DEFAULT ADK_TEST_UCLIBC_TESTSUITE=y"
  642. ;;
  643. glibc)
  644. DEFAULT="$DEFAULT ADK_TEST_GLIBC_TESTSUITE=y"
  645. ;;
  646. musl)
  647. DEFAULT="$DEFAULT ADK_TEST_MUSL_TESTSUITE=y"
  648. ;;
  649. *)
  650. echo "test suite not available"
  651. exit 1
  652. ;;
  653. esac
  654. fi
  655. if [ $2 = "native" ];then
  656. case $libc in
  657. uclibc-ng)
  658. DEFAULT="$DEFAULT ADK_TEST_UCLIBC_NG_NATIVE=y"
  659. ;;
  660. uclibc)
  661. DEFAULT="$DEFAULT ADK_TEST_UCLIBC_NATIVE=y"
  662. ;;
  663. musl)
  664. DEFAULT="$DEFAULT ADK_TEST_MUSL_NATIVE=y"
  665. ;;
  666. glibc)
  667. DEFAULT="$DEFAULT ADK_TEST_GLIBC_NATIVE=y"
  668. ;;
  669. *)
  670. echo "native build not available"
  671. exit 1
  672. ;;
  673. esac
  674. fi
  675. case $1 in
  676. aarch64)
  677. make $DEFAULT ADK_TARGET_ARCH=aarch64 ADK_TARGET_SYSTEM=qemu-aarch64 defconfig all
  678. ;;
  679. arm)
  680. make $DEFAULT ADK_TARGET_ARCH=arm ADK_TARGET_SYSTEM=qemu-arm ADK_TARGET_ABI=eabi ADK_TARGET_ENDIAN=little defconfig all
  681. ;;
  682. armhf)
  683. make $DEFAULT ADK_TARGET_ARCH=arm ADK_TARGET_SYSTEM=qemu-arm ADK_TARGET_ABI=eabihf ADK_TARGET_ENDIAN=little defconfig all
  684. ;;
  685. m68k)
  686. make $DEFAULT ADK_TARGET_ARCH=m68k ADK_TARGET_SYSTEM=aranym-m68k defconfig all
  687. ;;
  688. m68k-nommu)
  689. make $DEFAULT ADK_TARGET_ARCH=m68k ADK_TARGET_SYSTEM=qemu-m68k defconfig all
  690. ;;
  691. mips)
  692. make $DEFAULT ADK_TARGET_ARCH=mips ADK_TARGET_SYSTEM=qemu-mips ADK_TARGET_ENDIAN=big defconfig all
  693. ;;
  694. mipsel)
  695. make $DEFAULT ADK_TARGET_ARCH=mips ADK_TARGET_SYSTEM=qemu-mips ADK_TARGET_ENDIAN=little defconfig all
  696. ;;
  697. mips64)
  698. make $DEFAULT ADK_TARGET_ARCH=mips64 ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=big ADK_TARGET_ABI=o32 defconfig all
  699. ;;
  700. mips64n32)
  701. make $DEFAULT ADK_TARGET_ARCH=mips64 ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=big ADK_TARGET_ABI=n32 defconfig all
  702. ;;
  703. mips64n64)
  704. make $DEFAULT ADK_TARGET_ARCH=mips64 ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=big ADK_TARGET_ABI=n64 defconfig all
  705. ;;
  706. mips64el)
  707. make $DEFAULT ADK_TARGET_ARCH=mips64 ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=little ADK_TARGET_ABI=o32 defconfig all
  708. ;;
  709. mips64eln32)
  710. make $DEFAULT ADK_TARGET_ARCH=mips64 ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=little ADK_TARGET_ABI=n32 defconfig all
  711. ;;
  712. mips64eln64)
  713. make $DEFAULT ADK_TARGET_ARCH=mips64 ADK_TARGET_SYSTEM=qemu-mips64 ADK_TARGET_ENDIAN=little ADK_TARGET_ABI=n64 defconfig all
  714. ;;
  715. ppc-nofpu)
  716. make $DEFAULT ADK_TARGET_ARCH=ppc ADK_TARGET_SYSTEM=qemu-ppc defconfig all
  717. ;;
  718. sh)
  719. make $DEFAULT ADK_TARGET_ARCH=sh ADK_TARGET_SYSTEM=qemu-sh ADK_TARGET_ENDIAN=little defconfig all
  720. ;;
  721. sheb)
  722. make $DEFAULT ADK_TARGET_ARCH=sh ADK_TARGET_SYSTEM=qemu-sh ADK_TARGET_ENDIAN=big defconfig all
  723. ;;
  724. *)
  725. make $DEFAULT ADK_TARGET_ARCH=$1 ADK_TARGET_SYSTEM=qemu-$1 defconfig all
  726. ;;
  727. esac
  728. if [ $? -ne 0 ];then
  729. echo "build failed"
  730. exit 1
  731. fi
  732. cd ..
  733. }
  734. echo "Compiling base system and toolchain"
  735. if [ "$vendor" = "buildroot" ];then
  736. for arch in ${archlist}; do
  737. build_buildroot $arch notest
  738. done
  739. fi
  740. if [ "$vendor" = "openadk" ];then
  741. for arch in ${archlist}; do
  742. build_openadk $arch notest
  743. if [ ! -z "$tests" ];then
  744. for test in ${tests}; do
  745. if [ $test = "boot" -o $test = "libc" -o $test = "ltp" -o $test = "native" ];then
  746. case $arch in
  747. bfin|m68k|m68k-nommu|ppc|sheb|mips64eln32|mips64n32)
  748. echo "runtime tests disabled for $arch."
  749. ;;
  750. *)
  751. build_openadk $arch $test
  752. runtest $arch $test
  753. ;;
  754. esac
  755. else
  756. echo "Test $test is not valid. Allowed tests: boot libc ltp native"
  757. fi
  758. done
  759. fi
  760. done
  761. fi
  762. echo "All tests finished."
  763. exit 0