* [PATCH v6 3/4] crypto: AF_ALG: add random number generator support
From: Stephan Mueller @ 2014-12-25 22:00 UTC (permalink / raw)
To: 'Herbert Xu'
Cc: Daniel Borkmann, 'Quentin Gouchet', 'LKML',
linux-crypto, linux-api
In-Reply-To: <5682082.ffPqvQlSqN@tachyon.chronox.de>
This patch adds the random number generator support for AF_ALG.
A random number generator's purpose is to generate data without
requiring the caller to provide any data. Therefore, the AF_ALG
interface handler for RNGs only implements a callback handler for
recvmsg.
The following parameters provided with a recvmsg are processed by the
RNG callback handler:
* sock - to resolve the RNG context data structure accessing the
RNG instance private to the socket
* len - this parameter allows userspace callers to specify how
many random bytes the RNG shall produce and return. As the
kernel context for the RNG allocates a buffer of 128 bytes to
store random numbers before copying them to userspace, the len
parameter is checked that it is not larger than 128. If a
caller wants more random numbers, a new request for recvmsg
shall be made.
The size of 128 bytes is chose because of the following considerations:
* to increase the memory footprint of the kernel too much (note,
that would be 128 bytes per open socket)
* 128 is divisible by any typical cryptographic block size an
RNG may have
* A request for random numbers typically only shall supply small
amount of data like for keys or IVs that should only require
one invocation of the recvmsg function.
Note, during instantiation of the RNG, the code checks whether the RNG
implementation requires seeding. If so, the RNG is seeded with output
from get_random_bytes.
A fully working example using all aspects of the RNG interface is
provided at http://www.chronox.de/libkcapi.html
Signed-off-by: Stephan Mueller <smueller@chronox.de>
---
crypto/algif_rng.c | 192 +++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 192 insertions(+)
create mode 100644 crypto/algif_rng.c
diff --git a/crypto/algif_rng.c b/crypto/algif_rng.c
new file mode 100644
index 0000000..91c06f5
--- /dev/null
+++ b/crypto/algif_rng.c
@@ -0,0 +1,192 @@
+/*
+ * algif_rng: User-space interface for random number generators
+ *
+ * This file provides the user-space API for random number generators.
+ *
+ * Copyright (C) 2014, Stephan Mueller <smueller@chronox.de>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, and the entire permission notice in its entirety,
+ * including the disclaimer of warranties.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. The name of the author may not be used to endorse or promote
+ * products derived from this software without specific prior
+ * written permission.
+ *
+ * ALTERNATIVELY, this product may be distributed under the terms of
+ * the GNU General Public License, in which case the provisions of the GPL2
+ * are required INSTEAD OF the above restrictions. (This clause is
+ * necessary due to a potential bad interaction between the GPL and
+ * the restrictions contained in a BSD-style copyright.)
+ *
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF
+ * WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
+ * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+#include <linux/module.h>
+#include <crypto/rng.h>
+#include <linux/random.h>
+#include <crypto/if_alg.h>
+#include <linux/net.h>
+#include <net/sock.h>
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Stephan Mueller <smueller@chronox.de>");
+MODULE_DESCRIPTION("User-space interface for random number generators");
+
+struct rng_ctx {
+#define MAXSIZE 128
+ unsigned int len;
+ struct crypto_rng *drng;
+};
+
+static int rng_recvmsg(struct kiocb *unused, struct socket *sock,
+ struct msghdr *msg, size_t len, int flags)
+{
+ struct sock *sk = sock->sk;
+ struct alg_sock *ask = alg_sk(sk);
+ struct rng_ctx *ctx = ask->private;
+ int err = -EFAULT;
+ int genlen = 0;
+ u8 result[MAXSIZE];
+
+ if (len == 0)
+ return 0;
+ if (len > MAXSIZE)
+ len = MAXSIZE;
+
+ /*
+ * although not strictly needed, this is a precaution against coding
+ * errors
+ */
+ memset(result, 0, len);
+
+ /*
+ * The enforcement of a proper seeding of an RNG is done within an
+ * RNG implementation. Some RNGs (DRBG, krng) do not need specific
+ * seeding as they automatically seed. The X9.31 DRNG will return
+ * an error if it was not seeded properly.
+ */
+ genlen = crypto_rng_get_bytes(ctx->drng, result, len);
+ if (genlen < 0)
+ return genlen;
+
+ err = memcpy_to_msg(msg, result, len);
+ memzero_explicit(result, genlen);
+
+ return err ? err : len;
+}
+
+static struct proto_ops algif_rng_ops = {
+ .family = PF_ALG,
+
+ .connect = sock_no_connect,
+ .socketpair = sock_no_socketpair,
+ .getname = sock_no_getname,
+ .ioctl = sock_no_ioctl,
+ .listen = sock_no_listen,
+ .shutdown = sock_no_shutdown,
+ .getsockopt = sock_no_getsockopt,
+ .mmap = sock_no_mmap,
+ .bind = sock_no_bind,
+ .accept = sock_no_accept,
+ .setsockopt = sock_no_setsockopt,
+ .poll = sock_no_poll,
+ .sendmsg = sock_no_sendmsg,
+ .sendpage = sock_no_sendpage,
+
+ .release = af_alg_release,
+ .recvmsg = rng_recvmsg,
+};
+
+static void *rng_bind(const char *name, u32 type, u32 mask)
+{
+ return crypto_alloc_rng(name, type, mask);
+}
+
+static void rng_release(void *private)
+{
+ crypto_free_rng(private);
+}
+
+static void rng_sock_destruct(struct sock *sk)
+{
+ struct alg_sock *ask = alg_sk(sk);
+ struct rng_ctx *ctx = ask->private;
+
+ sock_kfree_s(sk, ctx, ctx->len);
+ af_alg_release_parent(sk);
+}
+
+static int rng_accept_parent(void *private, struct sock *sk)
+{
+ struct rng_ctx *ctx;
+ struct alg_sock *ask = alg_sk(sk);
+ unsigned int len = sizeof(*ctx);
+
+ ctx = sock_kmalloc(sk, len, GFP_KERNEL);
+ if (!ctx)
+ return -ENOMEM;
+
+ ctx->len = len;
+
+ /*
+ * No seeding done at that point -- if multiple accepts are
+ * done on one RNG instance, each resulting FD points to the same
+ * state of the RNG.
+ */
+
+ ctx->drng = private;
+ ask->private = ctx;
+ sk->sk_destruct = rng_sock_destruct;
+
+ return 0;
+}
+
+static int rng_setkey(void *private, const u8 *seed, unsigned int seedlen)
+{
+ /*
+ * Check whether seedlen is of sufficient size is done in RNG
+ * implementations.
+ */
+ return crypto_rng_reset(private, (u8 *)seed, seedlen);
+}
+
+static const struct af_alg_type algif_type_rng = {
+ .bind = rng_bind,
+ .release = rng_release,
+ .accept = rng_accept_parent,
+ .setkey = rng_setkey,
+ .ops = &algif_rng_ops,
+ .name = "rng",
+ .owner = THIS_MODULE
+};
+
+static int __init rng_init(void)
+{
+ return af_alg_register_type(&algif_type_rng);
+}
+
+void __exit rng_exit(void)
+{
+ int err = af_alg_unregister_type(&algif_type_rng);
+ BUG_ON(err);
+}
+
+module_init(rng_init);
+module_exit(rng_exit);
--
2.1.0
^ permalink raw reply related
* [PATCH v6 2/4] crypto: AF_ALG: enable AEAD interface compilation
From: Stephan Mueller @ 2014-12-25 21:59 UTC (permalink / raw)
To: 'Herbert Xu'
Cc: Daniel Borkmann, 'Quentin Gouchet', 'LKML',
linux-crypto-u79uwXL29TY76Z2rM5mHXA,
linux-api-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <5682082.ffPqvQlSqN-PJstQz4BMNNP20K/wil9xYQuADTiUCJX@public.gmane.org>
Enable compilation of the AEAD AF_ALG support and provide a Kconfig
option to compile the AEAD AF_ALG support.
Signed-off-by: Stephan Mueller <smueller-T9tCv8IpfcWELgA04lAiVw@public.gmane.org>
---
crypto/Kconfig | 9 +++++++++
crypto/Makefile | 1 +
2 files changed, 10 insertions(+)
diff --git a/crypto/Kconfig b/crypto/Kconfig
index 1618468..cd3e6fd 100644
--- a/crypto/Kconfig
+++ b/crypto/Kconfig
@@ -1514,6 +1514,15 @@ config CRYPTO_USER_API_SKCIPHER
This option enables the user-spaces interface for symmetric
key cipher algorithms.
+config CRYPTO_USER_API_AEAD
+ tristate "User-space interface for AEAD cipher algorithms"
+ depends on NET
+ select CRYPTO_AEAD
+ select CRYPTO_USER_API
+ help
+ This option enables the user-spaces interface for AEAD
+ cipher algorithms.
+
config CRYPTO_HASH_INFO
bool
diff --git a/crypto/Makefile b/crypto/Makefile
index 1445b91..593fd3c 100644
--- a/crypto/Makefile
+++ b/crypto/Makefile
@@ -99,6 +99,7 @@ obj-$(CONFIG_CRYPTO_GHASH) += ghash-generic.o
obj-$(CONFIG_CRYPTO_USER_API) += af_alg.o
obj-$(CONFIG_CRYPTO_USER_API_HASH) += algif_hash.o
obj-$(CONFIG_CRYPTO_USER_API_SKCIPHER) += algif_skcipher.o
+obj-$(CONFIG_CRYPTO_USER_API_AEAD) += algif_aead.o
#
# generic algorithms and the async_tx api
--
2.1.0
^ permalink raw reply related
* [PATCH v6 0/4] crypto: AF_ALG: add AEAD and RNG support
From: Stephan Mueller @ 2014-12-25 21:58 UTC (permalink / raw)
To: 'Herbert Xu'
Cc: Daniel Borkmann, 'Quentin Gouchet', 'LKML',
linux-crypto-u79uwXL29TY76Z2rM5mHXA,
linux-api-u79uwXL29TY76Z2rM5mHXA
Hi,
This patch set adds AEAD and RNG support to the AF_ALG interface
exported by the kernel crypto API. By extending AF_ALG with AEAD and RNG
support, all cipher types the kernel crypto API allows access to are
now accessible from userspace.
Both, AEAD and RNG implementations are stand-alone and do not depend
other AF_ALG interfaces (like hash or skcipher).
The AEAD implementation uses the same approach as provided with
skcipher by offering the following interfaces:
* sendmsg and recvmsg interfaces allowing multiple
invocations supporting a threaded user space. To support
multi-threaded user space, kernel-side buffering
is implemented similarly to skcipher.
* splice / vmsplice interfaces allowing a zero-copy
invocation
The RNG interface only implements the recvmsg interface as
zero-copy is not applicable.
The new AEAD and RNG interfaces are fully tested with the test application
provided at [1]. That test application exercises all newly added user space
interfaces. The testing covers:
* use of the sendmsg/recvmsg interface
* use of the splice / vmsplice interface
* invocation of all AF_ALG types (aead, rng, skcipher, hash)
* using all types of operation (encryption, decryption, keyed MD,
MD, random numbers, AEAD decryption with positive and negative
authentication verification)
* stress testing by running all tests for 30 minutes in an
endless loop
* test execution on 64 bit and 32 bit
[1] http://www.chronox.de/libkcapi.html
Changes v2:
* rebase to current cryptodev-2.6 tree
* use memzero_explicit to zeroize AEAD associated data
* use sizeof for determining length of AEAD associated data
* update algif_rng.c covering all suggestions from Daniel Borkmann
<dborkman-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
* addition of patch 9: add digestsize interface for hashes
* addition of patch to update documentation covering the userspace interface
* change numbers of getsockopt options: separate them from sendmsg interface
definitions
Changes v3:
* remove getsockopt interface
* AEAD: associated data is set prepended to the plain/ciphertext
* AEAD: allowing arbitrary associated data lengths
* remove setkey patch as protection was already in the existing code
Changes v4:
* stand-alone implementation of AEAD
* testing of all interfaces offered by AEAD
* stress testing of AEAD and RNG
Changes v5:
* AEAD: add outer while(size) loop in aead_sendmsg to ensure all data is
copied into the kernel (reporter Herbert Xu)
* AEAD: aead_sendmsg bug fix: change size -= len; to size -= plen;
* AF_ALG / AEAD: add aead_setauthsize and associated extension to
struct af_alg_type as well as alg_setsockopt (reporter Herbert Xu)
* RNG: rng_recvmsg: use 128 byte stack variable for output of RNG instead
of ctx->result (reporter Herbert Xu)
* RNG / AF_ALG: allow user space to seed RNG via setsockopt
* RNG: rng_recvmsg bug fix: use genlen as result variable for
crypto_rng_get_bytes as previously no negative errors were obtained
* AF_ALG: alg_setop: zeroize buffer before free
Changes v6:
* AEAD/RNG: port to 3.19-rc1 with the iov_iter handling
* RNG: use the setkey interface to obtain the seed and drop the patch adding
a separate reseeding interface
* extract the zeroization patch for alg_setkey into a stand-alone patch
submission
* fix bug in aead_sufficient_data (reporter Herbert Xu)
* testing of all interfaces with test application provided with libkcapi version
0.6.2
Stephan Mueller (4):
crypto: AF_ALG: add AEAD support
crypto: AF_ALG: enable AEAD interface compilation
crypto: AF_ALG: add random number generator support
crypto: AF_ALG: enable RNG interface compilation
crypto/Kconfig | 18 ++
crypto/Makefile | 2 +
crypto/algif_aead.c | 651 ++++++++++++++++++++++++++++++++++++++++++++++++++++
crypto/algif_rng.c | 192 ++++++++++++++++
4 files changed, 863 insertions(+)
create mode 100644 crypto/algif_aead.c
create mode 100644 crypto/algif_rng.c
--
2.1.0
^ permalink raw reply
* Re: [PATCH v5 3/8] crypto: AF_ALG: add AEAD support
From: Herbert Xu @ 2014-12-25 20:28 UTC (permalink / raw)
To: Stephan Mueller
Cc: Daniel Borkmann, 'Quentin Gouchet', 'LKML',
linux-crypto-u79uwXL29TY76Z2rM5mHXA,
linux-api-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <2159528.zCJB0y2Cap-PJstQz4BMNNP20K/wil9xYQuADTiUCJX@public.gmane.org>
On Wed, Dec 24, 2014 at 09:54:33AM +0100, Stephan Mueller wrote:
>
> That is right, but isn't that the nature of AEAD ciphers in general? Even if
> you are in the kernel, you need to have all scatter lists together for one
> invocation of the AEAD cipher.
It's actually only the nature of certain algorithms like CCM which
requires the total length to start the operation. Most AEAD
algorithms can be implemented in a way that allows piecemeal
operation. However, as the only users of AEAD is IPsec, it's
probably not worth adding more complexity for now.
So let's proceed with your current solution.
Thanks,
--
Email: Herbert Xu <herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply
* [PATCH v2 1/2] virtio_ring: document alignment requirements
From: Michael S. Tsirkin @ 2014-12-25 15:05 UTC (permalink / raw)
To: linux-kernel; +Cc: linux-api, virtualization
In-Reply-To: <1419517332-12291-1-git-send-email-mst@redhat.com>
Host needs to know vring element alignment requirements:
simply doing alignof on structures doesn't work reliably: on some
platforms gcc has alignof(uint32_t) == 2.
Add macros for alignment as specified in virtio 1.0 cs01,
export them to userspace as well.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
include/uapi/linux/virtio_ring.h | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/include/uapi/linux/virtio_ring.h b/include/uapi/linux/virtio_ring.h
index 61c818a..a3318f3 100644
--- a/include/uapi/linux/virtio_ring.h
+++ b/include/uapi/linux/virtio_ring.h
@@ -101,6 +101,13 @@ struct vring {
struct vring_used *used;
};
+/* Alignment requirements for vring elements.
+ * When using pre-virtio 1.0 layout, these fall out naturally.
+ */
+#define VRING_AVAIL_ALIGN_SIZE 2
+#define VRING_USED_ALIGN_SIZE 4
+#define VRING_DESC_ALIGN_SIZE 16
+
/* The standard layout for the ring is a continuous chunk of memory which looks
* like this. We assume num is a power of 2.
*
--
MST
^ permalink raw reply related
* Re: [PATCH v5 3/8] crypto: AF_ALG: add AEAD support
From: Stephan Mueller @ 2014-12-25 8:59 UTC (permalink / raw)
To: Herbert Xu
Cc: Daniel Borkmann, 'Quentin Gouchet', 'LKML',
linux-crypto-u79uwXL29TY76Z2rM5mHXA,
linux-api-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <2159528.zCJB0y2Cap-PJstQz4BMNNP20K/wil9xYQuADTiUCJX@public.gmane.org>
Am Mittwoch, 24. Dezember 2014, 09:54:33 schrieb Stephan Mueller:
Hi Stephan,
> Am Mittwoch, 24. Dezember 2014, 07:24:01 schrieb Herbert Xu:
>
> Hi Herbert,
>
> > On Tue, Dec 23, 2014 at 03:52:27PM +0100, Stephan Mueller wrote:
> > > Am Dienstag, 23. Dezember 2014, 22:56:26 schrieb Herbert Xu:
> > > > In fact AEAD is rather awkward because you need to do everything
> > > > in one go. Perhaps we could adapt our kernel interface to allow
> > > > partial AEAD operations?
> > >
> > > I am not sure what you are referring to. The invocation does not need to
> > > be in one go. You can have arbitrary number of sendmsg calls. But all
> > > input data needs to be supplied before you call recvmsg.
> >
> > What I mean is that unlike skcipher we cannot precede until we
> > have the complete input. So you cannot begin recvmsg until all
> > input has been sent.
>
> That is right, but isn't that the nature of AEAD ciphers in general? Even if
> you are in the kernel, you need to have all scatter lists together for one
> invocation of the AEAD cipher.
>
> In case of a threaded application, the recvmsg does not start until all data
> is in, marked with the missing MSG_MORE -- see aead_readable.
>
> All we can do is allow the user to use multiple system calls to collect all
> data before the AEAD operation takes place.
>
> Or do you see another way on how to invoke the AEAD operation in a different
> manner?
>
> The only item that I see that could be made better is the output side:
> currently the code allows only one and exactly one iovec to point to the
> output buffer. I would like to allow multiple iovec buffers that are filled
> with the output of one invocation of the AEAD operation. However, to avoid
> making a kernel-internal scratch buffer, I would need to somehow link the
> kernel-internal scatter lists with the iovec buffers. That only works when
> walking the iovec lists first and call af_alg_make_sg with every iovec entry
> and create the kernel-internal scatterlist representation. That is followed
> by the AEAD operation on the scatterlist.
>
> If we agree on walking the iovec list first, then the question arises how
> many iovec list entries we allow at max. Is 16 entries a sensible value?
I would be now ready with a new release of the AEAD and RNG interface patches
against the current code base (including the iov_iter update). Though, I would
like to get your answer regarding your concerns.
Thanks.
--
Ciao
Stephan
^ permalink raw reply
* [PATCH v3 20/20] kbuild: add a new kselftest_install make target to install selftests
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to install to install kernel selftests.
This new target will build and install selftests. kselftest
target now depends on kselftest_install and runs the generated
kselftest script to reduce duplicate work and for common look
and feel when running tests.
make kselftest_target:
-- exports kselftest INSTALL_KSFT_PATH
default $(INSTALL_MOD_PATH)/lib/kselftest/$(KERNELRELEASE)
-- exports INSTALL_KSFT_PATH
-- runs selftests make install target:
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
Makefile | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/Makefile b/Makefile
index b1c3254..99fac47 100644
--- a/Makefile
+++ b/Makefile
@@ -1072,12 +1072,21 @@ headers_check: headers_install
$(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/uapi/asm $(hdr-dst) HDRCHECK=1
# ---------------------------------------------------------------------------
-# Kernel selftest
+# Kernel selftest targets
+
+# Default base path for kselftest install
+INSTALL_KSFT_PATH = $(INSTALL_MOD_PATH)/lib/kselftest/$(KERNELRELEASE)
+export INSTALL_KSFT_PATH
PHONY += kselftest
kselftest:
$(Q)$(MAKE) -C tools/testing/selftests run_tests
+# Kernel selftest install
+PHONY += kselftest_install
+kselftest_install:
+ $(Q)$(MAKE) -C tools/testing/selftests install
+
# ---------------------------------------------------------------------------
# Modules
@@ -1286,6 +1295,9 @@ help:
@echo ' Build, install, and boot kernel before'
@echo ' running kselftest on it'
@echo ''
+ @echo ' kselftest_install - Install Kselftests to INSTALL_KSFT_PATH'
+ @echo ' default: $(INSTALL_MOD_PATH)/lib/kselftest/$(KERNELRELEASE)'
+ @echo ''
@echo 'Kernel packaging:'
@$(MAKE) $(build)=$(package-dir) help
@echo ''
--
2.1.0
^ permalink raw reply related
* [PATCH v3 19/20] selftests: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing selftests. This
new target will call install targets for the tests that are
specified in INSTALL_TARGETS. During install, a script is
generated to run tests that are installed. This script will
be installed in the selftest install directory. Individual
test Makefiles are changed to add to the script. This will
allow new tests to add install and run test commands to the
generated kselftest script. run_tests target runs the
generated kselftest script to run tests when it is initiated
from from "make kselftest" from top level source directory.
Approach:
Add a new kselftest_install target:
-- exports kselftest INSTALL_KSFT_PATH
default $(INSTALL_MOD_PATH)/lib/kselftest/$(KERNELRELEASE)
-- exports INSTALL_KSFT_PATH
-- runs selftests make kselftest_install target:
selftests make install target
-- Sets up environment for sub-makefiles
-- creates kselftest.sh script in install install dir
-- runs install targets for INSTALL_TARGETS
-- install target can be run only from top level source dir.
Individual test make install targets:
-- install test programs and/or scripts in install dir
-- append to the ksefltest.sh file to add commands to run test
-- install target can be run only from top level source dir.
Adds the following new ways to initiate selftests:
-- Installing and running kselftest from install directory
by running "make kselftest"
-- Running kselftest script from install directory
Maintains the following ways to run tests:
-- make TARGETS=net kselftest
-- make -C tools/testing/selftests run_tests
-- make -C tools/testing/selftests TARGETS=target run_tests
Ability specify targets: e.g TARGETS=net
-- make run_tests from tools/testing/selftests
-- make run_tests from individual test directories:
e.g: make run_tests in tools/testing/selftests/net
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/Makefile | 54 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 53 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index 4e51122..e70cdc9 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -22,15 +22,67 @@ TARGETS += vm
TARGETS_HOTPLUG = cpu-hotplug
TARGETS_HOTPLUG += memory-hotplug
+# Used in only run_tests target when make kselftest is run in
+# top level source directory
+ifeq "$(origin TARGETS)" "command line"
+no_install_run=1
+endif
+
+ifdef INSTALL_KSFT_PATH
+KSELFTEST=$(INSTALL_KSFT_PATH)/kselftest.sh
+export KSELFTEST
+# TODO add install target for SKIP_INSTALL_TARGETS
+SKIP_INSTALL_TARGETS = exec powerpc
+INSTALL_TARGETS = $(filter-out $(SKIP_INSTALL_TARGETS),$(TARGETS)) ipc
+else
+no_install_run=1
+endif
+
+INSTALL_KSFT_ERR = Run make kselftest_install in top level source directory
+
all:
for TARGET in $(TARGETS); do \
make -C $$TARGET; \
done;
-run_tests: all
+install:
+ifdef INSTALL_KSFT_PATH
+ rm -rf $(INSTALL_KSFT_PATH)
+ mkdir -p $(INSTALL_KSFT_PATH)
+
+ make all
+ @echo "#!/bin/sh\n# Kselftest Run Tests ...." >> $(KSELFTEST)
+ @echo "# This file is generated by kselftest_install" >> $(KSELFTEST)
+ @echo "# Please don't change it !!\n" >> $(KSELFTEST)
+ @echo echo ============================== >> $(KSELFTEST)
+ for TARGET in $(INSTALL_TARGETS); do \
+ echo Installing $$TARGET; \
+ echo echo Start $$TARGET test .... >> $(KSELFTEST); \
+ make -C $$TARGET install; \
+ echo echo End $$TARGET test .... >> $(KSELFTEST); \
+ echo echo ============================== >> $(KSELFTEST); \
+ done;
+ chmod +x $(KSELFTEST)
+else
+ @echo $(INSTALL_KSFT_ERR)
+endif
+
+run_tests:
+ifndef no_install_run
+# ifdef INSTALL_KSFT_PATH
+ make install
+ @cd $(INSTALL_KSFT_PATH); ./kselftest.sh; cd -
+# invoke run_tests for SKIP_INSTALL_TARGETS
+ for TARGET in $(SKIP_INSTALL_TARGETS); do \
+ make -C $$TARGET run_tests; \
+ done;
+# endif
+else
+ make all
for TARGET in $(TARGETS); do \
make -C $$TARGET run_tests; \
done;
+endif
hotplug:
for TARGET in $(TARGETS_HOTPLUG); do \
--
2.1.0
^ permalink raw reply related
* [PATCH v3 18/20] selftests/vm: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing test. This target
installs test in the kselftest install location and add to the
kselftest script to run the test. Install target can be run
only from top level kernel source directory.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/vm/Makefile | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile
index 4c4b1f6..761d17d 100644
--- a/tools/testing/selftests/vm/Makefile
+++ b/tools/testing/selftests/vm/Makefile
@@ -4,13 +4,22 @@ CC = $(CROSS_COMPILE)gcc
CFLAGS = -Wall
BINARIES = hugepage-mmap hugepage-shm map_hugetlb thuge-gen hugetlbfstest
BINARIES += transhuge-stress
+TEST_STR = /bin/sh ./run_vmtests || echo vmtests: [FAIL]
all: $(BINARIES)
%: %.c
$(CC) $(CFLAGS) -o $@ $^
+install:
+ifdef INSTALL_KSFT_PATH
+ install run_vmtests $(BINARIES) $(INSTALL_KSFT_PATH)
+ @echo "$(TEST_STR)" >> $(KSELFTEST)
+else
+ @echo Run make kselftest_install in top level source directory
+endif
+
run_tests: all
- @/bin/sh ./run_vmtests || (echo "vmtests: [FAIL]"; exit 1)
+ @$(TEST_STR)
clean:
$(RM) $(BINARIES)
--
2.1.0
^ permalink raw reply related
* [PATCH v3 17/20] selftests/user: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing test. This target
installs test in the kselftest install location and add to the
kselftest script to run the test. Install target can be run
only from top level kernel source directory.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/user/Makefile | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/user/Makefile b/tools/testing/selftests/user/Makefile
index 12c9d15..218c5aa 100644
--- a/tools/testing/selftests/user/Makefile
+++ b/tools/testing/selftests/user/Makefile
@@ -1,7 +1,17 @@
# Makefile for user memory selftests
+TEST_STR = ./test_user_copy.sh
+
# No binaries, but make sure arg-less "make" doesn't trigger "run_tests"
all:
+install:
+ifdef INSTALL_KSFT_PATH
+ install ./test_user_copy.sh $(INSTALL_KSFT_PATH)
+ @echo "$(TEST_STR)" >> $(KSELFTEST)
+else
+ @echo Run make kselftest_install in top level source directory
+endif
+
run_tests: all
- ./test_user_copy.sh
+ @$(TEST_STR)
--
2.1.0
^ permalink raw reply related
* [PATCH v3 16/20] selftests/timers: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing test. This target
installs test in the kselftest install location and add to the
kselftest script to run the test. Install target can be run
only from top level kernel source directory.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/timers/Makefile | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/timers/Makefile b/tools/testing/selftests/timers/Makefile
index eb2859f..922bad5 100644
--- a/tools/testing/selftests/timers/Makefile
+++ b/tools/testing/selftests/timers/Makefile
@@ -1,8 +1,18 @@
+TEST_STR = ./posix_timers
+
all:
gcc posix_timers.c -o posix_timers -lrt
+install:
+ifdef INSTALL_KSFT_PATH
+ install ./posix_timers $(INSTALL_KSFT_PATH)
+ @echo "$(TEST_STR)" >> $(KSELFTEST)
+else
+ @echo Run make kselftest_install in top level source directory
+endif
+
run_tests: all
- ./posix_timers
+ @$(TEST_STR)
clean:
rm -f ./posix_timers
--
2.1.0
^ permalink raw reply related
* [PATCH v3 15/20] selftests/sysctl: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing test. This target
installs test in the kselftest install location and add to the
kselftest script to run the test. Install target can be run
only from top level kernel source directory.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/sysctl/Makefile | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/sysctl/Makefile b/tools/testing/selftests/sysctl/Makefile
index 0a92ada..dfbaa58 100644
--- a/tools/testing/selftests/sysctl/Makefile
+++ b/tools/testing/selftests/sysctl/Makefile
@@ -4,12 +4,25 @@
# No binaries, but make sure arg-less "make" doesn't trigger "run_tests".
all:
+INSTALL_PROGS = common_tests run_numerictests run_stringtests
+NUMERIC_TEST_STR = /bin/sh ./run_numerictests
+STRING_TEST_STR = /bin/sh ./run_stringtests
+
# Allow specific tests to be selected.
test_num:
- @/bin/sh ./run_numerictests
+ @$(NUMERIC_TEST_STR)
test_string:
- @/bin/sh ./run_stringtests
+ @$(STRING_TEST_STR)
+
+install: all
+ifdef INSTALL_KSFT_PATH
+ install $(INSTALL_PROGS) $(INSTALL_KSFT_PATH)
+ @echo "$(NUMERIC_TEST_STR)" >> $(KSELFTEST)
+ @echo "$(STRING_TEST_STR)" >> $(KSELFTEST)
+else
+ @echo Run make kselftest_install in top level source directory
+endif
run_tests: all test_num test_string
--
2.1.0
^ permalink raw reply related
* [PATCH v3 14/20] selftests/size: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing test. This target
installs test in the kselftest install location and add to the
kselftest script to run the test. Install target can be run
only from top level kernel source directory.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/size/Makefile | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/size/Makefile b/tools/testing/selftests/size/Makefile
index 04dc25e..bb7113b 100644
--- a/tools/testing/selftests/size/Makefile
+++ b/tools/testing/selftests/size/Makefile
@@ -1,12 +1,22 @@
CC = $(CROSS_COMPILE)gcc
+TEST_STR = ./get_size || echo get_size selftests: [FAIL]
+
all: get_size
get_size: get_size.c
$(CC) -static -ffreestanding -nostartfiles -s $< -o $@
+install:
+ifdef INSTALL_KSFT_PATH
+ install ./get_size $(INSTALL_KSFT_PATH)
+ @echo "$(TEST_STR)" >> $(KSELFTEST)
+else
+ @echo Run make kselftest_install in top level source directory
+endif
+
run_tests: all
- ./get_size
+ @$(TEST_STR)
clean:
$(RM) get_size
--
2.1.0
^ permalink raw reply related
* [PATCH v3 13/20] selftests/ptrace: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing test. This target
installs test in the kselftest install location and add to the
kselftest script to run the test. Install target can be run
only from top level kernel source directory.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/ptrace/Makefile | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/ptrace/Makefile b/tools/testing/selftests/ptrace/Makefile
index 47ae2d3..f238212 100644
--- a/tools/testing/selftests/ptrace/Makefile
+++ b/tools/testing/selftests/ptrace/Makefile
@@ -1,10 +1,20 @@
CFLAGS += -iquote../../../../include/uapi -Wall
-peeksiginfo: peeksiginfo.c
-all: peeksiginfo
+TEST_STR = ./peeksiginfo || echo peeksiginfo selftests: [FAIL]
+
+all:
+ gcc peeksiginfo.c -o peeksiginfo
+
+install:
+ifdef INSTALL_KSFT_PATH
+ install ./peeksiginfo $(INSTALL_KSFT_PATH)
+ @echo "$(TEST_STR)" >> $(KSELFTEST)
+else
+ @echo Run make kselftest_install in top level source directory
+endif
clean:
rm -f peeksiginfo
run_tests: all
- @./peeksiginfo || echo "peeksiginfo selftests: [FAIL]"
+ @$(TEST_STR)
--
2.1.0
^ permalink raw reply related
* [PATCH v3 12/20] selftests/net: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing test. This target
installs test in the kselftest install location and add to the
kselftest script to run the test. Install target can be run
only from top level kernel source directory.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/net/Makefile | 20 +++++++++++++++++---
1 file changed, 17 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/net/Makefile b/tools/testing/selftests/net/Makefile
index 62f22cc..2ffc96f 100644
--- a/tools/testing/selftests/net/Makefile
+++ b/tools/testing/selftests/net/Makefile
@@ -6,14 +6,28 @@ CFLAGS = -Wall -O2 -g
CFLAGS += -I../../../../usr/include/
NET_PROGS = socket psock_fanout psock_tpacket
+INSTALL_PROGS = run_netsocktests run_afpackettests test_bpf.sh $(NET_PROGS)
+NETSOCK_TEST_STR = /bin/sh ./run_netsocktests || echo sockettests: [FAIL]
+AFPKT_TEST_STR = /bin/sh ./run_afpackettests || echo afpackettests: [FAIL]
+BFP_TEST_STR = ./test_bpf.sh
all: $(NET_PROGS)
%: %.c
$(CC) $(CFLAGS) -o $@ $^
+install:
+ifdef INSTALL_KSFT_PATH
+ install $(INSTALL_PROGS) $(INSTALL_KSFT_PATH)
+ @echo "$(NETSOCK_TEST_STR)" >> $(KSELFTEST)
+ @echo "$(AFPKT_TEST_STR)" >> $(KSELFTEST)
+ @echo "$(BFP_TEST_STR)" >> $(KSELFTEST)
+else
+ @echo Run make kselftest_install in top level source directory
+endif
+
run_tests: all
- @/bin/sh ./run_netsocktests || echo "sockettests: [FAIL]"
- @/bin/sh ./run_afpackettests || echo "afpackettests: [FAIL]"
- ./test_bpf.sh
+ @$(NETSOCK_TEST_STR)
+ @$(AFPKT_TEST_STR)
+ @$(BFP_TEST_STR)
clean:
$(RM) $(NET_PROGS)
--
2.1.0
^ permalink raw reply related
* [PATCH v3 11/20] selftests/mqueue: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing test. This target
installs test in the kselftest install location and add to the
kselftest script to run the test. Install target can be run
only from top level kernel source directory.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/mqueue/Makefile | 18 +++++++++++++++---
1 file changed, 15 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/mqueue/Makefile b/tools/testing/selftests/mqueue/Makefile
index 8056e2e..27757b9 100644
--- a/tools/testing/selftests/mqueue/Makefile
+++ b/tools/testing/selftests/mqueue/Makefile
@@ -1,10 +1,22 @@
+MQ_OPEN_TEST_STR = ./mq_open_tests /test1 || echo mq_open_tests: [FAIL]
+MQ_PERF_TEST_STR = ./mq_perf_tests || echo mq_perf_tests: [FAIL]
+
all:
gcc -O2 mq_open_tests.c -o mq_open_tests -lrt
gcc -O2 -o mq_perf_tests mq_perf_tests.c -lrt -lpthread -lpopt
-run_tests:
- @./mq_open_tests /test1 || echo "mq_open_tests: [FAIL]"
- @./mq_perf_tests || echo "mq_perf_tests: [FAIL]"
+install:
+ifdef INSTALL_KSFT_PATH
+ install ./mq_open_tests ./mq_perf_tests $(INSTALL_KSFT_PATH)
+ @echo "$(MQ_OPEN_TEST_STR)" >> $(KSELFTEST)
+ @echo "$(MQ_PERF_TEST_STR)" >> $(KSELFTEST)
+else
+ @echo Run make kselftest_install in top level source directory
+endif
+
+run_tests: all
+ @$(MQ_OPEN_TEST_STR)
+ @$(MQ_PERF_TEST_STR)
clean:
rm -f mq_open_tests mq_perf_tests
--
2.1.0
^ permalink raw reply related
* [PATCH v3 10/20] selftests/mount: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing test. This target
installs test in the kselftest install location and add to the
kselftest script to run the test. Install target can be run
only from top level kernel source directory.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/mount/Makefile | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/mount/Makefile b/tools/testing/selftests/mount/Makefile
index 337d853..607de4c 100644
--- a/tools/testing/selftests/mount/Makefile
+++ b/tools/testing/selftests/mount/Makefile
@@ -1,5 +1,7 @@
# Makefile for mount selftests.
+TEST_STR = if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi
+
all: unprivileged-remount-test
unprivileged-remount-test: unprivileged-remount-test.c
@@ -7,7 +9,15 @@ unprivileged-remount-test: unprivileged-remount-test.c
# Allow specific tests to be selected.
test_unprivileged_remount: unprivileged-remount-test
- @if [ -f /proc/self/uid_map ] ; then ./unprivileged-remount-test ; fi
+ @$(TEST_STR)
+
+install:
+ifdef INSTALL_KSFT_PATH
+ install ./unprivileged-remount-test $(INSTALL_KSFT_PATH)
+ @echo "$(TEST_STR)" >> $(KSELFTEST)
+else
+ @echo Run make kselftest_install in top level source directory
+endif
run_tests: all test_unprivileged_remount
--
2.1.0
^ permalink raw reply related
* [PATCH v3 09/20] selftests/memory-hotplug: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing test. This target
installs test in the kselftest install location and add to the
kselftest script to run the test. Install target can be run
only from top level kernel source directory.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/memory-hotplug/Makefile | 14 ++++++++++++--
.../memory-hotplug/{on-off-test.sh => mem-on-off-test.sh} | 0
2 files changed, 12 insertions(+), 2 deletions(-)
rename tools/testing/selftests/memory-hotplug/{on-off-test.sh => mem-on-off-test.sh} (100%)
diff --git a/tools/testing/selftests/memory-hotplug/Makefile b/tools/testing/selftests/memory-hotplug/Makefile
index d46b8d4..561ee2b 100644
--- a/tools/testing/selftests/memory-hotplug/Makefile
+++ b/tools/testing/selftests/memory-hotplug/Makefile
@@ -1,9 +1,19 @@
+TEST_STR=/bin/bash ./mem-on-off-test.sh -r 2 || echo memory-hotplug selftests: [FAIL]
+
all:
+install:
+ifdef INSTALL_KSFT_PATH
+ install ./mem-on-off-test.sh $(INSTALL_KSFT_PATH)/mem-on-off-test.sh
+ @echo "$(TEST_STR)" >> $(KSELFTEST) >> $(KSELFTEST)
+else
+ @echo Run make kselftest_install in top level source directory
+endif
+
run_tests:
- @/bin/bash ./on-off-test.sh -r 2 || echo "memory-hotplug selftests: [FAIL]"
+ @$(TEST_STR)
run_full_test:
- @/bin/bash ./on-off-test.sh || echo "memory-hotplug selftests: [FAIL]"
+ @/bin/bash ./mem-on-off-test.sh || echo "memory-hotplug selftests: [FAIL]"
clean:
diff --git a/tools/testing/selftests/memory-hotplug/on-off-test.sh b/tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
similarity index 100%
rename from tools/testing/selftests/memory-hotplug/on-off-test.sh
rename to tools/testing/selftests/memory-hotplug/mem-on-off-test.sh
--
2.1.0
^ permalink raw reply related
* [PATCH v3 08/20] selftests/memfd: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing test. This target
installs test in the kselftest install location and add to the
kselftest script to run the test. Install target can be run
only from top level kernel source directory.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/memfd/Makefile | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/tools/testing/selftests/memfd/Makefile b/tools/testing/selftests/memfd/Makefile
index b80cd10..5f70b33 100644
--- a/tools/testing/selftests/memfd/Makefile
+++ b/tools/testing/selftests/memfd/Makefile
@@ -2,19 +2,30 @@ CFLAGS += -D_FILE_OFFSET_BITS=64
CFLAGS += -I../../../../include/uapi/
CFLAGS += -I../../../../include/
+INSTALL_PROGS = memfd_test fuse_test run_fuse_test.sh
+MEMFD_TEST_STR = ./memfd_test || echo memfd_test: [FAIL]
+FUSE_TEST_STR = ./run_fuse_test.sh || echo fuse_test: [FAIL]
+
all:
gcc $(CFLAGS) memfd_test.c -o memfd_test
+install:
+ifdef INSTALL_KSFT_PATH
+ install $(INSTALL_PROGS) $(INSTALL_KSFT_PATH)
+ @echo "$(MEMFD_TEST_STR)" >> $(KSELFTEST)
+else
+ @echo Run make kselftest_install in top level source directory
+endif
+
run_tests: all
- gcc $(CFLAGS) memfd_test.c -o memfd_test
- @./memfd_test || echo "memfd_test: [FAIL]"
+ @$(MEMFD_TEST_STR)
build_fuse:
gcc $(CFLAGS) fuse_mnt.c `pkg-config fuse --cflags --libs` -o fuse_mnt
gcc $(CFLAGS) fuse_test.c -o fuse_test
run_fuse: build_fuse
- @./run_fuse_test.sh || echo "fuse_test: [FAIL]"
+ @$(FUSE_TEST_STR)
clean:
$(RM) memfd_test fuse_test
--
2.1.0
^ permalink raw reply related
* [PATCH v3 07/20] selftests/kcmp: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing test. This target
installs test in the kselftest install location and add to the
kselftest script to run the test. Install target can be run
only from top level kernel source directory.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/kcmp/Makefile | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/kcmp/Makefile b/tools/testing/selftests/kcmp/Makefile
index ff0eefd..8d640d0 100644
--- a/tools/testing/selftests/kcmp/Makefile
+++ b/tools/testing/selftests/kcmp/Makefile
@@ -1,10 +1,21 @@
CC := $(CROSS_COMPILE)$(CC)
CFLAGS += -I../../../../usr/include/
+TEST_STR = ./kcmp_test || echo kcmp_test: [FAIL]
+
all: kcmp_test
+install:
+ifdef INSTALL_KSFT_PATH
+ install ./kcmp_test $(INSTALL_KSFT_PATH)
+ @echo "$(TEST_STR)" >> $(KSELFTEST)
+ @echo rm -f kcmp-test-file >> $(KSELFTEST)
+else
+ @echo Run make kselftest_install in top level source directory
+endif
+
run_tests: all
- @./kcmp_test || echo "kcmp_test: [FAIL]"
+ @$(TEST_STR)
clean:
$(RM) kcmp_test kcmp-test-file
--
2.1.0
^ permalink raw reply related
* [PATCH v3 06/20] selftests/ipc: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing test. This target
installs test in the kselftest install location and add to the
kselftest script to run the test. Install target can be run
only from top level kernel source directory.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/ipc/Makefile | 19 ++++++++++++++++++-
1 file changed, 18 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ipc/Makefile b/tools/testing/selftests/ipc/Makefile
index 74bbefd..b43e8e8 100644
--- a/tools/testing/selftests/ipc/Makefile
+++ b/tools/testing/selftests/ipc/Makefile
@@ -11,6 +11,8 @@ endif
CFLAGS += -I../../../../usr/include/
+TEST_STR = ./msgque_test || echo ipc msgque test: [FAIL]
+
all:
ifeq ($(ARCH),x86)
gcc $(CFLAGS) msgque.c -o msgque_test
@@ -18,8 +20,23 @@ else
echo "Not an x86 target, can't build msgque selftest"
endif
+install:
+ifdef INSTALL_KSFT_PATH
+ifeq ($(ARCH),x86)
+ make all
+ install ./msgque_test $(INSTALL_KSFT_PATH)
+ @echo "$(TEST_STR)" >> $(KSELFTEST)
+else
+ @echo Not an x86 target, unable to install ipc msgque selftests
+endif
+else
+ @echo Run make kselftest_install in top level source directory
+endif
+
run_tests: all
- ./msgque_test
+ifeq ($(ARCH),x86)
+ @$(TEST_STR)
+endif
clean:
rm -fr ./msgque_test
--
2.1.0
^ permalink raw reply related
* [PATCH v3 05/20] selftests/ftrace: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing test. This target
installs test in the kselftest install location and add to the
kselftest script to run the test. Install target can be run
only from top level kernel source directory.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/ftrace/Makefile | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/tools/testing/selftests/ftrace/Makefile b/tools/testing/selftests/ftrace/Makefile
index 76cc9f1..7c7cf42 100644
--- a/tools/testing/selftests/ftrace/Makefile
+++ b/tools/testing/selftests/ftrace/Makefile
@@ -1,7 +1,16 @@
+TEST_STR = /bin/sh ./ftracetest || echo ftrace selftests: [FAIL]
+
all:
+install:
+ifdef INSTALL_KSFT_PATH
+ install ./ftracetest $(INSTALL_KSFT_PATH)
+ @cp -r test.d $(INSTALL_KSFT_PATH)
+ echo "$(TEST_STR)" >> $(KSELFTEST)
+endif
+
run_tests:
- @/bin/sh ./ftracetest || echo "ftrace selftests: [FAIL]"
+ @$(TEST_STR)
clean:
rm -rf logs/*
--
2.1.0
^ permalink raw reply related
* [PATCH v3 04/20] selftests/firmware: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing test. This target
installs test in the kselftest install location and add to the
kselftest script to run the test. Install target can be run
only from top level kernel source directory.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/firmware/Makefile | 43 +++++++++++++++++++------------
1 file changed, 26 insertions(+), 17 deletions(-)
diff --git a/tools/testing/selftests/firmware/Makefile b/tools/testing/selftests/firmware/Makefile
index e23cce0..7ac1cf3 100644
--- a/tools/testing/selftests/firmware/Makefile
+++ b/tools/testing/selftests/firmware/Makefile
@@ -1,25 +1,34 @@
# Makefile for firmware loading selftests
# No binaries, but make sure arg-less "make" doesn't trigger "run_tests"
+
+__fw_filesystem:
+fw_filesystem = if /bin/sh ./fw_filesystem.sh ; then
+fw_filesystem += echo fw_filesystem: ok;
+fw_filesystem += else echo fw_filesystem: [FAIL];
+fw_filesystem += fi
+
+__fw_userhelper:
+fw_userhelper = if /bin/sh ./fw_userhelper.sh ; then
+fw_userhelper += echo fw_userhelper: ok;
+fw_userhelper += else
+fw_userhelper += echo fw_userhelper: [FAIL];
+fw_userhelper += fi
+
all:
-fw_filesystem:
- @if /bin/sh ./fw_filesystem.sh ; then \
- echo "fw_filesystem: ok"; \
- else \
- echo "fw_filesystem: [FAIL]"; \
- exit 1; \
- fi
-
-fw_userhelper:
- @if /bin/sh ./fw_userhelper.sh ; then \
- echo "fw_userhelper: ok"; \
- else \
- echo "fw_userhelper: [FAIL]"; \
- exit 1; \
- fi
-
-run_tests: all fw_filesystem fw_userhelper
+install:
+ifdef INSTALL_KSFT_PATH
+ install ./fw_filesystem.sh ./fw_userhelper.sh $(INSTALL_KSFT_PATH)
+ @echo "$(fw_filesystem)" >> $(KSELFTEST)
+ @echo "$(fw_userhelper)" >> $(KSELFTEST)
+else
+ @echo Run make kselftest_install in top level source directory
+endif
+
+run_tests:
+ @$(fw_filesystem)
+ @$(fw_userhelper)
# Nothing to clean up.
clean:
--
2.1.0
^ permalink raw reply related
* [PATCH v3 03/20] selftests/efivarfs: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing test. This target
installs test in the kselftest install location and add to the
kselftest script to run the test. Install target can be run
only from top level kernel source directory.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/efivarfs/Makefile | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/tools/testing/selftests/efivarfs/Makefile b/tools/testing/selftests/efivarfs/Makefile
index 29e8c6b..aaf404b 100644
--- a/tools/testing/selftests/efivarfs/Makefile
+++ b/tools/testing/selftests/efivarfs/Makefile
@@ -3,10 +3,22 @@ CFLAGS = -Wall
test_objs = open-unlink create-read
-all: $(test_objs)
+TEST_STR = /bin/bash ./efivarfs.sh || echo efivarfs selftests: [FAIL]
+
+all:
+ gcc open-unlink.c -o open-unlink
+ gcc create-read.c -o create-read
+
+install:
+ifdef INSTALL_KSFT_PATH
+ install ./efivarfs.sh $(test_objs) $(INSTALL_KSFT_PATH)
+ @echo "$(TEST_STR)" >> $(KSELFTEST)
+else
+ @echo Run make kselftest_install in top level source directory
+endif
run_tests: all
- @/bin/bash ./efivarfs.sh || echo "efivarfs selftests: [FAIL]"
+ @$(TEST_STR)
clean:
rm -f $(test_objs)
--
2.1.0
^ permalink raw reply related
* [PATCH v3 02/20] selftests/cpu-hotplug: add install target to enable test install
From: Shuah Khan @ 2014-12-24 16:27 UTC (permalink / raw)
To: mmarek, gregkh, akpm, rostedt, mingo, davem, keescook,
tranmanphong, mpe, cov, dh.herrmann, hughd, bobby.prani,
serge.hallyn, ebiederm, tim.bird, josh, koct9i
Cc: Shuah Khan, linux-kbuild, linux-kernel, linux-api, netdev
In-Reply-To: <cover.1419387513.git.shuahkh@osg.samsung.com>
Add a new make target to enable installing test. This target
installs test in the kselftest install location and add to the
kselftest script to run the test. Install target can be run
only from top level kernel source directory.
Signed-off-by: Shuah Khan <shuahkh@osg.samsung.com>
---
tools/testing/selftests/cpu-hotplug/Makefile | 14 ++++++++++++--
.../cpu-hotplug/{on-off-test.sh => cpu-on-off-test.sh} | 0
2 files changed, 12 insertions(+), 2 deletions(-)
rename tools/testing/selftests/cpu-hotplug/{on-off-test.sh => cpu-on-off-test.sh} (100%)
diff --git a/tools/testing/selftests/cpu-hotplug/Makefile b/tools/testing/selftests/cpu-hotplug/Makefile
index e9c28d8..c9e15ee 100644
--- a/tools/testing/selftests/cpu-hotplug/Makefile
+++ b/tools/testing/selftests/cpu-hotplug/Makefile
@@ -1,9 +1,19 @@
+TEST_STR=/bin/bash ./cpu-on-off-test.sh || echo cpu-hotplug selftests: [FAIL]
+
all:
+install:
+ifdef INSTALL_KSFT_PATH
+ install ./cpu-on-off-test.sh $(INSTALL_KSFT_PATH)/cpu-on-off-test.sh
+ @echo "$(TEST_STR)" >> $(KSELFTEST)
+else
+ @echo Run make kselftest_install in top level source directory
+endif
+
run_tests:
- @/bin/bash ./on-off-test.sh || echo "cpu-hotplug selftests: [FAIL]"
+ @$(TEST_STR)
run_full_test:
- @/bin/bash ./on-off-test.sh -a || echo "cpu-hotplug selftests: [FAIL]"
+ @/bin/bash ./cpu-on-off-test.sh -a || echo "cpu-hotplug selftests: [FAIL]"
clean:
diff --git a/tools/testing/selftests/cpu-hotplug/on-off-test.sh b/tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
similarity index 100%
rename from tools/testing/selftests/cpu-hotplug/on-off-test.sh
rename to tools/testing/selftests/cpu-hotplug/cpu-on-off-test.sh
--
2.1.0
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox