From patchwork Tue Jan 2 05:38:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Muhammad Usama Anjum X-Patchwork-Id: 13508834 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 5D2CCC46CD2 for ; Tue, 2 Jan 2024 05:40:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9E826B0202; Tue, 2 Jan 2024 00:40:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E4E9D6B0203; Tue, 2 Jan 2024 00:40:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D165C6B0204; Tue, 2 Jan 2024 00:40:11 -0500 (EST) 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 C2B646B0202 for ; Tue, 2 Jan 2024 00:40:11 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 93B4CA0527 for ; Tue, 2 Jan 2024 05:40:11 +0000 (UTC) X-FDA: 81633270222.30.C72B91B Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) by imf21.hostedemail.com (Postfix) with ESMTP id E5BAC1C0005 for ; Tue, 2 Jan 2024 05:40:09 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=whSikbQ4; spf=pass (imf21.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=quarantine) header.from=collabora.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1704174010; a=rsa-sha256; cv=none; b=ckvh+nMPH4ssulvlsX6HsOjFoG4LTY/kJTKWFREBM71r+sG2/4xvK15F2SocEe6aEldCEA W9PXJnuETIGiM25LzY+1hxkgQ+q8XbSFKq4yk5R7ZK8QChzZNxsuTmMf9+dixK4GQkoMsm JefarsR7KL6X89+fOlFE6ADkNL1ppiE= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=collabora.com header.s=mail header.b=whSikbQ4; spf=pass (imf21.hostedemail.com: domain of usama.anjum@collabora.com designates 46.235.227.194 as permitted sender) smtp.mailfrom=usama.anjum@collabora.com; dmarc=pass (policy=quarantine) header.from=collabora.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1704174010; 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:references:dkim-signature; bh=zgS0nhsyEozsVkfWhz0/qWUEiUkHq06d1FqI4K3Ua5c=; b=MsBCDugPSA8YwAYcMnKIMI3YylKZK0DihSqL+/Enkee1wOuri8LVvuyvq27wKtSTrGNmEO tOu/FXGepHTOqlv8nIaLtdCUZB6O1nusS+6+RcpuI58xRWYUJu1o3KsxoFu6omBHrN1cdw M8pVqOr0qBpeXcUm+IIttfmknfsb+24= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1704174008; bh=z6qn03b6LeS1LR8vScT4yPeTy8AttWujLJP3TbJX0Vw=; h=From:To:Cc:Subject:Date:From; b=whSikbQ41Fkmk4oTuvRCSAHHiZgyXRal1tLdj4xqOMH2SvWKPFQuxBSnI+uK4u8fS sOC1yGTVaDpdMee+w00DPVirYc8EzYNrShQ6Mu8EbxZPKlJBcJZ9AH7EvhjGm6s4Ox v9A/gJGT2v5dkXNxGAps9I1dpKJFHl0f6tRYTDzJCO9dBBd9EHVsv+VYoavGRqYWHf 3TAioQSAxXhTxF2twGpgxmqDzYP9LHjtC/UoVQk+hiigpnpLDNsKIYG0caIQxaILsK 6WZPXDJHLTVs7y1wICaZLsrMv18WBtTMk/BlnLyiVO2dr/FnZ9Jipm1qf0yqtPy1+h RAsZZoYMidT6g== Received: from localhost.localdomain (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: usama.anjum) by madrid.collaboradmins.com (Postfix) with ESMTPSA id A5C0A3780FC7; Tue, 2 Jan 2024 05:40:06 +0000 (UTC) From: Muhammad Usama Anjum To: Andrew Morton , Shuah Khan Cc: Muhammad Usama Anjum , kernel@collabora.com, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [Patch v2] selftests/mm: gup_test: conform test to TAP format output Date: Tue, 2 Jan 2024 10:38:06 +0500 Message-ID: <20240102053807.2114200-1-usama.anjum@collabora.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: E5BAC1C0005 X-Stat-Signature: 1dgj3x3rmo68e3dgatjqwwptq7g8e7gh X-Rspam-User: X-HE-Tag: 1704174009-594711 X-HE-Meta: U2FsdGVkX19kRMZE3zJu/6j3ahAYLJxDkjND7Rizeffdxtr4iqcy/kdiob4ebby/xdmCXFgNk8DpfgjM1udhATHuyS2zaa2Je5SdEp587XJyqEWJhvyp6YHKiFeAio109/Gdy/ADvbTKRMqMQTViUvwBcoe6OCUAJrCOlfMWF5K5XRUJp2tBIVUsQaw+tjAzeWli9v7j6qMvmwxN3vKi30yc+dMLDD30q+ChkwIXbHqQXFIMtowo49QmqgmzpZxAKXYVi+5yRQgimRbqX7IoKaqd+ofVr40rVjrb77J3DyIocKqTQJV7YSjB9R8YNgopUIEyE3cE9WJuEBlLSTfaUX94BOIdHOsoo8Kh0seAJoZuje9s8rf1KLxpfMPglobk7c6BfjlxH8xUAhEGqD/up/q2juT1tfqrr9XAeLTBZFVKuAk4tth+yqq0Ixc8htEpLsMFI5VepCtf6IojwSMA5kMCAxb99jwtQNFRbHypIEv0PXon9ut5aFMyyPRYFDy7Sq5glsAGViioanRXxyhatX4ue0GzSl2+7NctrwTwjumq/dhMEPeiWdOEbicGtNcsei08q7iGTwPtaLiPmjabSPQX8cJaGVJQgaAE3EUFXP44zOkQy7/TnMILhHWCHx44JTkmvZLgRiviNHRfXcVepiOC+EwK+zMlJlO+ewpCZyzbHDmPiSfGGDC7mVp/R2Yr9qz7cjzFAWi0qY2tNwa1ThWQscQ8FZT2SPfjlUd/+KPdBAFWu+1ogkr+t8ymE8TIEp5IWtsX8zKtsp2PmMno3rZ0Fws0pguPL9YpKtjHMnpUYuWLYSDc8XpqcZgtLlSElFhW0AOqkdGL73tzsaEr3Yx9sI0cByIx+F5JZumXrUHEEllwBnv5etldINX9VAtMkZ9aPSTQz8pil2eFY5puz1+rnMfFZ6iemtQ9jXKCgyUz6gDQb5eL5JrmfOF3V4AnEb4S9CZORuY6oTl5LUM l7KnUQPG IJOEpdcsYHSr5ZYyFlo3z+JJ9pH+Zd8RZoKKgSjkwibVgu8fovBhS2OEpJJRPSMZNgGfgbDtS9DP5sitf6CX+VFWigIqgXxk1e+5m5Rtlv4/Qe9DxmsGRz5bWmhOolVnbDaYfNtAOgyHQU4HRsn4qgK4gTIfbOvsKFJy3rX9ZoAnFTU/bXUBynQHohpNdcTR6QkMY4j2EhbWoazZD5QVRctfI7fLmnd/wj3F4gMostTwuoUsD6SeBUnkEMQpz1SOuYkCkDD1o2SKXlucxfULb+cj5vjYEYvNZPJBxevQcBbjA4E8= 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: Conform the layout, informational and status messages to TAP. No functional change is intended other than the layout of output messages. Signed-off-by: Muhammad Usama Anjum --- Changes since v1: - Fix typo - Update subject --- tools/testing/selftests/mm/gup_test.c | 65 ++++++++++++++------------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/tools/testing/selftests/mm/gup_test.c b/tools/testing/selftests/mm/gup_test.c index ec2229136384..cbe99594d319 100644 --- a/tools/testing/selftests/mm/gup_test.c +++ b/tools/testing/selftests/mm/gup_test.c @@ -50,39 +50,41 @@ static char *cmd_to_str(unsigned long cmd) void *gup_thread(void *data) { struct gup_test gup = *(struct gup_test *)data; - int i; + int i, status; /* Only report timing information on the *_BENCHMARK commands: */ if ((cmd == PIN_FAST_BENCHMARK) || (cmd == GUP_FAST_BENCHMARK) || (cmd == PIN_LONGTERM_BENCHMARK)) { for (i = 0; i < repeats; i++) { gup.size = size; - if (ioctl(gup_fd, cmd, &gup)) - perror("ioctl"), exit(1); + status = ioctl(gup_fd, cmd, &gup); + if (status) + break; pthread_mutex_lock(&print_mutex); - printf("%s: Time: get:%lld put:%lld us", - cmd_to_str(cmd), gup.get_delta_usec, - gup.put_delta_usec); + ksft_print_msg("%s: Time: get:%lld put:%lld us", + cmd_to_str(cmd), gup.get_delta_usec, + gup.put_delta_usec); if (gup.size != size) - printf(", truncated (size: %lld)", gup.size); - printf("\n"); + ksft_print_msg(", truncated (size: %lld)", gup.size); + ksft_print_msg("\n"); pthread_mutex_unlock(&print_mutex); } } else { gup.size = size; - if (ioctl(gup_fd, cmd, &gup)) { - perror("ioctl"); - exit(1); - } + status = ioctl(gup_fd, cmd, &gup); + if (status) + goto return_; pthread_mutex_lock(&print_mutex); - printf("%s: done\n", cmd_to_str(cmd)); + ksft_print_msg("%s: done\n", cmd_to_str(cmd)); if (gup.size != size) - printf("Truncated (size: %lld)\n", gup.size); + ksft_print_msg("Truncated (size: %lld)\n", gup.size); pthread_mutex_unlock(&print_mutex); } +return_: + ksft_test_result(!status, "ioctl status %d\n", status); return NULL; } @@ -170,7 +172,7 @@ int main(int argc, char **argv) touch = 1; break; default: - return -1; + ksft_exit_fail_msg("Wrong argument\n"); } } @@ -198,11 +200,12 @@ int main(int argc, char **argv) } } + ksft_print_header(); + ksft_set_plan(nthreads); + filed = open(file, O_RDWR|O_CREAT); - if (filed < 0) { - perror("open"); - exit(filed); - } + if (filed < 0) + ksft_exit_fail_msg("Unable to open %s: %s\n", file, strerror(errno)); gup.nr_pages_per_call = nr_pages; if (write) @@ -213,27 +216,24 @@ int main(int argc, char **argv) switch (errno) { case EACCES: if (getuid()) - printf("Please run this test as root\n"); + ksft_print_msg("Please run this test as root\n"); break; case ENOENT: - if (opendir("/sys/kernel/debug") == NULL) { - printf("mount debugfs at /sys/kernel/debug\n"); - break; - } - printf("check if CONFIG_GUP_TEST is enabled in kernel config\n"); + if (opendir("/sys/kernel/debug") == NULL) + ksft_print_msg("mount debugfs at /sys/kernel/debug\n"); + ksft_print_msg("check if CONFIG_GUP_TEST is enabled in kernel config\n"); break; default: - perror("failed to open " GUP_TEST_FILE); + ksft_print_msg("failed to open %s: %s\n", GUP_TEST_FILE, strerror(errno)); break; } - exit(KSFT_SKIP); + ksft_test_result_skip("Please run this test as root\n"); + return ksft_exit_pass(); } p = mmap(NULL, size, PROT_READ | PROT_WRITE, flags, filed, 0); - if (p == MAP_FAILED) { - perror("mmap"); - exit(1); - } + if (p == MAP_FAILED) + ksft_exit_fail_msg("mmap: %s\n", strerror(errno)); gup.addr = (unsigned long)p; if (thp == 1) @@ -264,7 +264,8 @@ int main(int argc, char **argv) ret = pthread_join(tid[i], NULL); assert(ret == 0); } + free(tid); - return 0; + return ksft_exit_pass(); }