[U-Boot] [RFC PATCH 0/20] New 'sandbox' test architecture for U-Boot
Simon Glass
sjg at chromium.org
Sat Sep 17 18:46:35 CEST 2011
This patch set points towards a possible way to improve the test
infrastructure in U-Boot. The goal is to have a test suite that can run in
a minute or two on a Linux PC and test all non-platform code.
This RFC aims to be just enough boot to U-Boot to a command prompt. You
can type help; anything else will probably segfault :-) Press Ctrl-C to
exit.
This patch set does not include some other code I have been playing around
with, like a SPI flash driver and sandbox 'state' (so the state can be
examined and modified to test failure modes and the like).
$ ./u-boot
U-Boot 2011.09-rc1-00041-ge50de7d-dirty (Sep 17 2011 - 08:17:40)
DRAM: 128 MiB
Using default environment
In: serial
Out: serial
Err: serial
Detail
======
We can break the U-Boot code base into two parts:
1. Platform code, which is SOC-specifc. At present this is the CPU
init (arch/xxx/cpu/...) and SOC-specific drivers (mostly in the
drivers directory). There is also a small amount of generic CPU code
in arch/xxx/lib and some board-specific code/drivers (e.g. drivers not
within the SOC).
2. Portable/Generic U-Boot code, which is cross-platform. This
includes many drivers, the various commands, file system support,
things like the MMC, USB and network stacks, etc.
My focus in this patch set is the second part of the code base - all the
code which is not platform-specific, but can still have bugs.
Proposal
========
To a large extent, testing of this part of the code base could simply
be built on one or more of the available platforms. We could then run
the tests on that platform, and announce that the code base works fine
on that platform. Obviously the platform needs to support all possible
features of U-Boot.
However, this approach fails to take advantage of two useful
properties of this code:
- It is cross-platform, and even runs on x86
- It is standalone, requiring no OS libraries to run
For speed, debugging and convenience, it would be nice to run U-Boot
under a generic Linux environment on a workstation, and test all the
generic non-platform code. The basic problem with this is that the
non-platform code requires the platform code to operate. Even the x86
platform code is designed for standalone operation on a particular x86
board, and is not suitable for running under x86 Linux.
To get around this I propose that we create a new ‘sandbox’
architecture. We write code in ‘arch/sandbox’ which can run under
Linux. Since all the non-platform code will happily run under this new
‘architecture’, we can then write tests which run quickly under x86
Linux (or another Linux for that matter). This U-Boot 'architecture'
should build natively on any 32/64-bit Linux machine since it just
uses standard Linux system calls. Calls to Linux would be entirely
within this arch/sandbox subdirectory.
Benefit
=======
What will this buy us? Well we can do things like:
- Create a test SPI flash device, which is file-backed. Use this to
write a test of the cmd_sf layer by issuing a series of commands and
making sure that the correct SPI flash contents is obtained
- Create a test MMC or IDE device, backed by a file. Use this to issue
ext2 and fat commands to manipulate the filesystem. Then loopback
mount the file and check from Linux that U-Boot did the right thing
- Create a test Ethernet device with a mocked remote host attached.
Use this to issue network commands like bootp and tftp and check that
the correct results are obtained.
Ultimately (one day) we might have a set of unit tests for U-Boot
which can run to very quickly check that a patch does not break the
core U-Boot code.
Building
========
make ARCH=sandbox sandbox_config
make ARCH=sandbox all
(The lds script is targeted for bfd and might not work with the gold linker)
Comments
========
Comments are welcome and I have cc'd those who showed an interest to my
initial email. My goal is to create a real patch set in the next few weeks.
Please excuse the checkpatch violations, many of which seem to be less than
useful. This code is a bit rough in places, but I want comments on it before
polishing. There are a few strange things needed in the build as well, which
I hope to improve.
Simon Glass (20):
sandbox: Add architecture header files
sandbox: Add architecture image support
sandbox: Add compiler defines to support a 64-bit x86_64 platform
sandbox: Add cpu files
sandbox: Add architecture lib files
sandbox: Allow board_init_f() and board_init_r() to return
sandbox: Add sandbox board
sandbox: Add board info for architecture
sandbox: Add bootm support
sandbox: Disable built-in malloc
sandbox: Disable standalone/API support
sandbox: Force command sections to be 4-byte aligned
sandbox: Add OS dependent layer
sandbox: Add board_init()
sandbox: Add main program
sandbox: Add serial uart
sandbox: Add basic config file
sandbox: Remove unused variable warnings
sandbox: Use uintptr_t for 32/64-bit compatibility
sandbox: Makefile changes to build sandbox architecture
Makefile | 23 ++-
arch/sandbox/config.mk | 21 ++
arch/sandbox/cpu/sandbox/Makefile | 47 ++++
arch/sandbox/cpu/sandbox/cpu.c | 59 +++++
arch/sandbox/cpu/sandbox/u-boot.lds | 34 +++
arch/sandbox/include/asm/arch-sandbox/clock.h | 25 ++
arch/sandbox/include/asm/arch-sandbox/gpio.h | 29 +++
arch/sandbox/include/asm/bitops.h | 162 ++++++++++++++
arch/sandbox/include/asm/byteorder.h | 40 ++++
arch/sandbox/include/asm/config.h | 26 +++
arch/sandbox/include/asm/global_data.h | 68 ++++++
arch/sandbox/include/asm/io.h | 41 ++++
arch/sandbox/include/asm/posix_types.h | 85 +++++++
arch/sandbox/include/asm/ptrace.h | 39 ++++
arch/sandbox/include/asm/string.h | 52 +++++
arch/sandbox/include/asm/system.h | 36 +++
arch/sandbox/include/asm/types.h | 72 ++++++
arch/sandbox/include/asm/u-boot-sandbox.h | 59 +++++
arch/sandbox/include/asm/u-boot.h | 61 +++++
arch/sandbox/include/asm/unaligned.h | 41 ++++
arch/sandbox/lib/Makefile | 62 +++++
arch/sandbox/lib/board.c | 294 +++++++++++++++++++++++++
arch/sandbox/lib/interrupts.c | 39 ++++
board/sandbox/common/Makefile | 47 ++++
board/sandbox/common/board.c | 25 ++
board/sandbox/common/main.c | 34 +++
board/sandbox/common/os.c | 49 ++++
board/sandbox/sandbox/Makefile | 50 +++++
board/sandbox/sandbox/sandbox.c | 54 +++++
boards.cfg | 1 +
common/Makefile | 2 +
common/cmd_bdinfo.c | 34 +++-
common/cmd_bootm.c | 11 +-
common/cmd_mem.c | 4 +-
common/cmd_nvedit.c | 2 +-
common/fdt_support.c | 8 +-
common/image.c | 5 +-
doc/README.sandbox | 47 ++++
drivers/serial/Makefile | 1 +
drivers/serial/sandbox.c | 67 ++++++
include/command.h | 3 +-
include/common.h | 12 +-
include/compiler.h | 12 +-
include/configs/sandbox.h | 80 +++++++
include/image.h | 3 +
include/os.h | 27 +++
46 files changed, 1968 insertions(+), 25 deletions(-)
create mode 100644 arch/sandbox/config.mk
create mode 100644 arch/sandbox/cpu/sandbox/Makefile
create mode 100644 arch/sandbox/cpu/sandbox/cpu.c
create mode 100644 arch/sandbox/cpu/sandbox/u-boot.lds
create mode 100644 arch/sandbox/include/asm/arch-sandbox/clock.h
create mode 100644 arch/sandbox/include/asm/arch-sandbox/gpio.h
create mode 100644 arch/sandbox/include/asm/bitops.h
create mode 100644 arch/sandbox/include/asm/byteorder.h
create mode 100644 arch/sandbox/include/asm/config.h
create mode 100644 arch/sandbox/include/asm/global_data.h
create mode 100644 arch/sandbox/include/asm/io.h
create mode 100644 arch/sandbox/include/asm/posix_types.h
create mode 100644 arch/sandbox/include/asm/ptrace.h
create mode 100644 arch/sandbox/include/asm/string.h
create mode 100644 arch/sandbox/include/asm/system.h
create mode 100644 arch/sandbox/include/asm/types.h
create mode 100644 arch/sandbox/include/asm/u-boot-sandbox.h
create mode 100644 arch/sandbox/include/asm/u-boot.h
create mode 100644 arch/sandbox/include/asm/unaligned.h
create mode 100644 arch/sandbox/lib/Makefile
create mode 100644 arch/sandbox/lib/board.c
create mode 100644 arch/sandbox/lib/interrupts.c
create mode 100644 board/sandbox/common/Makefile
create mode 100644 board/sandbox/common/board.c
create mode 100644 board/sandbox/common/main.c
create mode 100644 board/sandbox/common/os.c
create mode 100644 board/sandbox/sandbox/Makefile
create mode 100644 board/sandbox/sandbox/sandbox.c
create mode 100644 doc/README.sandbox
create mode 100644 drivers/serial/sandbox.c
create mode 100644 include/configs/sandbox.h
create mode 100644 include/os.h
--
1.7.3.1
More information about the U-Boot
mailing list