Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp209892ybh; Fri, 6 Mar 2020 19:48:35 -0800 (PST) X-Google-Smtp-Source: ADFU+vtjDCqBD96o6xp72ROTnPStHhei3VIc09RG8V4v+p15kHBBggmFAUXdeVIj3Sxr4ybZrpU/ X-Received: by 2002:a05:6830:150:: with SMTP id j16mr5077762otp.301.1583552915808; Fri, 06 Mar 2020 19:48:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583552915; cv=none; d=google.com; s=arc-20160816; b=ykWSxbdJLHzoNI8KeH/TslMzf7oo3e5yzz2cVenK+bOXwclU+Vy9c+D+JCmetnQkot 9CxT+dWxy90aYzK+enK79RxBnINOWf6g3wRRhAvuumwOY5F0mCoYe8Oyc+iUzjuyPu6d uu+cRCr2suyw4LHyyhA46a2/Toih5TrFF+fgQZSmE4wHEXVcV2iIds6WJg566kTgKQUS sEuoWZ+T6M1HtBus+9UZ+3Uwmp8AnN/Livbz+uVeM+hX4n3tt36otmdS1q5s2D5p2CfS 8GUOLTkeHPKCn9hH9tTAyudP+PmjtCGKfAjDcjS2BGLhA8xjs+gZG6qJD0uIrg0TltlH 5Kyw== 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; bh=eKCK0vUw9V55oRcTq/UBOV3NAIkzwHl5A5ux/9+dyVY=; b=Gx+DzsVI4B8y4iD7WIKViu2XhY/2vUEILBIYLIw19mHomrsGfwcrdfvNpGSg/K/Ws1 TuxFyXl/snq9JZ0CMQn2nblYY3jEryC7Fs2vqgcYbrV6E//5YW8kDtp3VsqLrBXni8la rxBdBETZe3BP6JBpXKvYgstOM+OO3x68b97hMcroXeZspBeqNrXtHVGDabiYha8i1xfh 9yf8NVM2u9MRKLy4n/10GcH4Ojap2QXrLXhCR7MHHAld3ZSn7scc018Y5Tukd9R9zKdI R8Px0t+nr55sCFZqX83r8NKCbiBvB+kknCsUZSKjhlZSiCxlLFyqUUcR4nRwd12aLDvr NQcw== ARC-Authentication-Results: i=1; mx.google.com; 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u6si2801792otg.73.2020.03.06.19.48.24; Fri, 06 Mar 2020 19:48:35 -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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726898AbgCGDqN (ORCPT + 99 others); Fri, 6 Mar 2020 22:46:13 -0500 Received: from mga11.intel.com ([192.55.52.93]:57577 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726300AbgCGDqM (ORCPT ); Fri, 6 Mar 2020 22:46:12 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2020 19:46:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,524,1574150400"; d="scan'208";a="235035991" Received: from sai-dev-mach.sc.intel.com ([143.183.140.153]) by fmsmga008.fm.intel.com with ESMTP; 06 Mar 2020 19:46:12 -0800 From: Sai Praneeth Prakhya To: shuah@kernel.org, linux-kselftest@vger.kernel.org Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, tony.luck@intel.com, reinette.chatre@intel.com, babu.moger@amd.com, james.morse@arm.com, ravi.v.shankar@intel.com, fenghua.yu@intel.com, x86@kernel.org, linux-kernel@vger.kernel.org, Sai Praneeth Prakhya Subject: [PATCH V1 01/13] selftests/resctrl: Fix feature detection Date: Fri, 6 Mar 2020 19:40:42 -0800 Message-Id: <7e3e4b91f5786a489e68eecda21e1d8049b60181.1583657204.git.sai.praneeth.prakhya@intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: References: 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 From: Reinette Chatre The intention of the resctrl selftests is to only run the tests associated with the feature(s) supported by the platform. Through parsing of the feature flags found in /proc/cpuinfo it is possible to learn which features are supported by the plaform. There are currently two issues with the platform feature detection that together result in tests always being run, whether the platform supports a feature or not. First, the parsing of the the feature flags loads the line containing the flags in a buffer that is too small (256 bytes) to always contain all flags. The consequence is that the flags of the features being tested for may not be present in the buffer. Second, the actual test for presence of a feature has an error in the logic, negating the test for a particular feature flag instead of testing for the presence of a particular feature flag. These two issues combined results in all tests being run on all platforms, whether the feature is supported or not. Fix these issue by (1) increasing the buffer size being used to parse the feature flags, and (2) change the logic to test for presence of the feature being tested for. Signed-off-by: Reinette Chatre Signed-off-by: Sai Praneeth Prakhya --- tools/testing/selftests/resctrl/resctrlfs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/resctrl/resctrlfs.c b/tools/testing/selftests/resctrl/resctrlfs.c index 19c0ec4045a4..226dd7fdcfb1 100644 --- a/tools/testing/selftests/resctrl/resctrlfs.c +++ b/tools/testing/selftests/resctrl/resctrlfs.c @@ -596,11 +596,11 @@ bool check_resctrlfs_support(void) char *fgrep(FILE *inf, const char *str) { - char line[256]; int slen = strlen(str); + char line[2048]; while (!feof(inf)) { - if (!fgets(line, 256, inf)) + if (!fgets(line, 2048, inf)) break; if (strncmp(line, str, slen)) continue; @@ -631,7 +631,7 @@ bool validate_resctrl_feature_request(char *resctrl_val) if (res) { char *s = strchr(res, ':'); - found = s && !strstr(s, resctrl_val); + found = s && strstr(s, resctrl_val); free(res); } fclose(inf); -- 2.7.4