Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp4448386imb; Wed, 6 Mar 2019 13:44:38 -0800 (PST) X-Google-Smtp-Source: APXvYqz1MxhDFBEhwyte+fgYwD8JKQFCJtiip9B5zP2PUclH74V56Jntc0cR4XuJg6wUHQSnndlT X-Received: by 2002:aa7:8249:: with SMTP id e9mr9253686pfn.6.1551908678511; Wed, 06 Mar 2019 13:44:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551908678; cv=none; d=google.com; s=arc-20160816; b=uJN84YOdh+GxINKWn4X44nYcCaAb+oYkH+qVkPhTUOKr/zlJPiajdx9kRT1aUeBeyW TGi91bQlTLmH/skZe7pVAvvUxw9eyujCaodGHVDWhO7965MXDTBbFLh2fAh+3QO6wM+J 9nlrnRDD75I2OFq9JEQ/FK6iFeKLfN9aPhVddjX8cR/AbNXfTXKmJe+NkvkC6fAj1scZ G4c16ZyHrcX51Ax1ONOHSch+GlZnaZ6lBqTY2YpXV+UJbaich8AQ7QcUG1uytOs1A21r LyOc7NeN8XOQ6JyNWCK/EI5hiwpVUSN78UnhWdNK/uqHYmUYvJqKt5WfBOmMkChJMJ7p Gxhw== 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=pY5C2BvwLhKNzDpMpFyQW07oy97QWwWMcD8aq9oxvU4=; b=UMCAijHO5kUlVp1b9hrUTosW4VlBKjxSzxExgdB2DzW6LHa8g3jsNQp0PO07TqQ7YX 7aeN1RdEtHslvdFgVDqqUfDE2YBr/NfDRKswmeqRWGPDwsBhvQ650B0S0myVVOJzYgnR JY5PLosreEz6BuIEcPASL8tzY292YB+VeOdoFU+wrhEF8WFF/qkiJd/eipvsyQdgdHm+ PEmkP8Yuu1wZ+blowDDggLYWjZ+nEfPMvnLFXShqkX9SVrdj0L7aaw5UKouSLANHFvV3 8Lgvw9dw2w41wusuBEReWj65HMjmN+C5lmuqxGwUOwSbE6VqkXqLsE3nPGC17QCadIc3 gdAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=WIhH4N8b; 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 z23si2291971pgj.168.2019.03.06.13.44.23; Wed, 06 Mar 2019 13:44:38 -0800 (PST) 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=WIhH4N8b; 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 S1726409AbfCFVno (ORCPT + 99 others); Wed, 6 Mar 2019 16:43:44 -0500 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:50995 "EHLO out2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726082AbfCFVnn (ORCPT ); Wed, 6 Mar 2019 16:43:43 -0500 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id C7FD722112; Wed, 6 Mar 2019 16:43:42 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute3.internal (MEProxy); Wed, 06 Mar 2019 16:43:42 -0500 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=pY5C2BvwLhKNzDpMpFyQW07oy97QWwWMcD8aq9oxvU4=; b=WIhH4N8b QpXg7HmB8c7mRgr3K5V6edQUNp12uSGz4ZyEGRDtahciRyEvMlSXwI6lukXOiPv4 LFqbieAN1aNFXqbTBGnRGzFRcaZkqcCSeXomTA2zRzd8clZW7SKRriu+d3uuwW1V hL2HyxMFalSzDtITJQIKYn+VShxwXzqOrSyTvf9P2shu8LVeYp1/a0x6yUM9y4xL sl/xHhffT9xRfcocE7dC6t2Izbp4+mmDWwJE0Ey2MYzaddQfND/Lfi7A2MStHA+8 L8zFBKkk34syGlgDPNaTLREUshc10TrcNQabajsgLXTGrLkgczmJqF0DXQuzJTsh jpGLYeT4X7n/lw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrfeeigdekjecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepfdfvohgsihhn ucevrdcujfgrrhguihhnghdfuceothhosghinheskhgvrhhnvghlrdhorhhgqeenucfkph epuddvgedrudeiledrhedrudehkeenucfrrghrrghmpehmrghilhhfrhhomhepthhosghi nheskhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgepge X-ME-Proxy: Received: from eros.localdomain (124-169-5-158.dyn.iinet.net.au [124.169.5.158]) by mail.messagingengine.com (Postfix) with ESMTPA id 28091E4240; Wed, 6 Mar 2019 16:43:36 -0500 (EST) From: "Tobin C. Harding" To: Kees Cook , Shuah Khan Cc: "Tobin C. Harding" , 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 v3 5/7] lib: Use new kselftest header Date: Thu, 7 Mar 2019 08:42:24 +1100 Message-Id: <20190306214226.14598-6-tobin@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190306214226.14598-1-tobin@kernel.org> References: <20190306214226.14598-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. 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.20.1