@@ -312,6 +312,7 @@ tests.init.test_systemd.TestInitSystemSystemdRoNetworkd: *runtime_test
tests.init.test_systemd.TestInitSystemSystemdRwFull: *runtime_test
tests.init.test_systemd.TestInitSystemSystemdRwIfupdown: *runtime_test
tests.init.test_systemd.TestInitSystemSystemdRwNetworkd: *runtime_test
+tests.package.test_clang.TestClangCompilerRT: *runtime_test
tests.package.test_dropbear.TestDropbear: *runtime_test
tests.package.test_ipython.TestIPythonPy2: *runtime_test
tests.package.test_ipython.TestIPythonPy3: *runtime_test
new file mode 100644
@@ -0,0 +1 @@
+source "$BR2_EXTERNAL_CLANG_COMPILER_RT_PATH/package/libfuzzer/Config.in"
new file mode 100644
@@ -0,0 +1 @@
+name: CLANG_COMPILER_RT
new file mode 100644
@@ -0,0 +1 @@
+include $(sort $(wildcard $(BR2_EXTERNAL_CLANG_COMPILER_RT_PATH)/package/*/*.mk))
new file mode 100644
@@ -0,0 +1,7 @@
+config BR2_PACKAGE_LIBFUZZER
+ bool "libfuzzer"
+ help
+ This is a set of tests (benchmarks) for fuzzing
+ engines (fuzzers).
+
+ https://github.com/google/fuzzer-test-suite
new file mode 100644
@@ -0,0 +1,2 @@
+sha256 c0addb4d7f0447fc9fd7c80e5721fafe4c137f29a8ebd94c5fef7e1d6a2c944c libfuzzer-64e4d9aa19a8d33b61882154addbf8419d7416e1.tar.gz
+sha256 cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30 LICENSE
new file mode 100644
@@ -0,0 +1,24 @@
+################################################################################
+#
+# libfuzzer
+#
+################################################################################
+
+LIBFUZZER_VERSION = 64e4d9aa19a8d33b61882154addbf8419d7416e1
+LIBFUZZER_SITE = $(call github,google,fuzzer-test-suite,$(LIBFUZZER_VERSION))
+LIBFUZZER_LICENSE = Apache-2.0
+LIBFUZZER_LICENSE_FILES = LICENSE
+LIBFUZZER_DEPENDENCIES = compiler-rt
+
+define LIBFUZZER_BUILD_CMDS
+ $(HOST_DIR)/bin/clang++ -mcpu=cortex-a53 --sysroot=$(STAGING_DIR) \
+ -B $(HOST_DIR)/opt/ext-toolchain -fsanitize=address,fuzzer \
+ $(@D)/tutorial/fuzz_me.cc \
+ -o $(@D)/fuzz_me
+endef
+
+define LIBFUZZER_INSTALL_TARGET_CMDS
+ $(INSTALL) -D -m 755 $(@D)/fuzz_me $(TARGET_DIR)/usr/bin/fuzz_me
+endef
+
+$(eval $(generic-package))
new file mode 100644
@@ -0,0 +1,46 @@
+import os
+
+import infra.basetest
+
+FUZZ_TIMEOUT = 120
+
+
+class TestClangCompilerRT(infra.basetest.BRTest):
+ br2_external = [infra.filepath("tests/package/br2-external/clang-compiler-rt")]
+ config = \
+ """
+ BR2_aarch64=y
+ BR2_TOOLCHAIN_EXTERNAL=y
+ BR2_TARGET_GENERIC_GETTY_PORT="ttyAMA0"
+ BR2_LINUX_KERNEL=y
+ BR2_LINUX_KERNEL_CUSTOM_VERSION=y
+ BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="4.16.7"
+ BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
+ BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/aarch64-virt/linux.config"
+ BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y
+ BR2_PACKAGE_COMPILER_RT=y
+ BR2_PACKAGE_LLVM=y
+ BR2_TARGET_ROOTFS_CPIO=y
+ BR2_TARGET_ROOTFS_CPIO_GZIP=y
+ # BR2_TARGET_ROOTFS_TAR is not set
+ BR2_PACKAGE_LIBFUZZER=y
+ """
+
+ def login(self):
+ img = os.path.join(self.builddir, "images", "rootfs.cpio.gz")
+ kern = os.path.join(self.builddir, "images", "Image")
+ # Sanitizers overallocate memory and the minimum that seemed to work was 512MB
+ self.emulator.boot(arch="aarch64",
+ kernel=kern,
+ kernel_cmdline=["console=ttyAMA0"],
+ options=["-M", "virt", "-cpu", "cortex-a53", "-m", "512", "-initrd", img])
+ self.emulator.login()
+
+ def test_run(self):
+ self.login()
+
+ # The test case verifies both that the application executes and that
+ # the symbolizer is working to decode the stack trace
+ cmd = "fuzz_me 2>&1 | grep _M_replace"
+ _, exit_code = self.emulator.run(cmd, FUZZ_TIMEOUT)
+ self.assertEqual(exit_code, 0)