From patchwork Mon Jun 19 05:17:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yosry Ahmed X-Patchwork-Id: 13284002 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 A49D8EB64D9 for ; Mon, 19 Jun 2023 05:17:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F25678D0002; Mon, 19 Jun 2023 01:17:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id ED4058D0001; Mon, 19 Jun 2023 01:17:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D9C438D0002; Mon, 19 Jun 2023 01:17:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id C7ECC8D0001 for ; Mon, 19 Jun 2023 01:17:22 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 83DF9C03BC for ; Mon, 19 Jun 2023 05:17:22 +0000 (UTC) X-FDA: 80918339124.25.63B00F9 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf10.hostedemail.com (Postfix) with ESMTP id D22B7C0004 for ; Mon, 19 Jun 2023 05:17:20 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=gF61XMV3; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 33-SPZAoKCBQI8CBIu16yx08805y.w86527EH-664Fuw4.8B0@flex--yosryahmed.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=33-SPZAoKCBQI8CBIu16yx08805y.w86527EH-664Fuw4.8B0@flex--yosryahmed.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687151840; a=rsa-sha256; cv=none; b=mUQ4umOKMRK97WdMhS1X7SWCWeNNHaXqNoV54FSNqEHqsyFa3kIjR8uaY/LGF+v1X30dad jw2drA5ejjVvbnWXNPtcfdho+pU//4JtDdbs/rfAFBRjhwLpgd8KNFbX0dL5GxT223F8Ao AaWzj2Q38HOh+sboqOpXrbTAS316pHo= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20221208 header.b=gF61XMV3; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf10.hostedemail.com: domain of 33-SPZAoKCBQI8CBIu16yx08805y.w86527EH-664Fuw4.8B0@flex--yosryahmed.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=33-SPZAoKCBQI8CBIu16yx08805y.w86527EH-664Fuw4.8B0@flex--yosryahmed.bounces.google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1687151840; 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-type:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=wIJtbiNHWORZFFJvZlaFdgy0aymB8UjaLQ1n2ZbqAGA=; b=3EszdIJsR6SNU5+jjPrfeq3vfrCvZUbZBdlGdYqqMPQrVa4bsd8TqlMDxS6c3EYhvQxWQr LoC0817a2E2YoCx4ZtXthWlSj9TO5n9ltIr22rfxVBHWNuXsknOz1xbIoP/ZTA0mtMHBFl 9lYP1o8VxEwBNIJqlRoqo5AYVczcSkU= Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-56fffdea2d0so35715237b3.1 for ; Sun, 18 Jun 2023 22:17:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1687151840; x=1689743840; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=wIJtbiNHWORZFFJvZlaFdgy0aymB8UjaLQ1n2ZbqAGA=; b=gF61XMV36bH0I0OFvVtMJMGfMqtsf5GRLhWCa6KadS7mbkOfJd8Nx9f6fyfD0xONPr gWmimxA9RjSurXO02roA0UblNhg0/LzFtfe/76MNLOqk8f9E40XXbrQ+OXLQjhme9er0 6CVWLC/hLBlwKdhfotjAtiyH1l14V+xB12eI5kJJf84Jn36fg+DSVCh+xi1dPFJmsGgw 6oXNg/F33JJmP82PkyDzdux+9ZZZBoRQOXweSvCZJwPQafOLvflD1OXS0vtB8Si0QDor NrjaREvL25r/7Hjs1fV4HN2tV5ZQ0H55KOrMpxqUn40TA3clVeMbmIoNBPOWMcYoU+Gz x87A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687151840; x=1689743840; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=wIJtbiNHWORZFFJvZlaFdgy0aymB8UjaLQ1n2ZbqAGA=; b=F67IleUtpZyxnLb8dxrrR85XlMdGkcEX1zNBbFYlGHFcbGbkPIIKKX93H6GavxMAhW SGY+fXPtckaSxfIm+vMWq2z9OTD1l9+kAVUQ6ymF0hGZdMxCmETejULt/7E1nHX9o9kZ TXau4+owVfmzBphGjImNxtKDV8BQc1IbV4KAhLibt4puREK9HaKDgJn+5/xZsj4Xs9CB yLwCEKGsD0uz1t0NARwL6jRtaxcsJIgfYdFj168+ELJstO3XistGi17+1ugUb5kv6hj0 6NZ1fQ9ANLTBnI7TBkm5I/Uh/LCv+6Jy0uWz64rbEZ8DovWIWuyVKov+PoefN5NAUXJ+ hUsw== X-Gm-Message-State: AC+VfDzTurKHOy9wLtKUuIo3564++k57/W71J94x/vfoDEuYVP4KV9fl nBTOPYBVH9rMKNYqTomk2febF+J9JE5+tFvn X-Google-Smtp-Source: ACHHUZ4bERXIPoat5d1IzHXmL6LrgMtKb/8unGaeig1J8SlCYu4NeAeG5s68/yZupgeGKDfJMDcTzlOYVExCpEWM X-Received: from yosry.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:2327]) (user=yosryahmed job=sendgmr) by 2002:a81:e709:0:b0:568:f589:2b4e with SMTP id x9-20020a81e709000000b00568f5892b4emr3820382ywl.0.1687151839830; Sun, 18 Jun 2023 22:17:19 -0700 (PDT) Date: Mon, 19 Jun 2023 05:17:15 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.41.0.162.gfafddb0af9-goog Message-ID: <20230619051715.2306134-1-yosryahmed@google.com> Subject: [PATCH] selftests/cgroup: allow running a specific test with test_memcontrol From: Yosry Ahmed To: Roman Gushchin , Andrew Morton Cc: Johannes Weiner , Michal Hocko , Shakeel Butt , Muchun Song , cgroups@vger.kernel.org, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, Yosry Ahmed X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: D22B7C0004 X-Stat-Signature: onyhbugpm6ushkwpz7esfs3z9wqrhr1i X-HE-Tag: 1687151840-805060 X-HE-Meta: U2FsdGVkX1/hZwhMsa4w4ili6hUT1BSV47dGm3H+husBj51KZphhLYlc1nhAQtdTCnTmAFzqWFcD+7AqQ8BwhAy9JtUjayXjbuZnJRxmEnmZV99za35Vu6RYKx80zrnv9BcYvoA4+e7+6vZ4g2rgKq/LBJZsYhQWcsVyyNfmgMnt4Ai/Fn40O7USehonyVrgQLX0duYPn0EZFN/5j2P9LR9r1HtYG5DkYOwlSbkMl4ZiJaatlS7WjEaAH0KhVps9xR/GAwqKKDd4QqJJv5qDgavhyrzuFR/pGQ3EUz5M8FoNv+N2dtnMBfgo5gaSH6eyMuK9eI0oXUh0AjDkmIUunBABRyWtBdLCTZkLmdb7rOtA6RT7kotxhE+SKQG8sO2HjpjoD969XMFl/Qz33YSKVSoCN+F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rmeCi23QWzl5T8dRIlJz0kCbVh/wjZKUNbTAimExz77N0ZZgfVsXPfHaoSEsdzrgZ350CFFUrGLeHto89CBMPCgGkI9PnAleTLv02qKsBt9rb4NZaXVBhNUptu8X2sQFu2CPBG3zWocLXlQrAF7EV4OOZoxC41+QijR4A22J7LdS6rx3l+rXRIjiHpVHKlamKizOueOeuvHMtCQWkkdLGW5MIVSwAis0mrJJikJ1e1 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: It is handy during testing and/or debugging to be able to run a single test from test_memcontrol. Allow passing in a test name through a command line argument (e.g. ./test_memcontrol -t test_memcg_recharge). Change-Id: I0e0d74d81fdd9d997987389085a816715160467f Signed-off-by: Yosry Ahmed --- .../selftests/cgroup/test_memcontrol.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c index a2a90f4bfe9f..d8f8a13bc6c4 100644 --- a/tools/testing/selftests/cgroup/test_memcontrol.c +++ b/tools/testing/selftests/cgroup/test_memcontrol.c @@ -1308,9 +1308,36 @@ struct memcg_test { int main(int argc, char **argv) { + int opt; char root[PATH_MAX]; + int selected_test = -1; int i, proc_status, ret = EXIT_SUCCESS; + while ((opt = getopt(argc, argv, "ht:")) != -1) { + switch (opt) { + case 't': + for (i = 0; i < ARRAY_SIZE(tests); i++) { + if (!strcmp(tests[i].name, optarg)) { + selected_test = i; + break; + } + } + if (selected_test >= 0) + break; + fprintf(stderr, "test %s not found\n", optarg); + return EXIT_FAILURE; + case 'h': + fprintf(stderr, + "Usage: %s [-h] [-t name]\n" + "\t-h print help\n" + "\t-t name run specific test\n" + , argv[0]); + return ret; + default: + break; + } + } + if (cg_find_unified_root(root, sizeof(root))) ksft_exit_skip("cgroup v2 isn't mounted\n"); @@ -1336,6 +1363,9 @@ int main(int argc, char **argv) has_localevents = proc_status; for (i = 0; i < ARRAY_SIZE(tests); i++) { + if (selected_test >= 0 && selected_test != i) + continue; + switch (tests[i].fn(root)) { case KSFT_PASS: ksft_test_result_pass("%s\n", tests[i].name);