From patchwork Tue Apr 13 14:29:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12200711 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36B8EC433ED for ; Tue, 13 Apr 2021 14:29:57 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DE9E56124B for ; Tue, 13 Apr 2021 14:29:56 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DE9E56124B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 17C1F6B0080; Tue, 13 Apr 2021 10:29:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 03A9A6B0083; Tue, 13 Apr 2021 10:29:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BFB8F6B0081; Tue, 13 Apr 2021 10:29:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0039.hostedemail.com [216.40.44.39]) by kanga.kvack.org (Postfix) with ESMTP id A14B36B0080 for ; Tue, 13 Apr 2021 10:29:40 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 5748418024DFD for ; Tue, 13 Apr 2021 14:29:40 +0000 (UTC) X-FDA: 78027577320.12.C7DD9AF Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) by imf25.hostedemail.com (Postfix) with ESMTP id AB3F06000117 for ; Tue, 13 Apr 2021 14:29:37 +0000 (UTC) Received: by mail-qk1-f182.google.com with SMTP id 18so1148021qkl.3 for ; Tue, 13 Apr 2021 07:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=92l+8w7L4L+POeiMQ+785lRXaO47cAlZxhuw/8KNqwY=; b=D5CCyMvOHAvavZZifzx4/+Kx2do2w+7fV7Leh+8DN8pe0/hf7V6IMVp7BORvd6cELg M205egr4PFWX7ssqZOrFfS9V0NiB3KNEC1b6FXHtQszwlOIdw8X559Xv1wyoNhkN0Rvw Cf0r0q0iWyGhO8JPCwMNnzr/wXJL0EdZXSAmfTW+sH+H7U8rdv1Vz6dJzkPlVCzct86v 7DAfj/zyqxCxoHF3hoonazbak6qyan6Qy/BYlhnTemxGr17/1pXm4Krpk3Bfu7kkbWyL F5FjTr55CUmHKJ9miCerj/MsWuFeDodJzg0YFzBnkwu7rqD49sqQ8Ks8qne0vgwQGtlT GdBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=92l+8w7L4L+POeiMQ+785lRXaO47cAlZxhuw/8KNqwY=; b=lposv5PTe91N2NnxOpaCGa2LiuBiC4VaeyGmecSmKrblbOfnISGV1b5GOk9tqqb8KZ dIDxcbAvq/NEjtILu0r+eH8C4QBt+x6DJMFXvg5PST34uAKjAGkdk1/FOIz/SKWfxbFm pRFFLskWOGwLuZap9kBk2snbsJr+uEC0yNqbrlZNAhCkw30/PcHBlJUIj9U6Bt+Z8Hvq wDljDDxJ/bFy6MUAMphKpXNYpoFeBoEO1tLInNRndrpGMLOeJbw2NaYxFNLqabdE104o XiRH20cN2usp20PKZdsjW7jGCtJsZb/IoLpYhM2c4e4ybxAQUUzVLg4yDp6FBnD8SFoC zPTQ== X-Gm-Message-State: AOAM533Qr6Z4JCDdXPJeYkQFKaLhfdhLOoN3bbY36fjB3TPozY8wVAtv 9JivX9MYASF5gKvE5qhMyAU= X-Google-Smtp-Source: ABdhPJzbr9XfAuzz2YtBjbF1+1fPyvdwv9W7I0y57Cqa/Lz3KUZD54pnZe7Nr6u5aycSU7ZoCgDHHg== X-Received: by 2002:a37:89c7:: with SMTP id l190mr34745718qkd.361.1618324179276; Tue, 13 Apr 2021 07:29:39 -0700 (PDT) Received: from localhost.localdomain (ec2-35-169-212-159.compute-1.amazonaws.com. [35.169.212.159]) by smtp.gmail.com with ESMTPSA id 2sm6160911qko.134.2021.04.13.07.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Apr 2021 07:29:38 -0700 (PDT) From: SeongJae Park To: akpm@linux-foundation.org Cc: SeongJae Park , Jonathan.Cameron@Huawei.com, acme@kernel.org, alexander.shishkin@linux.intel.com, amit@kernel.org, benh@kernel.crashing.org, brendanhiggins@google.com, corbet@lwn.net, david@redhat.com, dwmw@amazon.com, elver@google.com, fan.du@intel.com, foersleo@amazon.de, greg@kroah.com, gthelen@google.com, guoju.fgj@alibaba-inc.com, mgorman@suse.de, minchan@kernel.org, mingo@redhat.com, namhyung@kernel.org, peterz@infradead.org, riel@surriel.com, rientjes@google.com, rostedt@goodmis.org, rppt@kernel.org, shakeelb@google.com, shuah@kernel.org, sj38.park@gmail.com, snu@amazon.de, vbabka@suse.cz, vdavydov.dev@gmail.com, zgf574564920@gmail.com, linux-damon@amazon.com, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v28 12/13] mm/damon: Add user space selftests Date: Tue, 13 Apr 2021 14:29:03 +0000 Message-Id: <20210413142904.556-13-sj38.park@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210413142904.556-1-sj38.park@gmail.com> References: <20210413142904.556-1-sj38.park@gmail.com> X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: AB3F06000117 X-Stat-Signature: xataj86bmuxczjp8ir481na7wrs7cjzz Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf25; identity=mailfrom; envelope-from=""; helo=mail-qk1-f182.google.com; client-ip=209.85.222.182 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1618324177-718553 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: From: SeongJae Park This commit adds a simple user space tests for DAMON. The tests are using kselftest framework. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/Makefile | 7 ++ .../selftests/damon/_chk_dependency.sh | 28 ++++++ .../testing/selftests/damon/debugfs_attrs.sh | 98 +++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 tools/testing/selftests/damon/Makefile create mode 100644 tools/testing/selftests/damon/_chk_dependency.sh create mode 100755 tools/testing/selftests/damon/debugfs_attrs.sh diff --git a/tools/testing/selftests/damon/Makefile b/tools/testing/selftests/damon/Makefile new file mode 100644 index 000000000000..8a3f2cd9fec0 --- /dev/null +++ b/tools/testing/selftests/damon/Makefile @@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0 +# Makefile for damon selftests + +TEST_FILES = _chk_dependency.sh +TEST_PROGS = debugfs_attrs.sh + +include ../lib.mk diff --git a/tools/testing/selftests/damon/_chk_dependency.sh b/tools/testing/selftests/damon/_chk_dependency.sh new file mode 100644 index 000000000000..e090836c2bf7 --- /dev/null +++ b/tools/testing/selftests/damon/_chk_dependency.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +# Kselftest framework requirement - SKIP code is 4. +ksft_skip=4 + +DBGFS=/sys/kernel/debug/damon + +if [ $EUID -ne 0 ]; +then + echo "Run as root" + exit $ksft_skip +fi + +if [ ! -d $DBGFS ] +then + echo "$DBGFS not found" + exit $ksft_skip +fi + +for f in attrs target_ids monitor_on +do + if [ ! -f "$DBGFS/$f" ] + then + echo "$f not found" + exit 1 + fi +done diff --git a/tools/testing/selftests/damon/debugfs_attrs.sh b/tools/testing/selftests/damon/debugfs_attrs.sh new file mode 100755 index 000000000000..4a8ab4910ee4 --- /dev/null +++ b/tools/testing/selftests/damon/debugfs_attrs.sh @@ -0,0 +1,98 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-2.0 + +source ./_chk_dependency.sh + +# Test attrs file +file="$DBGFS/attrs" + +ORIG_CONTENT=$(cat $file) + +echo 1 2 3 4 5 > $file +if [ $? -ne 0 ] +then + echo "$file write failed" + echo $ORIG_CONTENT > $file + exit 1 +fi + +echo 1 2 3 4 > $file +if [ $? -eq 0 ] +then + echo "$file write success (should failed)" + echo $ORIG_CONTENT > $file + exit 1 +fi + +CONTENT=$(cat $file) +if [ "$CONTENT" != "1 2 3 4 5" ] +then + echo "$file not written" + echo $ORIG_CONTENT > $file + exit 1 +fi + +echo $ORIG_CONTENT > $file + +# Test target_ids file +file="$DBGFS/target_ids" + +ORIG_CONTENT=$(cat $file) + +echo "1 2 3 4" > $file +if [ $? -ne 0 ] +then + echo "$file write fail" + echo $ORIG_CONTENT > $file + exit 1 +fi + +echo "1 2 abc 4" > $file +if [ $? -ne 0 ] +then + echo "$file write fail" + echo $ORIG_CONTENT > $file + exit 1 +fi + +CONTENT=$(cat $file) +if [ "$CONTENT" != "1 2" ] +then + echo "$file not written" + echo $ORIG_CONTENT > $file + exit 1 +fi + +echo abc 2 3 > $file +if [ $? -ne 0 ] +then + echo "$file wrong value write fail" + echo $ORIG_CONTENT > $file + exit 1 +fi + +if [ ! -z "$(cat $file)" ] +then + echo "$file not cleared" + echo $ORIG_CONTENT > $file + exit 1 +fi + +echo > $file +if [ $? -ne 0 ] +then + echo "$file init fail" + echo $ORIG_CONTENT > $file + exit 1 +fi + +if [ ! -z "$(cat $file)" ] +then + echo "$file not initialized" + echo $ORIG_CONTENT > $file + exit 1 +fi + +echo $ORIG_CONTENT > $file + +echo "PASS"