From patchwork Wed Feb 19 09:27:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1240583 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=xmvkzEb8; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) by ozlabs.org (Postfix) with ESMTP id 48Mspd3XsHz9sRG for ; Wed, 19 Feb 2020 20:28:25 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 48AC13C2671 for ; Wed, 19 Feb 2020 10:28:24 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) by picard.linux.it (Postfix) with ESMTP id 2CFCD3C250F for ; Wed, 19 Feb 2020 10:28:19 +0100 (CET) Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 830171001569 for ; Wed, 19 Feb 2020 10:27:34 +0100 (CET) Received: by mail-pf1-x444.google.com with SMTP id 84so12211221pfy.6 for ; Wed, 19 Feb 2020 01:28:18 -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=KSAF2Jf76CZlQBJhVR9dDoyC1lUCNDBG/NtvxmbRwnE=; b=xmvkzEb8O9mZ0+GStG2tVLLEUu1yPx6Dy5mLTFjgwEvX9vpBuwEMax9+TppzUxcYQ9 SmRlhUklqJ+8MMgcvzdp6Eb0E54nuwpfRtjrdQvNuOJtpLn2ECjIvoHhCBLWLBKQNmEh Fx2Fl1yWxHpfTHdw7daRzKeeYJKTXmT54yYKytmwUBfvWYBZI0U2sJgUdeNjCvwa7j9G nn3fNQ2auuBZ1Qq8snN6Q2qnYyTMidjuWS6dzTYFe8hbKLPpeTpstWknuDu5MKfGd4h9 UBB9EurZ62oVi34/jZ1pPfZb+nkkhsoid64iCuBPm6aXSt/4drz9gfsU63IECe4nl6om lhqA== 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=KSAF2Jf76CZlQBJhVR9dDoyC1lUCNDBG/NtvxmbRwnE=; b=SPRCwkdcsZezaFY7R1MQgrI/C8BSe/wQQv66L9hNPYqvMWalAwZ92vXqvNBDUZWtU9 7ZPnirRKsEkvpRY05D3smu3mKYhcr0bq+d6P4rygl1EZBIf+OI70uwZ/H0+JMJ4Ul6zG ju6uyI+APrlzu+F+oJIf2UTxQkzMFlnXD/3GewFHhNQB/+1BmBClWATOcuSNEeDsA9Tc BFa6UU9E+6D+9VWulUpICA1zDC09F7a8Gxqe57XwYspcejQ9Kz90sipB+4kZ88BV3ZHx 8b75TfID/kmMHEDJXIg6wklOdTmuiL+D4+yJ0e+WkvawUMTY/eHtGrek22TexWdqBTHT 3wFw== X-Gm-Message-State: APjAAAXI+qv+DSPz9GsF0VncoDYBJ98ifak2n3l7d9ZeEN/ca3bMkzFr TO4xmjHypiPVyjJAS2T6r3ojoaSo2IM= X-Google-Smtp-Source: APXvYqwtC2foXIVAGFDtPk8mzxcB7OPdw+rWL6448LnO2N9/GVrk298tlwsVnfzyG8+68I0h1P2NSw== X-Received: by 2002:a63:7311:: with SMTP id o17mr6093017pgc.377.1582104496443; Wed, 19 Feb 2020 01:28:16 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id p23sm1974697pgn.92.2020.02.19.01.28.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Feb 2020 01:28:15 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Wed, 19 Feb 2020 14:57:57 +0530 Message-Id: <199f58740e42bbdbcba0c847c194f62d2b3bb37b.1582104018.git.viresh.kumar@linaro.org> 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-4.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-4.smtp.seeweb.it Subject: [LTP] [PATCH V2 01/10] tst_device: Add tst_ismount() helper 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: Vincent Guittot , Vikas.Kumar2@arm.com, Viresh Kumar Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This patch moves the ismount() helper added to the fsmount syscall tests to the standard library and renames it to tst_ismount(). The helper can be used across different files now. Minor modifications are also done to the helper. Signed-off-by: Viresh Kumar Acked-by: Li Wang Reviewed-by: Petr Vorel --- include/tst_device.h | 6 +++++ lib/tst_device.c | 25 +++++++++++++++++++ testcases/kernel/syscalls/fsmount/fsmount01.c | 25 +------------------ 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/include/tst_device.h b/include/tst_device.h index 3ad33bd48e10..3f4aaf6f75ab 100644 --- a/include/tst_device.h +++ b/include/tst_device.h @@ -36,6 +36,12 @@ extern struct tst_device *tst_device; */ int tst_umount(const char *path); +/* + * Verifies if an earlier mount is successful or not. + * @path: Mount path to verify + */ +int tst_ismount(const char *path); + /* * Clears a first few blocks of the device. This is needed when device has * already been formatted with a filesystems, subset of mkfs.foo utils aborts diff --git a/lib/tst_device.c b/lib/tst_device.c index 8b5459def1cb..4d66b5d45996 100644 --- a/lib/tst_device.c +++ b/lib/tst_device.c @@ -386,6 +386,31 @@ int tst_umount(const char *path) return -1; } +int tst_ismount(const char *path) +{ + char line[256]; + FILE *file; + int ret = -1; + + file = SAFE_FOPEN(NULL, "/proc/mounts", "r"); + + while (fgets(line, sizeof(line), file)) { + if (strstr(line, path) != NULL) { + ret = 0; + break; + } + } + + SAFE_FCLOSE(NULL, file); + + if (ret) { + errno = ENOENT; + tst_resm(TWARN, "No device is mounted at %s", path); + } + + return ret; +} + int find_stat_file(const char *dev, char *path, size_t path_len) { const char *devname = strrchr(dev, '/') + 1; diff --git a/testcases/kernel/syscalls/fsmount/fsmount01.c b/testcases/kernel/syscalls/fsmount/fsmount01.c index 83185b48aedd..5b8e95176728 100644 --- a/testcases/kernel/syscalls/fsmount/fsmount01.c +++ b/testcases/kernel/syscalls/fsmount/fsmount01.c @@ -12,30 +12,10 @@ #include "tst_test.h" #include "lapi/fcntl.h" #include "lapi/fsmount.h" -#include "tst_safe_stdio.h" -#define LINELENGTH 256 #define MNTPOINT "newmount_point" static int sfd, mfd, is_mounted; -static int ismount(char *mntpoint) -{ - int ret = 0; - FILE *file; - char line[LINELENGTH]; - - file = SAFE_FOPEN("/proc/mounts", "r"); - - while (fgets(line, sizeof(line), file)) { - if (strstr(line, mntpoint) != NULL) { - ret = 1; - break; - } - } - SAFE_FCLOSE(file); - return ret; -} - static void cleanup(void) { if (is_mounted) @@ -76,12 +56,9 @@ static void test_fsmount(void) tst_res(TPASS, "move_mount() attached to the mount point"); SAFE_CLOSE(mfd); - if (ismount(MNTPOINT)) { - tst_res(TPASS, "device mounted"); + if (!tst_ismount(MNTPOINT)) { SAFE_UMOUNT(MNTPOINT); is_mounted = 0; - } else { - tst_res(TFAIL, "device not mounted"); } } From patchwork Wed Feb 19 09:27:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1240584 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=ZhcwadaE; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) by ozlabs.org (Postfix) with ESMTP id 48Mspl4b7gz9sRN for ; Wed, 19 Feb 2020 20:28:31 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 7884D3C252C for ; Wed, 19 Feb 2020 10:28:30 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-6.smtp.seeweb.it (in-6.smtp.seeweb.it [IPv6:2001:4b78:1:20::6]) by picard.linux.it (Postfix) with ESMTP id 9A9E33C2637 for ; Wed, 19 Feb 2020 10:28:22 +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-6.smtp.seeweb.it (Postfix) with ESMTPS id 4754214019E3 for ; Wed, 19 Feb 2020 10:28:21 +0100 (CET) Received: by mail-pj1-x1041.google.com with SMTP id m7so1587807pjs.0 for ; Wed, 19 Feb 2020 01:28:21 -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=37QIktMIjjUwiyUPZlelPdMw0kydozoDLmaxlm4trCw=; b=ZhcwadaEG7+LcLUkoIZncsTAtJ0lb2WZZtlgC2eHxSGdkb/0NeNwY31r6jAFdJtBhs c7NOLNZoArcPnqE1kZ3Ujm+CNinlYkNKq+gViDKpQrdjZk5UUb9QPB+xbVlPE7p4Ae7Y C+g5PPbGWFJsMAkRD+7et/seixTAFRsjsluZjeAeyVqP6UUuS+tCqPFh2ibMVG65mU7+ yseglTMpphYwHBZYTQrsYpNE4HeU8smq9QNM2ioQq6W2obVQu6HiRIxMj/JYwgJ/GW+y io3nBhHzQqtyRsdNUeXopN5qNSjPvIUQgQCqtV2vqIkOsyQPGTc+LnEfiSGGd14q4eiG HXcA== 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=37QIktMIjjUwiyUPZlelPdMw0kydozoDLmaxlm4trCw=; b=Z9XatrYwNZXgZKIMyrA9VQrX2AiQe1FN1GZOk9QNjJMTXNeSR4g2FyqEfTfJd0qwZu BGK453Mjr9LYY8yh9BAK46BKGuqFPwnj1689wBdYWP0CmDyRNIxBpRhy05h7ILKcmY58 FtcoyX1PoArZ6SJK2QxzgZKIeAxfkc17s/gYvDDlv/Q/EssLDY4crc/YgFpQUKEivZdR +XZ6g1OD1Ol4VPuV8gT7un6NBDrQYLUvVkVlIyJ+djkBfa2hLTXVujTe6ujaWeKTlano WNuFe5Ry20eVaT4LEp5VJdGSbSOZkX6E9vEmpHr1pGuxiCRLubO4GcLtKGhkqVGyDupT 7cig== X-Gm-Message-State: APjAAAVWrB76wny8qlAxxWg5+DIDZnp3m9U28PMc0vEC1oC/AgiPXn46 9zNZcFy4bO2GO8Qj6+LLJa6MDzf9a20= X-Google-Smtp-Source: APXvYqw5a3/pa0wlZ6DtPjirnQ/z+mQpDsCwjAekVlofy6EYvwqlA7fV3nE0wdGgp5tcQFUoQeeReQ== X-Received: by 2002:a17:90a:c20d:: with SMTP id e13mr8001525pjt.95.1582104499428; Wed, 19 Feb 2020 01:28:19 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id b18sm2046132pfd.63.2020.02.19.01.28.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Feb 2020 01:28:18 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Wed, 19 Feb 2020 14:57:58 +0530 Message-Id: <8d552688d85a7acc62d654832ab7ce270a70cf77.1582104018.git.viresh.kumar@linaro.org> 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-6.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-6.smtp.seeweb.it Subject: [LTP] [PATCH V2 02/10] lapi/fsmount.h: Add fsopen_supported_by_kernel() 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: Vincent Guittot , Vikas.Kumar2@arm.com, Viresh Kumar Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Add a helper to check if the fsmount() related syscalls are supported by the kernel or not. Signed-off-by: Viresh Kumar Reviewed-by: Petr Vorel --- include/lapi/fsmount.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/lapi/fsmount.h b/include/lapi/fsmount.h index 87f2f229c371..e23b52e3733b 100644 --- a/include/lapi/fsmount.h +++ b/include/lapi/fsmount.h @@ -130,5 +130,14 @@ enum fsconfig_command { #endif /* OPEN_TREE_CLONE */ +void fsopen_supported_by_kernel(void) +{ + if ((tst_kvercmp(5, 2, 0)) < 0) { + /* Check if the syscall is backported on an older kernel */ + TEST(syscall(__NR_fsopen, NULL, 0)); + if (TST_RET == -1 && TST_ERR == ENOSYS) + tst_brk(TCONF, "Test not supporter on kernel version < v5.2"); + } +} #endif /* FSMOUNT_H__ */ From patchwork Wed Feb 19 09:27:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1240585 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=MSFe98gU; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) by ozlabs.org (Postfix) with ESMTP id 48Msps24VDz9sRG for ; Wed, 19 Feb 2020 20:28:37 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 1EE2B3C24DC for ; Wed, 19 Feb 2020 10:28:36 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) by picard.linux.it (Postfix) with ESMTP id 941AA3C2674 for ; Wed, 19 Feb 2020 10:28:24 +0100 (CET) Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 0AA13100156A for ; Wed, 19 Feb 2020 10:27:40 +0100 (CET) Received: by mail-pj1-x1042.google.com with SMTP id dw13so2319374pjb.4 for ; Wed, 19 Feb 2020 01:28:23 -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=7JdHcs/rJtMwFHG93wlvPUns98WiAWOm0Bdd5VO1cbQ=; b=MSFe98gUiimm8lL0EBjKu6FXCWyP0SU1LNmdgeZfWmp8VQYQvwc6DCezz9j2P4GYfv IhSfBkDYoXEOAIXq3+rqrLp+fjYi8jTgviOtTIbN+vY36Y0jMAvzs+Qkt/czLKmcXiMw reHMDWrXnQvU+JtFh7lwXEz4/srswg6q59GjjEfDg3zz3ZLOkTblE8wloQbxcYJF9+JG sQY3JgGlo1QksQ/9pR5c6wmKmV5fYq2rTM/H0Gk/ge8aJBZW6gGVxgio4dMyIECogIdc FhSQXXUCEh9vZaSKIgKCeOUFIM3ZVeOTGeHGNzo1lTVuqxpfA+RDKlA3mbdDOPgNIVKM oxjQ== 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=7JdHcs/rJtMwFHG93wlvPUns98WiAWOm0Bdd5VO1cbQ=; b=dhqVwyQQ/u0iA/lLfrWQEcMloxz1FsCPiIkQC7aIjhh0Exkyxl99E9qT8UYahKUVIo T3KHK67Y6W8HUnm12PPzIj+pM/sTghLIXYzWYmLUw028PIXZiTrn8JZ7oXKTnsp//lFE k94SVQfFa9xIyt1POdKeyD6lc2Lojud82LCdMLlhHN6JUs1gOqJ9dBjGtj1kUhaIybSf y4bvMhIRcpi0186Yner9ohttdsHt2lXpzsXxmYbo5A55ip+WyAIQ8RgAB4YrLGBwVZiv TeX7FZaLJKbAtHx3sYz02aAlb/VYHxz4DF45L4p9UH8e33PoctwNE4ed/PXXC3cGQUjA QZ2g== X-Gm-Message-State: APjAAAVt2uEUisXiDiGDwt2Wwo+jzl/jUIBx8LkQYEycSRyzqB3Z1kqO s74ygTpEs0s/sWEGcQuHb3uzapChIuQ= X-Google-Smtp-Source: APXvYqwhlDNWum8FZ5hbclp/V0T0mSS2nhuRj/BLlxCBGNi+0yYG3ZmzkVBR5QUv3W/yAChBCn3UdA== X-Received: by 2002:a17:902:8642:: with SMTP id y2mr24622819plt.306.1582104502116; Wed, 19 Feb 2020 01:28:22 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id x7sm2228786pfp.93.2020.02.19.01.28.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Feb 2020 01:28:21 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Wed, 19 Feb 2020 14:57:59 +0530 Message-Id: <12230a17d3574ad2a5cc88ce47451e378c66ce05.1582104018.git.viresh.kumar@linaro.org> 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-4.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-4.smtp.seeweb.it Subject: [LTP] [PATCH V2 03/10] lapi/fsmount.h: Include "lapi/fcntl.h" 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: Vincent Guittot , Vikas.Kumar2@arm.com, Viresh Kumar Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" All the files that include (and that will include it in future) are most probably going to need the definitions from "lapi/fcntl.h", include it directly instead of , which will break it for old RHL distros. Signed-off-by: Viresh Kumar --- include/lapi/fsmount.h | 2 +- testcases/kernel/syscalls/fsmount/fsmount01.c | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/include/lapi/fsmount.h b/include/lapi/fsmount.h index e23b52e3733b..49738fede5d6 100644 --- a/include/lapi/fsmount.h +++ b/include/lapi/fsmount.h @@ -7,12 +7,12 @@ #ifndef FSMOUNT_H__ #define FSMOUNT_H__ -#include #include #include #include #include "config.h" +#include "lapi/fcntl.h" #include "lapi/syscalls.h" #ifndef HAVE_FSOPEN diff --git a/testcases/kernel/syscalls/fsmount/fsmount01.c b/testcases/kernel/syscalls/fsmount/fsmount01.c index 5b8e95176728..c3cf8106f63b 100644 --- a/testcases/kernel/syscalls/fsmount/fsmount01.c +++ b/testcases/kernel/syscalls/fsmount/fsmount01.c @@ -10,7 +10,6 @@ #include #include "tst_test.h" -#include "lapi/fcntl.h" #include "lapi/fsmount.h" #define MNTPOINT "newmount_point" From patchwork Wed Feb 19 09:28:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1240586 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=2001:1418:10:5::2; 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=TyTTvWHD; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) by ozlabs.org (Postfix) with ESMTP id 48Msq00QZ4z9sRG for ; Wed, 19 Feb 2020 20:28:44 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id DD66B3C2678 for ; Wed, 19 Feb 2020 10:28:42 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id 7B6243C266D for ; Wed, 19 Feb 2020 10:28:27 +0100 (CET) Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id A1AF6601A87 for ; Wed, 19 Feb 2020 10:28:26 +0100 (CET) Received: by mail-pj1-x1042.google.com with SMTP id ep11so2322198pjb.2 for ; Wed, 19 Feb 2020 01:28:26 -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=UYfBKtQQzBJoNX1E0Q2BYfJlvIQKEtb6h+sddYnLKm0=; b=TyTTvWHD37aG4Oovtz/1hR5iKR/mwfSgwfK41M/xqlVKBnE6ZeZ731+ZrUAv2HFDWx Iv/wKLvDWQdiApLtR+UtvBcMmKHMTMCWJUMtr0LmeETJ5UEyTnKKOlPmHuzdpVoVPQqE RZL7ZK33pht4Zh6bWiNh2vWqaYGJn9Nf6mpeUUCpmPYIBO47oE/33/hikCtds7609wtl ECLpztTSdtrfnlGPLZNHI9PisoFYvFsYbaFjuo++6kyJS2WjAMjZ8bCZ97FVVsLXYW9n +dBEj8nVgMKpF32oCFxyFa5wXhlc77TXgSLjgaRjQ80V2BGSmFv1BcTS8+xu+ZmAQ5OI ZG9Q== 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=UYfBKtQQzBJoNX1E0Q2BYfJlvIQKEtb6h+sddYnLKm0=; b=Kj3Bqe6gKQEg+Xgdgp3I6Lifs3mXFygy4SHXy+13v1AvJ0dQCoz1gRwTBtt+F0O8E+ DUI7fGlaXZgEwhwrhA6KO6yVtxSmscNiqrT3ueEMndM6371LyLMXQj7B8r8IP8vY8h01 NF1IiRW47AqGLu65w6o0H4TlKIc9FzAZtpI02rCkAClITF6Ph+/lDOc00B5dFe/AfHXV wjNJoyT28uqq3Pg06fMRUXdr7qGxLnBFnU/27ZZdxts25yBdc+tQi/0Sr0yElw1hNdLM Gw1HjKyS9ihbEzdub/cRDyADGIkDpOJ5fCeSuFm1JTxMPIv+F50TCbYZ7vcHM5gh06zT 1UVw== X-Gm-Message-State: APjAAAVl8E/AakKbURKNxh4KYYnS3xywKsUBrvDsU7GpOr5nyzjQr+aI u9vSTs1y6ftZISFo4mhWC4nKwbPkLFA= X-Google-Smtp-Source: APXvYqwGxG0yDu405Pd93Qn1c/61ejwlL/4N6QdhKW6Hn5y9JDRIObDFFgLUBR8AtvwgIf3O1xordQ== X-Received: by 2002:a17:90a:f88:: with SMTP id 8mr8285240pjz.72.1582104504758; Wed, 19 Feb 2020 01:28:24 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id b4sm2094728pfd.18.2020.02.19.01.28.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Feb 2020 01:28:24 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Wed, 19 Feb 2020 14:58:00 +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-2.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-2.smtp.seeweb.it Subject: [LTP] [PATCH V2 04/10] 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: Vincent Guittot , Vikas.Kumar2@arm.com, Viresh Kumar 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 --- runtest/syscalls | 3 + testcases/kernel/syscalls/fsopen/.gitignore | 2 + testcases/kernel/syscalls/fsopen/Makefile | 6 ++ testcases/kernel/syscalls/fsopen/fsopen01.c | 85 +++++++++++++++++++++ testcases/kernel/syscalls/fsopen/fsopen02.c | 57 ++++++++++++++ 5 files changed, 153 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/runtest/syscalls b/runtest/syscalls index 72e729c1cee9..f113342f0ded 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -343,6 +343,9 @@ fremovexattr02 fremovexattr02 fsmount01 fsmount01 +fsopen01 fsopen01 +fsopen02 fsopen02 + fstat02 fstat02 fstat02_64 fstat02_64 fstat03 fstat03 diff --git a/testcases/kernel/syscalls/fsopen/.gitignore b/testcases/kernel/syscalls/fsopen/.gitignore new file mode 100644 index 000000000000..5da868621883 --- /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..2753e5066805 --- /dev/null +++ b/testcases/kernel/syscalls/fsopen/fsopen01.c @@ -0,0 +1,85 @@ +// 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 struct tcase { + char *name; + unsigned int flags; +} tcases[] = { + {"Flag 0", 0}, + {"Flag FSOPEN_CLOEXEC", FSOPEN_CLOEXEC}, +}; + +static void setup(void) +{ + fsopen_supported_by_kernel(); +} + +static void run(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + int fd, fsmfd; + + TEST(fsopen(tst_device->fs_type, tc->flags)); + 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; + } + + if (!tst_ismount(MNTPOINT)) + tst_res(TPASS, "%s: fsopen() passed", tc->name); + + SAFE_UMOUNT(MNTPOINT); + +out: + SAFE_CLOSE(fd); +} + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tcases), + .test = run, + .setup = setup, + .needs_root = 1, + .format_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .dev_fs_flags = TST_FS_SKIP_FUSE, +}; diff --git a/testcases/kernel/syscalls/fsopen/fsopen02.c b/testcases/kernel/syscalls/fsopen/fsopen02.c new file mode 100644 index 000000000000..72cb940c5468 --- /dev/null +++ b/testcases/kernel/syscalls/fsopen/fsopen02.c @@ -0,0 +1,57 @@ +// 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) +{ + fsopen_supported_by_kernel(); + + 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 = { + .tcnt = ARRAY_SIZE(tcases), + .test = run, + .setup = setup, + .needs_root = 1, + .needs_device = 1, +}; From patchwork Wed Feb 19 09:28:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1240587 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=2001:1418:10:5::2; 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=Pkk7kNdX; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) by ozlabs.org (Postfix) with ESMTP id 48Msq55pLzz9sRG for ; Wed, 19 Feb 2020 20:28:49 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 9B5323C266C for ; Wed, 19 Feb 2020 10:28:48 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [IPv6:2001:4b78:1:20::5]) by picard.linux.it (Postfix) with ESMTP id AA9B03C2668 for ; Wed, 19 Feb 2020 10:28:30 +0100 (CET) Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 7DBE56011A8 for ; Wed, 19 Feb 2020 10:28:29 +0100 (CET) Received: by mail-pj1-x1043.google.com with SMTP id 12so2290125pjb.5 for ; Wed, 19 Feb 2020 01:28:29 -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=WyhU0Fk6k8uSFFfLaeUrCc3dEwENzX1SqNeXJOac3pg=; b=Pkk7kNdXm7PRGkzP6rQSPhFiMHB4H3MOHcLmbBdlNebS7oDln6p0LS+ixDpJHLdKSg pkZRans5HzQtunGABu8Um38blw4Z+cFn2q7krPXCWgN+2k38GvORiFdOXaP3PwTInNQJ I9GAFv1ZT/iEj7gUQbPjf1BZhw64NQQ5FXHmwu8u9igntR25cenArevnTZFhQsLC3p05 A2okVJ8CED1+tGdGEMzKC+FFhew2SJBT8CFOAiqj5tkMt6hrJpJgODTGrOgHyyKiNp51 YWaTZnhuWCD/pfwfBfCuCNj64SzELWnvUINrLfzFWx3Uekf3lYv7B0NPPqrtOaRaADAt jYrQ== 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=WyhU0Fk6k8uSFFfLaeUrCc3dEwENzX1SqNeXJOac3pg=; b=GCc+T1vFbe/hWis9V/q2b5ohyQYMJ7ecJi7oBEv6y8TF3CBu+7iaNfhnxnLPzEPcta u1aaqPdYvOkWQ92B/YFOHzYojFLSfvBQQ4JsLv2Pmd2tC6/7CciIscGA7wDkxrv8y/9i ortwgzILeGOix5c5usncLxuWFKp6yNnB7QEqCUfsfvSeYMIosClOKePE0nWf4E9OvNx5 VI3G3XDVynViI0ULN5XCX1fdCLpiyOAIQ7IcmjV3eFg+7UgAJEnHBq9GtTktQyYEPJOH yIdYWREs6qWzxJ7F5fMxgdR0Y1izXAKfZtMPpE+U+8rMufXDw7gmM8tbmJO9IKop+qHP Fq8w== X-Gm-Message-State: APjAAAWfL6lw//6JekUilUiWIJjEW62YDfDIS9KaxtjsBNAD88lR7GTR zcURIoDQ11RjtHkGh4r2fuJ5k7GA/sc= X-Google-Smtp-Source: APXvYqyGoCYUxocJzF/NzYMUNuULxvgfXBagslT7TnIXpz+Zj80aE4vOFd1+7LXpj+aG0E9OtVGoqw== X-Received: by 2002:a17:90a:8043:: with SMTP id e3mr7744833pjw.24.1582104507754; Wed, 19 Feb 2020 01:28:27 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id f13sm1907388pgk.12.2020.02.19.01.28.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Feb 2020 01:28:26 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Wed, 19 Feb 2020 14:58:01 +0530 Message-Id: <6ac7573e8ea5ab6f0ab9256b73802126d72b5156.1582104018.git.viresh.kumar@linaro.org> 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-5.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-5.smtp.seeweb.it Subject: [LTP] [PATCH V2 05/10] syscalls/fsconfig: 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: Vincent Guittot , Vikas.Kumar2@arm.com, Viresh Kumar Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Add tests to check working of fsconfig() syscall. Signed-off-by: Viresh Kumar --- runtest/syscalls | 3 + testcases/kernel/syscalls/fsconfig/.gitignore | 2 + testcases/kernel/syscalls/fsconfig/Makefile | 6 + .../kernel/syscalls/fsconfig/fsconfig01.c | 110 ++++++++++++++++++ .../kernel/syscalls/fsconfig/fsconfig02.c | 100 ++++++++++++++++ 5 files changed, 221 insertions(+) create mode 100644 testcases/kernel/syscalls/fsconfig/.gitignore create mode 100644 testcases/kernel/syscalls/fsconfig/Makefile create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig01.c create mode 100644 testcases/kernel/syscalls/fsconfig/fsconfig02.c diff --git a/runtest/syscalls b/runtest/syscalls index f113342f0ded..4fcbd5f710eb 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -341,6 +341,9 @@ fpathconf01 fpathconf01 fremovexattr01 fremovexattr01 fremovexattr02 fremovexattr02 +fsconfig01 fsconfig01 +fsconfig02 fsconfig02 + fsmount01 fsmount01 fsopen01 fsopen01 diff --git a/testcases/kernel/syscalls/fsconfig/.gitignore b/testcases/kernel/syscalls/fsconfig/.gitignore new file mode 100644 index 000000000000..2bc54b82751b --- /dev/null +++ b/testcases/kernel/syscalls/fsconfig/.gitignore @@ -0,0 +1,2 @@ +/fsconfig01 +/fsconfig02 diff --git a/testcases/kernel/syscalls/fsconfig/Makefile b/testcases/kernel/syscalls/fsconfig/Makefile new file mode 100644 index 000000000000..5ea7d67db123 --- /dev/null +++ b/testcases/kernel/syscalls/fsconfig/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/fsconfig/fsconfig01.c b/testcases/kernel/syscalls/fsconfig/fsconfig01.c new file mode 100644 index 000000000000..96bf8eef8e4b --- /dev/null +++ b/testcases/kernel/syscalls/fsconfig/fsconfig01.c @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Description: + * Basic fsconfig() test which tries to configure and mount the filesystem as + * well. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" + +#define MNTPOINT "mntpoint" + +static void setup(void) +{ + fsopen_supported_by_kernel(); +} + +static void run(void) +{ + int fd, fsmfd; + + TEST(fsopen(tst_device->fs_type, 0)); + fd = TST_RET; + + if (fd == -1) + tst_brk(TBROK | TERRNO, "fsopen() failed"); + + TEST(fsconfig(fd, FSCONFIG_SET_FLAG, "rw", NULL, 0)); + if (TST_RET == -1) { + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + goto out; + } + + TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); + if (TST_RET == -1) { + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + goto out; + } + + TEST(fsconfig(fd, FSCONFIG_SET_PATH, "foo", tst_device->dev, AT_FDCWD)); + if (TST_RET == -1) { + if (TST_ERR == EOPNOTSUPP) { + tst_res(TINFO, "fsconfig(): FSCONFIG_SET_PATH not supported"); + } else { + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + goto out; + } + } + + TEST(fsconfig(fd, FSCONFIG_SET_PATH_EMPTY, "foo", tst_device->dev, AT_FDCWD)); + if (TST_RET == -1) { + if (TST_ERR == EOPNOTSUPP) { + tst_res(TINFO, "fsconfig(): FSCONFIG_SET_PATH_EMPTY not supported"); + } else { + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + goto out; + } + } + + TEST(fsconfig(fd, FSCONFIG_SET_FD, "foo", NULL, 0)); + if (TST_RET == -1) { + if (TST_ERR == EOPNOTSUPP) { + tst_res(TINFO, "fsconfig(): FSCONFIG_SET_FD not supported"); + } else { + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + goto out; + } + } + + TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); + if (TST_RET == -1) { + tst_res(TFAIL | 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; + } + + if (!tst_ismount(MNTPOINT)) + tst_res(TPASS, "fsconfig() passed"); + + SAFE_UMOUNT(MNTPOINT); + +out: + SAFE_CLOSE(fd); +} + +static struct tst_test test = { + .test_all = run, + .setup = setup, + .needs_root = 1, + .format_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .dev_fs_flags = TST_FS_SKIP_FUSE, +}; diff --git a/testcases/kernel/syscalls/fsconfig/fsconfig02.c b/testcases/kernel/syscalls/fsconfig/fsconfig02.c new file mode 100644 index 000000000000..b892f303690b --- /dev/null +++ b/testcases/kernel/syscalls/fsconfig/fsconfig02.c @@ -0,0 +1,100 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Description: + * Basic fsconfig() failure tests. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" + +int fd = -1, temp_fd = -1, invalid_fd = -1; +int aux_0 = 0, aux_1 = 1, aux_fdcwd = AT_FDCWD, aux_minus1 = -1; + +static struct tcase { + char *name; + int *fd; + unsigned int cmd; + const char *key; + const void *value; + int *aux; + int exp_errno; +} tcases[] = { + {"invalid-fd", &invalid_fd, FSCONFIG_SET_FLAG, "user_xattr", NULL, &aux_0, EINVAL}, + {"invalid-cmd", &fd, 100, "rw", NULL, &aux_0, EOPNOTSUPP}, + {"set-flag-key", &fd, FSCONFIG_SET_FLAG, NULL, NULL, &aux_0, EINVAL}, + {"set-flag-value", &fd, FSCONFIG_SET_FLAG, "rw", "foo", &aux_0, EINVAL}, + {"set-flag-aux", &fd, FSCONFIG_SET_FLAG, "rw", NULL, &aux_1, EINVAL}, + {"set-string-key", &fd, FSCONFIG_SET_STRING, NULL, "#grand.central.org:root.cell.", &aux_0, EINVAL}, + {"set-string-value", &fd, FSCONFIG_SET_STRING, "source", NULL, &aux_0, EINVAL}, + {"set-string-aux", &fd, FSCONFIG_SET_STRING, "source", "#grand.central.org:root.cell.", &aux_1, EINVAL}, + {"set-binary-key", &fd, FSCONFIG_SET_BINARY, NULL, "foo", &aux_1, EINVAL}, + {"set-binary-value", &fd, FSCONFIG_SET_BINARY, "sync", NULL, &aux_1, EINVAL}, + {"set-binary-aux", &fd, FSCONFIG_SET_BINARY, "sync", "foo", &aux_0, EINVAL}, + {"set-path-key", &fd, FSCONFIG_SET_PATH, NULL, "/dev/sda1", &aux_fdcwd, EINVAL}, + {"set-path-value", &fd, FSCONFIG_SET_PATH, "sync", NULL, &aux_fdcwd, EINVAL}, + {"set-path-aux", &fd, FSCONFIG_SET_PATH, "sync", "/dev/sda1", &aux_minus1, EINVAL}, + {"set-path-empty-key", &fd, FSCONFIG_SET_PATH_EMPTY, NULL, "/dev/foo", &aux_fdcwd, EINVAL}, + {"set-path-empty-value", &fd, FSCONFIG_SET_PATH_EMPTY, "sync", NULL, &aux_fdcwd, EINVAL}, + {"set-path-empty-aux", &fd, FSCONFIG_SET_PATH_EMPTY, "sync", "/dev/foo", &aux_minus1, EINVAL}, + {"set-fd-key", &fd, FSCONFIG_SET_FD, NULL, NULL, &temp_fd, EINVAL}, + {"set-fd-value", &fd, FSCONFIG_SET_FD, "sync", "foo", &temp_fd, EINVAL}, + {"set-fd-aux", &fd, FSCONFIG_SET_FD, "sync", NULL, &aux_minus1, EINVAL}, + {"cmd-create-key", &fd, FSCONFIG_CMD_CREATE, "foo", NULL, &aux_0, EINVAL}, + {"cmd-create-value", &fd, FSCONFIG_CMD_CREATE, NULL, "foo", &aux_0, EINVAL}, + {"cmd-create-aux", &fd, FSCONFIG_CMD_CREATE, NULL, NULL, &aux_1, EINVAL}, + {"cmd-reconfigure-key", &fd, FSCONFIG_CMD_RECONFIGURE, "foo", NULL, &aux_0, EINVAL}, + {"cmd-reconfigure-value", &fd, FSCONFIG_CMD_RECONFIGURE, NULL, "foo", &aux_0, EINVAL}, + {"cmd-reconfigure-aux", &fd, FSCONFIG_CMD_RECONFIGURE, NULL, NULL, &aux_1, EINVAL}, +}; + +static void setup(void) +{ + fsopen_supported_by_kernel(); + + TEST(fsopen(tst_device->fs_type, 0)); + fd = TST_RET; + + if (fd == -1) + tst_brk(TBROK | TERRNO, "fsopen() failed"); + + temp_fd = open("testfile", O_RDWR | O_CREAT, 01444); + if (temp_fd == -1) + tst_res(TBROK, "Can't obtain temp_fd, open() failed"); +} + +static void cleanup(void) +{ + if (temp_fd != -1) + SAFE_CLOSE(temp_fd); + if (fd != -1) + SAFE_CLOSE(fd); +} + +static void run(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + + TEST(fsconfig(*tc->fd, tc->cmd, tc->key, tc->value, *tc->aux)); + + if (TST_RET != -1) { + tst_brk(TFAIL, "%s: fsconfig() succeeded unexpectedly (index: %d)", + tc->name, n); + } + + if (tc->exp_errno != TST_ERR) { + tst_brk(TFAIL | TTERRNO, "%s: fsconfig() should fail with %s", + tc->name, tst_strerrno(tc->exp_errno)); + } + + tst_res(TPASS | TTERRNO, "%s: fsconfig() failed as expected", tc->name); +} + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tcases), + .test = run, + .setup = setup, + .cleanup = cleanup, + .needs_root = 1, + .needs_device = 1, +}; From patchwork Wed Feb 19 09:28:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1240588 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=Nb+WFIVB; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) by ozlabs.org (Postfix) with ESMTP id 48MsqG02CYz9sRG for ; Wed, 19 Feb 2020 20:28:57 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id CFA363C253A for ; Wed, 19 Feb 2020 10:28:56 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) by picard.linux.it (Postfix) with ESMTP id 1F1D53C25EC for ; Wed, 19 Feb 2020 10:28:33 +0100 (CET) Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 4FBC12011E5 for ; Wed, 19 Feb 2020 10:28:32 +0100 (CET) Received: by mail-pg1-x544.google.com with SMTP id z12so12442540pgl.4 for ; Wed, 19 Feb 2020 01:28:32 -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=AeobkxJ45t1g99CsX9IgecgtBneRGWUQ0ONyL/Xg7aQ=; b=Nb+WFIVBcTrpZ9R87Yv9bQSCMEr7Wo4AeafMM0NVtauN1z87qJN00WDm56PG8cx149 gDskCGxnP9r/lXVBq/l/eoyU3LxtEOj3eFBxxmRUdx9ruBJmAbAvdRjY7aL0pQ2O313O kWRuieee4xKDVQUoVMFWGFNmEm8NC/3g20gtgmCN6DacVezcXROTOMT/Zg2DuOWxyNJl gPFjcU5Gd+cM93GcuGH6LRW5AiGYVqbKCeIRDLGcTfEKztTQpXXtUsb0wZt7vWHIFpZA X5bkwarjpiaQSC+0zEFVXIlWBg6H/Hh+HNhC/Q/fP3JpGaVAtexBW66uxlTj/iEs/4Zw 9AyA== 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=AeobkxJ45t1g99CsX9IgecgtBneRGWUQ0ONyL/Xg7aQ=; b=g1QV645j5K5p8bGZVreQBmiFgUxh0ISYQ8nRwghC2vVdDuKrDLDFd8NmfaPOsRf4yA DSItVHZK2P4Px95efOlOaD0U1cS24tK9GGz0uj3RzcQQ15ImjC042yDvmVRGjQ37sxrW ju590wDMBcqdHwP58oQ5Cl5zHil/TY2gU4goTPkJo/KGfM2StgYW8L2865v2ZbukmpuI wFMyAd1xQwnbuWugfRclP9ec7ApxJYm53C+CnmRxmJ490xNNX3Rx1QTXx8VoHnVFtigi pqOvBFhG8sVctzJsEsJO84KaajoRo5vSxgaV9NDeZTTHWaXSYQmazTpJw0tHgOq3UZ+9 m8tw== X-Gm-Message-State: APjAAAU5uzXIi9lqvX12ZxVcF1Mcay1zPhP2O13WHal/tNpRQ7tzKIbm t4ou9qIrh6Fkyo7p8y/VihdlwrN8fkw= X-Google-Smtp-Source: APXvYqz0WfRk7QkPAyABKdprAgvZMSkaFugy2KWkMMp5aV/ep+8fn9DCQD6bp5f7vzyGd7qVVgWhtw== X-Received: by 2002:a63:5508:: with SMTP id j8mr26365592pgb.170.1582104510378; Wed, 19 Feb 2020 01:28:30 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id y6sm1865612pgc.10.2020.02.19.01.28.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Feb 2020 01:28:29 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Wed, 19 Feb 2020 14:58:02 +0530 Message-Id: <9706f359006ea409d2f85c111d3e001ca6f6d128.1582104018.git.viresh.kumar@linaro.org> 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-7.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-7.smtp.seeweb.it Subject: [LTP] [PATCH V2 06/10] syscalls/fsmount: Improve fsmount01 test 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: Vincent Guittot , Vikas.Kumar2@arm.com, Viresh Kumar Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This patch updates the fsmount01.c file to make it look similar to all other fsmount related syscall tests and here is the list of all changes: - Test all fsmount flags and mount attributes - Remove extra PASS messages as all we want to test here is fsmount() and not other syscalls. - On the same lines, print TFAIL for fsmount() syscall and TBROK for other calls. - close sfd on failures - Make the file look similar to other fsmount related tests - General cleanup Signed-off-by: Viresh Kumar --- testcases/kernel/syscalls/fsmount/fsmount01.c | 92 ++++++++++++------- 1 file changed, 60 insertions(+), 32 deletions(-) diff --git a/testcases/kernel/syscalls/fsmount/fsmount01.c b/testcases/kernel/syscalls/fsmount/fsmount01.c index c3cf8106f63b..b746a14ba472 100644 --- a/testcases/kernel/syscalls/fsmount/fsmount01.c +++ b/testcases/kernel/syscalls/fsmount/fsmount01.c @@ -3,67 +3,95 @@ * Copyright (C) 2020 Red Hat, Inc. All rights reserved. * Author: Zorro Lang * - * Use new mount API from v5.2 (fsopen(), fsconfig(), fsmount(), move_mount()) - * to mount a filesystem without any specified mount options. + * Description: + * Basic fsmount() test. */ -#include - #include "tst_test.h" #include "lapi/fsmount.h" -#define MNTPOINT "newmount_point" -static int sfd, mfd, is_mounted; +#define MNTPOINT "mntpoint" + +static struct tcase { + char *name; + unsigned int flags; + unsigned int mount_attrs; +} tcases[] = { + {"Flag 0, attr RDONLY", 0, MOUNT_ATTR_RDONLY}, + {"Flag 0, attr NOSUID", 0, MOUNT_ATTR_NOSUID}, + {"Flag 0, attr NODEV", 0, MOUNT_ATTR_NODEV}, + {"Flag 0, attr NOEXEC", 0, MOUNT_ATTR_NOEXEC}, + {"Flag 0, attr RELATIME", 0, MOUNT_ATTR_RELATIME}, + {"Flag 0, attr NOATIME", 0, MOUNT_ATTR_NOATIME}, + {"Flag 0, attr STRICTATIME", 0, MOUNT_ATTR_STRICTATIME}, + {"Flag 0, attr NODIRATIME", 0, MOUNT_ATTR_NODIRATIME}, + {"Flag CLOEXEC, attr RDONLY", FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY}, + {"Flag CLOEXEC, attr NOSUID", FSMOUNT_CLOEXEC, MOUNT_ATTR_NOSUID}, + {"Flag CLOEXEC, attr NODEV", FSMOUNT_CLOEXEC, MOUNT_ATTR_NODEV}, + {"Flag CLOEXEC, attr NOEXEC", FSMOUNT_CLOEXEC, MOUNT_ATTR_NOEXEC}, + {"Flag CLOEXEC, attr RELATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_RELATIME}, + {"Flag CLOEXEC, attr NOATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_NOATIME}, + {"Flag CLOEXEC, attr STRICTATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_STRICTATIME}, + {"Flag CLOEXEC, attr NODIRATIME", FSMOUNT_CLOEXEC, MOUNT_ATTR_NODIRATIME}, +}; -static void cleanup(void) +static void setup(void) { - if (is_mounted) - SAFE_UMOUNT(MNTPOINT); + fsopen_supported_by_kernel(); } -static void test_fsmount(void) +static void run(unsigned int n) { + struct tcase *tc = &tcases[n]; + int sfd, mfd; + TEST(fsopen(tst_device->fs_type, FSOPEN_CLOEXEC)); - if (TST_RET < 0) - tst_brk(TBROK | TTERRNO, "fsopen() on %s failed", tst_device->fs_type); + if (TST_RET == -1) { + tst_brk(TBROK | TTERRNO, "fsopen() on %s failed", + tst_device->fs_type); + } sfd = TST_RET; - tst_res(TPASS, "fsopen() on %s", tst_device->fs_type); TEST(fsconfig(sfd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); - if (TST_RET < 0) + if (TST_RET < 0) { + SAFE_CLOSE(sfd); tst_brk(TBROK | TTERRNO, "fsconfig() failed to set source to %s", tst_device->dev); - tst_res(TPASS, "fsconfig() set source to %s", tst_device->dev); - + } TEST(fsconfig(sfd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); - if (TST_RET < 0) + if (TST_RET < 0) { + SAFE_CLOSE(sfd); tst_brk(TBROK | TTERRNO, "fsconfig() created superblock"); - tst_res(TPASS, "fsconfig() created superblock"); + } - TEST(fsmount(sfd, FSMOUNT_CLOEXEC, 0)); - if (TST_RET < 0) - tst_brk(TBROK | TTERRNO, "fsmount() failed to create a mount object"); - mfd = TST_RET; - tst_res(TPASS, "fsmount() created a mount object"); + TEST(fsmount(sfd, tc->flags, tc->mount_attrs)); SAFE_CLOSE(sfd); + if (TST_RET < 0) { + tst_brk(TFAIL | TTERRNO, + "fsmount() failed to create a mount object"); + } + mfd = TST_RET; + TEST(move_mount(mfd, "", AT_FDCWD, MNTPOINT, MOVE_MOUNT_F_EMPTY_PATH)); - if (TST_RET < 0) - tst_brk(TBROK | TTERRNO, "move_mount() failed to attach to the mount point"); - is_mounted = 1; - tst_res(TPASS, "move_mount() attached to the mount point"); SAFE_CLOSE(mfd); - if (!tst_ismount(MNTPOINT)) { - SAFE_UMOUNT(MNTPOINT); - is_mounted = 0; + if (TST_RET < 0) { + tst_brk(TBROK | TTERRNO, + "move_mount() failed to attach to the mount point"); } + + if (!tst_ismount(MNTPOINT)) + tst_res(TPASS, "%s: fsmount() passed", tc->name); + + SAFE_UMOUNT(MNTPOINT); } static struct tst_test test = { - .test_all = test_fsmount, - .cleanup = cleanup, + .tcnt = ARRAY_SIZE(tcases), + .test = run, + .setup = setup, .needs_root = 1, .mntpoint = MNTPOINT, .format_device = 1, From patchwork Wed Feb 19 09:28:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1240589 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=Oxgz8A04; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) by ozlabs.org (Postfix) with ESMTP id 48MsqQ5GDpz9sRG for ; Wed, 19 Feb 2020 20:29:06 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 851C23C2671 for ; Wed, 19 Feb 2020 10:29:05 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) by picard.linux.it (Postfix) with ESMTP id 99E413C2456 for ; Wed, 19 Feb 2020 10:28:35 +0100 (CET) Received: from mail-pl1-x643.google.com (mail-pl1-x643.google.com [IPv6:2607:f8b0:4864:20::643]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id DAB482011F9 for ; Wed, 19 Feb 2020 10:28:34 +0100 (CET) Received: by mail-pl1-x643.google.com with SMTP id b22so9314807pls.12 for ; Wed, 19 Feb 2020 01:28:34 -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=7gREXfolvfhmnQd7pj0HqIASlKZzAy/ZKCGdWJkQEcY=; b=Oxgz8A041sChJwpfQmksyKq46v9QVf8l8dfapeMba3IMPeeO6pmEmNHDgu0thE4SQx /faVzOoSpFLCpZVO6MH1N92qvRW1TBP5fj3uCGELKhhbEXikvmNgo9EDa3LMlS9cExj+ vFLP0F8OglWJ6dxl/WMTL0OduMlEsW5Sm0bUoyZc6/aBoYapCiGn9utjQ3oicSAEWwkx Rx/zNjHglrsKANVV7uGQIIxPvkRJCv27ZMKSbUej/EGaXFI67To6KIgNEcm+/elnICEf trdMFMX+xwpf82idMXZeMpzvxbroE7NC2QF/bVNCGUcJzaf/7I4NbXNiskzepcAc3ijK bS2g== 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=7gREXfolvfhmnQd7pj0HqIASlKZzAy/ZKCGdWJkQEcY=; b=k5E55/brEJ6HHgd5/QVuUXf41sQwKCi5NaEacIBOXLR3CYYbx5Pghz6umkfKjU0On8 cZ/QegioXCDzLyE35+8CKUvmsh1n9Od/LTBjIyLwIRVHoGKbTeQFgB6bF6QOhDE4+4yB D6S61BOJHCohjSPsmrZ5cs3kt5xkeIjTWAEDycdNAZwbuOXIbPHkvmREL+RLqrY/ZN11 iMkwN8v/71hb0u5oi1JwnKFf+PQi6CdT0W0pzz/GoMnLtYMUnM5XX5l6oeMhnpOC+PGM BvG25aTB9LbOu6c+lZJPN96Uz20CYpsio5BRGUd70OfkfyxKP91LQk8HTBDztTVoBrKU 4/0Q== X-Gm-Message-State: APjAAAXsmokjfD6AE2z3jgphSjbUlzjKDmdjzd/DiNQaj/9CoHpuZyKU 0r9jhbkBsPmu08Z1S7KXQFHSggSscNs= X-Google-Smtp-Source: APXvYqwK6o1aqbCpu2NopnPvXm8qA5MZjIgUCAG9TzPirVW5ML/NpKlS3Umhfh+hHRYg3jJygnGesw== X-Received: by 2002:a17:90a:e389:: with SMTP id b9mr7900052pjz.7.1582104512977; Wed, 19 Feb 2020 01:28:32 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id az9sm1781589pjb.3.2020.02.19.01.28.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Feb 2020 01:28:32 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Wed, 19 Feb 2020 14:58:03 +0530 Message-Id: <98ee754dfa93fa8e9d026fd8aa57ac1c4a94795c.1582104018.git.viresh.kumar@linaro.org> 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-7.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-7.smtp.seeweb.it Subject: [LTP] [PATCH V2 07/10] syscalls/fsmount: Add failure 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: Vincent Guittot , Vikas.Kumar2@arm.com, Viresh Kumar Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" This adds fsmount02.c tests to verify all the errors returned on failures. Signed-off-by: Viresh Kumar --- runtest/syscalls | 1 + testcases/kernel/syscalls/fsmount/.gitignore | 1 + testcases/kernel/syscalls/fsmount/fsmount02.c | 81 +++++++++++++++++++ 3 files changed, 83 insertions(+) create mode 100644 testcases/kernel/syscalls/fsmount/fsmount02.c diff --git a/runtest/syscalls b/runtest/syscalls index 4fcbd5f710eb..5b652a518dc6 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -345,6 +345,7 @@ fsconfig01 fsconfig01 fsconfig02 fsconfig02 fsmount01 fsmount01 +fsmount02 fsmount02 fsopen01 fsopen01 fsopen02 fsopen02 diff --git a/testcases/kernel/syscalls/fsmount/.gitignore b/testcases/kernel/syscalls/fsmount/.gitignore index e2f01ea17a40..7b77c5e33ee6 100644 --- a/testcases/kernel/syscalls/fsmount/.gitignore +++ b/testcases/kernel/syscalls/fsmount/.gitignore @@ -1 +1,2 @@ /fsmount01 +/fsmount02 diff --git a/testcases/kernel/syscalls/fsmount/fsmount02.c b/testcases/kernel/syscalls/fsmount/fsmount02.c new file mode 100644 index 000000000000..cdb43612ae75 --- /dev/null +++ b/testcases/kernel/syscalls/fsmount/fsmount02.c @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Description: + * Basic fsmount() failure tests. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" + +int fd = -1, invalid_fd = -1; + +#define MNTPOINT "mntpoint" + +static struct tcase { + char *name; + int *fd; + unsigned int flags; + unsigned int mount_attrs; + int exp_errno; +} tcases[] = { + {"invalid-fd", &invalid_fd, FSMOUNT_CLOEXEC, 0, EBADF}, + {"invalid-flags", &fd, 0x02, 0, EINVAL}, + {"invalid-attrs", &fd, FSMOUNT_CLOEXEC, 0x100, EINVAL}, +}; + +static void cleanup(void) +{ + if (fd != -1) + SAFE_CLOSE(fd); +} + +static void setup(void) +{ + fsopen_supported_by_kernel(); + + TEST(fsopen(tst_device->fs_type, 0)); + fd = TST_RET; + + if (fd == -1) + tst_brk(TBROK | TERRNO, "fsopen() failed"); + + TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); + if (TST_RET == -1) + tst_brk(TBROK | TERRNO, "fsconfig() failed"); + + TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); + if (TST_RET == -1) + tst_brk(TBROK | TERRNO, "fsconfig() failed"); +} + +static void run(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + + TEST(fsmount(*tc->fd, tc->flags, tc->mount_attrs)); + if (TST_RET != -1) { + SAFE_CLOSE(TST_RET); + tst_brk(TFAIL, "%s: fsmount() succeeded unexpectedly (index: %d)", + tc->name, n); + } + + if (tc->exp_errno != TST_ERR) { + tst_brk(TFAIL | TTERRNO, "%s: fsmount() should fail with %s", + tc->name, tst_strerrno(tc->exp_errno)); + } + + tst_res(TPASS | TTERRNO, "%s: fsmount() failed as expected", tc->name); +} + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tcases), + .test = run, + .setup = setup, + .cleanup = cleanup, + .needs_root = 1, + .mntpoint = MNTPOINT, + .format_device = 1, + .all_filesystems = 1, + .dev_fs_flags = TST_FS_SKIP_FUSE, +}; From patchwork Wed Feb 19 09:28:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1240590 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=2001:1418:10:5::2; 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=n+XMJGyc; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) by ozlabs.org (Postfix) with ESMTP id 48MsqX2stbz9sRN for ; Wed, 19 Feb 2020 20:29:12 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 2FAD43C2660 for ; Wed, 19 Feb 2020 10:29:11 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) by picard.linux.it (Postfix) with ESMTP id 5F3393C2660 for ; Wed, 19 Feb 2020 10:28:38 +0100 (CET) Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 8A52F601A8D for ; Wed, 19 Feb 2020 10:28:37 +0100 (CET) Received: by mail-pf1-x42d.google.com with SMTP id b185so1885372pfb.7 for ; Wed, 19 Feb 2020 01:28:37 -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=mYk4HhhSj5J6dj0io4itYe7fmPlptTvjQxQ41LwlCmk=; b=n+XMJGycxaSKgQb+dorRcbrZpytHdPIRyibdmTS83bNq5IyZI1yX1Ii8bp0bxk1Wxd gUrZlsHueTUkVHYuuGJkTUEJvmcjthPhWReFem768aCsnrQsjclAgvxVJQONZUQLUxkT FTBzR9lLZ/UDD3sFirvUcWvRVZl9MioyJAaYk3YPLq8MQZY3edrIrdBerVQSvPldqMrw txd5QmlUkUaFjdBEaVtoZASQcqWx/7Aa5+p4gnLmU+wE/bfP16hibO1mrc1Js/lN1lMR 6hXVF8ZZxDuO2ub0Bulvl5NRAsJ06IW+4T3qNlCoEypwS/1jWohEqHZeq/Oes9O2gqzH x0uA== 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=mYk4HhhSj5J6dj0io4itYe7fmPlptTvjQxQ41LwlCmk=; b=PCECRYIXoODWaFtk5B/C4nmXiNomuF6YyV+oh6E3HmnpABsCXzPwwWJFIfTLlVe4qs QmgHwdOmMfWuL73BbsKyH51l68rReIJf0mmzeR7UuAkUZY86U7FNb7hhMKpCgqiymEnu oi/1lu3uCzcEIy8eLWcPEdQhrfihXdcHkwi6Jyo8g7mX0wX1mP4bSVsrqJnwIkhqURyt oy7wO7n2oJvBmEQV+rIfxNl9p1d4hjKJsOpXstXXQw/iYn0g2pP7jJNu3uYxi+BGVGxT D2pKmqWd0UNVRUUwJl3iAxSni0zwRYZi3pPZ4JclgKX89CA9aT3LAHF3Uae+/YFkh1mX b2MQ== X-Gm-Message-State: APjAAAXQXc7dRU9I9vkPXScfXXqnk+47QBkrR3jJbezK/FD2/M+3o0Wv 1mMAPjCNLmUVZ3AkqwwlASEhjJ/Ft+0= X-Google-Smtp-Source: APXvYqwuqsLhggpUMSqJWT/pDiaFfe9Dm01ujHqrVxEq7KHPtk44iubdLU5GwEIWPy3nMJo2HMWH0A== X-Received: by 2002:a63:990a:: with SMTP id d10mr27955037pge.63.1582104515660; Wed, 19 Feb 2020 01:28:35 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id f13sm2206674pfk.64.2020.02.19.01.28.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Feb 2020 01:28:35 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Wed, 19 Feb 2020 14:58:04 +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-2.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-2.smtp.seeweb.it Subject: [LTP] [PATCH V2 08/10] syscalls/move_mount: 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: Vincent Guittot , Vikas.Kumar2@arm.com, Viresh Kumar Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Add tests to check working of move_mount() syscall. Signed-off-by: Viresh Kumar --- runtest/syscalls | 3 + .../kernel/syscalls/move_mount/.gitignore | 2 + testcases/kernel/syscalls/move_mount/Makefile | 6 ++ .../kernel/syscalls/move_mount/move_mount01.c | 82 ++++++++++++++++ .../kernel/syscalls/move_mount/move_mount02.c | 93 +++++++++++++++++++ 5 files changed, 186 insertions(+) create mode 100644 testcases/kernel/syscalls/move_mount/.gitignore create mode 100644 testcases/kernel/syscalls/move_mount/Makefile create mode 100644 testcases/kernel/syscalls/move_mount/move_mount01.c create mode 100644 testcases/kernel/syscalls/move_mount/move_mount02.c diff --git a/runtest/syscalls b/runtest/syscalls index 5b652a518dc6..f207a73c3e6d 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -731,6 +731,9 @@ mount04 mount04 mount05 mount05 mount06 mount06 +move_mount01 move_mount01 +move_mount02 move_mount02 + move_pages01 move_pages01 move_pages02 move_pages02 move_pages03 move_pages03 diff --git a/testcases/kernel/syscalls/move_mount/.gitignore b/testcases/kernel/syscalls/move_mount/.gitignore new file mode 100644 index 000000000000..83ae40145dff --- /dev/null +++ b/testcases/kernel/syscalls/move_mount/.gitignore @@ -0,0 +1,2 @@ +/move_mount01 +/move_mount02 diff --git a/testcases/kernel/syscalls/move_mount/Makefile b/testcases/kernel/syscalls/move_mount/Makefile new file mode 100644 index 000000000000..5ea7d67db123 --- /dev/null +++ b/testcases/kernel/syscalls/move_mount/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/move_mount/move_mount01.c b/testcases/kernel/syscalls/move_mount/move_mount01.c new file mode 100644 index 000000000000..ff281e0c565b --- /dev/null +++ b/testcases/kernel/syscalls/move_mount/move_mount01.c @@ -0,0 +1,82 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Description: + * Basic move_mount() test. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" + +#define MNTPOINT "mntpoint" + +static struct tcase { + char *name; + unsigned int flags; +} tcases[] = { + {"Flag MOVE_MOUNT_F_SYMLINKS", MOVE_MOUNT_F_SYMLINKS}, + {"Flag MOVE_MOUNT_F_AUTOMOUNTS", MOVE_MOUNT_F_AUTOMOUNTS}, + {"Flag MOVE_MOUNT_F_EMPTY_PATH", MOVE_MOUNT_F_EMPTY_PATH}, + {"Flag MOVE_MOUNT_T_SYMLINKS", MOVE_MOUNT_T_SYMLINKS}, + {"Flag MOVE_MOUNT_T_AUTOMOUNTS", MOVE_MOUNT_T_AUTOMOUNTS}, + {"Flag MOVE_MOUNT_T_EMPTY_PATH", MOVE_MOUNT_T_EMPTY_PATH}, +}; + +static void setup(void) +{ + fsopen_supported_by_kernel(); +} + +static void run(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + int fsmfd, fd; + + TEST(fsopen(tst_device->fs_type, 0)); + fd = TST_RET; + + if (fd == -1) + tst_brk(TBROK | TERRNO, "fsopen() failed"); + + TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_brk(TBROK | TERRNO, "fsconfig() failed"); + } + + TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_brk(TBROK | TERRNO, "fsconfig() failed"); + } + + TEST(fsmount(fd, 0, 0)); + SAFE_CLOSE(fd); + + if (TST_RET == -1) + tst_brk(TBROK | TERRNO, "fsmount() failed"); + + fsmfd = TST_RET; + TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT, + tc->flags | MOVE_MOUNT_F_EMPTY_PATH)); + SAFE_CLOSE(fsmfd); + + if (TST_RET == -1) + tst_brk(TFAIL | TERRNO, "move_mount() failed"); + + if (!tst_ismount(MNTPOINT)) + tst_res(TPASS, "%s: move_mount() passed", tc->name); + + SAFE_UMOUNT(MNTPOINT); +} + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tcases), + .test = run, + .setup = setup, + .needs_root = 1, + .format_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .dev_fs_flags = TST_FS_SKIP_FUSE, +}; diff --git a/testcases/kernel/syscalls/move_mount/move_mount02.c b/testcases/kernel/syscalls/move_mount/move_mount02.c new file mode 100644 index 000000000000..805a098bfac5 --- /dev/null +++ b/testcases/kernel/syscalls/move_mount/move_mount02.c @@ -0,0 +1,93 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Description: + * Basic move_mount() failure tests. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" + +#define MNTPOINT "mntpoint" + +int invalid_fd = -1, fsmfd; + +static struct tcase { + char *name; + int *from_dirfd; + const char *from_pathname; + int to_dirfd; + const char *to_pathname; + unsigned int flags; + int exp_errno; +} tcases[] = { + {"invalid-from-fd", &invalid_fd, "", AT_FDCWD, MNTPOINT, MOVE_MOUNT_F_EMPTY_PATH, EBADF}, + {"invalid-from-path", &fsmfd, "invalid", AT_FDCWD, MNTPOINT, MOVE_MOUNT_F_EMPTY_PATH, ENOENT}, + {"invalid-to-fd", &fsmfd, "", -1, MNTPOINT, MOVE_MOUNT_F_EMPTY_PATH, EBADF}, + {"invalid-to-path", &fsmfd, "", AT_FDCWD, "invalid", MOVE_MOUNT_F_EMPTY_PATH, ENOENT}, + {"invalid-flags", &fsmfd, "", AT_FDCWD, MNTPOINT, 0x08, EINVAL}, +}; + +static void setup(void) +{ + fsopen_supported_by_kernel(); +} + +static void run(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + int fd; + + TEST(fsopen(tst_device->fs_type, 0)); + fd = TST_RET; + + if (fd == -1) + tst_brk(TBROK | TERRNO, "fsopen() failed"); + + TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_brk(TBROK | TERRNO, "fsconfig() failed"); + } + + TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_brk(TBROK | TERRNO, "fsconfig() failed"); + } + + TEST(fsmount(fd, 0, 0)); + SAFE_CLOSE(fd); + + if (TST_RET == -1) + tst_brk(TBROK | TERRNO, "fsmount() failed"); + + fsmfd = TST_RET; + TEST(move_mount(*tc->from_dirfd, tc->from_pathname, tc->to_dirfd, + tc->to_pathname, tc->flags)); + SAFE_CLOSE(fsmfd); + + if (TST_RET != -1) { + SAFE_UMOUNT(MNTPOINT); + tst_brk(TFAIL, "%s: move_mount() succeeded unexpectedly (index: %d)", + tc->name, n); + } + + if (tc->exp_errno != TST_ERR) { + tst_brk(TFAIL | TTERRNO, "%s: move_mount() should fail with %s", + tc->name, tst_strerrno(tc->exp_errno)); + } + + tst_res(TPASS | TTERRNO, "%s: move_mount() failed as expected", tc->name); +} + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tcases), + .test = run, + .setup = setup, + .needs_root = 1, + .format_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .dev_fs_flags = TST_FS_SKIP_FUSE, +}; From patchwork Wed Feb 19 09:28:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1240591 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=EZnAlw95; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) by ozlabs.org (Postfix) with ESMTP id 48Msqf06hGz9sRG for ; Wed, 19 Feb 2020 20:29:17 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D427B3C2542 for ; Wed, 19 Feb 2020 10:29:16 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) by picard.linux.it (Postfix) with ESMTP id 1BDF63C250E for ; Wed, 19 Feb 2020 10:28:41 +0100 (CET) Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 51E321001569 for ; Wed, 19 Feb 2020 10:27:56 +0100 (CET) Received: by mail-pl1-x62f.google.com with SMTP id e8so9318019plt.9 for ; Wed, 19 Feb 2020 01:28:40 -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=0fVcKBwrDC8rlY63i8a4GfxbvnrR2OGYvxES4s3S/hw=; b=EZnAlw957NemVq+T/ZrXkZtkAOO4xdjWcD9eI6qFcBXLkYYHsycb/SBuegImNDoGTq do0xw4tw53HaXRhh7suktj2fGE5PoUbxT7s2dNJOolqMW/uf60hmwELwYtDeVDvFKVjq g3AMj5FfhC/Hxhp2hkGGfz/AkVm0Jzd2617aYGL8xAZEicN5fQuOJ0RnaDxDX9aEuZVl LCavMlvXQES4/8GklFZW8WI2pw+pRDSkVfnfLjQjhSunaAdrH2mBXmgaif/RcMcPCPIW zvoMg8TrpNhV2qCy9jDBRALZx/3Ahjyirew2CnUwB3y3q9/jJTL/K4p4OFg7kJONffvy 4a8w== 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=0fVcKBwrDC8rlY63i8a4GfxbvnrR2OGYvxES4s3S/hw=; b=uTXWQSq1wcr4n5v1enZBuefpl8+iGKQAlKUzCflLxrIMDY6/d6WFjouaDzP19/PV5Z bpnupqBCgB3k/JN31acXH9uknMqkkYTl+sGMX/QoH+VZyOMa9zUp2QpCSzeL4K31u/Yc 2CmGfdT2bCrkvWVpkwdg3ZiKdQ1WpefHLPFarlTyDBf6ca/R8j6JSJf3MWMUw3gpVUx4 GG2pfy6Ps/+ZE5cPaNSacrA1K7FSPRnAFfsr+4j5fal/+BoxKC7Tis2q3KJjXvPHiz5n UY1gSZka+yhpc0BJDPxoJfeWbwK8VDyIuvq1CiouTdCLQbQ2Nv5XT20YOdByxeRxXXud njiw== X-Gm-Message-State: APjAAAXTF2n9ESuhfr4m/Ywr4lOjtBejXOPTDh5vBSqWoDGvAA8k8f7/ oQBGgD2gKa4vNFPyEst5kMOPDc7+J2A= X-Google-Smtp-Source: APXvYqxQ7rtBuwmvtOOQVSFRJ5h6bp8c+XL2dpEgo9/6xMWCamGzPTYPOv4uUQpGdi27+iCRlc9/hA== X-Received: by 2002:a17:902:8d94:: with SMTP id v20mr26088782plo.259.1582104518194; Wed, 19 Feb 2020 01:28:38 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id v5sm1857963pgc.11.2020.02.19.01.28.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Feb 2020 01:28:37 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Wed, 19 Feb 2020 14:58:05 +0530 Message-Id: <7195b2e7ffcda3ba70715b9094cff450568d9298.1582104018.git.viresh.kumar@linaro.org> 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-4.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-4.smtp.seeweb.it Subject: [LTP] [PATCH V2 09/10] syscalls/fspick: 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: Vincent Guittot , Vikas.Kumar2@arm.com, Viresh Kumar Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Add tests to check working of fspick() syscall. Signed-off-by: Viresh Kumar --- runtest/syscalls | 3 + testcases/kernel/syscalls/fspick/.gitignore | 2 + testcases/kernel/syscalls/fspick/Makefile | 6 ++ testcases/kernel/syscalls/fspick/fspick01.c | 112 ++++++++++++++++++++ testcases/kernel/syscalls/fspick/fspick02.c | 107 +++++++++++++++++++ 5 files changed, 230 insertions(+) create mode 100644 testcases/kernel/syscalls/fspick/.gitignore create mode 100644 testcases/kernel/syscalls/fspick/Makefile create mode 100644 testcases/kernel/syscalls/fspick/fspick01.c create mode 100644 testcases/kernel/syscalls/fspick/fspick02.c diff --git a/runtest/syscalls b/runtest/syscalls index f207a73c3e6d..b73df9a7cbec 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -350,6 +350,9 @@ fsmount02 fsmount02 fsopen01 fsopen01 fsopen02 fsopen02 +fspick01 fspick01 +fspick02 fspick02 + fstat02 fstat02 fstat02_64 fstat02_64 fstat03 fstat03 diff --git a/testcases/kernel/syscalls/fspick/.gitignore b/testcases/kernel/syscalls/fspick/.gitignore new file mode 100644 index 000000000000..a8aa61dce18b --- /dev/null +++ b/testcases/kernel/syscalls/fspick/.gitignore @@ -0,0 +1,2 @@ +/fspick01 +/fspick02 diff --git a/testcases/kernel/syscalls/fspick/Makefile b/testcases/kernel/syscalls/fspick/Makefile new file mode 100644 index 000000000000..5ea7d67db123 --- /dev/null +++ b/testcases/kernel/syscalls/fspick/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/fspick/fspick01.c b/testcases/kernel/syscalls/fspick/fspick01.c new file mode 100644 index 000000000000..ac0b12195102 --- /dev/null +++ b/testcases/kernel/syscalls/fspick/fspick01.c @@ -0,0 +1,112 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Description: + * Basic fspick() test. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" + +#define MNTPOINT "mntpoint" + +static struct tcase { + char *name; + unsigned int flags; +} tcases[] = { + {"Flag FSPICK_CLOEXEC", FSPICK_CLOEXEC}, + {"Flag FSPICK_SYMLINK_NOFOLLOW", FSPICK_SYMLINK_NOFOLLOW}, + {"Flag FSPICK_NO_AUTOMOUNT", FSPICK_NO_AUTOMOUNT}, + {"Flag FSPICK_EMPTY_PATH", FSPICK_EMPTY_PATH}, +}; + +static int ismounted; + +static void cleanup(void) +{ + if (ismounted) + SAFE_UMOUNT(MNTPOINT); +} + +static void setup(void) +{ + int fd, fsmfd; + + fsopen_supported_by_kernel(); + + TEST(fsopen(tst_device->fs_type, 0)); + fd = TST_RET; + + if (fd == -1) + tst_brk(TBROK | TERRNO, "fsopen() failed"); + + TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_brk(TBROK | TERRNO, "fsconfig failed"); + } + + TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_brk(TBROK | TERRNO, "fsconfig failed"); + } + + TEST(fsmount(fd, 0, 0)); + SAFE_CLOSE(fd); + + if (TST_RET == -1) + tst_brk(TBROK | TERRNO, "fsmount() failed"); + + fsmfd = TST_RET; + TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT, + MOVE_MOUNT_F_EMPTY_PATH)); + SAFE_CLOSE(fsmfd); + + if (TST_RET == -1) + tst_brk(TBROK | TERRNO, "move_mount() failed"); + + ismounted = 1; + + if (tst_ismount(MNTPOINT)) + tst_brk(TBROK | TERRNO, "device not mounted"); +} + +static void run(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + int fspick_fd; + + TEST(fspick(AT_FDCWD, MNTPOINT, tc->flags)); + if (TST_RET == -1) + tst_brk(TFAIL | TERRNO, "fspick() failed"); + + fspick_fd = TST_RET; + + TEST(fsconfig(fspick_fd, FSCONFIG_SET_STRING, "user_xattr", "false", 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fspick_fd); + tst_brk(TBROK | TERRNO, "fsconfig() failed"); + } + + TEST(fsconfig(fspick_fd, FSCONFIG_SET_FLAG, "ro", NULL, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fspick_fd); + tst_brk(TBROK | TERRNO, "fsconfig() failed"); + } + + SAFE_CLOSE(fspick_fd); + tst_res(TPASS, "%s: fspick() passed", tc->name); +} + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tcases), + .test = run, + .setup = setup, + .cleanup = cleanup, + .needs_root = 1, + .format_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .dev_fs_flags = TST_FS_SKIP_FUSE, +}; diff --git a/testcases/kernel/syscalls/fspick/fspick02.c b/testcases/kernel/syscalls/fspick/fspick02.c new file mode 100644 index 000000000000..b5949177ee23 --- /dev/null +++ b/testcases/kernel/syscalls/fspick/fspick02.c @@ -0,0 +1,107 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Description: + * Basic fspick() failure tests. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" + +#define MNTPOINT "mntpoint" + +static struct tcase { + char *name; + int dirfd; + const char *pathname; + unsigned int flags; + int exp_errno; +} tcases[] = { + {"invalid-fd", -1, MNTPOINT, FSPICK_NO_AUTOMOUNT | FSPICK_CLOEXEC, EBADF}, + {"invalid-path", AT_FDCWD, "invalid", FSPICK_NO_AUTOMOUNT | FSPICK_CLOEXEC, ENOENT}, + {"invalid-flags", AT_FDCWD, MNTPOINT, 0x10, EINVAL}, +}; + +static int ismounted; + +static void cleanup(void) +{ + if (ismounted) + SAFE_UMOUNT(MNTPOINT); +} + +static void setup(void) +{ + int fd, fsmfd; + + fsopen_supported_by_kernel(); + + TEST(fsopen(tst_device->fs_type, 0)); + fd = TST_RET; + + if (fd == -1) + tst_brk(TBROK | TERRNO, "fsopen() failed"); + + TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_brk(TBROK | TERRNO, "fsconfig failed"); + } + + TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_brk(TBROK | TERRNO, "fsconfig failed"); + } + + TEST(fsmount(fd, 0, 0)); + SAFE_CLOSE(fd); + + if (TST_RET == -1) + tst_brk(TBROK | TERRNO, "fsmount() failed"); + + fsmfd = TST_RET; + + TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT, + MOVE_MOUNT_F_EMPTY_PATH)); + SAFE_CLOSE(fsmfd); + + if (TST_RET == -1) + tst_brk(TBROK | TERRNO, "move_mount() failed"); + + ismounted = 1; + + if (tst_ismount(MNTPOINT)) + tst_brk(TBROK | TERRNO, "device not mounted"); +} + +static void run(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + + TEST(fspick(tc->dirfd, tc->pathname, tc->flags)); + if (TST_RET != -1) { + SAFE_CLOSE(TST_RET); + tst_brk(TFAIL, "%s: fspick() succeeded unexpectedly (index: %d)", + tc->name, n); + } + + if (tc->exp_errno != TST_ERR) { + tst_brk(TFAIL | TTERRNO, "%s: fspick() should fail with %s", + tc->name, tst_strerrno(tc->exp_errno)); + } + + tst_res(TPASS | TTERRNO, "%s: fspick() failed as expected", tc->name); +} + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tcases), + .test = run, + .setup = setup, + .cleanup = cleanup, + .needs_root = 1, + .format_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .dev_fs_flags = TST_FS_SKIP_FUSE, +}; From patchwork Wed Feb 19 09:28:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1240592 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=FKmcyB34; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) by ozlabs.org (Postfix) with ESMTP id 48Msql6cskz9sRG for ; Wed, 19 Feb 2020 20:29:23 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id B7F303C253E for ; Wed, 19 Feb 2020 10:29:22 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) by picard.linux.it (Postfix) with ESMTP id 69AFE3C266F for ; Wed, 19 Feb 2020 10:28:44 +0100 (CET) Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id BD9191001575 for ; Wed, 19 Feb 2020 10:27:59 +0100 (CET) Received: by mail-pl1-x629.google.com with SMTP id p11so9311070plq.10 for ; Wed, 19 Feb 2020 01:28:43 -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=HUERrjfW7zaHlYpAxpUp6/gCZ6B2CxkSaawQuqlHexk=; b=FKmcyB34ybDWfqP5lvZngl4p+QQLLuVA5Mo7WeSDGBPqQ7Qq6Al34Wp+P9z6BaovqA FE218Q9xusv4U9cHhlRVx1WmVnti740pu2P7NMqzTzAeyYb/LX5H2oSC84MMv6o5qaMP ENWLE39oNtX7jznPyL7JwHOF7iC8Daebhzcdz/o5AobKYfLFrcDnFJBHcdiL0ItTL0EI OpUQlaPrs7NPk8E9kgcvu7EH4prA35mShy+qrh9+7/hWpXgk9Xq4e2sr2kC0xU0sRE+W DDuQNxmWUciP4um97SiD9NVr7vxkpmqysstzRBM+5Fn1WN1rgRfGvrSDkNxc9JPmwt5t GzWw== 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=HUERrjfW7zaHlYpAxpUp6/gCZ6B2CxkSaawQuqlHexk=; b=o+jHNPKvr7ADj/+DEMEOmKqM8O+Z6j3jsCjrczCkG/IGfM4nhpBmlxPvRPA8CLcU4N su1qESGH0IeXQ7QtNyhiOyzQCPycRdInaBxcpX6BeVJ7iGxWQHil1z8/pLsixTAz8ibO IqJf9actM+s42W6iUrme9PJcZhfXHfShsZsYjUR3ncID397TOA+p/wPR63GDn4FmvHHO LUw1EWCqxTnkgfDgyCiQ6jy/+SZfRmWws+D0x7biOYTh7FV7aC62Rbwe/WeA0VK/REh/ q/XKr2q1esYfrAcv+l39JG5mU4/tt8CbyQEAQR4+eTMOmOZD4xvQiGJNLdKM9R1q9ux+ Ytpw== X-Gm-Message-State: APjAAAXiVBDaltIF51uyxJUcYZhmEu+DmTFwQ60eQpNz5Tog0N58ClGz KurLf460GvdpOn4vy8i0zVGU9WMvihQ= X-Google-Smtp-Source: APXvYqziKKznCT8UzWhMwmhqDJDR4YaDOhhHAc6JitAVXE/JvYFKWMqhmd9BCVp8os01q73rqao77g== X-Received: by 2002:a17:902:6b07:: with SMTP id o7mr24569246plk.141.1582104520852; Wed, 19 Feb 2020 01:28:40 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id r2sm1792313pgg.41.2020.02.19.01.28.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 19 Feb 2020 01:28:40 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Wed, 19 Feb 2020 14:58:06 +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-4.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-4.smtp.seeweb.it Subject: [LTP] [PATCH V2 10/10] syscalls/open_tree: 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: Vincent Guittot , Vikas.Kumar2@arm.com, Viresh Kumar Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Add tests to check working of open_tree() syscall. Signed-off-by: Viresh Kumar --- runtest/syscalls | 3 + .../kernel/syscalls/open_tree/.gitignore | 2 + testcases/kernel/syscalls/open_tree/Makefile | 6 + .../kernel/syscalls/open_tree/open_tree01.c | 115 ++++++++++++++++++ .../kernel/syscalls/open_tree/open_tree02.c | 104 ++++++++++++++++ 5 files changed, 230 insertions(+) create mode 100644 testcases/kernel/syscalls/open_tree/.gitignore create mode 100644 testcases/kernel/syscalls/open_tree/Makefile create mode 100644 testcases/kernel/syscalls/open_tree/open_tree01.c create mode 100644 testcases/kernel/syscalls/open_tree/open_tree02.c diff --git a/runtest/syscalls b/runtest/syscalls index b73df9a7cbec..79a2579e5903 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -844,6 +844,9 @@ openat01 openat01 openat02 openat02 openat03 openat03 +open_tree01 open_tree01 +open_tree02 open_tree02 + mincore01 mincore01 mincore02 mincore02 diff --git a/testcases/kernel/syscalls/open_tree/.gitignore b/testcases/kernel/syscalls/open_tree/.gitignore new file mode 100644 index 000000000000..2f732b44518e --- /dev/null +++ b/testcases/kernel/syscalls/open_tree/.gitignore @@ -0,0 +1,2 @@ +/open_tree01 +/open_tree02 diff --git a/testcases/kernel/syscalls/open_tree/Makefile b/testcases/kernel/syscalls/open_tree/Makefile new file mode 100644 index 000000000000..5ea7d67db123 --- /dev/null +++ b/testcases/kernel/syscalls/open_tree/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/open_tree/open_tree01.c b/testcases/kernel/syscalls/open_tree/open_tree01.c new file mode 100644 index 000000000000..93df51a3fa11 --- /dev/null +++ b/testcases/kernel/syscalls/open_tree/open_tree01.c @@ -0,0 +1,115 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Description: + * Basic open_tree() test. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" + +#define MNTPOINT "mntpoint" +#define OT_MNTPOINT "ot_mntpoint" + +static struct tcase { + char *name; + unsigned int flags; +} tcases[] = { + {"Flag OPEN_TREE_CLONE", OPEN_TREE_CLONE}, + {"Flag OPEN_TREE_CLOEXEC", OPEN_TREE_CLONE | OPEN_TREE_CLOEXEC}, +}; + +static int dir_created; + +static void setup(void) +{ + fsopen_supported_by_kernel(); + + SAFE_MKDIR(OT_MNTPOINT, 0777); + dir_created = 1; +} + +static void cleanup(void) +{ + if (dir_created) + SAFE_RMDIR(OT_MNTPOINT); +} + +static void run(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + int fd, fsmfd, otfd; + + TEST(fsopen(tst_device->fs_type, 0)); + fd = TST_RET; + + if (fd == -1) + tst_brk(TBROK | TERRNO, "fsopen() failed"); + + TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_brk(TBROK | TERRNO, "fsconfig failed"); + } + + TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_brk(TBROK | TERRNO, "fsconfig failed"); + } + + TEST(fsmount(fd, 0, 0)); + SAFE_CLOSE(fd); + + if (TST_RET == -1) + tst_brk(TBROK | TERRNO, "fsmount() failed"); + + fsmfd = TST_RET; + + TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT, + MOVE_MOUNT_F_EMPTY_PATH)); + SAFE_CLOSE(fsmfd); + + if (TST_RET == -1) + tst_brk(TBROK | TERRNO, "move_mount() failed"); + + if (tst_ismount(MNTPOINT)) { + tst_res(TBROK | TERRNO, "device not mounted"); + goto out; + } + + TEST(open_tree(AT_FDCWD, MNTPOINT, tc->flags)); + if (TST_RET == -1) { + tst_res(TFAIL | TERRNO, "open_tree() failed"); + goto out; + } + + otfd = TST_RET; + TEST(move_mount(otfd, "", AT_FDCWD, OT_MNTPOINT, + MOVE_MOUNT_F_EMPTY_PATH)); + SAFE_CLOSE(otfd); + + if (TST_RET == -1) { + tst_res(TBROK | TERRNO, "move_mount() failed"); + goto out; + } + + if (!tst_ismount(OT_MNTPOINT)) + tst_res(TPASS, "%s: open_tree() passed", tc->name); + + SAFE_UMOUNT(OT_MNTPOINT); +out: + SAFE_UMOUNT(MNTPOINT); +} + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tcases), + .test = run, + .setup = setup, + .cleanup = cleanup, + .needs_root = 1, + .format_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .dev_fs_flags = TST_FS_SKIP_FUSE, +}; diff --git a/testcases/kernel/syscalls/open_tree/open_tree02.c b/testcases/kernel/syscalls/open_tree/open_tree02.c new file mode 100644 index 000000000000..e752bb45b24e --- /dev/null +++ b/testcases/kernel/syscalls/open_tree/open_tree02.c @@ -0,0 +1,104 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Description: + * Basic open_tree() failure tests. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" + +#define MNTPOINT "mntpoint" + +static struct tcase { + char *name; + int dirfd; + const char *pathname; + unsigned int flags; + int exp_errno; +} tcases[] = { + {"invalid-fd", -1, MNTPOINT, OPEN_TREE_CLONE, EBADF}, + {"invalid-path", AT_FDCWD, "invalid", OPEN_TREE_CLONE, ENOENT}, + {"invalid-flags", AT_FDCWD, MNTPOINT, 0xFFFFFFFF, EINVAL}, +}; + +static int ismounted; + +static void cleanup(void) +{ + if (ismounted) + SAFE_UMOUNT(MNTPOINT); +} + +static void setup(void) +{ + int fd, fsmfd; + + fsopen_supported_by_kernel(); + + TEST(fsopen(tst_device->fs_type, 0)); + fd = TST_RET; + + if (fd == -1) + tst_brk(TBROK | TERRNO, "fsopen() failed"); + + TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_brk(TBROK | TERRNO, "fsconfig failed"); + } + + TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_brk(TBROK | TERRNO, "fsconfig failed"); + } + + TEST(fsmount(fd, 0, 0)); + SAFE_CLOSE(fd); + + if (TST_RET == -1) + tst_brk(TBROK | TERRNO, "fsmount() failed"); + + fsmfd = TST_RET; + TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT, + MOVE_MOUNT_F_EMPTY_PATH)); + SAFE_CLOSE(fsmfd); + + if (TST_RET == -1) + tst_brk(TBROK | TERRNO, "move_mount() failed"); + + if (tst_ismount(MNTPOINT)) + tst_brk(TBROK | TERRNO, "device not mounted"); +} + +static void run(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + + TEST(open_tree(tc->dirfd, tc->pathname, tc->flags)); + if (TST_RET != -1) { + SAFE_CLOSE(TST_RET); + tst_brk(TFAIL, "%s: open_tree() succeeded unexpectedly (index: %d)", + tc->name, n); + } + + if (tc->exp_errno != TST_ERR) { + tst_brk(TFAIL | TTERRNO, "%s: open_tree() should fail with %s", + tc->name, tst_strerrno(tc->exp_errno)); + } + + tst_res(TPASS | TTERRNO, "%s: open_tree() failed as expected", tc->name); +} + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tcases), + .test = run, + .setup = setup, + .cleanup = cleanup, + .needs_root = 1, + .format_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .dev_fs_flags = TST_FS_SKIP_FUSE, +};