From patchwork Mon Apr 17 19:53:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 13214490 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 4AF43C77B76 for ; Mon, 17 Apr 2023 19:53:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D8AAB6B0081; Mon, 17 Apr 2023 15:53:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D3B018E0002; Mon, 17 Apr 2023 15:53:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB50C8E0001; Mon, 17 Apr 2023 15:53:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id AD0AB6B0081 for ; Mon, 17 Apr 2023 15:53:33 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 7A1051A060E for ; Mon, 17 Apr 2023 19:53:33 +0000 (UTC) X-FDA: 80691932706.01.FD253F7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 66125A000A for ; Mon, 17 Apr 2023 19:53:31 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hkiTDCUl; spf=pass (imf15.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681761211; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VlJAJroC0qfUjlayNMIBwxZydfuRD55bTGjabDZPAD4=; b=swuLEEc8hNZPp74szbyE+lxJmMoJXpIYiFr2iwHywYCpTqeSfrn6Ye4ESQ3fLQyYfoZ7fg /TYDdIu6ZQPo6WsKGIjy6gCROsiQeMkR179d+jC6dI4qdGfu7EEpEzSxYyNQGa4jhG5KMT d8cMbou/h9AewGZVtw8eiaz6/FHNQM0= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hkiTDCUl; spf=pass (imf15.hostedemail.com: domain of peterx@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681761211; a=rsa-sha256; cv=none; b=wfL8SKm0f3ph44+jW0Cgb0FprOPcf6P4r4A6SB5X6rdvid6VWvbLmzdzrp0Q4yBm09D7WB lO+CpuEd1um1JCB6ID1tOJV7neM5UUNIsDsD4eL4uTPtPw/b4SX+sFVPjaz11NgF8bV3LC zdIrho9hWE8htTv7LLpzVY8h+QEEqHU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681761210; h=from:from: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:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VlJAJroC0qfUjlayNMIBwxZydfuRD55bTGjabDZPAD4=; b=hkiTDCUlCBT3A+g7WD3e+kzku6Nny0wR/HLEVs1lkDFLlNrqZJHVFA97h65NqcJLePoWTz fFcJof5X9IvWQwZGvTNnSthcrXd72QSmqo0uHvKr6Ux58oDK/BFk0Qbdv//0hkw6/Hzhmo U0/6Ii/s/Y+as+OQMzx2HyBXmaH7uSg= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-376-CVDYZVBFN9WEyA-3bcccdg-1; Mon, 17 Apr 2023 15:53:27 -0400 X-MC-Unique: CVDYZVBFN9WEyA-3bcccdg-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-3ed767b30easo1905001cf.1 for ; Mon, 17 Apr 2023 12:53:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681761207; x=1684353207; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=VlJAJroC0qfUjlayNMIBwxZydfuRD55bTGjabDZPAD4=; b=l7qNVnQac3AG7A1P9/EM9r6fsD8HYoXZs3mYf8uz9kxyjM1EpD6I2fuRyr24e7SNop iY/iS89bZwneo+WfSc2xX1dvPKdJPy+cJdtOz1kE6GdBvNjW4cKm/EXUv5Ad+1SMUUWf SVBDcuvSMVUNEX6AVaSWlJTlsNoNU4ps225KRglWadJNrdOEaCRbJP1hMGN3yv0ClGbb XzIFu2SX4NSJiE7dW4zXjCe7+T6NGWUUOViOFY/xHBCWfPTVh9Xu2JM4cMUh7uriOQLh jdEtZnFTq09/1Y1eZSqnx/fNF5w3w+gWfH8mKUviXqDhCHXmJHkNNfqFbCEJINHMEYsX 9fSw== X-Gm-Message-State: AAQBX9dLFiR+3GcBZcMvAu/JK4ZS9DzgzOFIVTo1zOQzDNyJtJszQzx+ 6XEny5X5EnoyIFhiuGmCOoomN/lchopcF4ZRmzIzLOV6lilaFATbUtNkbvDesHUsSRSSC7WRRCQ T+vL4h8nseHY= X-Received: by 2002:ac8:4e43:0:b0:3bf:cf77:a861 with SMTP id e3-20020ac84e43000000b003bfcf77a861mr19130137qtw.4.1681761206739; Mon, 17 Apr 2023 12:53:26 -0700 (PDT) X-Google-Smtp-Source: AKy350atiTLtabqgcPaZB1CQI3pkzcoQyHjGkW0AJzAmgZF9tCzczfoqxlZpXO4VXi+keofELA+BDw== X-Received: by 2002:ac8:4e43:0:b0:3bf:cf77:a861 with SMTP id e3-20020ac84e43000000b003bfcf77a861mr19130115qtw.4.1681761206528; Mon, 17 Apr 2023 12:53:26 -0700 (PDT) Received: from x1n.redhat.com (bras-base-aurron9127w-grc-40-70-52-229-124.dsl.bell.ca. [70.52.229.124]) by smtp.gmail.com with ESMTPSA id r17-20020ac87ef1000000b003edfb5d7637sm1731278qtc.73.2023.04.17.12.53.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 12:53:25 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Mike Kravetz , Andrea Arcangeli , =?utf-8?q?Mika_Penttil=C3=A4?= , Andrew Morton , peterx@redhat.com, Axel Rasmussen , Nadav Amit , David Hildenbrand Subject: [PATCH v2 3/6] selftests/mm: Add a few options for uffd-unit-test Date: Mon, 17 Apr 2023 15:53:14 -0400 Message-Id: <20230417195317.898696-4-peterx@redhat.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230417195317.898696-1-peterx@redhat.com> References: <20230417195317.898696-1-peterx@redhat.com> MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Stat-Signature: 5eaag1mxpbokoygh76363ay7q9n3ghyb X-Rspam-User: X-Rspamd-Queue-Id: 66125A000A X-Rspamd-Server: rspam06 X-HE-Tag: 1681761211-165650 X-HE-Meta: U2FsdGVkX19XTd7skDqNbVV1UZ0n3wbXiEo8VixlI459KbQtaTD97tbJ4gvNq2U6VCoW1t+z6GKjJfkV57gPI1n0f1Ig6u7+G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tOxQgSr83Mj6N9l9Pb2vd2gZ/W6uxRKmApXesa4LEBxMZoI7yZ8+BGIIz11LyTLMuFDq7eOF3yb+1Vto6wnAvy7s2vMMRzt3hKht0Cmy/PIjCGaTOhvqdzXhbmtBY1BmsU6au4/xF/DngfeCFzucGp56IPWg6OyYovV1DEORzUccMsj5Ok+2KkePlTt6RcT9eftbAVl2RakPiNQNd+mcPp2DaPnnDUnun5KsHLIs+4b00ds3daxViNumnrBsySfHXyatUMIeJUr9p57sC6TbeV2AeHFlBHIAAQdhcHxHYF/d4LZ+xZs9mtTgl9HFeveZTsxwM7f/j X-Bogosity: Ham, tests=bogofilter, spamicity=0.000203, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Namely: "-f": add a wildcard filter for tests to run "-l": list tests rather than running any "-h": help msg Signed-off-by: Peter Xu Reviewed-by: David Hildenbrand --- tools/testing/selftests/mm/uffd-unit-tests.c | 52 +++++++++++++++++--- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/tools/testing/selftests/mm/uffd-unit-tests.c b/tools/testing/selftests/mm/uffd-unit-tests.c index d871bf732e62..452ca05a829d 100644 --- a/tools/testing/selftests/mm/uffd-unit-tests.c +++ b/tools/testing/selftests/mm/uffd-unit-tests.c @@ -909,28 +909,65 @@ uffd_test_case_t uffd_tests[] = { }, }; +static void usage(const char *prog) +{ + printf("usage: %s [-f TESTNAME]\n", prog); + puts(""); + puts(" -f: test name to filter (e.g., event)"); + puts(" -h: show the help msg"); + puts(" -l: list tests only"); + puts(""); + exit(KSFT_FAIL); +} + int main(int argc, char *argv[]) { int n_tests = sizeof(uffd_tests) / sizeof(uffd_test_case_t); int n_mems = sizeof(mem_types) / sizeof(mem_type_t); + const char *test_filter = NULL; + bool list_only = false; uffd_test_case_t *test; mem_type_t *mem_type; uffd_test_args_t args; char test_name[128]; const char *errmsg; - int has_uffd; + int has_uffd, opt; int i, j; - has_uffd = test_uffd_api(false); - has_uffd |= test_uffd_api(true); + while ((opt = getopt(argc, argv, "f:hl")) != -1) { + switch (opt) { + case 'f': + test_filter = optarg; + break; + case 'l': + list_only = true; + break; + case 'h': + default: + /* Unknown */ + usage(argv[0]); + break; + } + } + + if (!test_filter && !list_only) { + has_uffd = test_uffd_api(false); + has_uffd |= test_uffd_api(true); - if (!has_uffd) { - printf("Userfaultfd not supported or unprivileged, skip all tests\n"); - exit(KSFT_SKIP); + if (!has_uffd) { + printf("Userfaultfd not supported or unprivileged, skip all tests\n"); + exit(KSFT_SKIP); + } } for (i = 0; i < n_tests; i++) { test = &uffd_tests[i]; + if (test_filter && !strstr(test->name, test_filter)) + continue; + if (list_only) { + printf("%s\n", test->name); + continue; + } for (j = 0; j < n_mems; j++) { mem_type = &mem_types[j]; if (!(test->mem_targets & mem_type->mem_flag)) @@ -952,7 +989,8 @@ int main(int argc, char *argv[]) } } - uffd_test_report(); + if (!list_only) + uffd_test_report(); return ksft_get_fail_cnt() ? KSFT_FAIL : KSFT_PASS; }