Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1760299rbb; Mon, 26 Feb 2024 23:23:10 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW04DA/AgcaUzVYFqBKGzq7Avab3P18lPbvayBd8v9njFXLnQeA6DPtkPGtmNiSGFILVzx2hEU6bnqdxgoBPC7UkzI2oD/LEJqDriKYWw== X-Google-Smtp-Source: AGHT+IFSUdhb9T4K+kiHifYvFjNAyJFPHOnK3e2+GVheLnYR7OCgn4PoLhdhMZia9KFcOmdm1ChN X-Received: by 2002:a19:5e47:0:b0:512:ee61:c32b with SMTP id z7-20020a195e47000000b00512ee61c32bmr4311091lfi.43.1709018590580; Mon, 26 Feb 2024 23:23:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709018590; cv=pass; d=google.com; s=arc-20160816; b=fk6peYKvWZqHRTVL9VoAp/HcMzu5Q9EjoTMngLwaZjoE0JkCHu6kE/Wu/+dX2zw8YJ 72FbB1H/OMfvU88L/kzGLDzYAGwccfj7G7B6HJd1s3GpnWxps3QdnsH+79UU6ycN5wsS ueKOj56DjukfJPoFhArlfmhc3pLl9eWfSVv7aZEomPVVlnrK78PqC/JaFvQLANTnQhFi IVz4q8vhyLFe7ArwptVwmXBCWF/AelraQjhizV/cJLgVVCmF2hNIYIwTgl0Z61eH4EeW uBxd5UMIMoB74dEzlESPKCypHXbCRzC+VFQO6nq/5gqLm9ctLQKkD+jH0uJ4oLZJFhFu Mf0w== 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=6Ct3Zc7pIydRMtMcnLgKv1ChqU2v6n059BMXEVhwXEU=; fh=/pACME0x50g4vorTSG5vEdNwgU981WFvy8LGbk4DPBk=; b=quxHfpijI9WEWXKNk6CR6UIl8bXZSgZfuM18lJwmlN5TH6xx7vco2uVtO0o/4MX2AS m1Q20KQJZrqi0FsSkuDYWkRX+ZFAowBKMKlHvCKkpsYACvpeizwJjvPMM/jqfzOr47T1 /26iyQShq4rGn285/9hBpDcrHuWTiaO0GstufqeMsTYbByuPmU4GOKouH8H5qbsqkrz+ aCF+tS1HlRH/CFivX3dVVzucHMyuuQyapexejF+tIj52F8RBl2hHB+tRIGQPMBf2iKWS H4Ge8CawXIoDl6ACdY6Ia/R7O5CxPGSbkMg49KuIURDHv+ohniiH1KQvRhlj/EVAxzDU J4+w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dbTWJBnM; 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-82795-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82795-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gt9-20020a1709072d8900b00a43af3190f1si293890ejc.179.2024.02.26.23.23.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 23:23:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82795-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=dbTWJBnM; 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-82795-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82795-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 am.mirrors.kernel.org (Postfix) with ESMTPS id CB8021F2476D for ; Tue, 27 Feb 2024 07:22:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 848B154BF1; Tue, 27 Feb 2024 07:22:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="dbTWJBnM" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.15]) (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 5F57154775; Tue, 27 Feb 2024 07:22:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.15 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709018522; cv=none; b=emtBiV9LkFsXv7aFXdYRqV81hbyNTSDxXglxKWbQoM+a3OHbIghSW0ZVHfG5Ywbka+eMj+5qyU54aNW44Xkgnf6x1qpR93/YCq3mtPMBWvP3wJIPRg7XzP8RwbwkcmN8MpQNp7Gh3XMfVysX/wd0/iah7/9npTEtoJI9L1ZJCjM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709018522; c=relaxed/simple; bh=WTwAMZ8VnEDkTh0dE/dMd6d/Mq+BRQMlMkdEJRqlfZI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=obZJEAn5LOxkhxJCNLLH80GldMuTMM+J6i260W6eYx7TisbSxwu+V7K/OS73lJ9wdvhiX+adbjOYTCHDjEkEbGL38XNTmbjkGjZ0ICyzzpaVrf0E5Tm6t+I5ck75Scy3ltLXr3r13+QxZyD54kBaxjvVfNL/+nl93qfxzVcuaKQ= 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=dbTWJBnM; arc=none smtp.client-ip=192.198.163.15 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=1709018520; x=1740554520; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WTwAMZ8VnEDkTh0dE/dMd6d/Mq+BRQMlMkdEJRqlfZI=; b=dbTWJBnM+JVC1qFrJg9fJm5XGWw7WfCiQC5nTydcGPareNruXRva2FwI mgPd4K5X+yz35LfMcNVI/IdO46Hgxvyl1FScVE3OYiL43rjmzWyW8E0lW sQdVv7V1Dx6kXgVgFMD4v6VaF9LUOz6Vh1IgcXUw6UmfIwQisgTeupfEV YWfvpchFiUb6L+xNIon45t+bkQwzYEA4bIV3OzJFy0cwfppOUyusZfWI4 6hKJGSYSodRuBARxMarLmeELkRVpbhCXOwDj3gkM/5gQ3HCXT2YCGanT6 lQB7ZUquN+1OHHHL14Er+vf1XhJw3CH05qCBYEfr9dmXjF2dySN1PYCxx Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="3508435" X-IronPort-AV: E=Sophos;i="6.06,187,1705392000"; d="scan'208";a="3508435" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by fmvoesa109.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 23:22:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,187,1705392000"; d="scan'208";a="6910275" Received: from lzaleski-mobl.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.4.236]) by orviesa010-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 23:21:57 -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 v5 1/3] selftests/resctrl: Add cleanup function to test framework Date: Tue, 27 Feb 2024 08:21:41 +0100 Message-ID: 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 Resctrl selftests use very similar functions to cleanup after themselves. This creates a lot of code duplication. Also not being hooked to the test framework means that ctrl-c handler isn't aware of what test is currently running and executes all cleanups even though only one is needed. Add a function pointer to the resctrl_test struct and attach to it cleanup functions from individual tests. Signed-off-by: Maciej Wieczor-Retman Reviewed-by: Reinette Chatre --- Changelog v5: - Rebased onto kselftests/next. - Add Reinette's reviewed-by tag. tools/testing/selftests/resctrl/cat_test.c | 1 + tools/testing/selftests/resctrl/cmt_test.c | 1 + tools/testing/selftests/resctrl/mba_test.c | 1 + tools/testing/selftests/resctrl/mbm_test.c | 1 + tools/testing/selftests/resctrl/resctrl.h | 2 ++ 5 files changed, 6 insertions(+) diff --git a/tools/testing/selftests/resctrl/cat_test.c b/tools/testing/selftests/resctrl/cat_test.c index 4cb991be8e31..8fa4348ab461 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -373,6 +373,7 @@ struct resctrl_test l3_cat_test = { .resource = "L3", .feature_check = test_resource_feature_check, .run_test = cat_run_test, + .cleanup = cat_test_cleanup, }; struct resctrl_test l3_noncont_cat_test = { diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index a81f91222a89..a01ccf86e6ce 100644 --- a/tools/testing/selftests/resctrl/cmt_test.c +++ b/tools/testing/selftests/resctrl/cmt_test.c @@ -178,4 +178,5 @@ struct resctrl_test cmt_test = { .resource = "L3", .feature_check = cmt_feature_check, .run_test = cmt_run_test, + .cleanup = cmt_test_cleanup, }; diff --git a/tools/testing/selftests/resctrl/mba_test.c b/tools/testing/selftests/resctrl/mba_test.c index 7946e32e85c8..189fbe20dc7b 100644 --- a/tools/testing/selftests/resctrl/mba_test.c +++ b/tools/testing/selftests/resctrl/mba_test.c @@ -180,4 +180,5 @@ struct resctrl_test mba_test = { .vendor_specific = ARCH_INTEL, .feature_check = mba_feature_check, .run_test = mba_run_test, + .cleanup = mba_test_cleanup, }; diff --git a/tools/testing/selftests/resctrl/mbm_test.c b/tools/testing/selftests/resctrl/mbm_test.c index d67ffa3ec63a..73d6a8b989f5 100644 --- a/tools/testing/selftests/resctrl/mbm_test.c +++ b/tools/testing/selftests/resctrl/mbm_test.c @@ -150,4 +150,5 @@ struct resctrl_test mbm_test = { .vendor_specific = ARCH_INTEL, .feature_check = mbm_feature_check, .run_test = mbm_run_test, + .cleanup = mbm_test_cleanup, }; diff --git a/tools/testing/selftests/resctrl/resctrl.h b/tools/testing/selftests/resctrl/resctrl.h index 2051bd135e0d..221c94532733 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -72,6 +72,7 @@ struct user_params { * @disabled: Test is disabled * @feature_check: Callback to check required resctrl features * @run_test: Callback to run the test + * @cleanup: Callback to cleanup after the test */ struct resctrl_test { const char *name; @@ -82,6 +83,7 @@ struct resctrl_test { bool (*feature_check)(const struct resctrl_test *test); int (*run_test)(const struct resctrl_test *test, const struct user_params *uparams); + void (*cleanup)(void); }; /* -- 2.43.2