From 12efcf3285a75d197704d2eef23824b3e4f11e66 Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Mon, 5 Oct 2015 09:04:04 +0200 Subject: [PATCH] Add qemu_multiarch_testing/ Signed-off-by: Denys Vlasenko --- qemu_multiarch_testing/README | 63 +++++++++++++++++++ qemu_multiarch_testing/extract_od_binary.sh | 6 ++ qemu_multiarch_testing/hdc.dir/build | 45 +++++++++++++ qemu_multiarch_testing/hdc.dir/init | 9 +++ qemu_multiarch_testing/make-hdc-img.sh | 30 +++++++++ .../parallel-build-hdc-img.sh | 40 ++++++++++++ 6 files changed, 193 insertions(+) create mode 100644 qemu_multiarch_testing/README create mode 100755 qemu_multiarch_testing/extract_od_binary.sh create mode 100755 qemu_multiarch_testing/hdc.dir/build create mode 100755 qemu_multiarch_testing/hdc.dir/init create mode 100755 qemu_multiarch_testing/make-hdc-img.sh create mode 100755 qemu_multiarch_testing/parallel-build-hdc-img.sh diff --git a/qemu_multiarch_testing/README b/qemu_multiarch_testing/README new file mode 100644 index 000000000..69ddb76b8 --- /dev/null +++ b/qemu_multiarch_testing/README @@ -0,0 +1,63 @@ +How to test build using Aboriginal Linux system images. + +* Put a source tree into hdc.dir/. +For example, this should work: +git clone git://busybox.net/var/lib/git/busybox.git + +* Run ./make-hdc-img.sh: it will generate ext2 image file, +hdc.img, from hdc.dir/* data. This requires root for loop mount. + +* Download and unpack, or build from source and unpack +one or more system-image-ARCH directories into this directory +(the one which contains this README). + +* Run: ./parallel-build-hdc-img.sh system-image-DIR1 system-image-DIR2... +(background it if you don't want to see "Waiting to finish" thing). +This runs build in several qemu virtual machines in parallel. + +* Observe system-image-*.log file(s) with growing log of the build. + +There is no automated detection of errors for now: you need to examine +logs yourself. + +Log files will also contain uuencoded (or if all else fails, od -tx1'ed) +binary, if build was successful. + +To debug a build problem in one of the sandboxes, change keep_hdb +to "keep_hdb=true" in parallel-build-hdc-img.sh +- this preserves system-image-ARCH/hdb.img after the build, +so you can go into system-image-ARCH and run +"HDB=hdb.img ./dev-environment.sh" to debug the problem. + +You can also run "./parallel-build-hdc-img.sh -s system-image-ARCH" +- single mode, output is to screen and serial input is from keyboard. + +If hdc.dir/bin/busybox-$ARCH exists, it will be used during build +to supply additional tools. + +For me, the following system images worked: +system-image-armv4l +system-image-armv4tl +system-image-armv5l + od is buggy on arm*: + # echo Hello-hello-hello-hello | od -b + 0000000 110 145 154 154 157 055 150 145 154 154 157 055 150 145 154 154 + 0000000 157 055 150 145 154 154 157 012 + 0000000 +system-image-i686 +system-image-mips +system-image-mipsel + od is buggy on mips[el]: + # echo Hello-hello-hello-hello | od -b + 0000000 110 145 154 154 157 055 150 145 154 154 157 055 150 145 154 154 + 17767153361 157 055 150 145 154 154 157 012 + 0000000 +system-image-x86_64 + +And these did not: +system-image-armv6l - hang on "Uncompressing Linux... done, booting the kernel" +system-image-powerpc - hang early in kernel boot +system-image-sparc - hang early in userspace +system-image-m68k - my qemu doesn't like "-M q800" +system-image-mips64 - init dies "Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000a" +system-image-sh4 - qemu segfaults early in kernel boot diff --git a/qemu_multiarch_testing/extract_od_binary.sh b/qemu_multiarch_testing/extract_od_binary.sh new file mode 100755 index 000000000..e4c2c2a0a --- /dev/null +++ b/qemu_multiarch_testing/extract_od_binary.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +# Converts textual result of "od -tx1 /dev/null || { + sed 's/^.*CONFIG_FEATURE_COMPRESS_USAGE.*$/# CONFIG_FEATURE_COMPRESS_USAGE is not set/' -i .config + } + # These won't build because of toolchain/libc breakage: + sed 's/^.*CONFIG_FEATURE_SYNC_FANCY.*$/# CONFIG_FEATURE_SYNC_FANCY is not set/' -i .config # no syncfs() + sed 's/^.*CONFIG_FEATURE_WTMP.*$/# CONFIG_FEATURE_WTMP is not set/' -i .config + sed 's/^.*CONFIG_FEATURE_UTMP.*$/# CONFIG_FEATURE_UTMP is not set/' -i .config + sed 's/^.*CONFIG_FEATURE_INETD_RPC.*$/# CONFIG_FEATURE_INETD_RPC is not set/' -i .config + sed 's/^.*CONFIG_BRCTL.*$/# CONFIG_BRCTL is not set/' -i .config + sed 's/^.*CONFIG_IFPLUGD.*$/# CONFIG_IFPLUGD is not set/' -i .config + make #V=1 || sh + size busybox + ./busybox || echo "Exit code: $?" + if uuencode TEST /dev/null && bzip2 /dev/null; then + bzip2 &1 | tee build.log +mount -o remount,ro /home +sync +sleep 1 diff --git a/qemu_multiarch_testing/hdc.dir/init b/qemu_multiarch_testing/hdc.dir/init new file mode 100755 index 000000000..692371db6 --- /dev/null +++ b/qemu_multiarch_testing/hdc.dir/init @@ -0,0 +1,9 @@ +#!/bin/sh + +# Emit a msg to let user know this place was reached +echo "Copying to /home" +# Had a case where cp SEGVs, let's have diagnostics for it +cp -a /mnt /home || { echo "cp: $?"; exit 1; } +cd /home/mnt || { echo "cd: $?"; exit 1; } +exec ./build +echo "Failed to exec ./build" diff --git a/qemu_multiarch_testing/make-hdc-img.sh b/qemu_multiarch_testing/make-hdc-img.sh new file mode 100755 index 000000000..3c35f4ead --- /dev/null +++ b/qemu_multiarch_testing/make-hdc-img.sh @@ -0,0 +1,30 @@ +#!/bin/sh -ex + +mountpoint -q / +[ ! -e hdc.img.dir ] + +cleanup() +{ + trap - EXIT + if mountpoint -q hdc.img.dir; then + umount -d hdc.img.dir + fi + mountpoint -q hdc.img.dir || + rm -rf hdc.img.dir + exit $@ +} + +trap 'cleanup $?' EXIT +trap 'cleanup 1' HUP PIPE INT QUIT TERM + +size=$(du -ks hdc.dir | sed -rn 's/^([0-9]+).*/\1/p') +[ "$size" -gt 0 ] + +rm -f hdc.img +dd if=/dev/zero of=hdc.img count=1 bs=1024 seek=$(($size*2)) +mkfs.ext3 -q -F -b 1024 -i 4096 hdc.img +tune2fs -c 0 -i 0 hdc.img +mkdir hdc.img.dir +mount -o loop hdc.img hdc.img.dir +cp -a hdc.dir/* hdc.img.dir/ +umount -d hdc.img.dir diff --git a/qemu_multiarch_testing/parallel-build-hdc-img.sh b/qemu_multiarch_testing/parallel-build-hdc-img.sh new file mode 100755 index 000000000..9ee54ebb8 --- /dev/null +++ b/qemu_multiarch_testing/parallel-build-hdc-img.sh @@ -0,0 +1,40 @@ +#!/bin/sh + +export HDBMEGS=100 +keep_hdb=false + +build_in_dir() +{ + cd "$1" || exit 1 + rm -f hdb.img + nice -n10 time ./native-build.sh ../hdc.img + $keep_hdb || rm -f hdb.img + echo >&3 "Finished: $1" +} + +test "$1" = "-s" && { + dir="$2" + # single mode: build one directory, show output + test -d "$dir" || exit 1 + test -e "$dir/native-build.sh" || exit 1 + build_in_dir "$dir" + exit $? +} + +started=false +for dir; do + test -d "$dir" || continue + test -e "$dir/native-build.sh" || continue + echo "Starting: $dir" + build_in_dir "$dir" 3>&1 "$dir.log" 2>&1 & + started=true +done + +$started || { + echo "Give me system-image-ARCH directories on command line" + exit 1 +} + +echo "Waiting to finish" +wait +echo "Done, check the logs" -- 2.25.1