From patchwork Wed Jul 28 12:34:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1510829 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=oSycvn7U; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GZY606xNFz9sRR for ; Wed, 28 Jul 2021 22:35:20 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 4FE743C90F4 for ; Wed, 28 Jul 2021 14:35:18 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [IPv6:2001:4b78:1:20::5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 777503C642D for ; Wed, 28 Jul 2021 14:34:25 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 4D68A600F46 for ; Wed, 28 Jul 2021 14:34:24 +0200 (CEST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 9A46F1FF9F; Wed, 28 Jul 2021 12:34:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1627475663; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SJ2K5A9McykR5KtELFATs4EhE4EtfUZg8qFyIUdDi1I=; b=oSycvn7Um9F9ZfNdPu2hU4TUev6cDGOGXIh5BxCc81MmbjCr1qkGCVNM3CjmYmnHpuSzPv YGgZI+DSsSUCqrKaF7LSS3CHCl3dkJUsNdHSeqLIkEZ4jiIygz9r9SZVW9SQzBqIbmCabL rNuUDfqk+hGFgiF6Ybrlx9ZBPxBO2jM= Received: from g78.suse.de (unknown [10.163.24.38]) by relay2.suse.de (Postfix) with ESMTP id 69E8DA3B81; Wed, 28 Jul 2021 12:34:23 +0000 (UTC) To: ltp@lists.linux.it Date: Wed, 28 Jul 2021 13:34:05 +0100 Message-Id: <20210728123412.31858-2-rpalethorpe@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728123412.31858-1-rpalethorpe@suse.com> References: <20210728123412.31858-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH v3 1/8] Add Sparse based checker and TST_RET/ERR check X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Vendors in Sparse as a git module. Then uses it to check for stores to TST_RET/ERR within the library. Signed-off-by: Richard Palethorpe --- .gitmodules | 3 + tools/Makefile | 2 + tools/sparse/.gitignore | 1 + tools/sparse/Makefile | 27 +++++++ tools/sparse/README.md | 51 +++++++++++++ tools/sparse/sparse-ltp.c | 147 ++++++++++++++++++++++++++++++++++++++ tools/sparse/sparse-src | 1 + 7 files changed, 232 insertions(+) create mode 100644 tools/sparse/.gitignore create mode 100644 tools/sparse/Makefile create mode 100644 tools/sparse/README.md create mode 100644 tools/sparse/sparse-ltp.c create mode 160000 tools/sparse/sparse-src diff --git a/.gitmodules b/.gitmodules index 1c9e9c38a..a3c34af4b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "testcases/kernel/mce-test"] path = testcases/kernel/mce-test url = git://git.kernel.org/pub/scm/linux/kernel/git/gong.chen/mce-test.git +[submodule "tools/sparse/sparse-src"] + path = tools/sparse/sparse-src + url = git://git.kernel.org/pub/scm/devel/sparse/sparse.git diff --git a/tools/Makefile b/tools/Makefile index def1c6fa9..adbf4fe70 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -28,4 +28,6 @@ INSTALL_TARGETS := *.awk *.pl *.sh html_report_header.txt INSTALL_DIR := bin +FILTER_OUT_DIRS += sparse + include $(top_srcdir)/include/mk/generic_trunk_target.mk diff --git a/tools/sparse/.gitignore b/tools/sparse/.gitignore new file mode 100644 index 000000000..b2d2c37fa --- /dev/null +++ b/tools/sparse/.gitignore @@ -0,0 +1 @@ +sparse-ltp diff --git a/tools/sparse/Makefile b/tools/sparse/Makefile new file mode 100644 index 000000000..4247dd86e --- /dev/null +++ b/tools/sparse/Makefile @@ -0,0 +1,27 @@ +# SPDX-License-Identifier: GPL-2.0-or-later +# Copyright (c) 2021 SUSE LLC + +top_srcdir ?= ../.. + +include $(top_srcdir)/include/mk/env_pre.mk +include $(top_srcdir)/include/mk/functions.mk + +SPARSE_SRC ?= sparse-src + +$(SPARSE_SRC)/Makefile: +ifeq ($(SPARSE_SRC),sparse-src) + git submodule update --init +else + $(error "Can't find $(SPARSE_SRC)/Makefile") +endif + +$(SPARSE_SRC)/libsparse.a: $(SPARSE_SRC)/Makefile + $(MAKE) -C $(SPARSE_SRC) libsparse.a + +HOST_MAKE_TARGETS := sparse-ltp +MAKE_DEPS += $(SPARSE_SRC)/libsparse.a +HOST_CFLAGS += -I$(SPARSE_SRC) -Werror +HOST_LDLIBS += $(SPARSE_SRC)/libsparse.a + + +include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/tools/sparse/README.md b/tools/sparse/README.md new file mode 100644 index 000000000..aaf24f7ba --- /dev/null +++ b/tools/sparse/README.md @@ -0,0 +1,51 @@ +# Sparse based linting + +This tool checks LTP test and library code for common problems. + +## Usage + +It is integrated with the LTP build system. Just run `make check` or +`make check-a_test01`, where `a_test01` is an arbitrary test +executable or object file. + +## Building + +The bad news is you must get and build Sparse[^1]. The good news is +that this only takes a minute and the build system does it for +you. Just try running `make check` as described above. + +However if you want to reuse an existing Sparse checkout. Then you can +do the following. Where `$SRC_PATH` is the path to the Sparse +directory. + +```sh +$ cd tools/sparse +$ make SPARSE_SRC=$SRC_PATH +``` +You can also manually fetch it via the git submodule + +```sh +$ cd tools/sparse +$ git submodule update --init +``` + +### Modifying CFLAGS and -m32 + +When compiling the LTP with `-m32` it may break building +`sparse-ltp`. We do not pass LTP's `CFLAGS` or `HOST_CFLAGS` to +`libsparse.a`. In the best case it produces a lot of noise, in the +worst it breaks building anyway. + +To avoid issues with m32, just pre-build the checker with a non-m32 +config. It won't need to be built again unless you are modifying the +tool itself. Similar issues with cross-compiling could be handled in a +similar way. Simply pre-build `sparse-ltp` and `libsparse.a` with a separate +config. + +### Clang + +Note that while it is possible to build Sparse with Clang. This may +cause some issues. Namely `GCC_BASE` is set to the Clang resource +directory. This contains some headers Sparse can not parse. + +[1]: Many distributions have a Sparse package. This only contains some executables. There is no shared library diff --git a/tools/sparse/sparse-ltp.c b/tools/sparse/sparse-ltp.c new file mode 100644 index 000000000..45874e8eb --- /dev/null +++ b/tools/sparse/sparse-ltp.c @@ -0,0 +1,147 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (C) 2021 SUSE LLC + * + * Sparse allows us to perform checks on the AST (struct symbol) or on + * a linearized representation. In the latter case we are given a set + * of entry points (functions) containing basic blocks of + * instructions. + * + * The basic blocks contain byte code in SSA form. This is similar to + * the intermediate representation most compilers use during + * optimisation. + */ +#include +#include +#include +#include +#include +#include +#include + +#include "lib.h" +#include "allocate.h" +#include "opcode.h" +#include "token.h" +#include "parse.h" +#include "symbol.h" +#include "expression.h" +#include "linearize.h" + +/* The rules for test, library and tool code are different */ +enum ltp_tu_kind { + LTP_LIB, + LTP_OTHER, +}; + +static enum ltp_tu_kind tu_kind = LTP_OTHER; + +/* Check for LTP-002 + * + * Inspects the destination symbol of each store instruction. If it is + * TST_RET or TST_ERR then emit a warning. + */ +static void check_lib_sets_TEST_vars(const struct instruction *insn) +{ + static struct ident *TST_RES_id, *TST_ERR_id; + + if (!TST_RES_id) { + TST_RES_id = built_in_ident("TST_RET"); + TST_ERR_id = built_in_ident("TST_ERR"); + } + + if (insn->opcode != OP_STORE) + return; + if (insn->src->ident != TST_RES_id && + insn->src->ident != TST_ERR_id) + return; + + warning(insn->pos, + "LTP-002: Library should not write to TST_RET or TST_ERR"); +} + +static void do_basicblock_checks(struct basic_block *bb) +{ + struct instruction *insn; + + FOR_EACH_PTR(bb->insns, insn) { + if (!bb_reachable(insn->bb)) + continue; + + if (tu_kind == LTP_LIB) + check_lib_sets_TEST_vars(insn); + } END_FOR_EACH_PTR(insn); +} + +static void do_entrypoint_checks(struct entrypoint *ep) +{ + struct basic_block *bb; + + FOR_EACH_PTR(ep->bbs, bb) { + do_basicblock_checks(bb); + } END_FOR_EACH_PTR(bb); +} + +/* Compile the AST into a graph of basicblocks */ +static void process_symbols(struct symbol_list *list) +{ + struct symbol *sym; + + FOR_EACH_PTR(list, sym) { + struct entrypoint *ep; + + expand_symbol(sym); + ep = linearize_symbol(sym); + if (!ep || !ep->entry) + continue; + + do_entrypoint_checks(ep); + + if (dbg_entry) + show_entry(ep); + } END_FOR_EACH_PTR(sym); +} + +static void collect_info_from_args(const int argc, char *const *const argv) +{ + int i; + + for (i = 0; i < argc; i++) { + if (!strcmp("-DLTPLIB", argv[i])) + tu_kind = LTP_LIB; + } +} + +int main(int argc, char **argv) +{ + struct string_list *filelist = NULL; + char *file; + + Waddress_space = 0; + Wbitwise = 0; + Wcast_truncate = 0; + Wcontext = 0; + Wdecl = 0; + Wexternal_function_has_definition = 0; + Wflexible_array_array = 0; + Wimplicit_int = 0; + Wint_to_pointer_cast = 0; + Wmemcpy_max_count = 0; + Wnon_pointer_null = 0; + Wone_bit_signed_bitfield = 0; + Woverride_init = 0; + Wpointer_to_int_cast = 0; + Wvla = 0; + + do_output = 0; + + collect_info_from_args(argc, argv); + + process_symbols(sparse_initialize(argc, argv, &filelist)); + FOR_EACH_PTR(filelist, file) { + process_symbols(sparse(file)); + } END_FOR_EACH_PTR(file); + + report_stats(); + return 0; +} diff --git a/tools/sparse/sparse-src b/tools/sparse/sparse-src new file mode 160000 index 000000000..8af243292 --- /dev/null +++ b/tools/sparse/sparse-src @@ -0,0 +1 @@ +Subproject commit 8af2432923486c753ab52cae70b94ee684121080 From patchwork Wed Jul 28 12:34:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1510827 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=XOCI6viU; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GZY5d0hGyz9sPf for ; Wed, 28 Jul 2021 22:35:00 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 6AD943C90AA for ; Wed, 28 Jul 2021 14:34:58 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 28B503C641F for ; Wed, 28 Jul 2021 14:34:25 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 55E1F140115E for ; Wed, 28 Jul 2021 14:34:24 +0200 (CEST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id D65F8201A2; Wed, 28 Jul 2021 12:34:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1627475663; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UPyOTZLX2WwnL6nb1TjM1b/AVpJqNwXVIi8NEvGFRrA=; b=XOCI6viUzoXeF9MGatoNdKr3GyDKh2kLx1I2q+Ev5JEMNbJwNZJjVMHEI+OFOy8GwChR7p VKAgjAQMa/aqrSDdagxhJzWHdCRPRcrJv+9ElNUhAJupiZuqg2BnlOzUirlWIMGy1gVUOM klMbIOV35rqFxnWUGIZ2hKzBCD0ge/0= Received: from g78.suse.de (unknown [10.163.24.38]) by relay2.suse.de (Postfix) with ESMTP id A92EFA3B81; Wed, 28 Jul 2021 12:34:23 +0000 (UTC) To: ltp@lists.linux.it Date: Wed, 28 Jul 2021 13:34:06 +0100 Message-Id: <20210728123412.31858-3-rpalethorpe@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728123412.31858-1-rpalethorpe@suse.com> References: <20210728123412.31858-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH v3 2/8] Add 'make check' to the build system X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Allows one to run 'make check' or 'make check-$TARGET'. Which will execute the CHECK tool with that target's CC arguments and CHECK_FLAGS. By default the check tool is tools/sparse/main. Signed-off-by: Richard Palethorpe --- Makefile | 8 ++++++++ include/mk/env_post.mk | 8 ++++++++ include/mk/generic_leaf_target.inc | 5 ++++- include/mk/generic_trunk_target.inc | 7 ++++++- include/mk/lib.mk | 3 +++ include/mk/module.mk | 2 ++ include/mk/rules.mk | 9 +++++++++ include/mk/sparse.mk | 9 +++++++++ include/mk/testcases.mk | 1 + testcases/open_posix_testsuite/Makefile | 4 ++++ 10 files changed, 54 insertions(+), 2 deletions(-) create mode 100644 include/mk/sparse.mk diff --git a/Makefile b/Makefile index 56812d77b..3b0ba330d 100644 --- a/Makefile +++ b/Makefile @@ -79,6 +79,7 @@ BOOTSTRAP_TARGETS := $(sort $(COMMON_TARGETS) $(CLEAN_TARGETS) $(INSTALL_TARGETS CLEAN_TARGETS := $(addsuffix -clean,$(CLEAN_TARGETS)) INSTALL_TARGETS := $(addsuffix -install,$(INSTALL_TARGETS)) MAKE_TARGETS := $(addsuffix -all,$(filter-out lib,$(COMMON_TARGETS))) +CHECK_TARGETS := $(addsuffix -check,testcases lib) # There's no reason why we should run `all' twice. Otherwise we're just wasting # 3+ mins of useful CPU cycles on a modern machine, and even more time on an @@ -108,6 +109,10 @@ $(MAKE_TARGETS) include-all lib-all libs-all: $(MAKE) -C "$(subst -all,,$@)" \ -f "$(abs_top_srcdir)/$(subst -all,,$@)/Makefile" all +$(CHECK_TARGETS): tools-all + $(MAKE) -C "$(subst -check,,$@)" \ + -f "$(abs_top_srcdir)/$(subst -check,,$@)/Makefile" check + # Let's not conflict with ac-clean, maintainer-clean, etc, so. $(filter-out include-clean,$(CLEAN_TARGETS)):: -$(MAKE) -C "$(subst -clean,,$@)" \ @@ -189,6 +194,9 @@ INSTALL_TARGETS += $(addprefix $(DESTDIR)/$(bindir)/,$(BINDIR_INSTALL_SCRIPTS)) $(INSTALL_TARGETS): $(INSTALL_DIR) $(DESTDIR)/$(bindir) +.PHONY: check +check: $(CHECK_TARGETS) + ## Install install: $(INSTALL_TARGETS) diff --git a/include/mk/env_post.mk b/include/mk/env_post.mk index 1d22f9c53..4722da907 100644 --- a/include/mk/env_post.mk +++ b/include/mk/env_post.mk @@ -89,6 +89,14 @@ $(error You must define $$(prefix) before executing install) endif # END $(filter-out install,$(MAKECMDGOALS)),$(MAKECMDGOALS) endif +CHECK_TARGETS ?= $(addprefix check-,$(notdir $(patsubst %.c,%,$(sort $(wildcard $(abs_srcdir)/*.c))))) +CHECK_TARGETS := $(filter-out $(addprefix check-, $(FILTER_OUT_MAKE_TARGETS)), $(CHECK_TARGETS)) +CHECK ?= $(abs_top_srcdir)/tools/sparse/sparse-ltp + +ifeq ($(CHECK),$(abs_top_srcdir)/tools/sparse/sparse-ltp) +CHECK_DEPS += $(CHECK) +endif + include $(top_srcdir)/include/mk/rules.mk endif diff --git a/include/mk/generic_leaf_target.inc b/include/mk/generic_leaf_target.inc index 64953f89a..aa092a5a3 100644 --- a/include/mk/generic_leaf_target.inc +++ b/include/mk/generic_leaf_target.inc @@ -92,7 +92,7 @@ # INSTALL_DIR := $(libdir) # -.PHONY: all clean install +.PHONY: all clean install check ifneq ($(strip $(MAKE_TARGETS)),) $(MAKE_TARGETS) += $(HOST_MAKE_TARGETS) @@ -109,4 +109,7 @@ $(INSTALL_FILES): | $(INSTALL_DEPS) install: $(INSTALL_FILES) +$(CHECK_TARGETS): | $(CHECK_DEPS) +check: $(CHECK_TARGETS) + # vim: syntax=make diff --git a/include/mk/generic_trunk_target.inc b/include/mk/generic_trunk_target.inc index fc59f944f..32a108fbf 100644 --- a/include/mk/generic_trunk_target.inc +++ b/include/mk/generic_trunk_target.inc @@ -48,7 +48,7 @@ include $(top_srcdir)/include/mk/functions.mk -RECURSIVE_TARGETS ?= all install +RECURSIVE_TARGETS ?= all install check $(eval $(get_make_dirs)) @@ -68,6 +68,9 @@ $(INSTALL_FILES): | $(INSTALL_DEPS) trunk-install: $(INSTALL_FILES) +$(CHECK_TARGETS): | $(CHECK_DEPS) +trunk-check: $(CHECK_TARGETS) + # Avoid creating duplicate .PHONY references to all, clean, and install. IIRC, # I've seen some indeterministic behavior when one does this in the past with # GNU Make... @@ -108,4 +111,6 @@ else endif endif +check: trunk-check + # vim: syntax=make diff --git a/include/mk/lib.mk b/include/mk/lib.mk index f9b6c0aff..3bf63bf9e 100644 --- a/include/mk/lib.mk +++ b/include/mk/lib.mk @@ -26,6 +26,7 @@ # Makefile to include for libraries. include $(top_srcdir)/include/mk/env_pre.mk +include $(top_srcdir)/include/mk/sparse.mk INSTALL_DIR := $(libdir) @@ -57,6 +58,8 @@ LIBSRCS := $(filter-out $(FILTER_OUT_LIBSRCS),$(LIBSRCS)) LIBOBJS := $(LIBSRCS:.c=.o) +CHECK_TARGETS := $(addprefix check-,$(notdir $(LIBSRCS:.c=))) + $(LIB): $(notdir $(LIBOBJS)) @if [ -z "$(strip $^)" ] ; then \ echo "Cowardly refusing to create empty archive"; \ diff --git a/include/mk/module.mk b/include/mk/module.mk index 6c8814b96..3bb7350f1 100644 --- a/include/mk/module.mk +++ b/include/mk/module.mk @@ -47,6 +47,8 @@ endif CLEAN_TARGETS += .dep_modules *.mod built-in.a +CHECK_TARGETS := $(filter-out %.ko, $(CHECK_TARGETS)) + MODULE_SOURCES := $(patsubst %.ko,%.c,$(filter %.ko, $(MAKE_TARGETS))) # Ignoring the exit status of commands is done to be forward compatible with diff --git a/include/mk/rules.mk b/include/mk/rules.mk index c8f4bbbbe..2a04b2b67 100644 --- a/include/mk/rules.mk +++ b/include/mk/rules.mk @@ -37,3 +37,12 @@ else @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ $(LTPLDLIBS) $(LDLIBS) -o $@ @echo CC $(target_rel_dir)$@ endif + +.PHONY: $(CHECK_TARGETS) +$(CHECK_TARGETS): check-%: %.c +ifdef VERBOSE + $(CHECK) $(CHECK_FLAGS) $(CPPFLAGS) $(CFLAGS) $< +else + @$(CHECK) $(CHECK_FLAGS) $(CPPFLAGS) $(CFLAGS) $< + @echo CHECK $(target_rel_dir)$< +endif diff --git a/include/mk/sparse.mk b/include/mk/sparse.mk new file mode 100644 index 000000000..a86928393 --- /dev/null +++ b/include/mk/sparse.mk @@ -0,0 +1,9 @@ +# Rules to make sparse tool(s) for inclusion in lib and testcases Makefiles + +SPARSE_DIR:= $(abs_top_builddir)/tools/sparse + +$(SPARSE_DIR)/sparse-ltp: $(SPARSE_DIR) + $(MAKE) -C "$^" all + +$(SPARSE_DIR): %: + mkdir -p "$@" diff --git a/include/mk/testcases.mk b/include/mk/testcases.mk index 1c81773d0..444020f16 100644 --- a/include/mk/testcases.mk +++ b/include/mk/testcases.mk @@ -22,6 +22,7 @@ include $(top_srcdir)/include/mk/env_pre.mk include $(top_srcdir)/include/mk/functions.mk +include $(top_srcdir)/include/mk/sparse.mk APICMDS_DIR := $(abs_top_builddir)/tools/apicmds diff --git a/testcases/open_posix_testsuite/Makefile b/testcases/open_posix_testsuite/Makefile index 205ecdc00..fea6db14b 100644 --- a/testcases/open_posix_testsuite/Makefile +++ b/testcases/open_posix_testsuite/Makefile @@ -104,3 +104,7 @@ $(CRITICAL_MAKEFILE): \ $(top_srcdir)/LDFLAGS \ $(top_srcdir)/LDLIBS @$(MAKE) generate-makefiles + +.PHONY: check +check: + @echo "Checker not yet supported by Open POSIX testsuite" From patchwork Wed Jul 28 12:34:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1510824 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=uNUoQBOs; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GZY533gNSz9sX1 for ; Wed, 28 Jul 2021 22:34:30 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id CF0CD3C903B for ; Wed, 28 Jul 2021 14:34:26 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id DF9013C641F for ; Wed, 28 Jul 2021 14:34:24 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id 63A3C1401179 for ; Wed, 28 Jul 2021 14:34:24 +0200 (CEST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 20147201A3; Wed, 28 Jul 2021 12:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1627475664; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CkwJM0hgPyrg4bzL3IfRtWfNsIXTKjmrCaiGJWSowr8=; b=uNUoQBOs+qZpVfklhse9viMrV261p+rvDYdu+Xs5nR3rUDUZRMAJO8tov1IDsG4Bbe3hC+ t46H6T31R2LmwqtceM8axZSFf9pvC4NjaWHwPyu3taNaf1IJjQe9pKlO78CE1WOFbDfueI CNd+q2/BknODZ2ZhaMXkI8OAO/yCJ44= Received: from g78.suse.de (unknown [10.163.24.38]) by relay2.suse.de (Postfix) with ESMTP id E5468A3B81; Wed, 28 Jul 2021 12:34:23 +0000 (UTC) To: ltp@lists.linux.it Date: Wed, 28 Jul 2021 13:34:07 +0100 Message-Id: <20210728123412.31858-4-rpalethorpe@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728123412.31858-1-rpalethorpe@suse.com> References: <20210728123412.31858-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH v3 3/8] doc: Add rules and recommendations list X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Create a list of rules which are feasible to check automatically. The file is a table of tab separated values. It's intended to be machine readable. For now there is just an ID column, with IDs that look similar to CWE IDs or CVEs. For now these can just be used with 'git grep'. Also there is a description column. Clearly this is not an exhaustive list. It just contains a library rule already stated in the guide and the issue Sparse checks for. Signed-off-by: Richard Palethorpe --- doc/rules.tsv | 3 +++ doc/test-writing-guidelines.txt | 7 +++++++ 2 files changed, 10 insertions(+) create mode 100644 doc/rules.tsv diff --git a/doc/rules.tsv b/doc/rules.tsv new file mode 100644 index 000000000..d4081ce0f --- /dev/null +++ b/doc/rules.tsv @@ -0,0 +1,3 @@ +ID DESCRIPTION +LTP-001 Library source files have tst_ prefix +LTP-002 TST_RET and TST_ERR are never modified by test library functions diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt index d57e52655..1197c9a0d 100644 --- a/doc/test-writing-guidelines.txt +++ b/doc/test-writing-guidelines.txt @@ -10,6 +10,13 @@ NOTE: See also https://github.com/linux-test-project/ltp/wiki/Shell-Test-API[Shell Test API], https://github.com/linux-test-project/ltp/wiki/LTP-Library-API-Writing-Guidelines[LTP Library API Writing Guidelines]. +Rules and recommendations which are "machine checkable" should be +tagged with an ID like +LTP-XXX+. There will be a corresponding entry +in +https://github.com/linux-test-project/ltp/tree/master/doc/rules.tsv[doc/rules.tsv]. When +you run 'make check' or 'make check-test' it will display these IDs as +a reference. + 1. Guide to clean and understandable code ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From patchwork Wed Jul 28 12:34:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1510826 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=LIdKk1c7; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GZY5P5sXcz9sXG for ; Wed, 28 Jul 2021 22:34:49 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 94EE03C9074 for ; Wed, 28 Jul 2021 14:34:47 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [217.194.8.6]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 18AE63C643B for ; Wed, 28 Jul 2021 14:34:25 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-6.smtp.seeweb.it (Postfix) with ESMTPS id A010C140117E for ; Wed, 28 Jul 2021 14:34:24 +0200 (CEST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 5C51E22322; Wed, 28 Jul 2021 12:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1627475664; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TOgVM6Ly52mz2eyQDI3CYyhfdr0oS4busyQjiBVdyWg=; b=LIdKk1c7wkixI0+VxdvEvB32Xpp7qFcY3obozec60p7sVtyCq1hq1/UH4mA2l9mtil9hkS QntQ/oXlGRs90t9A+ztwTUNyaluRhtEaCiBRURajnyx9q67sfX1s3T/wmeE1KjKelw7yEo ZMccbU/KbfVHVR8B5rUC24M8zMX7eqs= Received: from g78.suse.de (unknown [10.163.24.38]) by relay2.suse.de (Postfix) with ESMTP id 2EF57A3B81; Wed, 28 Jul 2021 12:34:24 +0000 (UTC) To: ltp@lists.linux.it Date: Wed, 28 Jul 2021 13:34:08 +0100 Message-Id: <20210728123412.31858-5-rpalethorpe@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728123412.31858-1-rpalethorpe@suse.com> References: <20210728123412.31858-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-6.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-6.smtp.seeweb.it Subject: [LTP] [PATCH v3 4/8] doc: Remind authors and maintainers to run make check X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Richard Palethorpe --- doc/maintainer-patch-review-checklist.txt | 4 ++-- doc/test-writing-guidelines.txt | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/maintainer-patch-review-checklist.txt b/doc/maintainer-patch-review-checklist.txt index f6682b574..58662bed1 100644 --- a/doc/maintainer-patch-review-checklist.txt +++ b/doc/maintainer-patch-review-checklist.txt @@ -39,8 +39,8 @@ New test should * Use new https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#22-writing-a-test-in-c[C API] * Test binaries are added into corresponding '.gitignore' files * Check coding style with - https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/scripts/checkpatch.pl[checkpatch.pl] - (more in https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#131-c-coding-style[C coding style]) + https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/plain/scripts/checkpatch.pl[checkpatch.pl] and `make check` + (more in https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#21-c-coding-style[C coding style]) * Docparse documentation * If a test is a regression test it should include tags (more in https://github.com/linux-test-project/ltp/wiki/Test-Writing-Guidelines#2238-test-tags[Test tags]) diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt index 1197c9a0d..340c80cc6 100644 --- a/doc/test-writing-guidelines.txt +++ b/doc/test-writing-guidelines.txt @@ -310,6 +310,7 @@ NOTE: See also 3. The runtest entires are in place 4. Test binaries are added into corresponding '.gitignore' files 5. Patches apply over the latest git +6. 'make check' does not emit any warnings 6.1 About .gitignore files ~~~~~~~~~~~~~~~~~~~~~~~~~~ From patchwork Wed Jul 28 12:34:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1510828 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=eEQjUUIs; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GZY5q007hz9sRR for ; Wed, 28 Jul 2021 22:35:10 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id A7A413C90A1 for ; Wed, 28 Jul 2021 14:35:08 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 56B1C3C641F for ; Wed, 28 Jul 2021 14:34:25 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id DEFB4600F48 for ; Wed, 28 Jul 2021 14:34:24 +0200 (CEST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 9A889201A8; Wed, 28 Jul 2021 12:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1627475664; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tjl7pIiwME7/VQqhlW4Pne5fS/n2YjI0reOdfAu0GJc=; b=eEQjUUIsZk+LKDSgxNukSGELr4eIIQWiLYDfjIWQMC//qDq/yzVAgs50JN5HP8WMfUqllf REUUFr4w7mu1iIUCSw+VlcpMW6SmZtq9EB0ctaplvgK53GXRfDlu55vHAbPFkeHlyU/lFW kzCK5f/FdoGlzd2BtvlB1ttKYiwrt1U= Received: from g78.suse.de (unknown [10.163.24.38]) by relay2.suse.de (Postfix) with ESMTP id 6BE46A3B81; Wed, 28 Jul 2021 12:34:24 +0000 (UTC) To: ltp@lists.linux.it Date: Wed, 28 Jul 2021 13:34:09 +0100 Message-Id: <20210728123412.31858-6-rpalethorpe@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728123412.31858-1-rpalethorpe@suse.com> References: <20210728123412.31858-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH v3 5/8] doc: Document TEST macro and state TST_RET/ERR rule LTP-002 X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" There are cases where these variables can be safely used by the library. However it is a difficult problem to identify these cases automatically. Identifying any library code which uses them is relatively easy. In fact it is easier to automate it than by code review. Because it is such a boring thing to repeatedly look for and comment on. If a test library function needs these variables it can recreate its own private copies. Signed-off-by: Richard Palethorpe --- doc/c-test-api.txt | 54 +++++++++++++++++++++++++- doc/library-api-writing-guidelines.txt | 14 +++++++ 2 files changed, 66 insertions(+), 2 deletions(-) diff --git a/doc/c-test-api.txt b/doc/c-test-api.txt index dd6c608a4..25b9beb7c 100644 --- a/doc/c-test-api.txt +++ b/doc/c-test-api.txt @@ -291,8 +291,58 @@ static void test(void) } ------------------------------------------------------------------------------- -The 'TST_EXP_FAIL2()' is the same as 'TST_EXP_FAIL()' except the return value -is expected to be non-negative integer if call passes. +The 'TST_EXP_FAIL2()' is the same as 'TST_EXP_FAIL()' except the +return value is expected to be non-negative integer if call +passes. These macros build upon the +TEST()+ macro and associated +variables. + +[source,c] +------------------------------------------------------------------------------- +TEST(socket(AF_INET, SOCK_RAW, 1)); +if (TST_RET > -1) { + tst_res(TFAIL, "Created raw socket"); + SAFE_CLOSE(TST_RET); +} else if (TST_ERR != EPERM) { + tst_res(TFAIL | TTERRNO, + "Failed to create socket for wrong reason"); +} else { + tst_res(TPASS | TTERRNO, "Didn't create raw socket"); +} +------------------------------------------------------------------------------- + +The +TEST+ macro sets +TST_RET+ to its argument's return value and ++TST_ERR+ to +errno+. The +TTERNO+ flag can be used to print the error +number's symbolic value. + +No LTP library function or macro, except those in 'tst_test_macros.h', +will write to these variables (rule 'LTP-002'). So their values will +not be changed unexpectedly. + +[source,c] +------------------------------------------------------------------------------- +TST_EXP_POSITIVE(wait(&status)); + +if (!TST_PASS) + return; +------------------------------------------------------------------------------- + +If the return value of 'wait' is positive. This macro will print a +pass result and set +TST_PASS+ appropriately. If the return value is +zero or negative, then it will print fail. + +As seen above, this and similar macros take optional variadic +arguments. These begin with a format string and then appropriate +values to be formatted. So + +[source,c] +------------------------------------------------------------------------------- +TST_EXP_PASS(chown("a/file", uid, gid), "chown(%s,%d,%d)", + "a/file", uid, gid); +------------------------------------------------------------------------------- + +expects +chown+ to return 0 and emits a pass or a fail. The arguments +to +chown+ will be printed in either case. There are many similar +macros to those shown here, please see 'tst_test_macros.h'. [source,c] ------------------------------------------------------------------------------- diff --git a/doc/library-api-writing-guidelines.txt b/doc/library-api-writing-guidelines.txt index a4393fc54..2819d4177 100644 --- a/doc/library-api-writing-guidelines.txt +++ b/doc/library-api-writing-guidelines.txt @@ -21,10 +21,24 @@ Don't forget to update docs when you change the API. 2. C API -------- +2.1 LTP-001: Sources have tst_ prefix +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + API source code is in headers `include/*.h`, `include/lapi/*.h` (backward compatibility for old kernel and libc) and C sources in `lib/*.c`. Files have 'tst_' prefix. +2.2 LTP-002: TST_RET and TST_ERR are not modified +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The test author is guaranteed that the test API will not modify these +variables. This prevents silent errors where the return value and +errno are overwritten before the test has chance to check them. + +The macros which are clearly intended to update these variables. That +is +TEST+ and those in 'tst_test_macros.h'. Are of course allowed to +update these variables. + 3. Shell API ------------ From patchwork Wed Jul 28 12:34:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1510830 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=RJYOF+Uh; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GZY6D523cz9sRR for ; Wed, 28 Jul 2021 22:35:32 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id AF6DF3C9047 for ; Wed, 28 Jul 2021 14:35:29 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [217.194.8.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 91C043C641F for ; Wed, 28 Jul 2021 14:34:25 +0200 (CEST) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 2902D2000D0 for ; Wed, 28 Jul 2021 14:34:25 +0200 (CEST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id DBD7E22326; Wed, 28 Jul 2021 12:34:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1627475664; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gzzHSP2t5UqIOib+PLSsxKIdhrp/BhmJGn8aXnNjFjI=; b=RJYOF+UhQQOStEpafUKubuV28W+JhPnoQRTSx1AyKwIep/3bfZGy10XS+UTG6VDUdgY0N1 d3moGoqw3YVoGTPCtipbBA7fsn5G7EGERTQPRO8RlRht2Y+nxFge2ghdMLP/QINPTQ+OA1 G5XBuyTIWydcyM7Y3mrdTQk6emmmY4I= Received: from g78.suse.de (unknown [10.163.24.38]) by relay2.suse.de (Postfix) with ESMTP id ABB9FA3B81; Wed, 28 Jul 2021 12:34:24 +0000 (UTC) To: ltp@lists.linux.it Date: Wed, 28 Jul 2021 13:34:10 +0100 Message-Id: <20210728123412.31858-7-rpalethorpe@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728123412.31858-1-rpalethorpe@suse.com> References: <20210728123412.31858-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-7.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-7.smtp.seeweb.it Subject: [LTP] [PATCH v3 6/8] Reference LTP-002 rule in Cocci scripts X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Avoid duplication of rule description Signed-off-by: Richard Palethorpe --- scripts/coccinelle/libltp-test-macro-vars.cocci | 6 +----- scripts/coccinelle/libltp-test-macro.cocci | 4 +--- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/scripts/coccinelle/libltp-test-macro-vars.cocci b/scripts/coccinelle/libltp-test-macro-vars.cocci index ed5459a48..e0fe4e2a7 100644 --- a/scripts/coccinelle/libltp-test-macro-vars.cocci +++ b/scripts/coccinelle/libltp-test-macro-vars.cocci @@ -1,11 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (c) 2021 SUSE LLC -// The TEST macro should not be used in the library because it sets -// TST_RET and TST_ERR which are global variables. The test author -// only expects these to be changed if *they* call TEST directly. - -// Find all positions where TEST's variables are used +// Find violations of LTP-002 @ find_use exists @ expression E; @@ diff --git a/scripts/coccinelle/libltp-test-macro.cocci b/scripts/coccinelle/libltp-test-macro.cocci index 7563d23aa..86c55c6c4 100644 --- a/scripts/coccinelle/libltp-test-macro.cocci +++ b/scripts/coccinelle/libltp-test-macro.cocci @@ -1,9 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright (c) 2021 SUSE LLC -// The TEST macro should not be used in the library because it sets -// TST_RET and TST_ERR which are global variables. The test author -// only expects these to be changed if *they* call TEST directly. +// Find and fix violations of rule LTP-002 // Set with -D fix virtual fix From patchwork Wed Jul 28 12:34:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1510831 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=ZXBJvjKj; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GZY6P30qhz9sRR for ; Wed, 28 Jul 2021 22:35:41 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id CB6853CA5A5 for ; Wed, 28 Jul 2021 14:35:38 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [IPv6:2001:4b78:1:20::5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id CD58D3C641F for ; Wed, 28 Jul 2021 14:34:25 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 69BB7600F48 for ; Wed, 28 Jul 2021 14:34:25 +0200 (CEST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 25B0C1FF9F; Wed, 28 Jul 2021 12:34:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1627475665; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=f2UvmmvNF4XVDI5AYNrFJNSxzQrFumuKXkPMfGRj5x8=; b=ZXBJvjKj1CDD2YsYCMTdU1BNAZawRK0VXBlL6vPgnk6b3paU9OlJhZEHWWhz+mtnGFvkho k3XokYiAtMoOpgepCy6plvMRTFTSPKM81KdtRV3GmMPG6JEa+v732fm3hEEMprvCZN2YmQ tyWCwT1qr/LwHbGgHTa/vPnW1NcbVp8= Received: from g78.suse.de (unknown [10.163.24.38]) by relay2.suse.de (Postfix) with ESMTP id EC48AA3B81; Wed, 28 Jul 2021 12:34:24 +0000 (UTC) To: ltp@lists.linux.it Date: Wed, 28 Jul 2021 13:34:11 +0100 Message-Id: <20210728123412.31858-8-rpalethorpe@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728123412.31858-1-rpalethorpe@suse.com> References: <20210728123412.31858-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH v3 7/8] API: Move libtsc.h from realtime tests include to tst_tsc.h X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Allow the meltdown test to use this file without modifying the CFLAGS. This avoids having to add the include also to the CHECK_FLAGS. Signed-off-by: Richard Palethorpe --- testcases/realtime/include/libtsc.h => include/tst_tsc.h | 0 testcases/cve/Makefile | 2 -- testcases/cve/meltdown.c | 2 +- testcases/realtime/func/async_handler/async_handler_tsc.c | 3 ++- testcases/realtime/func/measurement/preempt_timing.c | 3 ++- testcases/realtime/func/measurement/rdtsc-latency.c | 3 ++- 6 files changed, 7 insertions(+), 6 deletions(-) rename testcases/realtime/include/libtsc.h => include/tst_tsc.h (100%) diff --git a/testcases/realtime/include/libtsc.h b/include/tst_tsc.h similarity index 100% rename from testcases/realtime/include/libtsc.h rename to include/tst_tsc.h diff --git a/testcases/cve/Makefile b/testcases/cve/Makefile index ddf8b6fe1..c5308794d 100644 --- a/testcases/cve/Makefile +++ b/testcases/cve/Makefile @@ -18,8 +18,6 @@ ifneq ($(ANDROID),1) cve-2014-0196: LDLIBS += -lutil endif -meltdown: CFLAGS += -I$(abs_srcdir)/../realtime/include - ifneq (,$(filter $(HOST_CPU),x86 x86_64)) meltdown: CFLAGS += -msse2 endif diff --git a/testcases/cve/meltdown.c b/testcases/cve/meltdown.c index a387b3205..5a984aba3 100644 --- a/testcases/cve/meltdown.c +++ b/testcases/cve/meltdown.c @@ -19,7 +19,7 @@ #include -#include "libtsc.h" +#include "tst_tsc.h" #define TARGET_OFFSET 9 #define TARGET_SIZE (1 << TARGET_OFFSET) diff --git a/testcases/realtime/func/async_handler/async_handler_tsc.c b/testcases/realtime/func/async_handler/async_handler_tsc.c index 7da4324a5..73d4ee5c6 100644 --- a/testcases/realtime/func/async_handler/async_handler_tsc.c +++ b/testcases/realtime/func/async_handler/async_handler_tsc.c @@ -46,7 +46,8 @@ #include #include #include -#include + +#include "tst_tsc.h" #define HANDLER_PRIO 98 #define SIGNAL_PRIO 99 diff --git a/testcases/realtime/func/measurement/preempt_timing.c b/testcases/realtime/func/measurement/preempt_timing.c index 8b5333480..b84d54692 100644 --- a/testcases/realtime/func/measurement/preempt_timing.c +++ b/testcases/realtime/func/measurement/preempt_timing.c @@ -52,7 +52,8 @@ #include #include #include -#include + +#include "tst_tsc.h" #define ITERATIONS 1000000ULL #define INTERVALS 10 diff --git a/testcases/realtime/func/measurement/rdtsc-latency.c b/testcases/realtime/func/measurement/rdtsc-latency.c index d6ab89ff0..3829947bc 100644 --- a/testcases/realtime/func/measurement/rdtsc-latency.c +++ b/testcases/realtime/func/measurement/rdtsc-latency.c @@ -44,7 +44,8 @@ #include #include #include -#include + +#include "tst_tsc.h" #define ITERATIONS 1000000 From patchwork Wed Jul 28 12:34:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Palethorpe X-Patchwork-Id: 1510832 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=suse.com header.i=@suse.com header.a=rsa-sha256 header.s=susede1 header.b=iC9E5HaN; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GZY6d0Yf9z9sRR for ; Wed, 28 Jul 2021 22:35:52 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 35F363CA70E for ; Wed, 28 Jul 2021 14:35:50 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [217.194.8.5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by picard.linux.it (Postfix) with ESMTPS id 0CFC33C641F for ; Wed, 28 Jul 2021 14:34:26 +0200 (CEST) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id B12B2600F4B for ; Wed, 28 Jul 2021 14:34:25 +0200 (CEST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 65B8D201A2; Wed, 28 Jul 2021 12:34:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1627475665; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wlo3EwMihenbLS05yRwYT95Zi3vpovMNIxMDELxOY78=; b=iC9E5HaNluHn9OAANrejHqj3e8nUqyR2pdR+ZLFsLtwOWXWdrFQwZ7aG/Iq43YPNBfMLi+ a0SRkKnOYlRnhNqHVRaTE2flx6J6bjQ2LcmdeZouxA5r01kaE5F0ED8PqDIhvaKH7BJV7q yEE6P1OTCr0hQQ8QXX8eTR2EBwz2Dd4= Received: from g78.suse.de (unknown [10.163.24.38]) by relay2.suse.de (Postfix) with ESMTP id 362E1A3B81; Wed, 28 Jul 2021 12:34:25 +0000 (UTC) To: ltp@lists.linux.it Date: Wed, 28 Jul 2021 13:34:12 +0100 Message-Id: <20210728123412.31858-9-rpalethorpe@suse.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210728123412.31858-1-rpalethorpe@suse.com> References: <20210728123412.31858-1-rpalethorpe@suse.com> MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.102.4 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH v3 8/8] API/tst_tsc: Add guards and remove some boilerplate X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Palethorpe via ltp From: Richard Palethorpe Reply-To: Richard Palethorpe Cc: Richard Palethorpe Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Richard Palethorpe --- include/tst_tsc.h | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) diff --git a/include/tst_tsc.h b/include/tst_tsc.h index 9ad5fd659..3f49a6ca7 100644 --- a/include/tst_tsc.h +++ b/include/tst_tsc.h @@ -1,28 +1,6 @@ -/****************************************************************************** - * - * Copyright © International Business Machines Corp., 2006-2008 - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See - * the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * NAME - * libtsc.h - * - * DESCRIPTION - * - * USAGE: - * To be included in some testcases. +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright © International Business Machines Corp., 2006-2008 * * AUTHOR * Darren Hart @@ -30,8 +8,10 @@ * * HISTORY * It directly comes from the librttest.h (see its HISTORY). - * - *****************************************************************************/ + */ + +#ifndef TST_TSC_H +#define TST_TSC_H #undef TSC_UNSUPPORTED @@ -70,3 +50,4 @@ #define TSC_UNSUPPORTED #endif +#endif