lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Tue, 25 Jun 2024 17:54:08 +0530
From: Dev Jain <dev.jain@....com>
To: shuah@...nel.org,
	linux-arm-kernel@...ts.infradead.org,
	linux-kselftest@...r.kernel.org,
	Catalin.Marinas@....com,
	will@...nel.org
Cc: broonie@...nel.org,
	ryan.roberts@....com,
	rob.herring@....com,
	mark.rutland@....com,
	linux@...linux.org.uk,
	suzuki.poulose@....com,
	Anshuman.Khandual@....com,
	aneesh.kumar@...nel.org,
	linux-kernel@...r.kernel.org,
	Dev Jain <dev.jain@....com>
Subject: [PATCH v3 9/9] selftests: Add build infrastructure along with README

Add arm target, individual Makefile targets, and instructions to build the
tests, along with .gitignore files. All the Makefiles are similar to
selftests/arm64, except abi: use TEST_CUSTOM_PROGS to override the make
rule from lib.mk. Also, do not build ptrace_64 if we are running a
32-bit kernel.

Signed-off-by: Dev Jain <dev.jain@....com>
---
v2->v3:
 - Add abi Makefile and .gitignore
 - Remove config file

v1->v2:
 - Add config file

 tools/testing/selftests/Makefile              |  1 +
 tools/testing/selftests/arm/Makefile          | 56 +++++++++++++++++++
 tools/testing/selftests/arm/README            | 32 +++++++++++
 tools/testing/selftests/arm/abi/.gitignore    |  4 ++
 tools/testing/selftests/arm/abi/Makefile      | 26 +++++++++
 tools/testing/selftests/arm/elf/.gitignore    |  2 +
 tools/testing/selftests/arm/elf/Makefile      |  6 ++
 tools/testing/selftests/arm/mm/.gitignore     |  2 +
 tools/testing/selftests/arm/mm/Makefile       |  6 ++
 tools/testing/selftests/arm/signal/.gitignore |  3 +
 tools/testing/selftests/arm/signal/Makefile   | 30 ++++++++++
 11 files changed, 168 insertions(+)
 create mode 100644 tools/testing/selftests/arm/Makefile
 create mode 100644 tools/testing/selftests/arm/README
 create mode 100644 tools/testing/selftests/arm/abi/.gitignore
 create mode 100644 tools/testing/selftests/arm/abi/Makefile
 create mode 100644 tools/testing/selftests/arm/elf/.gitignore
 create mode 100644 tools/testing/selftests/arm/elf/Makefile
 create mode 100644 tools/testing/selftests/arm/mm/.gitignore
 create mode 100644 tools/testing/selftests/arm/mm/Makefile
 create mode 100644 tools/testing/selftests/arm/signal/.gitignore
 create mode 100644 tools/testing/selftests/arm/signal/Makefile

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 9039f3709aff..d7420825f165 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -1,6 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 TARGETS += alsa
 TARGETS += amd-pstate
+TARGETS += arm
 TARGETS += arm64
 TARGETS += bpf
 TARGETS += breakpoints
diff --git a/tools/testing/selftests/arm/Makefile b/tools/testing/selftests/arm/Makefile
new file mode 100644
index 000000000000..54e44c4a62bf
--- /dev/null
+++ b/tools/testing/selftests/arm/Makefile
@@ -0,0 +1,56 @@
+# SPDX-License-Identifier: GPL-2.0
+
+ARCH ?= $(shell uname -m 2>/dev/null || echo not)
+
+ifneq (,$(filter $(ARCH),aarch64 arm64 arm armv7l armv8l))
+ARM_SUBTARGETS ?= abi elf mm signal
+else
+ARM_SUBTARGETS :=
+endif
+
+CFLAGS := -Wall -O2 -g -static
+
+# A proper top_srcdir is needed by KSFT(lib.mk)
+top_srcdir = $(realpath ../../../../)
+
+# Additional include paths needed by kselftest.h and local headers
+CFLAGS += -I$(top_srcdir)/tools/testing/selftests/
+
+CFLAGS += -I$(top_srcdir)/tools/include
+
+export CFLAGS
+export top_srcdir
+
+all:
+	@for DIR in $(ARM_SUBTARGETS); do				\
+		BUILD_TARGET=$(OUTPUT)/$$DIR;			\
+		mkdir -p $$BUILD_TARGET;			\
+		make OUTPUT=$$BUILD_TARGET -C $$DIR $@;		\
+	done
+
+install: all
+	@for DIR in $(ARM_SUBTARGETS); do				\
+		BUILD_TARGET=$(OUTPUT)/$$DIR;			\
+		make OUTPUT=$$BUILD_TARGET -C $$DIR $@;		\
+	done
+
+run_tests: all
+	@for DIR in $(ARM_SUBTARGETS); do				\
+		BUILD_TARGET=$(OUTPUT)/$$DIR;			\
+		make OUTPUT=$$BUILD_TARGET -C $$DIR $@;		\
+	done
+
+# Avoid any output on non arm on emit_tests
+emit_tests:
+	@for DIR in $(ARM_SUBTARGETS); do				\
+		BUILD_TARGET=$(OUTPUT)/$$DIR;			\
+		make OUTPUT=$$BUILD_TARGET -C $$DIR $@;		\
+	done
+
+clean:
+	@for DIR in $(ARM_SUBTARGETS); do				\
+		BUILD_TARGET=$(OUTPUT)/$$DIR;			\
+		make OUTPUT=$$BUILD_TARGET -C $$DIR $@;		\
+	done
+
+.PHONY: all clean install run_tests emit_tests
diff --git a/tools/testing/selftests/arm/README b/tools/testing/selftests/arm/README
new file mode 100644
index 000000000000..75b7cf4baec3
--- /dev/null
+++ b/tools/testing/selftests/arm/README
@@ -0,0 +1,32 @@
+KSelfTest ARM
+===============
+
+- This is a series of compatibility tests, wherein the source files are
+  built statically into a 32 bit ELF; they should pass on both 32 and 64
+  bit kernels. They are not built or run but just skipped completely when
+  env-variable ARCH is found to be different than 'arm64' or 'arm' and
+  `uname -m` reports other than 'aarch64', 'armv7l' or 'armv8l'.
+
+- If building the tests on a 64-bit kernel, please ensure that the kernel is
+  built with CONFIG_COMPAT enabled.
+
+- Holding true the above, ARM KSFT tests can be run within the KSelfTest
+  framework using standard Linux top-level-makefile targets. Please set
+  $(CROSS_COMPILE) to 'arm-linux-gnueabi-' or 'arm-linux-gnueabihf-'.
+
+      $ make TARGETS=arm kselftest-clean
+      $ make $(CROSS_COMPILE) TARGETS=arm kselftest
+
+      or
+
+      $ make $(CROSS_COMPILE) -C tools/testing/selftests TARGETS=arm \
+		INSTALL_PATH=<your-installation-path> install
+
+      or, alternatively, only specific arm/ subtargets can be picked:
+
+      $ make $(CROSS_COMPILE) -C tools/testing/selftests TARGETS=arm \
+		ARM_SUBTARGETS="signal" INSTALL_PATH=<your-installation-path> \
+			install
+
+   Further details on building and running KFST can be found in:
+     Documentation/dev-tools/kselftest.rst
diff --git a/tools/testing/selftests/arm/abi/.gitignore b/tools/testing/selftests/arm/abi/.gitignore
new file mode 100644
index 000000000000..75af3c416fc3
--- /dev/null
+++ b/tools/testing/selftests/arm/abi/.gitignore
@@ -0,0 +1,4 @@
+# SPDX-License-Identifier: GPL-2.0-only
+ptrace
+ptrace_64
+trivial_32bit_program
diff --git a/tools/testing/selftests/arm/abi/Makefile b/tools/testing/selftests/arm/abi/Makefile
new file mode 100644
index 000000000000..160b6aadb064
--- /dev/null
+++ b/tools/testing/selftests/arm/abi/Makefile
@@ -0,0 +1,26 @@
+# SPDX-License-Identifier: GPL-2.0-only
+# Copyright (C) 2024 ARM Limited
+
+TEST_GEN_PROGS := ptrace
+
+include ../../lib.mk
+
+# Do not build 64-bit programs if running on a native 32-bit kernel
+UNAME_M := $(shell uname -m)
+ifneq (,$(filter $(UNAME_M),aarch64 arm64))
+TEST_CUSTOM_PROGS := $(OUTPUT)/ptrace_64
+
+TRIVIAL_32BIT := $(OUTPUT)/trivial_32bit_program
+
+all: $(TEST_CUSTOM_PROGS) $(TRIVIAL_32BIT)
+
+
+$(TRIVIAL_32BIT): $(OUTPUT)/%: %.c
+	$(CC) -o $@ $^ -static
+
+$(OUTPUT)/ptrace_64: ptrace_64.c ptrace.h
+	gcc -o $@ $^
+
+EXTRA_CLEAN := $(TEST_CUSTOM_PROGS) $(TRIVIAL_32BIT)
+endif
+
diff --git a/tools/testing/selftests/arm/elf/.gitignore b/tools/testing/selftests/arm/elf/.gitignore
new file mode 100644
index 000000000000..41458ecbcd72
--- /dev/null
+++ b/tools/testing/selftests/arm/elf/.gitignore
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+parse_elf
diff --git a/tools/testing/selftests/arm/elf/Makefile b/tools/testing/selftests/arm/elf/Makefile
new file mode 100644
index 000000000000..86636fe02994
--- /dev/null
+++ b/tools/testing/selftests/arm/elf/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2024 ARM Limited
+
+TEST_GEN_PROGS := parse_elf
+
+include ../../lib.mk
diff --git a/tools/testing/selftests/arm/mm/.gitignore b/tools/testing/selftests/arm/mm/.gitignore
new file mode 100644
index 000000000000..eb28169bb1b5
--- /dev/null
+++ b/tools/testing/selftests/arm/mm/.gitignore
@@ -0,0 +1,2 @@
+# SPDX-License-Identifier: GPL-2.0-only
+compat_va
diff --git a/tools/testing/selftests/arm/mm/Makefile b/tools/testing/selftests/arm/mm/Makefile
new file mode 100644
index 000000000000..d8bfa45df98c
--- /dev/null
+++ b/tools/testing/selftests/arm/mm/Makefile
@@ -0,0 +1,6 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2024 ARM Limited
+
+TEST_GEN_PROGS := compat_va
+
+include ../../lib.mk
diff --git a/tools/testing/selftests/arm/signal/.gitignore b/tools/testing/selftests/arm/signal/.gitignore
new file mode 100644
index 000000000000..85b81356bf41
--- /dev/null
+++ b/tools/testing/selftests/arm/signal/.gitignore
@@ -0,0 +1,3 @@
+# SPDX-License-Identifier: GPL-2.0-only
+mangle_cpsr_invalid_aif_bits
+mangle_cpsr_invalid_compat_toggle
diff --git a/tools/testing/selftests/arm/signal/Makefile b/tools/testing/selftests/arm/signal/Makefile
new file mode 100644
index 000000000000..3540a25de75a
--- /dev/null
+++ b/tools/testing/selftests/arm/signal/Makefile
@@ -0,0 +1,30 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (C) 2024 ARM Limited
+
+# Additional include paths needed by kselftest.h and local headers
+CFLAGS += -D_GNU_SOURCE -std=gnu99 -I.
+
+SRCS := $(filter-out testcases/testcases.c,$(wildcard testcases/*.c))
+PROGS := $(patsubst %.c,%,$(SRCS))
+
+# Generated binaries to be installed by top KSFT script
+TEST_GEN_PROGS := $(notdir $(PROGS))
+
+# Get Kernel headers installed and use them.
+
+# Including KSFT lib.mk here will also mangle the TEST_GEN_PROGS list
+# to account for any OUTPUT target-dirs optionally provided by
+# the toplevel makefile
+include ../../lib.mk
+
+$(TEST_GEN_PROGS): $(PROGS)
+	cp $(PROGS) $(OUTPUT)/
+
+# Common test-unit targets to build common-layout test-cases executables
+# Needs secondary expansion to properly include the testcase c-file in pre-reqs
+COMMON_SOURCES := test_signals.c test_signals_utils.c
+COMMON_HEADERS := test_signals.h test_signals_utils.h
+
+.SECONDEXPANSION:
+$(PROGS): $$@.c ${COMMON_SOURCES} ${COMMON_HEADERS}
+	$(CC) $(CFLAGS) ${@}.c ${COMMON_SOURCES} -o $@
-- 
2.39.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ