From patchwork Thu Dec 19 10:43:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pengfei Xu X-Patchwork-Id: 1213143 X-Patchwork-Delegate: petr.vorel@gmail.com 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; dmarc=fail (p=none dis=none) header.from=intel.com 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 47dpGT6LZdz9s4Y for ; Thu, 19 Dec 2019 21:37:04 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 3B89E3C180A for ; Thu, 19 Dec 2019 11:37:01 +0100 (CET) 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]) by picard.linux.it (Postfix) with ESMTP id BC1533C0302 for ; Thu, 19 Dec 2019 11:36:57 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id BE408609695 for ; Thu, 19 Dec 2019 11:36:53 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Dec 2019 02:36:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,331,1571727600"; d="scan'208";a="206161047" Received: from xpf-desktop.sh.intel.com ([10.239.13.102]) by orsmga007.jf.intel.com with ESMTP; 19 Dec 2019 02:36:50 -0800 From: Pengfei Xu To: ltp , Pengfei Xu , Neri Ricardo , Su Heng , Cyril Hrubis Date: Thu, 19 Dec 2019 18:43:20 +0800 Message-Id: <20191219104321.23267-1-pengfei.xu@intel.com> X-Mailer: git-send-email 2.14.1 X-Virus-Scanned: clamav-milter 0.99.2 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH v2 1/2] lib/tst_kconfig.c: Add any kconfig to match the expected value function 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: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Example: CONFIG_X86_INTEL_UMIP=y for umip kconfig before and v5.4 mainline kernel. CONFIG_X86_UMIP=y for umip kconfig after v5.5 mainline kernel. Format: CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y Signed-off-by: Pengfei Xu --- lib/tst_kconfig.c | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/lib/tst_kconfig.c b/lib/tst_kconfig.c index 4b51413e5..74c46ebec 100644 --- a/lib/tst_kconfig.c +++ b/lib/tst_kconfig.c @@ -167,7 +167,8 @@ void tst_kconfig_read(const char *const *kconfigs, struct match matches[cnt]; FILE *fp; unsigned int i, j; - char buf[1024]; + char buf[1024], kconfig_multi[100]; + char *kconfig_token = NULL, *p_left = NULL; for (i = 0; i < cnt; i++) { const char *val = strchr(kconfigs[i], '='); @@ -176,12 +177,9 @@ void tst_kconfig_read(const char *const *kconfigs, tst_brk(TBROK, "Invalid config string '%s'", kconfigs[i]); matches[i].match = 0; - matches[i].len = strlen(kconfigs[i]); - if (val) { + if (val) matches[i].val = val + 1; - matches[i].len -= strlen(val); - } results[i].match = 0; results[i].value = NULL; @@ -193,17 +191,29 @@ void tst_kconfig_read(const char *const *kconfigs, while (fgets(buf, sizeof(buf), fp)) { for (i = 0; i < cnt; i++) { - if (match(&matches[i], kconfigs[i], &results[i], buf)) { - for (j = 0; j < cnt; j++) { - if (matches[j].match) - break; + memset(kconfig_multi, 0, sizeof(kconfig_multi)); + /* strtok_r will split kconfigs[i] to multi string, so copy it */ + memcpy(kconfig_multi, kconfigs[i], strlen(kconfigs[i])); + kconfig_token = strtok_r(kconfig_multi, "|=", &p_left); + + while (kconfig_token != NULL) { + if (strncmp("CONFIG_", kconfig_token, 7)) + tst_brk(TBROK, "Invalid config string '%s'", kconfig_token); + matches[i].len = strlen(kconfig_token); + if (match(&matches[i], kconfig_token, &results[i], buf)) { + for (j = 0; j < cnt; j++) { + if (matches[j].match) + break; + } } - - if (j == cnt) - goto exit; + kconfig_token = strtok_r(NULL, "|=", &p_left); + /* avoid to use after "=" string */ + if (strlen(p_left) == 0) + break; } + if (j == cnt) + goto exit; } - } exit: From patchwork Thu Dec 19 10:43:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pengfei Xu X-Patchwork-Id: 1213144 X-Patchwork-Delegate: petr.vorel@gmail.com 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; dmarc=fail (p=none dis=none) header.from=intel.com 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 47dpGd35fmz9s4Y for ; Thu, 19 Dec 2019 21:37:13 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id CA6823C239A for ; Thu, 19 Dec 2019 11:37:10 +0100 (CET) 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]) by picard.linux.it (Postfix) with ESMTP id 634E33C0302 for ; Thu, 19 Dec 2019 11:36:58 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 68DC7609693 for ; Thu, 19 Dec 2019 11:36:57 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Dec 2019 02:36:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.69,331,1571727600"; d="scan'208,223";a="206161052" Received: from xpf-desktop.sh.intel.com ([10.239.13.102]) by orsmga007.jf.intel.com with ESMTP; 19 Dec 2019 02:36:51 -0800 From: Pengfei Xu To: ltp , Pengfei Xu , Neri Ricardo , Su Heng , Cyril Hrubis Date: Thu, 19 Dec 2019 18:43:21 +0800 Message-Id: <20191219104321.23267-2-pengfei.xu@intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20191219104321.23267-1-pengfei.xu@intel.com> References: <20191219104321.23267-1-pengfei.xu@intel.com> X-Virus-Scanned: clamav-milter 0.99.2 at in-5.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=SPF_HELO_NONE,SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-5.smtp.seeweb.it Subject: [LTP] [PATCH v2 2/2] umip_basic_test.c: improve kconfig check to avoid umip wrong abort case 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: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" From v5.5 main line, umip kconfig changed from "CONFIG_X86_INTEL_UMIP=y" to "CONFIG_X86_UMIP=y". We could use "CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y" to check kconfig CONFIG_X86_INTEL_UMIP=y(old kernel) or CONFIG_X86_UMIP=y(new kernel) for umip. Signed-off-by: Pengfei Xu --- testcases/kernel/security/umip/umip_basic_test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testcases/kernel/security/umip/umip_basic_test.c b/testcases/kernel/security/umip/umip_basic_test.c index 1baa26c52..24eca8890 100644 --- a/testcases/kernel/security/umip/umip_basic_test.c +++ b/testcases/kernel/security/umip/umip_basic_test.c @@ -171,7 +171,7 @@ static struct tst_test test = { .forks_child = 1, .test = verify_umip_instruction, .needs_kconfigs = (const char *[]){ - "CONFIG_X86_INTEL_UMIP=y", + "CONFIG_X86_INTEL_UMIP|CONFIG_X86_UMIP=y", NULL }, .needs_root = 1,