Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1785849yba; Thu, 4 Apr 2019 19:03:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQJMnuFXJXpadL3CMn0kmIEhNej3l0/QxF++FwHPcsYHwYc1J33r132WvXy476DLSnZQxx X-Received: by 2002:a62:ac02:: with SMTP id v2mr9649100pfe.163.1554429796604; Thu, 04 Apr 2019 19:03:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554429796; cv=none; d=google.com; s=arc-20160816; b=xR7dwOaXgertd92luISzHdtOI+z5Lrfz1Pk2A+aMpK5pKljd0mYy9HkeWgBzNkpe0h e/nJ7dTg9YwYV5poCRaU0kCFXqpHDS6/hMyL0MuXG6Bidt4qlI+sGSOMAv+v73N2gqsi LzvKfPfd8qYN9BwhOsOtsWAG85tXs7fWOBj8/yYU7LMUbsO9ZZioAOAKiS6zvzhDUTOh j80JP1Diur2hPU3yRVEQBWXwcsA7TPcDnoRAGYWqg0yQgDquHhsuQvRmVrhKSrXevQ+i tykgP9W+VLcpFkc5OtiPIybsyMGNok47IoEhE5r2L4A0XxuuTNBLfVyJEKkfY/wDLgqF 1Xow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=F5wlZTLbeYxNvK8jDdAkPtw7SafqfSrmofrPTK/quZQ=; b=cpCsgpTJnrkog+llFnep5tAssg+2TpshW9hRbMna5EHRc/oggD8o1u8HoUvHTZtvlH WYB+K+xotG1gqcfj5ddu3dNrWSjcALDedH5XJ/ZiRWRvSsUjYaoBhuaN3GWL5hem/sVK qfx5m0HSh0wGyMQE5Qwx8KebsQxWxs3I+6i9iNmiblETPApEzmYaYvZriDDTEi8kSneE 88Fo/8FLeLjla2lEYgzOQCStDZURlfX9qLTW+D9GdUIHLWGukhvbTu5KWn7QPgt5jKEJ GAiKoqzd1gGWHfsT/kCdZhJJCu8JXB4ZqUaXt3JV1uy1BxYvYjo01X1PpgAaOmCuFpEL WfBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=1liXXXo2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b9si10298471pfd.79.2019.04.04.19.03.01; Thu, 04 Apr 2019 19:03:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=1liXXXo2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730777AbfDECA1 (ORCPT + 99 others); Thu, 4 Apr 2019 22:00:27 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:34887 "EHLO out1-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727051AbfDECA0 (ORCPT ); Thu, 4 Apr 2019 22:00:26 -0400 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 8D28B24D66; Thu, 4 Apr 2019 22:00:25 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Thu, 04 Apr 2019 22:00:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=F5wlZTLbeYxNvK8jDdAkPtw7SafqfSrmofrPTK/quZQ=; b=1liXXXo2 sSNt/PiNhZt6ue+3PMt6qs7OONjY33X+ELGAB8JENgHEFagEf9kBsUoS5tLLZNFJ 4YNP9+MxkbK5WI/KcjkofMhUUETjNAQSWXIp0iiG23FSn6Y4Mau7fAjuFFGV8/9A Xzq4HVIzKxfpXpG1Z7oMQ17uGGbbNNLdLLTQqgyFLnds+qoRJUuW1uTYMYaZr02n kagv1fJCUpTpQbcefm2c639e5MPYJ78IL7sXEcrowTZIbmilLhjg8HVgayqv3EtY nv1/sJpZnWXTkol6epsbwAuCG2BR3EFzQmLOAiZ0gPhWMiXDF0c0i6orNEnvQxfQ l84uCCXSpKVagw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduuddrtdeigdehtdculddtuddrgedutddrtddtmd cutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhvffufffkofgjfhgggfestdekredtredttden ucfhrhhomhepfdfvohgsihhnucevrdcujfgrrhguihhnghdfuceothhosghinheskhgvrh hnvghlrdhorhhgqeenucfkphepuddvgedrudegledruddugedrkeeinecurfgrrhgrmhep mhgrihhlfhhrohhmpehtohgsihhnsehkvghrnhgvlhdrohhrghenucevlhhushhtvghruf hiiigvpeef X-ME-Proxy: Received: from eros.localdomain (124-149-114-86.dyn.iinet.net.au [124.149.114.86]) by mail.messagingengine.com (Postfix) with ESMTPA id 666DE10319; Thu, 4 Apr 2019 22:00:19 -0400 (EDT) From: "Tobin C. Harding" To: Shuah Khan Cc: "Tobin C. Harding" , Kees Cook , Jann Horn , Andy Shevchenko , Randy Dunlap , Rasmus Villemoes , Stephen Rothwell , Andy Lutomirski , Daniel Micay , Arnd Bergmann , Miguel Ojeda , "Gustavo A. R. Silva" , Greg Kroah-Hartman , Alexander Shishkin , kernel-hardening@lists.openwall.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 4/6] lib: Use new kselftest header Date: Fri, 5 Apr 2019 12:58:57 +1100 Message-Id: <20190405015859.32755-5-tobin@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190405015859.32755-1-tobin@kernel.org> References: <20190405015859.32755-1-tobin@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We just added a new C header file for use with test modules that are intended to be run with kselftest. We can reduce code duplication by using this header. Use new kselftest header to reduce code duplication in test_printf and test_bitmap test modules. Acked-by: Kees Cook Signed-off-by: Tobin C. Harding --- lib/test_bitmap.c | 20 ++++---------------- lib/test_printf.c | 23 +++++------------------ 2 files changed, 9 insertions(+), 34 deletions(-) diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c index 6cd7d0740005..792d90608052 100644 --- a/lib/test_bitmap.c +++ b/lib/test_bitmap.c @@ -12,6 +12,8 @@ #include #include +#include "../tools/testing/selftests/kselftest_module.h" + static unsigned total_tests __initdata; static unsigned failed_tests __initdata; @@ -361,7 +363,7 @@ static void noinline __init test_mem_optimisations(void) } } -static int __init test_bitmap_init(void) +static void __init selftest(void) { test_zero_clear(); test_fill_set(); @@ -369,22 +371,8 @@ static int __init test_bitmap_init(void) test_bitmap_arr32(); test_bitmap_parselist(); test_mem_optimisations(); - - if (failed_tests == 0) - pr_info("all %u tests passed\n", total_tests); - else - pr_warn("failed %u out of %u tests\n", - failed_tests, total_tests); - - return failed_tests ? -EINVAL : 0; } -static void __exit test_bitmap_cleanup(void) -{ -} - -module_init(test_bitmap_init); -module_exit(test_bitmap_cleanup); - +KSTM_MODULE_LOADERS(test_bitmap); MODULE_AUTHOR("david decotigny "); MODULE_LICENSE("GPL"); diff --git a/lib/test_printf.c b/lib/test_printf.c index 601e8519319a..f4fcc1c43739 100644 --- a/lib/test_printf.c +++ b/lib/test_printf.c @@ -21,6 +21,8 @@ #include #include +#include "../tools/testing/selftests/kselftest_module.h" + #define BUF_SIZE 256 #define PAD_SIZE 16 #define FILL_CHAR '$' @@ -590,12 +592,11 @@ test_pointer(void) flags(); } -static int __init -test_printf_init(void) +static void __init selftest(void) { alloced_buffer = kmalloc(BUF_SIZE + 2*PAD_SIZE, GFP_KERNEL); if (!alloced_buffer) - return -ENOMEM; + return; test_buffer = alloced_buffer + PAD_SIZE; test_basic(); @@ -604,22 +605,8 @@ test_printf_init(void) test_pointer(); kfree(alloced_buffer); - - if (failed_tests == 0) - pr_info("all %u tests passed\n", total_tests); - else - pr_warn("failed %u out of %u tests\n", failed_tests, total_tests); - - return failed_tests ? -EINVAL : 0; } -module_init(test_printf_init); - -static void __exit test_printf_exit(void) -{ -} - -module_exit(test_printf_exit); - +KSTM_MODULE_LOADERS(test_printf); MODULE_AUTHOR("Rasmus Villemoes "); MODULE_LICENSE("GPL"); -- 2.21.0