| #!/bin/bash -eu |
| |
| build() { |
| echo "I: Using $("$gnuarch-gcc" --version | head -1)" |
| echo "I: Using $("$gnuarch-ld" --version | head -1)" |
| |
| echo "I: Generating kernel UAPI headers for ARCH=$kernelarch" |
| rm -rf ../linux/usr/include || return |
| make -C ../linux "ARCH=$kernelarch" headers_install || return |
| echo "I: Building with ARCH=$arch CROSS_COMPILE=$gnuarch- $makeflags" |
| make -C ../klibc all test "ARCH=$arch" "CROSS_COMPILE=$gnuarch-" $makeflags \ |
| || return |
| } |
| |
| clean() { |
| echo "I: Cleaning" |
| make -C ../klibc clean "ARCH=$arch" |
| } |
| |
| run_test_program() { |
| local progname="$1" |
| shift |
| local logname="test-$gnuarch-$progname.log" |
| |
| if "qemu-$qemuarch-static" ../klibc/usr/klibc/tests/"$progname" \ |
| > "$logname"; then |
| if grep -qw ERROR "$logname"; then |
| echo "E: $progname: Error found in output" |
| return 1 |
| fi |
| while [ $# -ge 1 ]; do |
| if ! grep -qF -- "$1" "$logname"; then |
| echo "E: $progname: Expected text '$1' not found in output" |
| return 1 |
| fi |
| shift |
| done |
| echo "I: $progname: pass" |
| else |
| echo "E: $progname: fail" |
| return 1 |
| fi |
| } |
| |
| run_shell() { |
| local command="$1" |
| |
| if "qemu-$qemuarch-static" ../klibc/usr/dash/sh -c "$command"; then |
| echo "I: shell '$command': pass" |
| else |
| echo "E: shell '$command': fail" |
| return 1 |
| fi |
| } |
| |
| run_tests() { |
| local err=0 |
| |
| run_test_program microhello || err=1 |
| run_test_program minihello || err=1 |
| run_test_program hello || err=1 |
| run_test_program environ 'Verifying envp == environ... ok' || err=1 |
| run_test_program fcntl || err=1 |
| run_test_program malloctest || err=1 |
| run_test_program malloctest2 || err=1 |
| run_test_program opentest "Line 1 = $(head -1 /etc/passwd)" || err=1 |
| run_test_program pipetest || err=1 |
| run_test_program select || err=1 |
| run_test_program setjmptest \ |
| "calling longjmp with 256... setjmp returned 256" || err=1 |
| run_test_program sigint "Signal received OK" || err=1 |
| run_test_program socket || err=1 |
| run_test_program sscanf || err=1 |
| run_test_program stdio "Hello, World!" \ |
| "Hello again - and some more - and some more" || err=1 |
| run_test_program strlcpycat || err=1 |
| run_test_program vfork || err=1 |
| |
| run_shell "exit" || err=1 |
| run_shell "../klibc/usr/utils/static/true; exit" || err=1 |
| |
| return $err |
| } |
| |
| process() { |
| arch="$1" |
| kernelarch="$2" |
| gnuarch="$3" |
| qemuarch="$4" |
| makeflags="${5:-}" |
| |
| echo "I: Architecture $arch/$gnuarch: begin" |
| if clean && build && run_tests; then |
| echo "I: Architecture $arch/$gnuarch: pass" |
| else |
| echo "E: Architecture $arch/$gnuarch: fail" |
| fi |
| clean || true |
| } |
| |
| echo "I: $0 started at $(date)" |
| echo "I: Using klibc $(GIT_DIR=../klibc/.git git describe)" |
| echo "I: Using Linux $(make -C ../linux -s kernelversion)" |
| |
| rm -rf ../klibc/linux |
| ln -s ../linux/usr ../klibc/linux |
| |
| process alpha alpha alpha-linux-gnu alpha |
| # arm OABI is no longer supported in Debian. |
| #process arm arm arm-linux-gnu arm |
| process arm arm arm-linux-gnueabi arm "CONFIG_AEABI=y" |
| process arm arm arm-linux-gnueabihf arm "CONFIG_AEABI=y CPU_ARCH=armv7-a CPU_TUNE=cortex-a8 CONFIG_KLIBC_THUMB=y" |
| process arm64 arm64 aarch64-linux-gnu aarch64 |
| # cris is not supported in Debian. |
| #process cris cris cris-linux-gnu cris |
| process i386 x86 i686-linux-gnu i386 |
| # ia64 cross-compiler is currently missing in Debian, as is QEMU support. |
| #process ia64 ia64 ia64-linux-gnu ??? |
| process m68k m68k m68k-linux-gnu m68k |
| process mips mips mips-linux-gnu mips |
| process mips mips mipsel-linux-gnu mipsel |
| # Big-endian mips64 is not supported in Debian. |
| #process mips64 mips mips64-linux-gnuabi64 mips64 |
| process mips64 mips mips64el-linux-gnuabi64 mips64el |
| process parisc parisc hppa-linux-gnu hppa |
| process ppc powerpc powerpc-linux-gnu ppc |
| process ppc powerpc powerpc-linux-gnuspe ppc |
| process ppc64 powerpc powerpc64-linux-gnu ppc64 |
| process ppc64 powerpc powerpc64le-linux-gnu ppc64le |
| process riscv64 riscv riscv64-linux-gnu riscv64 |
| # 32-bit s390 is no longer supported in Debian. |
| #process s390 s390 s390-linux-gnu s390 |
| process s390x s390 s390x-linux-gnu s390x |
| process sh sh sh4-linux-gnu sh4 |
| # 32-bit sparc is no longer supported in Debian. |
| #process sparc sparc sparc-linux-gnu sparc |
| process sparc64 sparc sparc64-linux-gnu sparc64 |
| process x86_64 x86 x86_64-linux-gnu x86_64 |
| |
| echo "I: $0 finished at $(date)" |