embedded-test.sh 20 KB

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