From patchwork Wed Nov 30 20:09:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13060356 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 97F5EC4321E for ; Wed, 30 Nov 2022 20:09:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0C3556B0082; Wed, 30 Nov 2022 15:09:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 073D76B0085; Wed, 30 Nov 2022 15:09:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E06576B0087; Wed, 30 Nov 2022 15:09:50 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id C1A006B0082 for ; Wed, 30 Nov 2022 15:09:50 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 745D8411D7 for ; Wed, 30 Nov 2022 20:09:50 +0000 (UTC) X-FDA: 80191199340.28.E4D8FF0 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf28.hostedemail.com (Postfix) with ESMTP id EB219C0009 for ; Wed, 30 Nov 2022 20:09:49 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6E039B81CD3; Wed, 30 Nov 2022 20:09:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 99DDBC43144; Wed, 30 Nov 2022 20:09:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669838987; bh=qgpIYxCoLxiSbmookPCEJSX95mijzZoDksXEWue5IhI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ph1+PQPZYu6to+v4+E7MJsXG71DdCfottZMxf1eZpKiRNy4oCyTaMkgg7vIjsTWfd zMoWUqXoDWvNEBc0SXOkA4kCbcz8+t/yk+iMNwmT2Un1nhaDleVV8d+NV40r6ftxFj cxwH/mphoi9jaylPCjBmsFX3CMsKSYtVmfsXEzVqvsWNcpVFcrTW+ZEB67mk9YGLv3 W3mh7bEz/PuxeV5DmQzgOSjK/tDXQOeP7Ga1mIlO5ES80sVZ8vV4i+f8DRDnA3LTnS EtP2kTMnYfhQeCLR8axup+u4wdlSNN+bgwsXC3Q71oVMYx0c/72Z8Ngh4GMbBzYA1Y JDRI5XE0qxaHQ== From: SeongJae Park To: SeongJae Park , Andrew Morton Cc: Shuah Khan , damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH v2 09/11] selftests/damon/sysfs: test filters directory Date: Wed, 30 Nov 2022 20:09:35 +0000 Message-Id: <20221130200937.118005-10-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221130200937.118005-1-sj@kernel.org> References: <20221130200937.118005-1-sj@kernel.org> MIME-Version: 1.0 ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1669838990; a=rsa-sha256; cv=none; b=ssHoYGiwIyYTj0wFIOhzFpZcBDeKtVBzQpAWjx5kiJha4DfOvnWsskSMbqWLZ0uUXCv24H E7uhHOvZlR/UbiLbt/R7M/nO/DIPbLI8aEC4aqhU/YwdvLzLzKFZ2lLekAYYF+NzPBKU/4 QdcXgcV9wC4stukYRf3/0Zm182c8Efc= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ph1+PQPZ; spf=pass (imf28.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1669838990; 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=+OTj21n3Wg9gwrrIBxAx4NidZtXBp6SPjJpmtwVGK9A=; b=ue9PalOL+wFeR+qBrbPr6BSUP5x4Xj8N7UWd8BNDqTrpuzUHK40TPmmIPXEhBCEG5WAU26 CTWPQ79rej0sgMhUGXuT2q46nXbgyBtfuzIzE78UwkfaRxtVIE5qRSyRXSnQYjUNamtCJg oqP5TBxvBAJEj92+D3zvRkRjFHomLyc= X-Stat-Signature: x4a87no7yqxwqk5hfdu47gxfnjwbhei7 X-Rspamd-Queue-Id: EB219C0009 X-Rspam-User: Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ph1+PQPZ; spf=pass (imf28.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam05 X-HE-Tag: 1669838989-647302 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: Add simple test cases for scheme filters of DAMON sysfs interface. The test cases check if the files are populated as expected, receives some valid inputs, and refuses some invalid inputs. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/sysfs.sh | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/testing/selftests/damon/sysfs.sh b/tools/testing/selftests/damon/sysfs.sh index db4942383a50..a00336ffdcad 100644 --- a/tools/testing/selftests/damon/sysfs.sh +++ b/tools/testing/selftests/damon/sysfs.sh @@ -96,6 +96,34 @@ test_stats() done } +test_filter() +{ + filter_dir=$1 + ensure_file "$filter_dir/type" "exist" "600" + ensure_write_succ "$filter_dir/type" "anon" "valid input" + ensure_write_succ "$filter_dir/type" "memcg" "valid input" + ensure_write_fail "$filter_dir/type" "foo" "invalid input" + ensure_file "$filter_dir/matching" "exist" "600" + ensure_file "$filter_dir/memcg_path" "exist" "600" +} + +test_filters() +{ + filters_dir=$1 + ensure_dir "$filters_dir" "exist" + ensure_file "$filters_dir/nr_filters" "exist" "600" + ensure_write_succ "$filters_dir/nr_filters" "1" "valid input" + test_filter "$filters_dir/0" + + ensure_write_succ "$filters_dir/nr_filters" "2" "valid input" + test_filter "$filters_dir/0" + test_filter "$filters_dir/1" + + ensure_write_succ "$filters_dir/nr_filters" "0" "valid input" + ensure_dir "$filters_dir/0" "not_exist" + ensure_dir "$filters_dir/1" "not_exist" +} + test_watermarks() { watermarks_dir=$1 @@ -143,6 +171,7 @@ test_scheme() test_access_pattern "$scheme_dir/access_pattern" test_quotas "$scheme_dir/quotas" test_watermarks "$scheme_dir/watermarks" + test_filters "$scheme_dir/filters" test_stats "$scheme_dir/stats" test_tried_regions "$scheme_dir/tried_regions" }