Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1720501rdb; Tue, 20 Feb 2024 05:15:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUHFKgvHcLaBH7XcqFJJZPCt9+zSTdg+sQnD5+a2lulX6B3wVgiLf2aZ/8hmur8WPN/OaEPoqSb7OZmURyh5bibZxRUwVH5h5VP/hHIqA== X-Google-Smtp-Source: AGHT+IHLMgpf51nKLMVHS2W/4odoZKXqCz0v9PiWfLwDolSZh49yT7uh/PcTF1mdVahTrsZd5+dS X-Received: by 2002:a17:902:7b90:b0:1db:e7dc:3031 with SMTP id w16-20020a1709027b9000b001dbe7dc3031mr5427392pll.2.1708434957064; Tue, 20 Feb 2024 05:15:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708434957; cv=pass; d=google.com; s=arc-20160816; b=HBidNCvX8sljoWWZIjyyZmLlFhN5knchjx0BafRme+xckXlEZVpGhNJ/W/99bUqkxF LqsRY1WHI3aFQ+/boJKJ0imEwzyRZ3N32ZaqBHl3nDjIDXUoWUKyrF39MjHwVpWUcpAb GEw46x5spQ28otmWh6gxfx5F26AGMluOb7/51x2q4jjE9GgCy6z47a3TpfShX20e/WUp Wdne7oTqvTZWxuEi9NrVeU/SZ0hteR/eV+TcHsadT3i2++W0hESSYN715wZkAP3Iwye+ d3sL/FSmkMXHhgOnhiMQD++qJ7Tt30ONY77YV/V5kEqzMnJ9hO7+GuauF5PY9zPfaftH Kk5A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=0PueEQJj6Hmh5au48/JXUZI+omLsXuZuoccC7QP1g/8=; fh=/pACME0x50g4vorTSG5vEdNwgU981WFvy8LGbk4DPBk=; b=bI/fGXt084O82xLcqsurfTmm196kcObfCgbIwZ+w9CeHcGMzky5YS8PxXoFwVin0PM NaPwKRqVsZ1/RtSFPy8b9gkROFKHW0Rti0iythcK6MOVCjoduuXyTC754ZnTx3yWAR7N /gFP7eFUqoHXwHgkCl3mTOrH1ENUSoxzZ4y8v2twVoo8J7l4+efjY8qUetKBjedprOck I7OxTmZ082A3YxfnAtYe9GGY/6UoxZV1IrDiPmh2sshquS7zzAqJkvwwh0i8dvUxVhad ue5qGgGn1QggnrO2j4z+DOcI4ifpftTPmczSAE/W0NUDUO+Yv0xxS8NuV3B1BZCHAVJi TPeQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Q+dVKl8L; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-73060-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73060-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h22-20020a170902ac9600b001d50ecf8686si6036640plr.520.2024.02.20.05.15.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Feb 2024 05:15:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-73060-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=Q+dVKl8L; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-73060-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-73060-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D81F6B210EB for ; Tue, 20 Feb 2024 13:15:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DB7786A035; Tue, 20 Feb 2024 13:15:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Q+dVKl8L" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 527C26A030; Tue, 20 Feb 2024 13:15:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.17 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708434920; cv=none; b=FFR0ieS/foREuzcct4evMW4AC/Oqd0sYCWlOfcWjsUJ0xX5f7hi3wArkc3v+tFVQvPH1LKxPvtaHZlLDJTaAwCiKCmVEYqgfsqNT1xD4KtCql+mEE5ZwUU2hsc68XtL2ovYGmTWmx1J8NGBa4cbQ/rB8ztTKAtruMsEz09Mrisk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708434920; c=relaxed/simple; bh=is7X7bYYLaNl4Xd9u1Jgp8nNiOY1JjyfGPu5LdGB1Mo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sDsvQNXe+ra/ItAjyXVvMpaWS2ejvo8RMa9lt9Jiy6h9S6N9jMSZUbQKTTKoWA7wcgbxiaZrJBIaFWOvJtHuPrDu6xdrV8nbc1o+IUug/14S6w0cUEamJrPqBdB8XsqHQO6neDE403R63CCXmhem50u6rhWQy+CE83o0DymllSw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Q+dVKl8L; arc=none smtp.client-ip=198.175.65.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1708434918; x=1739970918; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=is7X7bYYLaNl4Xd9u1Jgp8nNiOY1JjyfGPu5LdGB1Mo=; b=Q+dVKl8L7XCWwcFZOlcjdjQTaoGVbAzrqNXLejJjvHDP6ZGAi3GmJ9u2 kGxOGxYT/k1E1po26qoAiedd9C2D85cqJd84gXgxUtRYzslX1cYSZlGsm 2+7h9py4R/lshgFbnpw4hCmUEPhqjMDsxAwySHHcui+BplSx4cxQJqeyJ T8iSLEPVHdvkYluOnMW2ot1KR9Ab+DLfVPwKfNDdv/zOdhCLhC67Z68PB 2Kl9WJIXAU8LOiiKcdA7yF0ERUzAmiJYzR9DrHOEpf4GL6KwysctpaTIP 4ZP2WZ84qjZWc9IK/+sjjFrtfoC38UFijZKQKsvdNMZaKX0MfRLiDDdRP g==; X-IronPort-AV: E=McAfee;i="6600,9927,10989"; a="2660634" X-IronPort-AV: E=Sophos;i="6.06,172,1705392000"; d="scan'208";a="2660634" Received: from orviesa006.jf.intel.com ([10.64.159.146]) by orvoesa109.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 05:15:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,172,1705392000"; d="scan'208";a="5131033" Received: from jmuniak-mobl.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.4.63]) by orviesa006-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 20 Feb 2024 05:15:15 -0800 From: Maciej Wieczor-Retman To: Fenghua Yu , Reinette Chatre , Shuah Khan Cc: ilpo.jarvinen@linux.intel.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org Subject: [PATCH 3/3] selftests/resctrl: Move cleanups out of individual tests Date: Tue, 20 Feb 2024 14:14:34 +0100 Message-ID: <63b9763211c2954f0ef517a817b3bf0c482df8cd.1708434017.git.maciej.wieczor-retman@intel.com> X-Mailer: git-send-email 2.43.2 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Every test calls its cleanup function at the end of it's test function. After the cleanup function pointer is added to the test framework this can be simplified to executing the callback function at the end of the generic test running function. Make test cleanup functions static and call them from the end of run_single_test() from the resctrl_test's cleanup function pointer. Signed-off-by: Maciej Wieczor-Retman --- tools/testing/selftests/resctrl/cat_test.c | 4 +--- tools/testing/selftests/resctrl/cmt_test.c | 3 +-- tools/testing/selftests/resctrl/mba_test.c | 4 +--- tools/testing/selftests/resctrl/mbm_test.c | 4 +--- tools/testing/selftests/resctrl/resctrl.h | 4 ---- tools/testing/selftests/resctrl/resctrl_tests.c | 2 ++ 6 files changed, 6 insertions(+), 15 deletions(-) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 2d2f69d3e5b7..ad5ebce65c07 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -128,7 +128,7 @@ static int check_results(struct resctrl_val_param *param, const char *cache_type return fail; } -void cat_test_cleanup(void) +static void cat_test_cleanup(void) { remove(RESULT_FILE_NAME); } @@ -289,8 +289,6 @@ static int cat_run_test(const struct resctrl_test *test, const struct user_param ret = check_results(¶m, test->resource, cache_total_size, full_cache_mask, start_mask); out: - cat_test_cleanup(); - return ret; } diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index 32ddee87e43d..c477f3c9635f 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -91,7 +91,7 @@ static int check_results(struct resctrl_val_param *param, size_t span, int no_of MAX_DIFF, MAX_DIFF_PERCENT, runs - 1, true); } -void cmt_test_cleanup(void) +static void cmt_test_cleanup(void) { remove(RESULT_FILE_NAME); } @@ -161,7 +161,6 @@ static int cmt_run_test(const struct resctrl_test *test, const struct user_param ksft_print_msg("Intel CMT may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n"); out: - cmt_test_cleanup(); free(span_str); return ret; diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 7cc4067ce930..e4cd484941ec 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -137,7 +137,7 @@ static int check_results(void) return show_mba_info(bw_imc, bw_resc); } -void mba_test_cleanup(void) +static void mba_test_cleanup(void) { remove(RESULT_FILE_NAME); } @@ -163,8 +163,6 @@ static int mba_run_test(const struct resctrl_test *test, const struct user_param ret = check_results(); out: - mba_test_cleanup(); - return ret; } diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index 071e2d3808a7..405edd7df816 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -105,7 +105,7 @@ static int mbm_setup(const struct resctrl_test *test, return ret; } -void mbm_test_cleanup(void) +static void mbm_test_cleanup(void) { remove(RESULT_FILE_NAME); } @@ -133,8 +133,6 @@ static int mbm_run_test(const struct resctrl_test *test, const struct user_param ksft_print_msg("Intel MBM may be inaccurate when Sub-NUMA Clustering is enabled. Check BIOS configuration.\n"); out: - mbm_test_cleanup(); - return ret; } diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 79b45cbeb628..c2a74e11a65e 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -156,8 +156,6 @@ int resctrl_val(const struct resctrl_test *test, const char * const *benchmark_cmd, struct resctrl_val_param *param); void tests_cleanup(void); -void mbm_test_cleanup(void); -void mba_test_cleanup(void); unsigned long create_bit_mask(unsigned int start, unsigned int len); unsigned int count_contiguous_bits(unsigned long val, unsigned int *start); int get_full_cbm(const char *cache_type, unsigned long *mask); @@ -166,9 +164,7 @@ int get_cache_size(int cpu_no, const char *cache_type, unsigned long *cache_size void ctrlc_handler(int signum, siginfo_t *info, void *ptr); int signal_handler_register(void); void signal_handler_unregister(void); -void cat_test_cleanup(void); unsigned int count_bits(unsigned long n); -void cmt_test_cleanup(void); void perf_event_attr_initialize(struct perf_event_attr *pea, __u64 config); void perf_event_initialize_read_format(struct perf_event_read *pe_read); diff --git a/tools/testing/selftests/resctrl/resctrl_tests.c b/tools/testing/selftests/resctrl/resctrl_tests.c index b17f7401892c..e01937e798ee 100644 --- a/tools/testing/selftests/resctrl/resctrl_tests.c +++ b/tools/testing/selftests/resctrl/resctrl_tests.c @@ -142,6 +142,8 @@ static void run_single_test(const struct resctrl_test *test, const struct user_p } ret = test->run_test(test, uparams); + if (test->cleanup) + test->cleanup(); ksft_test_result(!ret, "%s: test\n", test->name); cleanup: -- 2.43.2