[PATCH v2 00/14] selftests/nolibc: add minimal kernel config support - part1

From: Zhangjin Wu
Date: Wed Jul 19 2023 - 09:17:27 EST


Hi, Willy, Thomas

Here is the first part of v2 of our tinyconfig support for nolibc-test
[1], the patchset subject is reserved as before.

As discussed in v1 thread [1], to easier the review progress, the whole
tinyconfig support is divided into several parts, mainly by
architecture, here is the first part, include basic preparation and
powerpc example.

This patchset should be applied after the 32/64-bit powerpc support [2],
exactly these two are required by us:

* selftests/nolibc: add extra config file customize support
* selftests/nolibc: add XARCH and ARCH mapping support

In this patchset, we firstly add some misc preparations and at last add
the tinyconfig target and use powerpc as the first example.

Tests:

// powerpc run-user
$ for arch in powerpc powerpc64 powerpc64le; do \
rm -rf $PWD/kernel-$arch; \
mkdir -p $PWD/kernel-$arch; \
make run-user XARCH=$arch O=$PWD/kernel-$arch RUN_OUT=$PWD/run.$arch.out | grep "status: "; \
done
165 test(s): 157 passed, 8 skipped, 0 failed => status: warning
165 test(s): 157 passed, 8 skipped, 0 failed => status: warning
165 test(s): 157 passed, 8 skipped, 0 failed => status: warning

// powerpc run
$ for arch in powerpc powerpc64 powerpc64le; do \
rm -rf $PWD/kernel-$arch; \
mkdir -p $PWD/kernel-$arch; \
make tinyconfig run XARCH=$arch O=$PWD/kernel-$arch RUN_OUT=$PWD/run.$arch.out; \
done

$ for arch in powerpc powerpc64 powerpc64le; do \
make report XARCH=$arch O=$PWD/kernel-$arch RUN_OUT=$PWD/run.$arch.out | grep "status: "; \
done
165 test(s): 156 passed, 9 skipped, 0 failed => status: warning
165 test(s): 156 passed, 9 skipped, 0 failed => status: warning
165 test(s): 156 passed, 9 skipped, 0 failed => status: warning

// the others, randomly choose some
$ make run-user XARCH=arm O=$PWD/kernel-arm RUN_OUT=$PWD/run.arm.out CROSS_COMPILE=arm-linux-gnueabi- | grep status:
165 test(s): 156 passed, 9 skipped, 0 failed => status: warning
$ make run-user XARCH=x86_64 O=$PWD/kernel-arm RUN_OUT=$PWD/run.x86_64.out CROSS_COMPILE=x86_64-linux-gnu- | grep status:
165 test(s): 157 passed, 8 skipped, 0 failed => status: warning
$ make run-libc-test | grep status:
165 test(s): 153 passed, 12 skipped, 0 failed => status: warning

// x86_64, require noapic kernel command line option for old qemu-system-x86_64 (v4.2.1)
$ make run XARCH=x86_64 O=$PWD/kernel-x86_64 RUN_OUT=$PWD/run.x86_64.out CROSS_COMPILE=x86_64-linux-gnu- | grep status
$ make rerun XARCH=x86_64 O=$PWD/kernel-x86_64 RUN_OUT=$PWD/run.x86_64.out CROSS_COMPILE=x86_64-linux-gnu- | grep status
165 test(s): 159 passed, 6 skipped, 0 failed => status: warning

tinyconfig mainly targets as a time-saver, the misc preparations service
for the same goal, let's take a look:

* selftests/nolibc: allow report with existing test log

Like rerun without rebuild, Add report (without rerun) to summarize
the existing test log, this may work perfectly with the 'grep status'

* selftests/nolibc: add macros to enhance maintainability

Several macros are added to dedup the shared code to shrink lines
and easier the maintainability

The macros are added just before the using area to avoid code change
conflicts in the future.

* selftests/nolibc: print running log to screen

Enable logging to let developers learn what is happening at the
first glance, without the need to edit the Makefile and rerun it.

These helps a lot when there is a long-time running, a failed
poweroff or even a forever hang.

For test summmary, the 'grep status' can be used together with the
standalone report target.

* selftests/nolibc: fix up O= option support

With objtree instead srctree for .config and IMAGE, now, O= works.

Using O=$PWD/kernel-$arch avoid the mrproer for every build.

* selftests/nolibc: add menuconfig for development

Allow manually tuning some options, mainly for a new architecture
porting.

* selftests/nolibc: add mrproper for development
selftests/nolibc: defconfig: remove mrproper target

Split the mrproper target out of defconfig, when with O=, mrproper is not
required by defconfig, but reserve it for the other use scenes.

* selftests/nolibc: string the core targets

Allow simply 'make run' instead of 'make defconfig; make extconfig;
make kernel; make run'.

* selftests/nolibc: allow quit qemu-system when poweroff fails

When poweroff fails, allow exit while detects the power off string
from output or the wait time is too long (specified by QEMU_TIMEOUT).

This helps the boards who have no poweroff support or the kernel not
enable the poweroff options (mainly for tinyconfig).

* selftests/nolibc: allow customize CROSS_COMPILE by architecture
* selftests/nolibc: customize CROSS_COMPILE for 32/64-bit powerpc

This further saves a CROSS_COMPILE option for 'make run', it is very
important when iterates all of the supported architectures and the
compilers are not just prefixed with the XARCH variable.

For example, binary of big endian powerpc64 can be compiled with
powerpc64le-linux-gnu-, but the prefix is powerpc64le.

Even if the pre-customized compiler not exist, we can configure
CROSS_COMPILE_<ARCH> before the test loop to use the code.

* selftests/nolibc: add tinyconfig target
selftests/nolibc: tinyconfig: add extra common options
selftests/nolibc: tinyconfig: add support for 32/64-bit powerpc

Here is the first architecture(and its variants) support tinyconfig.

powerpc is actually a very good architecture, for it has 'various'
variants for test.

Best regards,
Zhangjin
---
[1]: https://lore.kernel.org/lkml/cover.1687706332.git.falcon@xxxxxxxxxxx/
[2]: https://lore.kernel.org/lkml/cover.1689713175.git.falcon@xxxxxxxxxxx/


Zhangjin Wu (14):
selftests/nolibc: allow report with existing test log
selftests/nolibc: add macros to enhance maintainability
selftests/nolibc: print running log to screen
selftests/nolibc: fix up O= option support
selftests/nolibc: add menuconfig for development
selftests/nolibc: add mrproper for development
selftests/nolibc: defconfig: remove mrproper target
selftests/nolibc: string the core targets
selftests/nolibc: allow quit qemu-system when poweroff fails
selftests/nolibc: allow customize CROSS_COMPILE by architecture
selftests/nolibc: customize CROSS_COMPILE for 32/64-bit powerpc
selftests/nolibc: add tinyconfig target
selftests/nolibc: tinyconfig: add extra common options
selftests/nolibc: tinyconfig: add support for 32/64-bit powerpc

tools/testing/selftests/nolibc/Makefile | 102 ++++++++++++++----
.../selftests/nolibc/configs/common.config | 4 +
.../selftests/nolibc/configs/powerpc.config | 3 +
.../selftests/nolibc/configs/powerpc64.config | 3 +
.../nolibc/configs/powerpc64le.config | 4 +
5 files changed, 98 insertions(+), 18 deletions(-)
create mode 100644 tools/testing/selftests/nolibc/configs/common.config
create mode 100644 tools/testing/selftests/nolibc/configs/powerpc64.config
create mode 100644 tools/testing/selftests/nolibc/configs/powerpc64le.config

--
2.25.1