From patchwork Mon Apr 22 13:34:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 791068 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF2C5746E for ; Mon, 22 Apr 2024 13:35:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=150.107.74.76 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713792905; cv=none; b=YeFRgg0JIMvtIWuqz4f1uHO3lCkTpJgNd5YbhuntELcmLxFc/AN0zz0QfgnREwZMjhPfUNQNin34sbglyNhU0QYhY4GweyzvZlMFhr1J+h4HHx38Omq0XqD7Saofv1Rw5WxfRVGO9MQ8sWgiQqFH4knoKhBQbQrfki0s8treczc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713792905; c=relaxed/simple; bh=EYwJW3pnXgt4/u7Seybxsaep8LZndnyUdkTiuK1YgXM=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=Ti+G5OxGCGjbRXcQFlhYZQmhDRM98p2UetIyNabpcDe/dvzzNOXn/WAt5mDHfzCjU5a2FB+pnNe1GcFcedAS9Q4RHXM31gHwxmITDMoZUPzf8MUYTPyTiY0KVNYPVJu0k5uNn/Acv5bU5eXqRZyXFlmI0A50h4/6DqJ5mirPchc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au; spf=pass smtp.mailfrom=ellerman.id.au; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b=SEbA+mag; arc=none smtp.client-ip=150.107.74.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ellerman.id.au Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b="SEbA+mag" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1713792901; bh=I1zTLridn3MpRPNHPrFiL4i0EYaFFg6luEW2Ul9teu8=; h=From:To:Cc:Subject:Date:From; b=SEbA+magKolkwPrdQv3Gx6W+5WqSYPglBuj8K0d9dbF23oWo7sEmcHPiVtWWFHX97 JMZ0Mf53kovsXBiwMqHtPVriFpqU7xZe5bUHLBswuXQQx1BBNM5sMy5ZHpC98PwYqf 1ithabMsxrWjY3pX0r/cfDJK5jhTs/GGCoFaSeKKNQ9Pot6VosS7mN558S1OSns8Z3 KK2DOB6yvpdLMokLsX1lCyk3YSQuUNfTzAc40nDoSANhER9+JOicvDL++FD2KhZQV1 EkmA4BFOTG61CCIytPexOjAGXlUfS+LiovFCLl5wUaaAgWTG1nSnoucx7BR05FQDHO 9hqBXhmRrcakw== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4VNR7m6Qnfz4wc5; Mon, 22 Apr 2024 23:35:00 +1000 (AEST) From: Michael Ellerman To: Cc: , spoorthy@linux.ibm.com, Subject: [PATCH v2 1/2] selftests/powerpc: Convert pmu Makefile to for loop style Date: Mon, 22 Apr 2024 23:34:52 +1000 Message-ID: <20240422133453.1793988-1-mpe@ellerman.id.au> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The pmu Makefile has grown more sub directories over the years. Rather than open coding the rules for each subdir, use for loops. Signed-off-by: Michael Ellerman Tested-by: Madhavan Srinivasan --- tools/testing/selftests/powerpc/pmu/Makefile | 43 ++++++++++---------- 1 file changed, 22 insertions(+), 21 deletions(-) v2: Actually send both patches. diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile index 1fcacae1b188..773933e5180e 100644 --- a/tools/testing/selftests/powerpc/pmu/Makefile +++ b/tools/testing/selftests/powerpc/pmu/Makefile @@ -9,7 +9,9 @@ top_srcdir = ../../../../.. include ../../lib.mk include ../flags.mk -all: $(TEST_GEN_PROGS) ebb sampling_tests event_code_tests +SUB_DIRS := ebb sampling_tests event_code_tests + +all: $(TEST_GEN_PROGS) $(SUB_DIRS) $(TEST_GEN_PROGS): $(EXTRA_SOURCES) @@ -23,12 +25,16 @@ $(OUTPUT)/count_stcx_fail: loop.S $(EXTRA_SOURCES) $(OUTPUT)/per_event_excludes: ../utils.c +$(SUB_DIRS): + BUILD_TARGET=$(OUTPUT)/$@; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $@ all + DEFAULT_RUN_TESTS := $(RUN_TESTS) override define RUN_TESTS $(DEFAULT_RUN_TESTS) - +TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests - +TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests - +TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests + +@for TARGET in $(SUB_DIRS); do \ + BUILD_TARGET=$(OUTPUT)/$$TARGET; \ + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET run_tests; \ + done; endef emit_tests: @@ -36,34 +42,29 @@ emit_tests: BASENAME_TEST=`basename $$TEST`; \ echo "$(COLLECTION):$$BASENAME_TEST"; \ done - +TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests - +TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests - +TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests + +@for TARGET in $(SUB_DIRS); do \ + BUILD_TARGET=$(OUTPUT)/$$TARGET; \ + $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests; \ + done; DEFAULT_INSTALL_RULE := $(INSTALL_RULE) override define INSTALL_RULE $(DEFAULT_INSTALL_RULE) - +TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install - +TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install - +TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install + +@for TARGET in $(SUB_DIRS); do \ + BUILD_TARGET=$(OUTPUT)/$$TARGET; \ + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install; \ + done; endef DEFAULT_CLEAN := $(CLEAN) override define CLEAN $(DEFAULT_CLEAN) $(RM) $(TEST_GEN_PROGS) $(OUTPUT)/loop.o - +TARGET=ebb; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean - +TARGET=sampling_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean - +TARGET=event_code_tests; BUILD_TARGET=$$OUTPUT/$$TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean + +@for TARGET in $(SUB_DIRS); do \ + BUILD_TARGET=$(OUTPUT)/$$TARGET; \ + $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET clean; \ + done; endef -ebb: - TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all - -sampling_tests: - TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all - -event_code_tests: - TARGET=$@; BUILD_TARGET=$$OUTPUT/$$TARGET; mkdir -p $$BUILD_TARGET; $(MAKE) OUTPUT=$$BUILD_TARGET -k -C $$TARGET all .PHONY: all run_tests ebb sampling_tests event_code_tests emit_tests From patchwork Mon Apr 22 13:34:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Ellerman X-Patchwork-Id: 791362 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9DBE3399F for ; Mon, 22 Apr 2024 13:35:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=150.107.74.76 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713792906; cv=none; b=lEXkoHQSpP4a91r9+d0OBzNfAfibuifPyg6EEfCmCx9fn2c0sprcNNIFqzDBiRxHH8AK3ECzi8bRFHHyIZfilQ7TchnfC3aDlzbnKgWwKCpcs1IWWNsid/PSAFsepfgXge3AiKZMjqHZe4aaLCN67ctw5Spq921sSMVUx0PqW6g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713792906; c=relaxed/simple; bh=ktz31sI6/I7ubtILb/S0GuZZkUWrAbBCpm20AnPWH3g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=f/f+SAAibWizcosXfTrx6KhNN3EqFV/QJue7tKo5DyJkZnNAw8s7bXtqwLn0ZOo9Nvhine8BZK4GkI1b7TzXHmwLU2kE/jXxRMQStfLPpQNI6i0zMmQgRG13RBZ5OjfLjAxU3e6guyKvMEgzJ3xeLut/Wm1ZD7BrRVUkq4QbUuM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au; spf=pass smtp.mailfrom=ellerman.id.au; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b=RYB2LdTM; arc=none smtp.client-ip=150.107.74.76 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ellerman.id.au Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ellerman.id.au header.i=@ellerman.id.au header.b="RYB2LdTM" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ellerman.id.au; s=201909; t=1713792901; bh=lGYy+DAVhn//1uZq7YadoT8Fb/965/RcmDnVpIaZqMc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RYB2LdTM3NUQeFa8c6X2LY5m6vt+VZz2etXJhJpH33eh9JWjYbGxjmZdB0fSWn+db JIKuBbdw5Fs1CAEajXk3QP3V0NrTfYtM5tOD0tsEa6fz3xl6e6XQJLH9hZZrAWqaSS FZeJFvscxxW5PzzYFQLbpp7d7nN/Sdubw25k+24iqkacDfnqy3mF9At8IaMcz8BTWz 5fwUzOtI3pFeyKL1DOzpnU79iY+dkdy4Sb08GWN5e+LxoSfUpf9WExlkRzh++nm7DC 4TFSUd2DfvfBH18blY/rSx5PaI11uIP53SWnntgB6KFWYrohZ2qevVHd+jt2myzvU1 C0p+vqpaGpaDg== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4VNR7n2sdTz4wcF; Mon, 22 Apr 2024 23:35:01 +1000 (AEST) From: Michael Ellerman To: Cc: , spoorthy@linux.ibm.com, Subject: [PATCH v2 2/2] selftests/powerpc: Install tests in sub-directories Date: Mon, 22 Apr 2024 23:34:53 +1000 Message-ID: <20240422133453.1793988-2-mpe@ellerman.id.au> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240422133453.1793988-1-mpe@ellerman.id.au> References: <20240422133453.1793988-1-mpe@ellerman.id.au> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The sources for the powerpc selftests are arranged into sub-directories. However when the tests are built and installed, the sub-directories are squashed, losing the structure. For example, with the current code the result of installing the selftests is: $ tree tools/testing/selftests/kselftest_install tools/testing/selftests/kselftest_install ├── kselftest │   ├── ktap_helpers.sh │   ├── module.sh │   ├── prefix.pl │   └── runner.sh ├── kselftest-list.txt ├── powerpc │   ├── alignment_handler │   ├── attr_test │   ├── back_to_back_ebbs_test │   ├── bad_accesses │   ├── bhrb_filter_map_test │   ├── bhrb_no_crash_wo_pmu_test │   ├── blacklisted_events_test │   ├── cache_shape │   ├── close_clears_pmcc_test │   ├── context_switch │   ├── copy_first_unaligned ... │   ├── settings ... │   └── wild_bctr └── run_kselftest.sh All the powerpc tests are squashed into the single powerpc directory. In particular, note that there is a single `settings` file, even though there are multiple settings files in the powerpc selftest sources. One of the settings files ends up installed, depending on install order, even if they have different contents. Similarly if there were two tests with the same name in different sub-directories they would clobber each other. Fix it by replicating the directory structure of the source tree into the install directory. The result being for example: $ tree tools/testing/selftests/kselftest_install tools/testing/selftests/kselftest_install ├── kselftest │   ├── ktap_helpers.sh │   ├── module.sh │   ├── prefix.pl │   └── runner.sh ├── kselftest-list.txt ├── powerpc │   ├── alignment │   │   ├── alignment_handler │   │   └── copy_first_unaligned │   ├── benchmarks │   │   ├── context_switch │   │   ├── exec_target │   │   ├── fork │   │   ├── futex_bench │   │   ├── gettimeofday │   │   ├── mmap_bench │   │   ├── null_syscall │   │   └── settings ... │   ├── eeh │   │   ├── eeh-basic.sh │   │   ├── eeh-functions.sh │   │   └── settings ... │   └── vphn │   └── test-vphn └── run_kselftest.sh Note multiple settings files in different sub-directories. This change also has the effect of changing the names of the tests from the point of view of the kselftest runner. Before the tests are named eg: powerpc:copy_first_unaligned powerpc:cache_shape powerpc:reg_access_test After, the test collection names include the sub-directory: powerpc/alignment:copy_first_unaligned powerpc/cache_shape:cache_shape powerpc/pmu/ebb:reg_access_test That means whereas previously all powerpc tests could be run with: $ ./run_kselftest.sh -c powerpc After the change it's necessary to pass a regex that matches all powerpc entries, eg: $ ./run_kselftest.sh -c "powerpc.*" The latter form also works before and after the change. Signed-off-by: Michael Ellerman --- tools/testing/selftests/powerpc/Makefile | 4 ++-- tools/testing/selftests/powerpc/pmu/Makefile | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) v2: Unchanged. diff --git a/tools/testing/selftests/powerpc/Makefile b/tools/testing/selftests/powerpc/Makefile index 2f299fd04d2d..b175e94e1901 100644 --- a/tools/testing/selftests/powerpc/Makefile +++ b/tools/testing/selftests/powerpc/Makefile @@ -52,14 +52,14 @@ endef override define INSTALL_RULE +@for TARGET in $(SUB_DIRS); do \ BUILD_TARGET=$(OUTPUT)/$$TARGET; \ - $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install;\ + $(MAKE) OUTPUT=$$BUILD_TARGET INSTALL_PATH=$$INSTALL_PATH/$$TARGET -C $$TARGET install;\ done; endef emit_tests: +@for TARGET in $(SUB_DIRS); do \ BUILD_TARGET=$(OUTPUT)/$$TARGET; \ - $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET $@;\ + $(MAKE) OUTPUT=$$BUILD_TARGET COLLECTION=$(COLLECTION)/$$TARGET -s -C $$TARGET $@;\ done; override define CLEAN diff --git a/tools/testing/selftests/powerpc/pmu/Makefile b/tools/testing/selftests/powerpc/pmu/Makefile index 773933e5180e..7e9dbf3d0d09 100644 --- a/tools/testing/selftests/powerpc/pmu/Makefile +++ b/tools/testing/selftests/powerpc/pmu/Makefile @@ -44,7 +44,7 @@ emit_tests: done +@for TARGET in $(SUB_DIRS); do \ BUILD_TARGET=$(OUTPUT)/$$TARGET; \ - $(MAKE) OUTPUT=$$BUILD_TARGET -s -C $$TARGET emit_tests; \ + $(MAKE) OUTPUT=$$BUILD_TARGET COLLECTION=$(COLLECTION)/$$TARGET -s -C $$TARGET emit_tests; \ done; DEFAULT_INSTALL_RULE := $(INSTALL_RULE) @@ -52,7 +52,7 @@ override define INSTALL_RULE $(DEFAULT_INSTALL_RULE) +@for TARGET in $(SUB_DIRS); do \ BUILD_TARGET=$(OUTPUT)/$$TARGET; \ - $(MAKE) OUTPUT=$$BUILD_TARGET -C $$TARGET install; \ + $(MAKE) OUTPUT=$$BUILD_TARGET INSTALL_PATH=$$INSTALL_PATH/$$TARGET -C $$TARGET install; \ done; endef