Skip to content

Commit 83c0b27

Browse files
ddissbrauner
authored andcommitted
initramfs_test: kunit tests for initramfs unpacking
Provide some basic initramfs unpack sanity tests covering: - simple file / dir extraction - filename field overrun, as reported and fixed separately via https://lore.kernel.org/r/[email protected] - "070702" cpio data checksums - hardlinks Signed-off-by: David Disseldorp <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christian Brauner <[email protected]>
1 parent 5f469c4 commit 83c0b27

File tree

4 files changed

+418
-0
lines changed

4 files changed

+418
-0
lines changed

init/.kunitconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CONFIG_KUNIT=y
2+
CONFIG_BLK_DEV_INITRD=y
3+
CONFIG_INITRAMFS_TEST=y

init/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,6 +1454,13 @@ config INITRAMFS_PRESERVE_MTIME
14541454

14551455
If unsure, say Y.
14561456

1457+
config INITRAMFS_TEST
1458+
bool "Test initramfs cpio archive extraction" if !KUNIT_ALL_TESTS
1459+
depends on BLK_DEV_INITRD && KUNIT=y
1460+
default KUNIT_ALL_TESTS
1461+
help
1462+
Build KUnit tests for initramfs. See Documentation/dev-tools/kunit
1463+
14571464
choice
14581465
prompt "Compiler optimization level"
14591466
default CC_OPTIMIZE_FOR_PERFORMANCE

init/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ else
1212
obj-$(CONFIG_BLK_DEV_INITRD) += initramfs.o
1313
endif
1414
obj-$(CONFIG_GENERIC_CALIBRATE_DELAY) += calibrate.o
15+
obj-$(CONFIG_INITRAMFS_TEST) += initramfs_test.o
1516

1617
obj-y += init_task.o
1718

0 commit comments

Comments
 (0)