From: Cristian Marussi <cristian.marussi@arm.com>
To: linux-kselftest@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, shuah@kernel.org
Cc: amit.kachhap@arm.com, andreyknvl@google.com, dave.martin@arm.com,
suzuki.poulose@arm.com
Subject: [PATCH v10 05/12] kselftest: arm64: extend test_init functionalities
Date: Fri, 25 Oct 2019 18:57:10 +0100 [thread overview]
Message-ID: <20191025175717.15154-6-cristian.marussi@arm.com> (raw)
In-Reply-To: <20191025175717.15154-1-cristian.marussi@arm.com>
Extend signal testing framework to allow the definition of a custom per
test initialization function to be run at the end of the common test_init
after test setup phase has completed and before test-run routine.
This custom per-test initialization function also enables the test writer
to decide on its own when forcibly skip the test itself using standard KSFT
mechanism.
Reviewed-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Cristian Marussi <cristian.marussi@arm.com>
---
v9 --> v10
- resolving conflicts due to [v10 2/12] removal of feats tests
v7 --> v8
- per test .init() helper added new in v8 (splitted out of v7 05/11)
---
.../selftests/arm64/signal/test_signals.c | 6 ++--
.../selftests/arm64/signal/test_signals.h | 7 +++--
.../arm64/signal/test_signals_utils.c | 30 ++++++++++++++-----
.../arm64/signal/test_signals_utils.h | 1 +
4 files changed, 31 insertions(+), 13 deletions(-)
diff --git a/tools/testing/selftests/arm64/signal/test_signals.c b/tools/testing/selftests/arm64/signal/test_signals.c
index cb970346b280..416b1ff43199 100644
--- a/tools/testing/selftests/arm64/signal/test_signals.c
+++ b/tools/testing/selftests/arm64/signal/test_signals.c
@@ -19,11 +19,11 @@ int main(int argc, char *argv[])
current = &tde;
ksft_print_msg("%s :: %s\n", current->name, current->descr);
- if (test_setup(current)) {
+ if (test_setup(current) && test_init(current)) {
test_run(current);
- test_result(current);
test_cleanup(current);
}
+ test_result(current);
- return current->pass ? KSFT_PASS : KSFT_FAIL;
+ return current->result;
}
diff --git a/tools/testing/selftests/arm64/signal/test_signals.h b/tools/testing/selftests/arm64/signal/test_signals.h
index d730e9041da9..c431e7b3e46c 100644
--- a/tools/testing/selftests/arm64/signal/test_signals.h
+++ b/tools/testing/selftests/arm64/signal/test_signals.h
@@ -68,17 +68,20 @@ struct tdescr {
unsigned int timeout;
bool triggered;
bool pass;
+ unsigned int result;
/* optional sa_flags for the installed handler */
int sa_flags;
ucontext_t saved_uc;
/* optional test private data */
void *priv;
- /* a custom setup function to be called before test starts */
+ /* a custom setup: called alternatively to default_setup */
int (*setup)(struct tdescr *td);
+ /* a custom init: called by default test init after test_setup */
+ bool (*init)(struct tdescr *td);
/* a custom cleanup function called before test exits */
void (*cleanup)(struct tdescr *td);
- /* an optional function to be used as a trigger for test starting */
+ /* an optional function to be used as a trigger for starting test */
int (*trigger)(struct tdescr *td);
/*
* the actual test-core: invoked differently depending on the
diff --git a/tools/testing/selftests/arm64/signal/test_signals_utils.c b/tools/testing/selftests/arm64/signal/test_signals_utils.c
index fbce41750590..76eaa505a789 100644
--- a/tools/testing/selftests/arm64/signal/test_signals_utils.c
+++ b/tools/testing/selftests/arm64/signal/test_signals_utils.c
@@ -11,6 +11,8 @@
#include <linux/auxvec.h>
#include <ucontext.h>
+#include <kselftest.h>
+
#include "test_signals.h"
#include "test_signals_utils.h"
#include "testcases/testcases.h"
@@ -52,12 +54,18 @@ static void unblock_signal(int signum)
static void default_result(struct tdescr *td, bool force_exit)
{
- if (td->pass)
+ if (td->result == KSFT_SKIP) {
+ fprintf(stderr, "==>> completed. SKIP.\n");
+ } else if (td->pass) {
fprintf(stderr, "==>> completed. PASS(1)\n");
- else
+ td->result = KSFT_PASS;
+ } else {
fprintf(stdout, "==>> completed. FAIL(0)\n");
+ td->result = KSFT_FAIL;
+ }
+
if (force_exit)
- exit(td->pass ? EXIT_SUCCESS : EXIT_FAILURE);
+ exit(td->result);
}
/*
@@ -209,7 +217,7 @@ static inline int default_trigger(struct tdescr *td)
return !raise(td->sig_trig);
}
-static int test_init(struct tdescr *td)
+int test_init(struct tdescr *td)
{
td->minsigstksz = getauxval(AT_MINSIGSTKSZ);
if (!td->minsigstksz)
@@ -236,7 +244,14 @@ static int test_init(struct tdescr *td)
~td->feats_supported));
}
+ /* Perform test specific additional initialization */
+ if (td->init && !td->init(td)) {
+ fprintf(stderr, "FAILED Testcase initialization.\n");
+ return 0;
+ }
td->initialized = 1;
+ fprintf(stderr, "Testcase initialized.\n");
+
return 1;
}
@@ -248,9 +263,8 @@ int test_setup(struct tdescr *td)
assert(td->name);
assert(td->run);
- if (!test_init(td))
- return 0;
-
+ /* Default result is FAIL if test setup fails */
+ td->result = KSFT_FAIL;
if (td->setup)
return td->setup(td);
else
@@ -271,7 +285,7 @@ int test_run(struct tdescr *td)
void test_result(struct tdescr *td)
{
- if (td->check_result)
+ if (td->initialized && td->result != KSFT_SKIP && td->check_result)
td->check_result(td);
default_result(td, 0);
}
diff --git a/tools/testing/selftests/arm64/signal/test_signals_utils.h b/tools/testing/selftests/arm64/signal/test_signals_utils.h
index 47a7592b7c53..5e3a2b7aaa8b 100644
--- a/tools/testing/selftests/arm64/signal/test_signals_utils.h
+++ b/tools/testing/selftests/arm64/signal/test_signals_utils.h
@@ -6,6 +6,7 @@
#include "test_signals.h"
+int test_init(struct tdescr *td);
int test_setup(struct tdescr *td);
void test_cleanup(struct tdescr *td);
int test_run(struct tdescr *td);
--
2.17.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-10-25 18:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-25 17:57 [PATCH v10 00/12] Add arm64/signal initial kselftest support Cristian Marussi
2019-10-25 17:57 ` [PATCH v10 01/12] kselftest: arm64: extend toplevel skeleton Makefile Cristian Marussi
2019-10-25 17:57 ` [PATCH v10 02/12] kselftest: arm64: mangle_pstate_invalid_compat_toggle and common utils Cristian Marussi
2019-10-25 17:57 ` [PATCH v10 03/12] kselftest: arm64: mangle_pstate_invalid_daif_bits Cristian Marussi
2019-10-25 17:57 ` [PATCH v10 04/12] kselftest: arm64: mangle_pstate_invalid_mode_el[123][ht] Cristian Marussi
2019-10-25 17:57 ` Cristian Marussi [this message]
2019-10-25 17:57 ` [PATCH v10 06/12] kselftest: arm64: add helper get_current_context Cristian Marussi
2019-10-25 17:57 ` [PATCH v10 07/12] kselftest: arm64: fake_sigreturn_bad_magic Cristian Marussi
2019-10-25 17:57 ` [PATCH v10 08/12] kselftest: arm64: fake_sigreturn_bad_size_for_magic0 Cristian Marussi
2019-10-25 17:57 ` [PATCH v10 09/12] kselftest: arm64: fake_sigreturn_missing_fpsimd Cristian Marussi
2019-10-25 17:57 ` [PATCH v10 10/12] kselftest: arm64: fake_sigreturn_duplicated_fpsimd Cristian Marussi
2019-10-25 17:57 ` [PATCH v10 11/12] kselftest: arm64: fake_sigreturn_bad_size Cristian Marussi
2019-10-25 17:57 ` [PATCH v10 12/12] kselftest: arm64: fake_sigreturn_misaligned_sp Cristian Marussi
2019-11-08 14:50 ` [PATCH v10 00/12] Add arm64/signal initial kselftest support Catalin Marinas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191025175717.15154-6-cristian.marussi@arm.com \
--to=cristian.marussi@arm.com \
--cc=amit.kachhap@arm.com \
--cc=andreyknvl@google.com \
--cc=dave.martin@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
--cc=suzuki.poulose@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).