qemu_multiarch_testing/: a directory with scripts for build testing

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
diff --git a/qemu_multiarch_testing/README b/qemu_multiarch_testing/README
new file mode 100644
index 0000000..e1bdb75
--- /dev/null
+++ b/qemu_multiarch_testing/README
@@ -0,0 +1,42 @@
+How to test strace build using Aboriginal Linux's system images.
+
+* Put a autoconf'ed strace source tree into hdc.dir/strace dir.
+For example, this should work:
+git clone git://strace.git.sourceforge.net/gitroot/strace/strace &&
+cd strace && autoreconf -i -f
+
+* 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 a strace build in several qemu virtual machines in parallel.
+
+* Observe system-image-*.log file(s) with growing log of strace build.
+
+There is no automated detection of errors for now: you need to examine
+logs yourself.
+
+For me, the following system images worked:
+system-image-armv4l
+system-image-armv4tl
+system-image-armv5l
+system-image-armv6l
+system-image-i686 (had to s/qemu-system-i386/qemu/ in run-emulator.sh)
+system-image-mipsel
+system-image-mips
+system-image-x86_64
+
+And these did not:
+system-image-armv4eb - VFS: Cannot open root device "sda" or unknown-block(0,0)
+system-image-m68k    - run-emulator.sh has no call of qemu-system-* (not supported yet??)
+system-image-mips64  -
+	need to run ./native-build.sh ../hdc.img by hand;
+	copying in /mnt/init fails (segv?)
+system-image-powerpc - qemu-system-ppc: command not found
+system-image-sh4     - hdc does not mount (no support for 2 disks)
+system-image-sparc   - qemu-system-sparc: command not found
diff --git a/qemu_multiarch_testing/hdc.dir/init b/qemu_multiarch_testing/hdc.dir/init
new file mode 100755
index 0000000..ea905ab
--- /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 || exit $?
+exec ./init2
+echo "Failed to exec ./init2"
diff --git a/qemu_multiarch_testing/hdc.dir/init2 b/qemu_multiarch_testing/hdc.dir/init2
new file mode 100755
index 0000000..58225c6
--- /dev/null
+++ b/qemu_multiarch_testing/hdc.dir/init2
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+umount /mnt # optional
+echo "Building"
+(
+	cd strace &&
+	./configure &&
+	make &&
+	echo "Build: SUCCESS" &&
+	./strace
+	# strace may segfault, let's see exit code
+	echo "Exit code: $?"
+) 2>&1 | tee strace_build.log
+mount -o remount,ro /home
+sync
+sleep 1
diff --git a/qemu_multiarch_testing/make-hdc-img.sh b/qemu_multiarch_testing/make-hdc-img.sh
new file mode 100755
index 0000000..8258448
--- /dev/null
+++ b/qemu_multiarch_testing/make-hdc-img.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+HDCMEGS=128
+
+rm hdc.img 2>/dev/null
+umount -d hdc.img.dir 2>/dev/null
+rm -rf hdc.img.dir 2>/dev/null
+
+dd if=/dev/zero of=hdc.img bs=1024 seek=$((HDCMEGS*1024-1)) count=1 &&
+mke2fs -q -b 1024 -F -i 4096 hdc.img &&
+tune2fs -j -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 &&
+rm -rf hdc.img.dir &&
+true
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 0000000..dd77b82
--- /dev/null
+++ b/qemu_multiarch_testing/parallel-build-hdc-img.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+build_in_dir()
+{
+	cd "$1" || exit 1
+	rm -f hdb.img 2>/dev/null
+	./native-build.sh ../hdc.img
+	rm -f hdb.img 2>/dev/null
+}
+
+started=false
+for dir; do
+	test -d "$dir" || continue
+	test -e "$dir/native-build.sh" || continue
+	echo "Starting: $dir"
+	build_in_dir "$dir" </dev/null >"$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"