diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-05 09:04:04 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-10-05 09:04:04 +0200 |
commit | 12efcf3285a75d197704d2eef23824b3e4f11e66 (patch) | |
tree | 1e518da57b55f527768e2d5031a71fbdca0f998f /qemu_multiarch_testing | |
parent | 28b00ce6ff8cde91f3e83632e705709b7cd2ab20 (diff) | |
download | busybox-w32-12efcf3285a75d197704d2eef23824b3e4f11e66.tar.gz busybox-w32-12efcf3285a75d197704d2eef23824b3e4f11e66.tar.bz2 busybox-w32-12efcf3285a75d197704d2eef23824b3e4f11e66.zip |
Add qemu_multiarch_testing/
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'qemu_multiarch_testing')
-rw-r--r-- | qemu_multiarch_testing/README | 63 | ||||
-rwxr-xr-x | qemu_multiarch_testing/extract_od_binary.sh | 6 | ||||
-rwxr-xr-x | qemu_multiarch_testing/hdc.dir/build | 45 | ||||
-rwxr-xr-x | qemu_multiarch_testing/hdc.dir/init | 9 | ||||
-rwxr-xr-x | qemu_multiarch_testing/make-hdc-img.sh | 30 | ||||
-rwxr-xr-x | qemu_multiarch_testing/parallel-build-hdc-img.sh | 40 |
6 files changed, 193 insertions, 0 deletions
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 @@ | |||
1 | How to test build using Aboriginal Linux system images. | ||
2 | |||
3 | * Put a source tree into hdc.dir/. | ||
4 | For example, this should work: | ||
5 | git clone git://busybox.net/var/lib/git/busybox.git | ||
6 | |||
7 | * Run ./make-hdc-img.sh: it will generate ext2 image file, | ||
8 | hdc.img, from hdc.dir/* data. This requires root for loop mount. | ||
9 | |||
10 | * Download and unpack, or build from source and unpack | ||
11 | one or more system-image-ARCH directories into this directory | ||
12 | (the one which contains this README). | ||
13 | |||
14 | * Run: ./parallel-build-hdc-img.sh system-image-DIR1 system-image-DIR2... | ||
15 | (background it if you don't want to see "Waiting to finish" thing). | ||
16 | This runs build in several qemu virtual machines in parallel. | ||
17 | |||
18 | * Observe system-image-*.log file(s) with growing log of the build. | ||
19 | |||
20 | There is no automated detection of errors for now: you need to examine | ||
21 | logs yourself. | ||
22 | |||
23 | Log files will also contain uuencoded (or if all else fails, od -tx1'ed) | ||
24 | binary, if build was successful. | ||
25 | |||
26 | To debug a build problem in one of the sandboxes, change keep_hdb | ||
27 | to "keep_hdb=true" in parallel-build-hdc-img.sh | ||
28 | - this preserves system-image-ARCH/hdb.img after the build, | ||
29 | so you can go into system-image-ARCH and run | ||
30 | "HDB=hdb.img ./dev-environment.sh" to debug the problem. | ||
31 | |||
32 | You can also run "./parallel-build-hdc-img.sh -s system-image-ARCH" | ||
33 | - single mode, output is to screen and serial input is from keyboard. | ||
34 | |||
35 | If hdc.dir/bin/busybox-$ARCH exists, it will be used during build | ||
36 | to supply additional tools. | ||
37 | |||
38 | For me, the following system images worked: | ||
39 | system-image-armv4l | ||
40 | system-image-armv4tl | ||
41 | system-image-armv5l | ||
42 | od is buggy on arm*: | ||
43 | # echo Hello-hello-hello-hello | od -b | ||
44 | 0000000 110 145 154 154 157 055 150 145 154 154 157 055 150 145 154 154 | ||
45 | 0000000 157 055 150 145 154 154 157 012 | ||
46 | 0000000 | ||
47 | system-image-i686 | ||
48 | system-image-mips | ||
49 | system-image-mipsel | ||
50 | od is buggy on mips[el]: | ||
51 | # echo Hello-hello-hello-hello | od -b | ||
52 | 0000000 110 145 154 154 157 055 150 145 154 154 157 055 150 145 154 154 | ||
53 | 17767153361 157 055 150 145 154 154 157 012 | ||
54 | 0000000 | ||
55 | system-image-x86_64 | ||
56 | |||
57 | And these did not: | ||
58 | system-image-armv6l - hang on "Uncompressing Linux... done, booting the kernel" | ||
59 | system-image-powerpc - hang early in kernel boot | ||
60 | system-image-sparc - hang early in userspace | ||
61 | system-image-m68k - my qemu doesn't like "-M q800" | ||
62 | system-image-mips64 - init dies "Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000a" | ||
63 | 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 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Converts textual result of "od -tx1 <FILE" | ||
4 | # back into a binary FILE | ||
5 | |||
6 | grep -a '^[0-7][0-7][0-7][0-7][0-7][0-7][0-7] [0-9a-f][0-9a-f] [0-9a-f][0-9a-f] [0-9a-f][0-9a-f] [0-9a-f][0-9a-f]' | busybox hexdump -R | ||
diff --git a/qemu_multiarch_testing/hdc.dir/build b/qemu_multiarch_testing/hdc.dir/build new file mode 100755 index 000000000..8a65a5582 --- /dev/null +++ b/qemu_multiarch_testing/hdc.dir/build | |||
@@ -0,0 +1,45 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | umount /mnt # optional | ||
4 | |||
5 | test -x "bin/busybox-$HOST" && { | ||
6 | echo "Found bin/busybox-$HOST, using it" | ||
7 | cp -a "bin/busybox-$HOST" bin/busybox | ||
8 | bin/busybox --install -s bin/ | ||
9 | # Supply missing stuff (e.g. bzip2): | ||
10 | PATH="$PATH:$PWD/bin" | ||
11 | # Override known-buggy host binaries: | ||
12 | cp -af bin/od `which od` | ||
13 | } | ||
14 | |||
15 | ( | ||
16 | #set -e -x | ||
17 | cd busybox | ||
18 | make defconfig | ||
19 | # Want static build | ||
20 | sed 's/^.*CONFIG_STATIC.*$/CONFIG_STATIC=y/' -i .config | ||
21 | # Drats, newer Aboriginal Linux has no bzip2 | ||
22 | bzip2 </dev/null >/dev/null || { | ||
23 | sed 's/^.*CONFIG_FEATURE_COMPRESS_USAGE.*$/# CONFIG_FEATURE_COMPRESS_USAGE is not set/' -i .config | ||
24 | } | ||
25 | # These won't build because of toolchain/libc breakage: | ||
26 | sed 's/^.*CONFIG_FEATURE_SYNC_FANCY.*$/# CONFIG_FEATURE_SYNC_FANCY is not set/' -i .config # no syncfs() | ||
27 | sed 's/^.*CONFIG_FEATURE_WTMP.*$/# CONFIG_FEATURE_WTMP is not set/' -i .config | ||
28 | sed 's/^.*CONFIG_FEATURE_UTMP.*$/# CONFIG_FEATURE_UTMP is not set/' -i .config | ||
29 | sed 's/^.*CONFIG_FEATURE_INETD_RPC.*$/# CONFIG_FEATURE_INETD_RPC is not set/' -i .config | ||
30 | sed 's/^.*CONFIG_BRCTL.*$/# CONFIG_BRCTL is not set/' -i .config | ||
31 | sed 's/^.*CONFIG_IFPLUGD.*$/# CONFIG_IFPLUGD is not set/' -i .config | ||
32 | make #V=1 || sh | ||
33 | size busybox | ||
34 | ./busybox || echo "Exit code: $?" | ||
35 | if uuencode TEST </dev/null >/dev/null && bzip2 </dev/null >/dev/null; then | ||
36 | bzip2 <busybox | uuencode busybox.bz2 | ||
37 | else | ||
38 | od -tx1 <busybox | ||
39 | fi | ||
40 | #test "x$FTP_PORT" = x || | ||
41 | # ftpput -P "$FTP_PORT" "$FTP_SERVER" strace | ||
42 | ) 2>&1 | tee build.log | ||
43 | mount -o remount,ro /home | ||
44 | sync | ||
45 | 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 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | # Emit a msg to let user know this place was reached | ||
4 | echo "Copying to /home" | ||
5 | # Had a case where cp SEGVs, let's have diagnostics for it | ||
6 | cp -a /mnt /home || { echo "cp: $?"; exit 1; } | ||
7 | cd /home/mnt || { echo "cd: $?"; exit 1; } | ||
8 | exec ./build | ||
9 | 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 @@ | |||
1 | #!/bin/sh -ex | ||
2 | |||
3 | mountpoint -q / | ||
4 | [ ! -e hdc.img.dir ] | ||
5 | |||
6 | cleanup() | ||
7 | { | ||
8 | trap - EXIT | ||
9 | if mountpoint -q hdc.img.dir; then | ||
10 | umount -d hdc.img.dir | ||
11 | fi | ||
12 | mountpoint -q hdc.img.dir || | ||
13 | rm -rf hdc.img.dir | ||
14 | exit $@ | ||
15 | } | ||
16 | |||
17 | trap 'cleanup $?' EXIT | ||
18 | trap 'cleanup 1' HUP PIPE INT QUIT TERM | ||
19 | |||
20 | size=$(du -ks hdc.dir | sed -rn 's/^([0-9]+).*/\1/p') | ||
21 | [ "$size" -gt 0 ] | ||
22 | |||
23 | rm -f hdc.img | ||
24 | dd if=/dev/zero of=hdc.img count=1 bs=1024 seek=$(($size*2)) | ||
25 | mkfs.ext3 -q -F -b 1024 -i 4096 hdc.img | ||
26 | tune2fs -c 0 -i 0 hdc.img | ||
27 | mkdir hdc.img.dir | ||
28 | mount -o loop hdc.img hdc.img.dir | ||
29 | cp -a hdc.dir/* hdc.img.dir/ | ||
30 | 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 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | export HDBMEGS=100 | ||
4 | keep_hdb=false | ||
5 | |||
6 | build_in_dir() | ||
7 | { | ||
8 | cd "$1" || exit 1 | ||
9 | rm -f hdb.img | ||
10 | nice -n10 time ./native-build.sh ../hdc.img | ||
11 | $keep_hdb || rm -f hdb.img | ||
12 | echo >&3 "Finished: $1" | ||
13 | } | ||
14 | |||
15 | test "$1" = "-s" && { | ||
16 | dir="$2" | ||
17 | # single mode: build one directory, show output | ||
18 | test -d "$dir" || exit 1 | ||
19 | test -e "$dir/native-build.sh" || exit 1 | ||
20 | build_in_dir "$dir" | ||
21 | exit $? | ||
22 | } | ||
23 | |||
24 | started=false | ||
25 | for dir; do | ||
26 | test -d "$dir" || continue | ||
27 | test -e "$dir/native-build.sh" || continue | ||
28 | echo "Starting: $dir" | ||
29 | build_in_dir "$dir" 3>&1 </dev/null >"$dir.log" 2>&1 & | ||
30 | started=true | ||
31 | done | ||
32 | |||
33 | $started || { | ||
34 | echo "Give me system-image-ARCH directories on command line" | ||
35 | exit 1 | ||
36 | } | ||
37 | |||
38 | echo "Waiting to finish" | ||
39 | wait | ||
40 | echo "Done, check the logs" | ||