From: Masayoshi Mizuma <msys.mizuma@gmail.com>
To: linux-nvdimm@lists.01.org
Cc: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Subject: [PATCH v2 1/2] ndctl, test: add some helper function for test script
Date: Tue, 12 Jun 2018 21:56:15 -0400 [thread overview]
Message-ID: <20180613015616.26487-2-msys.mizuma@gmail.com> (raw)
In-Reply-To: <20180613015616.26487-1-msys.mizuma@gmail.com>
From: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
Some test scripts have same function. So, this patch introduces
the functions to 'test/common' new file.
Signed-off-by: Masayoshi Mizuma <m.mizuma@jp.fujitsu.com>
---
test/common | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)
create mode 100644 test/common
diff --git a/test/common b/test/common
new file mode 100644
index 0000000..8fafa91
--- /dev/null
+++ b/test/common
@@ -0,0 +1,60 @@
+
+# SPDX-License-Identifier: GPL-2.0
+# Copyright(c) 2018, FUJITSU LIMITED. All rights reserved.
+
+# Global variables
+
+# ndctl
+#
+if [ -f "../ndctl/ndctl" ] && [ -x "../ndctl/ndctl" ]; then
+ export ndctl=../ndctl/ndctl
+elif [ -f "./ndctl/ndctl" ] && [ -x "./ndctl/ndctl" ]; then
+ export ndctl=./ndctl/ndctl
+else
+ echo "Couldn't find an ndctl binary"
+ exit 1
+fi
+
+# Functions
+
+# err
+# $1: line number which error detected
+# $2: cleanup function (optional)
+#
+err()
+{
+ echo test/$(basename $0): failed at line $1
+ [ -n "$2" ] && "$2"
+ exit $rc
+}
+
+# check_min_kver
+# $1: Supported kernel version. format: X.Y
+#
+check_min_kver()
+{
+ local ver="$1"
+ : "${KVER:=$(uname -r)}"
+
+ [ -n "$ver" ] || return 1
+ [[ "$ver" == "$(echo -e "$ver\n$KVER" | sort -V | head -1)" ]]
+}
+
+# do_skip
+# $1: Skip message
+#
+do_skip()
+{
+ echo kernel $(uname -r): $1
+ exit 77
+}
+
+# check_prereq
+# $1: command to check
+#
+check_prereq()
+{
+ if ! command -v "$1" >/dev/null; then
+ do_skip "missing $1, skipping..."
+ fi
+}
--
2.18.0.rc1
_______________________________________________
Linux-nvdimm mailing list
Linux-nvdimm@lists.01.org
https://lists.01.org/mailman/listinfo/linux-nvdimm
next prev parent reply other threads:[~2018-06-13 1:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-13 1:56 [PATCH v2 0/2] ndctl, test: add some helper function and cleanup test script Masayoshi Mizuma
2018-06-13 1:56 ` Masayoshi Mizuma [this message]
2018-06-13 1:56 ` [PATCH v2 2/2] ndctl, test: cleanup test scripts Masayoshi Mizuma
2018-06-13 17:51 ` [PATCH v2 0/2] ndctl, test: add some helper function and cleanup test script Verma, Vishal L
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=20180613015616.26487-2-msys.mizuma@gmail.com \
--to=msys.mizuma@gmail.com \
--cc=linux-nvdimm@lists.01.org \
--cc=m.mizuma@jp.fujitsu.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