All of lore.kernel.org
 help / color / mirror / Atom feed
From: pvorel at suse.cz (Petr Vorel)
Subject: [RFC PATCH 1/2] selftests: Start shell API
Date: Sat,  6 Apr 2019 23:49:14 +0200	[thread overview]
Message-ID: <20190406214915.16914-2-pvorel@suse.cz> (raw)
In-Reply-To: <20190406214915.16914-1-pvorel@suse.cz>

kselftest.sh is a beginning of shell API.
ATM it's a stub (target could be as rich as LTP API), containing only:
* exit codes
* filling TEST variable
* logging functions
* requiring root function
* add script directory into PATH

Inspired by kexec functions (with some cleanup)
and LTP.

Signed-off-by: Petr Vorel <pvorel at suse.cz>
---
 tools/testing/selftests/kselftest.sh | 53 ++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 tools/testing/selftests/kselftest.sh

diff --git a/tools/testing/selftests/kselftest.sh b/tools/testing/selftests/kselftest.sh
new file mode 100644
index 000000000000..519ec2707dd8
--- /dev/null
+++ b/tools/testing/selftests/kselftest.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Petr Vorel <pvorel at suse.cz>
+
+PATH="$(dirname $0):$PATH"
+
+KSFT_PASS=0
+KSFT_FAIL=1
+KSFT_XFAIL=2
+KSFT_XPASS=3
+KSFT_SKIP=4
+
+TEST=$(basename $0)
+
+ksft_info()
+{
+	echo "[INFO] $TEST: $1"
+}
+
+ksft_pass()
+{
+	echo "[PASS] $TEST: $1"
+	exit $KSFT_PASS
+}
+
+ksft_fail()
+{
+	echo "[FAIL] $TEST: $1"
+	exit $KSFT_FAIL
+}
+
+ksft_xfail()
+{
+	echo "[FAIL] $TEST: $1"
+	exit $KSFT_XFAIL
+}
+
+ksft_xpass()
+{
+	echo "[PASS] $TEST: $1"
+	exit $KSFT_XPASS
+}
+
+ksft_skip()
+{
+	echo "[SKIP] $TEST: $1"
+	exit $KSFT_SKIP
+}
+
+ksft_require_root()
+{
+	[ $(id -ru) -eq 0 ] || ksft_skip "requires root privileges"
+}
-- 
2.20.1

WARNING: multiple messages have this Message-ID
From: pvorel@suse.cz (Petr Vorel)
Subject: [RFC PATCH 1/2] selftests: Start shell API
Date: Sat,  6 Apr 2019 23:49:14 +0200	[thread overview]
Message-ID: <20190406214915.16914-2-pvorel@suse.cz> (raw)
Message-ID: <20190406214914.ykyJLwWyQBPtHoIu2-rOtz5oRetZbw7pLyHr1hkVAwQ@z> (raw)
In-Reply-To: <20190406214915.16914-1-pvorel@suse.cz>

kselftest.sh is a beginning of shell API.
ATM it's a stub (target could be as rich as LTP API), containing only:
* exit codes
* filling TEST variable
* logging functions
* requiring root function
* add script directory into PATH

Inspired by kexec functions (with some cleanup)
and LTP.

Signed-off-by: Petr Vorel <pvorel at suse.cz>
---
 tools/testing/selftests/kselftest.sh | 53 ++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 tools/testing/selftests/kselftest.sh

diff --git a/tools/testing/selftests/kselftest.sh b/tools/testing/selftests/kselftest.sh
new file mode 100644
index 000000000000..519ec2707dd8
--- /dev/null
+++ b/tools/testing/selftests/kselftest.sh
@@ -0,0 +1,53 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2019 Petr Vorel <pvorel at suse.cz>
+
+PATH="$(dirname $0):$PATH"
+
+KSFT_PASS=0
+KSFT_FAIL=1
+KSFT_XFAIL=2
+KSFT_XPASS=3
+KSFT_SKIP=4
+
+TEST=$(basename $0)
+
+ksft_info()
+{
+	echo "[INFO] $TEST: $1"
+}
+
+ksft_pass()
+{
+	echo "[PASS] $TEST: $1"
+	exit $KSFT_PASS
+}
+
+ksft_fail()
+{
+	echo "[FAIL] $TEST: $1"
+	exit $KSFT_FAIL
+}
+
+ksft_xfail()
+{
+	echo "[FAIL] $TEST: $1"
+	exit $KSFT_XFAIL
+}
+
+ksft_xpass()
+{
+	echo "[PASS] $TEST: $1"
+	exit $KSFT_XPASS
+}
+
+ksft_skip()
+{
+	echo "[SKIP] $TEST: $1"
+	exit $KSFT_SKIP
+}
+
+ksft_require_root()
+{
+	[ $(id -ru) -eq 0 ] || ksft_skip "requires root privileges"
+}
-- 
2.20.1

  reply	other threads:[~2019-04-06 21:49 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-06 21:49 [RFC PATCH 0/2] Kselftest shell (or even C) API pvorel
2019-04-06 21:49 ` Petr Vorel
2019-04-06 21:49 ` pvorel [this message]
2019-04-06 21:49   ` [RFC PATCH 1/2] selftests: Start shell API Petr Vorel
2019-04-08 11:06   ` zohar
2019-04-08 11:06     ` Mimi Zohar
2019-04-08 12:22     ` pvorel
2019-04-08 12:22       ` Petr Vorel
2019-04-08 11:38   ` chrubis
2019-04-08 11:38     ` Cyril Hrubis
2019-04-08 13:07     ` pvorel
2019-04-08 13:07       ` Petr Vorel
2019-04-06 21:49 ` [RFC PATCH 2/2] selftest/kexec: Use kselftest " pvorel
2019-04-06 21:49   ` Petr Vorel
2019-04-08 11:29   ` zohar
2019-04-08 11:29     ` Mimi Zohar
2019-04-08 11:43 ` [RFC PATCH 0/2] Kselftest shell (or even C) API chrubis
2019-04-08 11:43   ` Cyril Hrubis
2019-04-08 13:25   ` pvorel
2019-04-08 13:25     ` Petr Vorel
2019-04-08 12:14 ` zohar
2019-04-08 12:14   ` Mimi Zohar
2019-04-08 12:29   ` pvorel
2019-04-08 12:29     ` Petr Vorel

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=20190406214915.16914-2-pvorel@suse.cz \
    --to=unknown@example.com \
    --subject='Re: [RFC PATCH 1/2] selftests: Start shell API' \
    /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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.