All of lore.kernel.org
 help / color / mirror / Atom feed
From: Knut Omang <knut.omang@oracle.com>
To: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org,
	Shuah Khan <shuah@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Michal Marek <michal.lkml@markovi.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Shreyans Devendra Doshi <0xinfosect0r@gmail.com>,
	Alan Maguire <alan.maguire@oracle.com>,
	Brendan Higgins <brendanhiggins@google.com>,
	Kevin Hilman <khilman@baylibre.com>,
	Hidenori Yamaji <hidenori.yamaji@sony.com>,
	Frank Rowand <frowand.list@gmail.com>,
	Timothy Bird <Tim.Bird@sony.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	"Theodore Ts'o" <tytso@mit.edu>, Daniel Vetter <daniel@ffwll.ch>,
	Stephen Boyd <sboyd@kernel.org>,
	Knut Omang <knut.omang@oracle.com>
Subject: [RFC 17/19] ktf: Toplevel ktf Makefile/makefile includes and scripts to run from kselftest
Date: Tue, 13 Aug 2019 08:09:32 +0200	[thread overview]
Message-ID: <79b7a9ac73c098d3d6ed7a4dde6952b655232b1c.1565676440.git-series.knut.omang@oracle.com> (raw)
In-Reply-To: <cover.92d76bb4f6dcedc971d0b72a49e8e459a98bca54.1565676440.git-series.knut.omang@oracle.com>

Signed-off-by: Knut Omang <knut.omang@oracle.com>
---
 tools/testing/selftests/ktf/Makefile            |  21 ++++-
 tools/testing/selftests/ktf/scripts/ktf_syms.mk |  16 +++-
 tools/testing/selftests/ktf/scripts/runtests.mk |   3 +-
 tools/testing/selftests/ktf/scripts/runtests.sh | 100 +++++++++++++++++-
 tools/testing/selftests/ktf/scripts/top_make.mk |  14 ++-
 5 files changed, 154 insertions(+)
 create mode 100644 tools/testing/selftests/ktf/Makefile
 create mode 100644 tools/testing/selftests/ktf/scripts/ktf_syms.mk
 create mode 100644 tools/testing/selftests/ktf/scripts/runtests.mk
 create mode 100755 tools/testing/selftests/ktf/scripts/runtests.sh
 create mode 100644 tools/testing/selftests/ktf/scripts/top_make.mk

diff --git a/tools/testing/selftests/ktf/Makefile b/tools/testing/selftests/ktf/Makefile
new file mode 100644
index 0000000..0fef39c
--- /dev/null
+++ b/tools/testing/selftests/ktf/Makefile
@@ -0,0 +1,21 @@
+
+ifneq ($(TARGETS),)
+# We end up here if called from selftests/Makefile
+# Invoke our "module target" to get everything built
+all:
+	$(Q)$(MAKE) -C $(abs_objtree) M=tools/testing/selftests/ktf
+
+clean:
+	$(Q)$(MAKE) -C $(abs_objtree) M=tools/testing/selftests/ktf clean
+
+run_tests:
+	@echo "running tests"
+	$(MAKE) BUILD=$(abs_objtree)/tools/testing/selftests -f scripts/runtests.mk $@
+
+endif
+obj-m += kernel/
+obj-m += selftest/
+obj-m += examples/
+obj-m += lib/
+obj-m += user/
+
diff --git a/tools/testing/selftests/ktf/scripts/ktf_syms.mk b/tools/testing/selftests/ktf/scripts/ktf_syms.mk
new file mode 100644
index 0000000..a332223
--- /dev/null
+++ b/tools/testing/selftests/ktf/scripts/ktf_syms.mk
@@ -0,0 +1,16 @@
+ktf_symfile=$(shell (cd $(srctree)/$(src) && ls ktf_syms.txt 2> /dev/null || true))
+ktf_syms = $(ktf_symfile:%.txt=%.h)
+
+ifneq ($(ktf_symfile),)
+
+$(obj)/self.o: $(obj)/$(ktf_syms)
+
+ktf_scripts = $(srctree)/$(src)/../scripts
+
+$(obj)/$(ktf_syms): $(srctree)/$(src)/ktf_syms.txt $(ktf_scripts)/resolve
+	@echo "  KTFSYMS $@"
+	$(Q)$(ktf_scripts)/resolve $(ccflags-y) $< $@
+
+clean-files += $(ktf_syms)
+
+endif
diff --git a/tools/testing/selftests/ktf/scripts/runtests.mk b/tools/testing/selftests/ktf/scripts/runtests.mk
new file mode 100644
index 0000000..7fd3651
--- /dev/null
+++ b/tools/testing/selftests/ktf/scripts/runtests.mk
@@ -0,0 +1,3 @@
+TEST_PROGS := scripts/runtests.sh
+
+include ../lib.mk
diff --git a/tools/testing/selftests/ktf/scripts/runtests.sh b/tools/testing/selftests/ktf/scripts/runtests.sh
new file mode 100755
index 0000000..3396aec
--- /dev/null
+++ b/tools/testing/selftests/ktf/scripts/runtests.sh
@@ -0,0 +1,100 @@
+#!/bin/bash -e
+
+verbose=1
+
+# Convenience function to return a string that
+# is a reverse list of the incoming arguments:
+#
+reverse()
+{
+    args=($*)
+    for (( i=((${#args[*]} - 1)); i >= 0; i-- )); do
+	echo ${args[$i]}
+    done
+}
+
+# Set paths to a particular module - if no path is set to a module, use modprobe:
+#
+declare -A a_mpath
+mpath()
+{
+    local module="$1"
+    local mpath="$2"
+    [[ $mpath != "" ]] || fail "Usage: mpath module path"
+
+    a_mpath[$module]="$BUILD/$mpath"
+}
+
+# Set parameters to load a given module with for test purposes:
+declare -A a_params
+params()
+{
+    local module="$1"
+    shift
+    a_params[$module]="$*"
+}
+
+log()
+{
+    (( $verbose )) && echo $*
+}
+
+mod_probe()
+{
+    local fm=""
+    local name="$1"
+    shift
+
+    mp=${a_mpath[$name]}
+    if [[ $mp != "" ]]; then
+	fm="$mp"
+    fi
+
+    is_loaded=$(lsmod | egrep "^$name" || true)
+    if [[ $is_loaded != "" ]]; then
+	echo "Module \"$name\" is already loaded!" 1>&2
+	return 0
+    fi
+
+    if [[ $fm == "" ]]; then
+	log "Modprobing $name"
+	$sudo modprobe $name ${a_params[$name]}
+    else
+	fm=${a_mpath[$name]}
+        log "Insmod'ing module \"$name\"" 1>&2
+	$sudo insmod $fm ${a_params[$name]}
+    fi
+}
+
+# If/when more modules are to be loaded, this could go in a config file
+# but for the purpose of this example, just do it inline:
+#
+mpath ktf 	ktf/kernel/ktf.ko
+mpath selftest	ktf/selftest/selftest.ko
+
+load_modules="ktf selftest"
+
+unload_modules=$(reverse $load_modules)
+
+sudo=""
+if [[ $USER != "root" ]]; then
+    sudo="sudo"
+fi
+
+for m in $load_modules; do
+    mod_probe $m
+done
+
+if [[ $GTEST_PATH == "" ]];then
+    echo "Set environment variable GTEST_PATH to point to your googletest build!"
+    exit 1
+fi
+
+export LD_LIBRARY_PATH="$BUILD/ktf/lib:$GTEST_PATH/lib64:$GTEST_PATH/lib"
+$BUILD/ktf/user/ktftest || stat=$?
+
+for m in $unload_modules; do
+    $sudo rmmod $m
+done
+
+exit $stat
diff --git a/tools/testing/selftests/ktf/scripts/top_make.mk b/tools/testing/selftests/ktf/scripts/top_make.mk
new file mode 100644
index 0000000..978068e
--- /dev/null
+++ b/tools/testing/selftests/ktf/scripts/top_make.mk
@@ -0,0 +1,14 @@
+ifneq ($(TARGETS),)
+# We end up here if called from selftests/Makefile
+# Invoke our "module target" to get everything built
+all:
+	$(Q)$(MAKE) -C $(abs_objtree) M=tools/testing/selftests/ktf
+
+clean:
+	$(Q)$(MAKE) -C $(abs_objtree) M=tools/testing/selftests/ktf clean
+
+run_tests:
+	@echo "running tests"
+	$(MAKE) BUILD=$(abs_objtree)/tools/testing/selftests -f scripts/runtests.mk $@
+
+endif
-- 
git-series 0.9.1

  parent reply	other threads:[~2019-08-13  6:12 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-13  6:09 [RFC 00/19] Integration of Kernel Test Framework (KTF) into the kernel tree Knut Omang
2019-08-13  6:09 ` [RFC 01/19] kbuild: Fixes to rules for host-cshlib and host-cxxshlib Knut Omang
2019-08-13 14:01   ` Masahiro Yamada
2019-08-13 14:01     ` Masahiro Yamada
2019-08-13 16:19     ` Knut Omang
2019-08-13 16:19       ` Knut Omang
2019-08-14  2:02       ` Masahiro Yamada
2019-08-14  2:02         ` Masahiro Yamada
2019-08-14  5:50         ` Knut Omang
2019-08-14  5:50           ` Knut Omang
2019-08-14  5:52         ` Knut Omang
2019-08-14  5:52           ` Knut Omang
2019-08-14 12:52           ` Knut Omang
2019-08-14 12:52             ` Knut Omang
2019-08-21  1:47             ` Masahiro Yamada
2019-08-21  1:47               ` Masahiro Yamada
2019-08-21  4:03               ` Knut Omang
2019-08-21  4:03                 ` Knut Omang
2019-08-13  6:09 ` [RFC 02/19] ktf: Introduce the main part of the kernel side of ktf Knut Omang
2019-09-09  1:23   ` Brendan Higgins
2019-09-10  6:15     ` Knut Omang
2019-08-13  6:09 ` [RFC 03/19] ktf: Introduce a generic netlink protocol for test result communication Knut Omang
2019-09-09  1:28   ` Brendan Higgins
2019-09-10  6:30     ` Knut Omang
2019-08-13  6:09 ` [RFC 04/19] ktf: An implementation of a generic associative array container Knut Omang
2019-08-13  6:09 ` [RFC 05/19] ktf: Implementation of ktf support for overriding function entry and return Knut Omang
2019-08-13  6:09 ` [RFC 06/19] ktf: A simple debugfs interface to test results Knut Omang
2019-08-13  8:21   ` Greg Kroah-Hartman
2019-08-14 17:17     ` Knut Omang
2019-08-15  8:49       ` Greg Kroah-Hartman
2019-08-15 10:35         ` Knut Omang
2019-08-15 10:52           ` Greg Kroah-Hartman
2019-08-13  6:09 ` [RFC 07/19] ktf: Simple coverage support Knut Omang
2019-08-13  6:09 ` [RFC 08/19] ktf: Configurable context support for network info setup Knut Omang
2019-08-13  6:09 ` [RFC 09/19] ktf: resolve: A helper utility to aid in exposing private kernel symbols to KTF tests Knut Omang
2019-08-13  6:09 ` [RFC 10/19] ktf: Add documentation for Kernel Test Framework (KTF) Knut Omang
2019-08-13  6:09 ` [RFC 11/19] ktf: Add a small test suite with a few tests to test KTF itself Knut Omang
2019-08-13  6:09 ` [RFC 12/19] ktf: Main part of user land library for executing tests Knut Omang
2019-08-13  6:09 ` [RFC 13/19] ktf: Integration logic for running ktf tests from googletest Knut Omang
2019-08-13  6:09 ` [RFC 14/19] ktf: Internal debugging facilities Knut Omang
2019-08-13  6:09 ` [RFC 15/19] ktf: Some simple examples Knut Omang
2019-08-13  6:09 ` [RFC 16/19] ktf: Some user applications to run tests Knut Omang
2019-08-13  6:09 ` Knut Omang [this message]
2019-08-13  6:09 ` [RFC 18/19] kselftests: Enable building ktf Knut Omang
2019-08-13  6:09 ` [RFC 19/19] Documentation/dev-tools: Add index entry for KTF documentation Knut Omang
2019-08-13  8:10 ` [RFC 00/19] Integration of Kernel Test Framework (KTF) into the kernel tree Brendan Higgins
2019-08-13  8:10   ` Brendan Higgins
2019-08-13  8:17 ` Brendan Higgins
2019-08-13  8:17   ` Brendan Higgins
2019-08-13 11:29   ` Knut Omang
2019-08-13 11:29     ` Knut Omang
2019-08-13 17:50     ` Brendan Higgins
2019-08-13 17:50       ` Brendan Higgins
2019-08-13  8:23 ` Greg Kroah-Hartman
2019-08-13  9:51   ` Knut Omang
2019-08-13 17:02     ` Brendan Higgins
2019-08-13 17:02       ` Brendan Higgins

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=79b7a9ac73c098d3d6ed7a4dde6952b655232b1c.1565676440.git-series.knut.omang@oracle.com \
    --to=knut.omang@oracle.com \
    --cc=0xinfosect0r@gmail.com \
    --cc=Tim.Bird@sony.com \
    --cc=alan.maguire@oracle.com \
    --cc=brendanhiggins@google.com \
    --cc=corbet@lwn.net \
    --cc=daniel@ffwll.ch \
    --cc=frowand.list@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hidenori.yamaji@sony.com \
    --cc=khilman@baylibre.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kbuild@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=sboyd@kernel.org \
    --cc=shuah@kernel.org \
    --cc=tytso@mit.edu \
    --cc=yamada.masahiro@socionext.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 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.