From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id F252BC83F1A for ; Sun, 20 Jul 2025 17:17:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D79C56B00AC; Sun, 20 Jul 2025 13:17:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D05096B00AD; Sun, 20 Jul 2025 13:17:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B7D906B00AE; Sun, 20 Jul 2025 13:17:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8A3DA6B00AD for ; Sun, 20 Jul 2025 13:17:20 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 66A9F16056F for ; Sun, 20 Jul 2025 17:17:20 +0000 (UTC) X-FDA: 83685299040.16.A02106C Received: from nyc.source.kernel.org (nyc.source.kernel.org [147.75.193.91]) by imf03.hostedemail.com (Postfix) with ESMTP id 0FEAF20002 for ; Sun, 20 Jul 2025 17:17:18 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PVTw87av; spf=pass (imf03.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1753031839; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=wQ4hdVZjWG4b6jDwIf1I5MuIQ2t/sIYpchfJ6lh58CI=; b=d1DW3mnzHashHE1NZzMHuKBHOc3QtcnuztjSQMrOrgX8FhZVFKSwZ8zIR6m0C/HsRUZArC ESsYsbvgSzexgHGLFD4drzkuCzq9JvU26jghuEIClWybIO13VzeUEpdirLjzsxnWcQWQ6M aQhbtVJdO29smUoKqLC9BZ+feQrZrsQ= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=PVTw87av; spf=pass (imf03.hostedemail.com: domain of sj@kernel.org designates 147.75.193.91 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1753031839; a=rsa-sha256; cv=none; b=2jUju5PimYOgnFyySuuExaWpXAirlSnmrIvW2k1PZ0W1J3LiFxPYba9+VAY4wAg6HJis1n b9VIERZ6MNbd3OiHQoYmqxu3w70juG2af5zVNYleyxO7kEJUpVZF0jNVz49D+sAuNGZ7HL HxBeAhJQDEILay+sS+rJ0FBU/Ing9Hk= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by nyc.source.kernel.org (Postfix) with ESMTP id 7A2B2A5272F; Sun, 20 Jul 2025 17:17:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 02DFCC4CEEB; Sun, 20 Jul 2025 17:17:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1753031838; bh=tlyYCuebypsS1rYr+0TB9gAjyBmHC3iclhm4zOJtldg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PVTw87avXtYA3rlMLOZL0pfGKrDZ+cdzVOb4lTjpiTIF84ms95iyxsh+rOfq7gags LwDwKL84bi8mp+zA0YauWcVJpjJZNXOD1yTnsdWC+RMGpDL9AaObxqiox8VE0ANHZQ XNVB7HkLj3rtOw26WEV5JrgiNZwzcpCvysg6S11oRMyWG3hof371doDi0mbiMXj8cI 404auVsTNIBKzvbjbu3n5OQ/N/VIliWnFwU3yG2EjKegKBGUpxowLabI+uPtYskZpu 3CAJ757G+dIrEoHTY8GInkFyqugT/gpiTOgyUMrUBRl9NZhtwbfJxbVYHnrBgvegCT /rys963tR8GZw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Shuah Khan , damon@lists.linux.dev, kernel-team@meta.com, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 20/22] selftests/damon/sysfs.py: generalize DAMON context commit assertion Date: Sun, 20 Jul 2025 10:16:50 -0700 Message-Id: <20250720171652.92309-21-sj@kernel.org> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250720171652.92309-1-sj@kernel.org> References: <20250720171652.92309-1-sj@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Stat-Signature: hyity68d1weczcyrdwqpje3y4ht19ecf X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 0FEAF20002 X-Rspam-User: X-HE-Tag: 1753031838-674041 X-HE-Meta: U2FsdGVkX1/jYZJj0Ae/Hv9dBFXXm4P7fQHJ4jZoEEOMDARyNt6gP4edqzj9oRaOOAiFEauX77mi5U30xXCqh0C/2HgcYgFzSoSCgzIbG5tj/2laoXgZh3GNCljnU3ei3XNmYvw8Ufo5fPGf3A9h73xustawXvrtE6yDqqOCJ4AtEHk8vaAmKZxlXqQJ2amhz4ZIpn92hmFuPVNhnT2Z3REj43ZkreUg7rAyHA/rUbJB3fgkNW6JzdpLyqEpoQ44sWCi06ccWYMA7EEKbaWPvVrrHEHzcwAPeUateX8E9w6r3uWaubnCtLNKq1G+9ir2eZ/VNnnCN+x3DChQsd8axErtNqUxbv79oUI+6ECqjrAFAxTF3OyoOlC9KOZUsoWaKMLjwN1HM5m9y95oyxH4GwMWbybkIfZtWwQll0uKo0687+9mZRCgCOn6QLqHicn9wQ2ZgfzfKDn7Aq3sgu9m3OhxD/2mDgZDO4H72CRdGlpRP0XpGhB3ykqc3Hyks3vSCyuPyfE42Roou8oetrj9uYgaXfZewWWXmKxq2pUHc/O0y0/dIDAL6TumA8CWZbieTlm4L1JSDK1Oum9KHaotnnTXwT2B9QbWteX/Zwk8eZ6AQbGuB5TsKcp2dBT1e9Tx5d9KtJRkN5ajFACu8fJJ8eCVcjekxM73fUNHOPRbkV74LWHpuWf3KN4KNKF0yfDbAzs8vL2lb7EcUeIlpvF5HGHgbtT/b2l77YYzYlyeAvCRmEfnWdpS3hn7nppEbh1Pp81lpx4Kc5H3UfDcf6SsALq+CBVsyqLRuyUxxK5jMpqTfohVKkT/fi0gFpf11ePHG6ktQrxo3/QIleuDI/eZexn7tCnklBl5RLhP1JwpojaP9ywcyiJ4klDd5TdfzIm6Qs3D4foV37nWDfMoPiMn+JwVBt3jBW+xo+R9nwx4ir0qBC+y2+HjiQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: DAMON context commitment assertion is hard-coded for a specific test case. Split it out into a general version that can be reused for different test cases. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/sysfs.py | 28 +++++++++++++++----------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/damon/sysfs.py b/tools/testing/selftests/damon/sysfs.py index ed4c3e9fc972..429865e5ac9c 100755 --- a/tools/testing/selftests/damon/sysfs.py +++ b/tools/testing/selftests/damon/sysfs.py @@ -160,6 +160,21 @@ def assert_monitoring_attrs_committed(attrs, dump): assert_true(dump['max_nr_regions'] == attrs.max_nr_regions, 'max_nr_regions', dump) +def assert_ctx_committed(ctx, dump): + ops_val = { + 'vaddr': 0, + 'fvaddr': 1, + 'paddr': 2, + } + assert_true(dump['ops']['id'] == ops_val[ctx.ops], 'ops_id', dump) + assert_monitoring_attrs_committed(ctx.monitoring_attrs, dump['attrs']) + assert_schemes_committed(ctx.schemes, dump['schemes']) + +def assert_ctxs_committed(ctxs, dump): + assert_true(len(ctxs) == len(dump), 'ctxs length', dump) + for idx, ctx in enumerate(ctxs): + assert_ctx_committed(ctx, dump[idx]) + def main(): kdamonds = _damon_sysfs.Kdamonds( [_damon_sysfs.Kdamond( @@ -177,18 +192,7 @@ def main(): print(err) exit(1) - if len(status['contexts']) != 1: - fail('number of contexts', status) - - ctx = status['contexts'][0] - - assert_monitoring_attrs_committed(_damon_sysfs.DamonAttrs(), ctx['attrs']) - - if ctx['adaptive_targets'] != [ - { 'pid': 0, 'nr_regions': 0, 'regions_list': []}]: - fail('adaptive targets', status) - - assert_schemes_committed([_damon_sysfs.Damos()], ctx['schemes']) + assert_ctxs_committed(kdamonds.kdamonds[0].contexts, status['contexts']) kdamonds.stop() -- 2.39.5