On Mon, Oct 30, 2023 at 03:58:14PM +0100, [email protected] wrote:
> From: Janpieter Sollie <[email protected]>
> 
> Allow the tests to run on a non-ABI-compatible cpu,
> verify code when the architecture isn't physically available.
> in the future, bcachefs-tools should be cross-compiled,
> and the list of CPU types should be expanded
> 
> Signed-off-by: jpsollie <[email protected]>
> ---
>  build-test-kernel |  2 +-
>  lib/common.sh     | 11 ++++++++---
>  lib/libktest.sh   |  8 ++++++--
>  lib/testrunner    | 10 +++++++++-
>  root_image        |  8 +++++++-
>  tests/kconfig.sh  |  2 ++
>  6 files changed, 33 insertions(+), 8 deletions(-)
> 
> diff --git a/build-test-kernel b/build-test-kernel
> index 72990ba..9121fd1 100755
> --- a/build-test-kernel
> +++ b/build-test-kernel
> @@ -107,7 +107,7 @@ ktest_kernel_source=$(readlink -e "$ktest_kernel_source")
>  ktest_kernel_build="$ktest_out/kernel_build.$ktest_arch"
>  mkdir -p "$ktest_kernel_build"
>  
> -if [[ -n $CROSS_COMPILE ]]; then
> +if [[ -z ${CROSS_COMPILE:+x} ]]; then

???

This looks like a workaround for test, i.e. [ - [[ behaves better.

> diff --git a/lib/testrunner b/lib/testrunner
> index acbc45f..a8e8d17 100755
> --- a/lib/testrunner
> +++ b/lib/testrunner
> @@ -20,6 +20,10 @@ ktest_out="/host/$ktest_out"
>  ln -sf $ktest_dir /ktest
>  ln -sf $ktest_out /ktest-out
>  
> +. /ktest/lib/common.sh
> +
> +parse_arch $(uname -m)
> +
>  # Some home directories are in weird places:
>  mkdir -p $(dirname $home)
>  ln -sf /host/$home $home
> @@ -92,7 +96,11 @@ for i in "${ktest_make_install[@]}"; do
>      if [[ -f configure && ! -f Makefile ]]; then
>       run_quiet "configure $(basename $i)" ./configure
>      fi
> -    run_quiet "building $(basename $i)" make -j $ktest_cpus
> +    #this won't make me popular - compiling bcachefs tools with rust support 
> on a emulated machine is too heavy to be useful, so omit it:
> +    rustcompile="" && [[ "$(systemd-detect-virt)" == "qemu" ]] && 
> rustcompile="NO_RUST=1"
> +    #bcachefs tools sometimes seems to use compiled files from previous 
> runs, even if other architecture, so clean out:
> +    [ "bcachefs-tools" == "$(basename $i)" ] && [ "$(objdump -f bcachefs.o | 
> grep architecture | cut -d' ' -f 2)" == "$(objdump -f /bin/bash | grep 
> architecture | cut -d' ' -f 2)" ] || make clean
> +    run_quiet "building $(basename $i)" make $rustcompile -j $ktest_cpus
>      run_quiet "installing $(basename $i)" make -j $ktest_cpus install
>      popd > /dev/null

Nope, don't put bcachefs-tools specific stuff in testrunner.

>  done
> diff --git a/root_image b/root_image
> index 26c99fe..87add22 100755
> --- a/root_image
> +++ b/root_image
> @@ -118,7 +118,12 @@ PACKAGES+=(cryptsetup)
>  PACKAGES+=(multipath-tools sg3-utils srptools)
>  
>  # ZFS support
> -PACKAGES+=("linux-headers-generic" dkms zfsutils-linux zfs-dkms)
> +PACKAGES+=("linux-headers-generic")
> +# unless no other option when cross-compiling, ignore ZFS
> +# DKMS needs to cross-compile the module,
> +# against a different kernel on a different CPUarchitecture.
> +# this has to cause errors
> +[ $CROSS_COMPILE == 1 ] || PACKAGES+=(dkms zfsutils-linux zfs-dkms)

CROSS_COMPILE isn't for root_image - not sure what you're trying to do
here.

Reply via email to