Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1290818rbb; Mon, 26 Feb 2024 05:07:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUggA5sn1J2znkYTrZFX08Zj+IyvGtPOdOgBADvfRkP7g8iWfT7MSFo3M6KDgquXM66fOALUgPGe6gGFIIYN54K5ni/afcA+uiGeuxJ2Q== X-Google-Smtp-Source: AGHT+IEMIu0fW0wRtq/4CQGUdzvyQ7J+pdmv+U6UtSc58OAz/3lJpIfEe6oUD74WcHC80IkkXKJ1 X-Received: by 2002:a05:6a20:6f90:b0:1a0:e89c:38e4 with SMTP id gv16-20020a056a206f9000b001a0e89c38e4mr4819925pzb.48.1708952825331; Mon, 26 Feb 2024 05:07:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708952825; cv=pass; d=google.com; s=arc-20160816; b=z9z+mDa1gyX8hGH3gz5DzVyNvlWNe6yueoClGmgDwcchI4hsAemjt97fE5LZjZQHWq Ss9B3c4dE2Spjne5jGu5cX7rywkprMA7pK+KhnyKlgDxniLo4ATYjuGAooy4B6Iv4W5n EmwA94XGS0rpOdNSvmwGVRl7a9Ow8R40U20PikccQzevbadtg3+YN5ZsUl8FEogOh+dH XZmIT3KaM1PrYk1uAkJJK0PviOWX/VGDOTR3ATQcdbmRmiat5YCj6wnE8zaMA9bkSyQv 7tGhJh6mRKVIZPpCTEihoobDSa+cnk49UOrJ70EtdVU3tPRjl9/oK88jgYLLuUa88ykt mjlA== 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=Kz+Gt17KXu3MufKvcjoPUtuGH/UHQhj9Uv5dvuxf7Ik=; fh=/pACME0x50g4vorTSG5vEdNwgU981WFvy8LGbk4DPBk=; b=vlA/1xdtpSziDgqGOrVF1xR8YLLKBUCVc7OOnMPRXTqjHgoR9brrhqPQ1pJFwhPBoT YAdipE9sQ4ZRC5BzRfshZK4pRT33aTmwsr0mh+1qUF6Z3Sl7JNdcN6nbl9Bx4B+EVFwP rUHhCHDDPFPcjmzDKDceVYDPpfxBizVboWxKVWVXyx6Xz7c853dt1Cg8n5eHGcsnsKwa fk0jhzNBuxeJ0OxD4mKQufyq3XR5o9uMfxw6eCAqGYXP+ftsgoKRU/3pDwMLZohhebcy 3HN0cGlhOHcal0pAjK//dDPBOR2mBmP8AIcwjAcjq7gdBhJmm4gAC2EG/+dybgq77QXW gLwg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l08s83AP; 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-81441-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81441-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id v4-20020a632f04000000b005c279da45f1si3697340pgv.566.2024.02.26.05.07.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 05:07:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-81441-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=l08s83AP; 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-81441-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-81441-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 0C625289811 for ; Mon, 26 Feb 2024 13:07:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4FAB18004C; Mon, 26 Feb 2024 13:06:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="l08s83AP" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (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 B2DFB7F7CA; Mon, 26 Feb 2024 13:06:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708952816; cv=none; b=BpB+h9MeORpguan4yZ0gXlIW8TlIPzOm0S3mSaHceZW4UFNbRG6n0JI0+rxsEkQllj85qYHP7y/ypyDQf9h4VbqHDroC1OW4Uli3mp3N9ovNlOa6UE8HPqjDJRhnldPFS0xJcdqP4GLVw1arOkEBWQMdDAY4MhvyhGXoyZWIrP0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708952816; c=relaxed/simple; bh=Gi1VkP9GPyzQfNuuc0NAYEJ6mkbO6wyMOkVcf8T5EK0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BsnzTCe3Cd6d4dV2grE2HVMGbFO+YmrP6OEAKkg/wYf7h0XhvXCktSE9eggJAEt/LfIECIFUc/cILvjHPZJ8fBlPZn58CXAw+bJowSkRcyv3UtSwWwmwfscP7R8yVRUYrN1Hv8IIS+aAMFTBsC/O27LOIWjtbo/YWvneJNIWPps= 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=l08s83AP; arc=none smtp.client-ip=198.175.65.12 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=1708952815; x=1740488815; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Gi1VkP9GPyzQfNuuc0NAYEJ6mkbO6wyMOkVcf8T5EK0=; b=l08s83APiZ8x2d7Mif3u29a8N7jUWuZKVXuda2syxalAZLtso5HMcFI+ BXS3QBZ9AhEsyw0YpyTgJVjiYLaa1Gw1+L3Tn+nLXdksG5t8d2pTDB/ZA QhBrJeU3BHLrshUktqTmllHiLeoiKbiRkFJyuUhDYqItuKqDsmRz9cML1 Xxlg65cvva5aYt8HOeIX/fgNZmNGD+Cu2u3bMHoETKyLG4hTHiEtCSU8Q mGqNyjnMyo9x0DhH2416jjGNQXpW0LVo+QJq37M8wVFCed3Pr4B1KHQza jN4kJZswi+NWALcGJ5QpB67iH+dP9Pcdpf6Ti9eSrS8kjQpU1oZqdiefD w==; X-IronPort-AV: E=McAfee;i="6600,9927,10995"; a="14669083" X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="14669083" Received: from fmviesa009.fm.intel.com ([10.60.135.149]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 05:06:28 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,185,1705392000"; d="scan'208";a="6586227" Received: from pkwiatko-mobl.ger.corp.intel.com (HELO wieczorr-mobl1.intel.com) ([10.213.23.220]) by fmviesa009-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Feb 2024 05:06:25 -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 v4 1/3] selftests/resctrl: Add cleanup function to test framework Date: Mon, 26 Feb 2024 14:05:48 +0100 Message-ID: <357fdb981c7dddcc474818f7bedb1f57a79e117c.1708949785.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 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 --- 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 24af8310288a..2d2f69d3e5b7 100644 --- a/tools/testing/selftests/resctrl/cat_test.c +++ b/tools/testing/selftests/resctrl/cat_test.c @@ -299,4 +299,5 @@ struct resctrl_test l3_cat_test = { .resource = "L3", .feature_check = test_resource_feature_check, .run_test = cat_run_test, + .cleanup = cat_test_cleanup, }; diff --git a/tools/testing/selftests/resctrl/cmt_test.c b/tools/testing/selftests/resctrl/cmt_test.c index dd5ca343c469..32ddee87e43d 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 da256d2dbe5c..7cc4067ce930 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 34879e7b71a0..071e2d3808a7 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 c52eaf46f24d..0f49df4961ea 100644 --- a/tools/testing/selftests/resctrl/resctrl.h +++ b/tools/testing/selftests/resctrl/resctrl.h @@ -70,6 +70,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; @@ -79,6 +80,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