From patchwork Fri Feb 14 11:35:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1237987 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=DNAszzNO; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48Jrtp1J1Vz9sNg for ; Fri, 14 Feb 2020 22:36:34 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 6D4863C2555 for ; Fri, 14 Feb 2020 12:36:31 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) by picard.linux.it (Postfix) with ESMTP id 6A8513C243C for ; Fri, 14 Feb 2020 12:36:12 +0100 (CET) Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 87CEC1A023CE for ; Fri, 14 Feb 2020 12:36:11 +0100 (CET) Received: by mail-pj1-x1041.google.com with SMTP id fa20so3786505pjb.1 for ; Fri, 14 Feb 2020 03:36:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Jr/cweVeFaJnzPNtHgLdjMUtCf9aKKlwzFJrsLxdFSI=; b=DNAszzNOhzYdcEK5pe75re7FbsrRtxT+L8KPWvO/tLI6OkbnHR2X8v0YVzZReMPwZC JSXRZf+iwv3ooBomdnKf83rudSPYgUDCEnHKOPhkON3tqkRP70iOlvBR558lkpTERP0q TNx+xHWPQbm0jhFPZvpczUVM8Sw0TLRktek33s5iRjMCT9/mxx0S3zZZ0votBMh+YEpv Ly2pJ+gCcXgu9vy2IMVQPYMaPe3JoVagyGrCGOXkuxUMIwk5sfIyk5c7JH9qB9l7V2Y+ qQjdFiFE5G12TUyNjA1FCi5m4NIkEuDuibrdbYM5inOs02iej3aMJzm/TKQZ6a/kYmFN LOPQ== 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:mime-version:content-transfer-encoding; bh=Jr/cweVeFaJnzPNtHgLdjMUtCf9aKKlwzFJrsLxdFSI=; b=oOviSPLC7v786qJpouz0T97Q78jx32UdyG7UDGcYMQJNEYQ3I3MxdM6csrQphuutkr ors7fFNlBaKoC25+YFERR2XmvUW48YYNsYdpVJ0lyclbtGNawIdtc/EBd7mjQkjSsed8 9NnPM05xa84wfXL0hdyn8pvDNvQsyXKHOkRcx6Bllfqh9HRAQo96Kkwp/aVoeyxBPOhY 2auaUIzbu8POJpcpetW0PSb9hjP4VeQnht8K6plwaUrw03Gp7UCJTr9K5WwOEnuAbUsU qtf/0brrEDLP6Ghqsv+bbKajEERMuZcupPfYVSwZhJ98UWDWvAfJrbTinMpfblSRU/sn 6uJA== X-Gm-Message-State: APjAAAVHO9vP6QrlqOaAqos/RU4HNlaadjizJy53YZfrSQXIxdxQZZdh a6JG5OtSxliDu4lDa3wKZF3QEg== X-Google-Smtp-Source: APXvYqxtSWSJcrl9m1W27Ki//aA3WTevHbA4qwicGf29I1yH9I6Y33LaOV7yQBzsWSV6NE41eS+5zg== X-Received: by 2002:a17:90b:243:: with SMTP id fz3mr3146256pjb.29.1581680169878; Fri, 14 Feb 2020 03:36:09 -0800 (PST) Received: from localhost ([122.167.210.63]) by smtp.gmail.com with ESMTPSA id 144sm6923720pfc.45.2020.02.14.03.36.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Feb 2020 03:36:09 -0800 (PST) From: Viresh Kumar To: Cyril Hrubis Date: Fri, 14 Feb 2020 17:05:51 +0530 Message-Id: X-Mailer: git-send-email 2.21.0.rc0.269.g1a574e7a288b In-Reply-To: References: MIME-Version: 1.0 X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, SPF_HELO_NONE, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH 2/7] syscalls/fsopen: New tests X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Viresh Kumar , Vincent Guittot , ltp@lists.linux.it, Vikas.Kumar2@arm.com Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Add tests to check working of fsopen() syscall. Signed-off-by: Viresh Kumar --- configure.ac | 1 + runtest/syscalls | 3 + testcases/kernel/syscalls/fsopen/.gitignore | 2 + testcases/kernel/syscalls/fsopen/Makefile | 6 ++ testcases/kernel/syscalls/fsopen/fsopen01.c | 71 +++++++++++++++++++++ testcases/kernel/syscalls/fsopen/fsopen02.c | 56 ++++++++++++++++ 6 files changed, 139 insertions(+) create mode 100644 testcases/kernel/syscalls/fsopen/.gitignore create mode 100644 testcases/kernel/syscalls/fsopen/Makefile create mode 100644 testcases/kernel/syscalls/fsopen/fsopen01.c create mode 100644 testcases/kernel/syscalls/fsopen/fsopen02.c diff --git a/configure.ac b/configure.ac index df4e8c8322fc..4125160a19bb 100644 --- a/configure.ac +++ b/configure.ac @@ -80,6 +80,7 @@ AC_CHECK_FUNCS([ \ execveat \ fallocate \ fchownat \ + fsopen \ fstatat \ getdents \ getdents64 \ diff --git a/runtest/syscalls b/runtest/syscalls index 0743cf4e3f74..0a56599ebad9 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -542,6 +542,9 @@ fanotify13 fanotify13 fanotify14 fanotify14 fanotify15 fanotify15 +fsopen01 fsopen01 +fsopen02 fsopen02 + ioperm01 ioperm01 ioperm02 ioperm02 diff --git a/testcases/kernel/syscalls/fsopen/.gitignore b/testcases/kernel/syscalls/fsopen/.gitignore new file mode 100644 index 000000000000..80089dd137a7 --- /dev/null +++ b/testcases/kernel/syscalls/fsopen/.gitignore @@ -0,0 +1,2 @@ +fsopen01 +fsopen02 diff --git a/testcases/kernel/syscalls/fsopen/Makefile b/testcases/kernel/syscalls/fsopen/Makefile new file mode 100644 index 000000000000..5ea7d67db123 --- /dev/null +++ b/testcases/kernel/syscalls/fsopen/Makefile @@ -0,0 +1,6 @@ +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk +include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/syscalls/fsopen/fsopen01.c b/testcases/kernel/syscalls/fsopen/fsopen01.c new file mode 100644 index 000000000000..3587c67636ea --- /dev/null +++ b/testcases/kernel/syscalls/fsopen/fsopen01.c @@ -0,0 +1,71 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Description: + * Basic fsopen() test which tries to configure and mount the filesystem as + * well. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" + +#define MNTPOINT "mntpoint" + +static void run(void) +{ + int fd, fsmfd; + + TEST(fsopen(tst_device->fs_type, 0)); + fd = TST_RET; + + if (fd == -1) + tst_brk(TFAIL | TERRNO, "fsopen() failed"); + + TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); + if (TST_RET == -1) { + tst_res(TBROK | TERRNO, "fsconfig() failed"); + goto out; + } + + TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); + if (TST_RET == -1) { + tst_res(TBROK | TERRNO, "fsconfig() failed"); + goto out; + } + + TEST(fsmount(fd, 0, 0)); + if (TST_RET == -1) { + tst_res(TBROK | TERRNO, "fsmount() failed"); + goto out; + } + + fsmfd = TST_RET; + + TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT, + MOVE_MOUNT_F_EMPTY_PATH)); + + SAFE_CLOSE(fsmfd); + + if (TST_RET == -1) { + tst_res(TBROK | TERRNO, "move_mount() failed"); + goto out; + } + + SAFE_CLOSE(TST_RET); + + TEST(umount(MNTPOINT)); + + tst_res(TPASS, "fsopen() passed"); + +out: + SAFE_CLOSE(fd); +} + +static struct tst_test test = { + .min_kver = "5.2", + .test_all = run, + .needs_root = 1, + .needs_tmpdir = 1, + .format_device = 1, + .mntpoint = MNTPOINT, +}; diff --git a/testcases/kernel/syscalls/fsopen/fsopen02.c b/testcases/kernel/syscalls/fsopen/fsopen02.c new file mode 100644 index 000000000000..6831a12c696b --- /dev/null +++ b/testcases/kernel/syscalls/fsopen/fsopen02.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Description: + * Basic fsopen() failure tests. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" + +const char *invalid_fs = "invalid"; +const char *valid_fs; + +static struct tcase { + char *name; + const char **fs; + unsigned int flags; + int exp_errno; +} tcases[] = { + {"invalid-fs", &invalid_fs, 0, ENODEV}, + {"invalid-flags", &valid_fs, 0x10, EINVAL}, +}; + +static void setup(void) +{ + valid_fs = tst_device->fs_type; +} + +static void run(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + + TEST(fsopen(*tc->fs, tc->flags)); + + if (TST_RET != -1) { + SAFE_CLOSE(TST_RET); + tst_brk(TFAIL, "%s: fsopen() succeeded unexpectedly (index: %d)", + tc->name, n); + } + + if (tc->exp_errno != TST_ERR) { + tst_brk(TFAIL | TTERRNO, "%s: fsopen() should fail with %s", + tc->name, tst_strerrno(tc->exp_errno)); + } + + tst_res(TPASS | TTERRNO, "%s: fsopen() failed as expected", tc->name); +} + +static struct tst_test test = { + .min_kver = "5.2", + .tcnt = ARRAY_SIZE(tcases), + .test = run, + .setup = setup, + .needs_root = 1, + .needs_device = 1, +};