1import os 2 3import infra.basetest 4 5FUZZ_TIMEOUT = 120 6 7 8class TestClangCompilerRT(infra.basetest.BRTest): 9 br2_external = [infra.filepath("tests/package/br2-external/clang-compiler-rt")] 10 config = \ 11 """ 12 BR2_aarch64=y 13 BR2_TOOLCHAIN_EXTERNAL=y 14 BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0" 15 BR2_LINUX_KERNEL=y 16 BR2_LINUX_KERNEL_CUSTOM_VERSION=y 17 BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.19.283" 18 BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y 19 BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config" 20 BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y 21 BR2_PACKAGE_COMPILER_RT=y 22 BR2_PACKAGE_LLVM=y 23 BR2_TARGET_ROOTFS_CPIO=y 24 BR2_TARGET_ROOTFS_CPIO_GZIP=y 25 # BR2_TARGET_ROOTFS_TAR is not set 26 BR2_PACKAGE_LIBFUZZER=y 27 """ 28 29 def login(self): 30 img = os.path.join(self.builddir, "images", "rootfs.cpio.gz") 31 kern = os.path.join(self.builddir, "images", "Image") 32 # Sanitizers overallocate memory and the minimum that seemed to work was 512MB 33 self.emulator.boot(arch="aarch64", 34 kernel=kern, 35 kernel_cmdline=["console=ttyAMA0"], 36 options=["-M", "virt", "-cpu", "cortex-a53", "-m", "512", "-initrd", img]) 37 self.emulator.login() 38 39 def test_run(self): 40 self.login() 41 42 # The test case verifies the application executes and that 43 # the symbolizer is working to decode the stack trace. 44 cmd = "fuzz_me 2>&1 | grep heap-buffer-overflow" 45 _, exit_code = self.emulator.run(cmd, FUZZ_TIMEOUT) 46 self.assertEqual(exit_code, 0) 47