From patchwork Thu Feb 27 05:14:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1245524 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=YcjAgjfg; 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 48Sgpb0bXtz9sPK for ; Thu, 27 Feb 2020 16:15:02 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 4CEBC3C25C5 for ; Thu, 27 Feb 2020 06:15:00 +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 8EAF73C2599 for ; Thu, 27 Feb 2020 06:14:50 +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-2.smtp.seeweb.it (Postfix) with ESMTPS id 41C53600B73 for ; Thu, 27 Feb 2020 06:14:49 +0100 (CET) Received: by mail-pl1-x643.google.com with SMTP id t14so639426plr.8 for ; Wed, 26 Feb 2020 21:14:49 -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=ATI559pEwoGPR6cAkpsnRh0mqiHeu0Fv8fR6tyKb0Ls=; b=YcjAgjfg7fuyuXbuOxvhBKqXOf16KCht+aihPceB63H2WeN9MQO59YTXult8I9P1MK xN3Jwo2Q8rAGskaE9OdHlNMIIPxhO3N7WBF9VPXVtZm2VS7UXG7DYNB+W3GlQUELge9q yJ4bJ9vvFxb9cD9jcFhCVby9WQCn0r1a8etqKQEz1egeovm/l57flHo9fVKeT+Tp/fRS u3KRu9J+zvLOKbducewTE3K7tE7ShNpdhHPvmK2w5zIfnxGMwvGW3jy0xQJHEXgO9M4T eE3hvV4J8yQ4mrKorTdgxAFCa2gy3sVN+eZF9zHmdbFw8S52LHFXeuXChn0Ll+I1eRh0 bdyA== 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=ATI559pEwoGPR6cAkpsnRh0mqiHeu0Fv8fR6tyKb0Ls=; b=GXH7EI0C/jYA3S+Egij2YkLX4K3TR4Wkik6uv785g7ee4QIF0GPZq+RpndvZENlaTs HKi973LUY5BSmp59MOPovo9hte32jwn9bWf09hKLSXZaa48D26LMbPyT0SXsXoRIfSrY HmSiN5vPhYaylnw+JM0t+g+ghtVW0SH45+qcWSX/eMa4rsbUtqFNTvR7kIvJE544Bcoj EG70jHJxn6ecVYHl0CGHyO2praxz/G22Fu29WGkpKtoh7uYdAU+8EpeDggTxgGF+PPD+ txDxPu5c4wNmlCGDHQw8/AWDC3kgNcuYU1uXkaR9HIDljosMj4dT+rxu2Ir2uKSQi/hl vtxg== X-Gm-Message-State: APjAAAVCwjcT7qmJDBkUJPz5TlNnyfe7ds6sOtLkmeARy/H2XFYedws2 tU3wKiBvcZV3ChxASd6RtIirKkWiDBc= X-Google-Smtp-Source: APXvYqx/02b6kdIvlIrkgRLfvAAiyZO2yWyC0OCXKZR/eYRbzZ0bkwLsOQ2IpAAMPsSxOT8nmMC5Nw== X-Received: by 2002:a17:902:aa49:: with SMTP id c9mr2932399plr.145.1582780487106; Wed, 26 Feb 2020 21:14:47 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id k67sm4549494pga.91.2020.02.26.21.14.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Feb 2020 21:14:46 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Thu, 27 Feb 2020 10:44:29 +0530 Message-Id: <2071e47d7d8cb3e7f8bc6558e86999eddd9c3762.1582779464.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-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 V5 01/10] tst_device: Add tst_is_mounted() 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_is_mounted(). The helper can be used across different files now. Minor modifications are also done to the helper. Acked-by: Li Wang Reviewed-by: Petr Vorel Signed-off-by: Viresh Kumar --- include/tst_device.h | 6 +++++ lib/tst_device.c | 14 +++++++++++ testcases/kernel/syscalls/fsmount/fsmount01.c | 25 +------------------ 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/include/tst_device.h b/include/tst_device.h index f5609f5986bb..bd6910672d2f 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_is_mounted(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..8bf6dacf5973 100644 --- a/lib/tst_device.c +++ b/lib/tst_device.c @@ -386,6 +386,20 @@ int tst_umount(const char *path) return -1; } +int tst_is_mounted(const char *path) +{ + char cmd[PATH_MAX]; + int ret; + + snprintf(cmd, sizeof(cmd), "mountpoint -q %s", path); + ret = tst_system(cmd); + + if (ret) + tst_resm(TINFO, "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..8e29a1537334 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_is_mounted(MNTPOINT)) { SAFE_UMOUNT(MNTPOINT); is_mounted = 0; - } else { - tst_res(TFAIL, "device not mounted"); } } From patchwork Thu Feb 27 05:14:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1245525 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=kbsnvNqQ; 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 48Sgpp4C1Yz9sPK for ; Thu, 27 Feb 2020 16:15:14 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id EAF933C25CE for ; Thu, 27 Feb 2020 06:15:11 +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 496CC3C25C6 for ; Thu, 27 Feb 2020 06:14:52 +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-4.smtp.seeweb.it (Postfix) with ESMTPS id 9DCE01000C32 for ; Thu, 27 Feb 2020 06:14:51 +0100 (CET) Received: by mail-pj1-x1041.google.com with SMTP id q39so656439pjc.0 for ; Wed, 26 Feb 2020 21:14:51 -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=Ux/3onDMUO6pOVwIkjNFpneYEOippMKOaX++Yzv0Ils=; b=kbsnvNqQ7EZeZaS+6BYHAsCjlqrSFlYnWkoEO93VI2ESSUNMR9yomzFQvTGreadPJk addpjbTBNdJEvNGiPBH5mdiLDtMQ9sZYS5blu9lB7hfAEe5Srs01frWsCXxajSKEOVUs 0Wb1adS/jyj7hmRPbpSNaWLRyR0njITsZOkOPMFoMjRKMLzgC7vCoAhF1R2YTSN+fp+O 8Ad2UrjIi3h5vxr4SCcL85C6bmE5UehR9v3xVZ7Sve7QvvB3NyjREkq6/AlLOuNq7r95 gw8q8DPeztyOxHy0H6Ns2+N0QHj/E/bPhV6vz7lDFH9d/aeTqPl3KMoy7zPGip1f34x1 UH6A== 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=Ux/3onDMUO6pOVwIkjNFpneYEOippMKOaX++Yzv0Ils=; b=VYUVLW4vxYmcYMdg8EItR5yZ4UAJVvnwZ0PP2HGgADcIUvtZRzeW1/eSNjxNvUZKlL JFYAgrAKL51meuzksl2heRSB0hPEWGum5wJ9VBdH2g+LoQCRp660gPiVaF0G+CCmCEJ5 0HFnrY8MFyY4IA9kOOvEQb7TWuCM6vsrLL1OCfwwlM+A3DGE2eZCJd92m6TeiDZvJbf0 +qzrcpWMaLBjImAJqiaO6lF91ZLSb/TmfFEH7MKcy3EOKqJsVsvQKIJX0WF4HggeKcBc sbNkLpsXYrgQPqeXs0KfWeQnAaMkNZuJfub1A2Q283KU9zmAAUIw+pfD6go/Y3UN+DW1 uNtA== X-Gm-Message-State: APjAAAXp2pbyyNM+co6L1tG9kx8XMWZ+gr9ByMneE7gFU0KanCapHr4z C7aqvLwcNsPMKa5aVO5YLKW8RYmqlM4= X-Google-Smtp-Source: APXvYqzH63HAJXVq/7C/cIJryWgCFbXxr94rWetVF/XH/SdPl4B/B69TYXBysZGZdgWchF3s70h8kQ== X-Received: by 2002:a17:902:8549:: with SMTP id d9mr2763143plo.153.1582780489791; Wed, 26 Feb 2020 21:14:49 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id y193sm2199461pgd.87.2020.02.26.21.14.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Feb 2020 21:14:49 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Thu, 27 Feb 2020 10:44:30 +0530 Message-Id: <21026a48ffa25ed8b09616cb939dc417459d2d74.1582779464.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 V5 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. Reviewed-by: Petr Vorel Acked-by: Li Wang Signed-off-by: Viresh Kumar --- include/lapi/fsmount.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/lapi/fsmount.h b/include/lapi/fsmount.h index 87f2f229c371..a6a24904e66d 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 supported on kernel version < v5.2"); + } +} #endif /* FSMOUNT_H__ */ From patchwork Thu Feb 27 05:14:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1245526 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=b71i5Czn; 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 48Sgq21zDmz9sPK for ; Thu, 27 Feb 2020 16:15:26 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 753E93C2591 for ; Thu, 27 Feb 2020 06:15:23 +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 3459C3C25CD for ; Thu, 27 Feb 2020 06:14:55 +0100 (CET) Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (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 8361D60092C for ; Thu, 27 Feb 2020 06:14:54 +0100 (CET) Received: by mail-pg1-x542.google.com with SMTP id b1so818317pgm.8 for ; Wed, 26 Feb 2020 21:14:54 -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=igC8sNIqb3C9sWcEIoUIFuUzh6VpccovgjPm4/pN6fw=; b=b71i5CznJRLAZnK0W2gzHjF02g87OkEYXL7/zzI88WHeYLh2qtmczHE6cieXRVdw7L u/aehs7u1XEeAqeXH/rYCg5D13ALbEpcjzjXCuUNk6R8CaF4krYay0CL58dFeI4ZdwrW q/Bi6XUquwKdrz7g1TzSIHM7pt67wSqt8JBUImnkvJCh30PGSdWYjv0px0VzEqv/JqKc MKS+lpSFtGaTWjKUiyGybbbo7VCczgxsSyEFkLN2D2ZjvWmAoUIxDrVW90Pfb9Cgwp5U 6iNTky0siy6iPqTRrd7KW4+5pgxgZl1OM5tU81wN6/xFlAUyCjyakYZA71yucHcm6Qnb 2aMg== 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=igC8sNIqb3C9sWcEIoUIFuUzh6VpccovgjPm4/pN6fw=; b=QIrLXXOuXQgd7TiYtB9E4HREgiYe8FtYKMs2FljUg7ehRcnvpTwD5YJo0Nw3/wgP6x HPwyB0wCKB98ave7pJQzu6kRzwfnrk1bgQx52KLO/2u5HlW//jEmij+c9qSdDJyz02OC Y9HBlNJa7+zy9zAVf3t1Fl+tA9BBXsmb4SMmM4K3UhtJpc6cZMii76m4RwDj5ijPks19 hO5e9T52eEh6y+5H8w2P+pXFUbZaaKeWnwP4zJ/SBull8aT8/UR7eQooWO6thyVedlje 8tM5yGFwL1VXTxArEHXrG0zzNs0ITS+qV1m7rqo4kVBT6rPhV+vrFF+S1QfsfF5BIBkB C3bA== X-Gm-Message-State: APjAAAUIK34Mxhe7KNSe0RJFmn7NBMFbpzcDSgg5lORgzwsC1XiOzVvn 3Iho2tjJ88Rz9JZLtWSVH1soqsvkeIE= X-Google-Smtp-Source: APXvYqwMu/f5QhD8cUO1kRiXSYJ+8bVggj+M539sStryQnW8XL6rOW9DWzlfccWfK6vsiaKevvkL6A== X-Received: by 2002:a62:2ad1:: with SMTP id q200mr2359367pfq.123.1582780492625; Wed, 26 Feb 2020 21:14:52 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id 133sm5269424pfy.14.2020.02.26.21.14.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Feb 2020 21:14:51 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Thu, 27 Feb 2020 10:44:31 +0530 Message-Id: <7a20c9dc8df8c99f07d5aff5c153a38b21dbdc19.1582779464.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 V5 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. Acked-by: Petr Vorel Acked-by: Li Wang 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 a6a24904e66d..5e5eaca7e6ff 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 8e29a1537334..514d3b0b38f8 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 Thu Feb 27 05:14:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1245527 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=cZaP7Oj1; 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 48SgqD30M2z9sPK for ; Thu, 27 Feb 2020 16:15:36 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id BFDCE3C2599 for ; Thu, 27 Feb 2020 06:15:33 +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 [217.194.8.3]) by picard.linux.it (Postfix) with ESMTP id F28F13C25C8 for ; Thu, 27 Feb 2020 06:14:59 +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-3.smtp.seeweb.it (Postfix) with ESMTPS id 170B61A00E17 for ; Thu, 27 Feb 2020 06:14:59 +0100 (CET) Received: by mail-pg1-x544.google.com with SMTP id m15so266440pgv.12 for ; Wed, 26 Feb 2020 21:14:59 -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=cclDDoI7/i7jpYsZePA7DcXVHiD0HBovMZELbRnGimQ=; b=cZaP7Oj1VKZUxFKIW48ortEvJ5fIFLtt+Pb/WG7vIyBlYQiKV8UkuGf6xxrw4WPVSY YLOIMmyc4TDxMWEP0J4YGEbi3oMA44fc4TeCnz/+tbDYranRReQ/WqUTUfXhQxpeGXCb vzzWznreVKVkee5m0IDsS0QcolhGJ6l47+afDC1TTRSC3P78sAiw9demG1ZibW87Dhid fOA+vqARGvZdOILpio4HHgBgpl9OkQ/Xe5NLmGBj0kkkXwPOXa0MR2hKYCkNVddFSFyZ C7XeiJQJAjb8lbUDW5zCeUi5bFR/vlpcGVI0H1GGndmtATBGAlheLu4tg8SaRS1MbFOz bRKg== 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=cclDDoI7/i7jpYsZePA7DcXVHiD0HBovMZELbRnGimQ=; b=frwdbQxhYArF7zYMsTxSb+EdCt8H4I+uMG+75eo8k0IOL7xGO1xFPOgfsE1K9IGYjR +fbzqN3Z4LyWrLB42lHeAauJiIYq5nh+LDCwCDaak7t7nXWVjk7TSj20v37UAIs9xz79 5vY2/X+a1g0FEpVUfHnfpVU3knGkfZiOrGzK8EbmFugBsKldy6ks6IKXog2hs4dyrADB N8Ds8TsUEGRIlzOviQ+E8ePqWkbbk2nw4+hsPvCmutW+XhHVwzV9tMJvQyNIu4YKte1W t6C6vdvNLEdFZByqojG9PFX1XG4+ngig+GxstbLJilQCrbV+JbztQN1YJ1EEO6B/7qnY pi0Q== X-Gm-Message-State: APjAAAV6E11qNBnktiGXoSixeVHXk5AGzZtLjY5hGP7Q5k1HlT8KV4Tf +moqmFrM7A3oVwG3SYz25fS6m6v5ih0= X-Google-Smtp-Source: APXvYqyz7YxTJRrZTwf+fiNFcqyuIZisnVMkhSr2YkJ/rsZtQx2FPn8oMZ5ofHZele7EZ7JFN+Nyzg== X-Received: by 2002:a63:6cc7:: with SMTP id h190mr2345265pgc.440.1582780496345; Wed, 26 Feb 2020 21:14:56 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id f1sm4389118pjq.31.2020.02.26.21.14.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Feb 2020 21:14:55 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Thu, 27 Feb 2020 10:44:32 +0530 Message-Id: <495a95969c63d67868b82d2b15bd663f19780d0e.1582779464.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-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 V5 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. Acked-by: Li Wang 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 | 80 +++++++++++++++++++++ testcases/kernel/syscalls/fsopen/fsopen02.c | 58 +++++++++++++++ 5 files changed, 149 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 f51456b8fb53..1f21cc55bf2d 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..abf5f15c4721 --- /dev/null +++ b/testcases/kernel/syscalls/fsopen/fsopen01.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Basic fsopen() test which tries to configure and mount the filesystem as + * well. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" + +#define MNTPOINT "mntpoint" + +#define TCASE_ENTRY(_flags) {.name = "Flag " #_flags, .flags = _flags} + +static struct tcase { + char *name; + unsigned int flags; +} tcases[] = { + TCASE_ENTRY(0), + TCASE_ENTRY(FSOPEN_CLOEXEC), +}; + +static void run(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + int fd, fsmfd; + + TEST(fd = fsopen(tst_device->fs_type, tc->flags)); + if (fd == -1) { + tst_res(TFAIL | TERRNO, "fsopen() failed"); + return; + } + + 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_CMD_CREATE, NULL, NULL, 0)); + if (TST_RET == -1) { + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + goto out; + } + + TEST(fsmfd = fsmount(fd, 0, 0)); + if (fsmfd == -1) { + tst_res(TFAIL | TERRNO, "fsmount() failed"); + goto out; + } + + TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT, + MOVE_MOUNT_F_EMPTY_PATH)); + + SAFE_CLOSE(fsmfd); + + if (TST_RET == -1) { + tst_res(TFAIL | TERRNO, "move_mount() failed"); + goto out; + } + + if (tst_is_mounted(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 = fsopen_supported_by_kernel, + .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..3f287bf2962b --- /dev/null +++ b/testcases/kernel/syscalls/fsopen/fsopen02.c @@ -0,0 +1,58 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * 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_res(TFAIL, "%s: fsopen() succeeded unexpectedly (index: %d)", + tc->name, n); + return; + } + + if (tc->exp_errno != TST_ERR) { + tst_res(TFAIL | TTERRNO, "%s: fsopen() should fail with %s", + tc->name, tst_strerrno(tc->exp_errno)); + return; + } + + 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 Thu Feb 27 05:14:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1245528 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=FpzBJnyU; 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 48SgqQ1HJPz9sPK for ; Thu, 27 Feb 2020 16:15:46 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 65D723C254F for ; Thu, 27 Feb 2020 06:15:43 +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 E82603C25CC for ; Thu, 27 Feb 2020 06:15:02 +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-6.smtp.seeweb.it (Postfix) with ESMTPS id 131831401A6C for ; Thu, 27 Feb 2020 06:15:01 +0100 (CET) Received: by mail-pj1-x1042.google.com with SMTP id n96so623520pjc.3 for ; Wed, 26 Feb 2020 21:15:00 -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=a7FpPEuoH/OvXq6AjOvDugUetlxA5acvC03iRa3x75M=; b=FpzBJnyUHoOZN9KD9RZe1MSvO0axkqUdwawXe/bi3ZVxoqoMbILiKApa1p/63t9/cH uUKtgZlr7NqHc6yiC0hSLt3s1vG8FZ2C52UoxhCskSytb75XVhwJOee8Umbh5rYbV/Rf rGhfMWD38dloz3kxfD5GkeUFsy1yVe52ERzLCHFC4IHGDO/yIOl+9EbflNOxkpsxs1rB 8Uv7KbTyO0UWMD3pHy5qvGqx9/p2AghRvA+rTxXItP4bUrvpOPQAJ3G4IAJ59VtzVIta T3RU9jypFyEwbOTK1AjLtLENcREbgLcSHM1uBriahFotBDUwQO64gSh8o9nLBJVy9OS9 CxBw== 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=a7FpPEuoH/OvXq6AjOvDugUetlxA5acvC03iRa3x75M=; b=UiXZ3JDlcEnNidVX9Yq0bO5tOwhLSb5M5VhjYUv4Czqt8tRY7/HdxWwd/JpWQvjh0M 6vcDHg6MtYcCTgSmC41kmWeVBtJfE22dcOn7mj3jHeMqAkgE4ro/bcO65ScOG5o9lcir cbzR5aebUOE7lPfArR8G44OEWSV9/tb4VtfTMxm+9nv8Xxkn2Uqj9wsMskTf4aZQQuls AEwfV20AOxa6wS7lj6xpX2J9Q4Jm7jISU9vdah6EYn2i4ed6l20xgTuu1FIVgsXe2WPq GC9RSbnJdrR4tK5ZaC20rFY2G2X16oiXL+IchDXPwSs0AxUjK8FzWakHIfGR9hwQsRxl /8CA== X-Gm-Message-State: APjAAAU/8bVjZbLkrCYABOqsM031+sibP7ALnEcEPBxayOCLzNvkvPIi eiYl1BZm1JhCfVsMdMKwCDPj5nDSiuM= X-Google-Smtp-Source: APXvYqze3SswtGgp8XDpSEX1t/JB5D5I9tMCr0rmiC63sV+qvqP2hY9PWP42GuqMFvYWzIUkYvhFGw== X-Received: by 2002:a17:902:fe05:: with SMTP id g5mr1752679plj.248.1582780499003; Wed, 26 Feb 2020 21:14:59 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id y15sm4368507pgj.78.2020.02.26.21.14.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Feb 2020 21:14:58 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Thu, 27 Feb 2020 10:44:33 +0530 Message-Id: <01949a4ba3d2c125a9be8422ec27c8436a53f6a8.1582779464.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 V5 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. Acked-by: Li Wang Reviewed-by: Petr Vorel 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 | 101 ++++++++++++++++++ .../kernel/syscalls/fsconfig/fsconfig02.c | 99 +++++++++++++++++ 5 files changed, 211 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 1f21cc55bf2d..97c0fea2fe57 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..e32b23e9586b --- /dev/null +++ b/testcases/kernel/syscalls/fsconfig/fsconfig01.c @@ -0,0 +1,101 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * 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 run(void) +{ + int fd, fsmfd; + + TEST(fd = fsopen(tst_device->fs_type, 0)); + 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, "sync", tst_device->dev, 0)); + if (TST_RET == -1) { + if (TST_ERR == EOPNOTSUPP) { + tst_res(TCONF, "fsconfig(): FSCONFIG_SET_PATH not supported"); + } else { + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + goto out; + } + } + + TEST(fsconfig(fd, FSCONFIG_SET_PATH_EMPTY, "sync", tst_device->dev, 0)); + if (TST_RET == -1) { + if (TST_ERR == EOPNOTSUPP) { + tst_res(TCONF, "fsconfig(): FSCONFIG_SET_PATH_EMPTY not supported"); + } else { + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + goto out; + } + } + + TEST(fsconfig(fd, FSCONFIG_SET_FD, "sync", NULL, 0)); + if (TST_RET == -1) { + if (TST_ERR == EOPNOTSUPP) { + tst_res(TCONF, "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(fsmfd = fsmount(fd, 0, 0)); + if (fsmfd == -1) { + tst_res(TBROK | TERRNO, "fsmount() failed"); + goto out; + } + + 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_is_mounted(MNTPOINT)) + tst_res(TPASS, "fsconfig() passed"); + + SAFE_UMOUNT(MNTPOINT); + +out: + SAFE_CLOSE(fd); +} + +static struct tst_test test = { + .test_all = run, + .setup = fsopen_supported_by_kernel, + .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..e6e7b4b9f1de --- /dev/null +++ b/testcases/kernel/syscalls/fsconfig/fsconfig02.c @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Basic fsconfig() failure tests. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" + +static int fd = -1, temp_fd = -1, invalid_fd = -1; +static 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(fd = fsopen(tst_device->fs_type, 0)); + 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_res(TFAIL, "%s: fsconfig() succeeded unexpectedly (index: %d)", + tc->name, n); + return; + } + + if (tc->exp_errno != TST_ERR) { + tst_res(TFAIL | TTERRNO, "%s: fsconfig() should fail with %s", + tc->name, tst_strerrno(tc->exp_errno)); + return; + } + + 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 Thu Feb 27 05:14:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1245529 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=fc5bgYyr; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (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 48Sgqg2Mt5z9sPK for ; Thu, 27 Feb 2020 16:15:59 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id A47E23C25CF for ; Thu, 27 Feb 2020 06:15:56 +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 A88373C25CF for ; Thu, 27 Feb 2020 06:15:04 +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-2.smtp.seeweb.it (Postfix) with ESMTPS id 839ED600B73 for ; Thu, 27 Feb 2020 06:15:03 +0100 (CET) Received: by mail-pj1-x1043.google.com with SMTP id 12so644417pjb.5 for ; Wed, 26 Feb 2020 21:15:03 -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=6C8GzG1G6D6OWQFqy5c8OAlud50lOnkKOnOD8S8DLnQ=; b=fc5bgYyr2am3QKOoJrIoFH08EME7lXpfuRBw1vu3gp+ZEpGyR+o4whj2L/ZTjZl9+B yDBF3X3GlLLjya6fwuDEDJk/zjulOuyM4A29ZrNN1nTYk827hkBcDaW7DKVtQADtk2ag MK0TW50evCTaAkaPyPyC2zu9qdHrTK2qPiuFJZxwGZWaYTuou3PfD1x3PeADN4qkRLzw U4K9+R9djx4YwUYYqCquoawQyNUo7tJuXf+fHE6BpnB9vKAAgk49fM6yKkpv51kp817t On7nipvYoN31fubxkdOTXaKcf2szdoNPXPjUbL0A3miJIqmvnZNHL9neRNifDmmaNGWt rr1A== 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=6C8GzG1G6D6OWQFqy5c8OAlud50lOnkKOnOD8S8DLnQ=; b=jBAh7FYPcsq0lFFyG4eGVGw0xukOUd4Ky2ztkPCPXVw5xQIBZyX5SS0XHkmQ0gUvX3 HTvoqp9H592VRicD0AzyYkEKhsv2PPz9siV6psiNGJ6duvY8ilj9f2wz1YXZ7mOmA7kX 51ZunXGnTmSiHKqV9Yx5LQ5SLxEv5stSJNVJQt2utH+xhGW4usW4X3Z9bkCeNwqpFXMj Pz8K+HMBcjdxM/mVKjO4SAXUw1l+O51VZ2xO0uUJr/oYr+aPHQZMqST+wNOS1uRMmHW3 mfF98Upr1xIV7jofvEUfZgxlmWz/YfvONPB906Xxg1B285FyKL0v0JmAMIqvZBW0Qgwf dZ2w== X-Gm-Message-State: APjAAAWB0DxclCluYXE0qIVl9/HiI3JNSbQfp5A25neW6rp3CPBnbpwY gi0SKkVIQIKVYm6b9e8mAEuZfDJKbI8= X-Google-Smtp-Source: APXvYqyy3oc41uMtDOtXLtbtvhHJm6Z1C4d4geHQdLJhXcUb74mjjWRhc2RBuLDIKvF1nFuGx30QHQ== X-Received: by 2002:a17:902:a514:: with SMTP id s20mr2850488plq.300.1582780501615; Wed, 26 Feb 2020 21:15:01 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id n2sm4507368pgi.48.2020.02.26.21.15.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Feb 2020 21:15:01 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Thu, 27 Feb 2020 10:44:34 +0530 Message-Id: <15594e36e83ddf307d423777b930e9b848c6a943.1582779464.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-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 V5 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 Acked-by: Li Wang Signed-off-by: Viresh Kumar --- testcases/kernel/syscalls/fsmount/fsmount01.c | 103 +++++++++++------- 1 file changed, 65 insertions(+), 38 deletions(-) diff --git a/testcases/kernel/syscalls/fsmount/fsmount01.c b/testcases/kernel/syscalls/fsmount/fsmount01.c index 514d3b0b38f8..8c3538bf8c84 100644 --- a/testcases/kernel/syscalls/fsmount/fsmount01.c +++ b/testcases/kernel/syscalls/fsmount/fsmount01.c @@ -3,67 +3,94 @@ * 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. + * 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 void cleanup(void) -{ - if (is_mounted) - SAFE_UMOUNT(MNTPOINT); -} +#define TCASE_ENTRY(_flags, _attrs) {.name = "Flag " #_flags ", Attr " #_attrs, .flags = _flags, .attrs = _attrs} -static void test_fsmount(void) +static struct tcase { + char *name; + unsigned int flags; + unsigned int attrs; +} tcases[] = { + TCASE_ENTRY(0, MOUNT_ATTR_RDONLY), + TCASE_ENTRY(0, MOUNT_ATTR_NOSUID), + TCASE_ENTRY(0, MOUNT_ATTR_NODEV), + TCASE_ENTRY(0, MOUNT_ATTR_NOEXEC), + TCASE_ENTRY(0, MOUNT_ATTR_RELATIME), + TCASE_ENTRY(0, MOUNT_ATTR_NOATIME), + TCASE_ENTRY(0, MOUNT_ATTR_STRICTATIME), + TCASE_ENTRY(0, MOUNT_ATTR_NODIRATIME), + TCASE_ENTRY(FSMOUNT_CLOEXEC, MOUNT_ATTR_RDONLY), + TCASE_ENTRY(FSMOUNT_CLOEXEC, MOUNT_ATTR_NOSUID), + TCASE_ENTRY(FSMOUNT_CLOEXEC, MOUNT_ATTR_NODEV), + TCASE_ENTRY(FSMOUNT_CLOEXEC, MOUNT_ATTR_NOEXEC), + TCASE_ENTRY(FSMOUNT_CLOEXEC, MOUNT_ATTR_RELATIME), + TCASE_ENTRY(FSMOUNT_CLOEXEC, MOUNT_ATTR_NOATIME), + TCASE_ENTRY(FSMOUNT_CLOEXEC, MOUNT_ATTR_STRICTATIME), + TCASE_ENTRY(FSMOUNT_CLOEXEC, MOUNT_ATTR_NODIRATIME), +}; + +static void run(unsigned int n) { - TEST(fsopen(tst_device->fs_type, FSOPEN_CLOEXEC)); - if (TST_RET < 0) - 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); + struct tcase *tc = &tcases[n]; + int sfd, mfd; + + TEST(sfd = fsopen(tst_device->fs_type, FSOPEN_CLOEXEC)); + if (sfd == -1) { + tst_res(TFAIL | TTERRNO, "fsopen() on %s failed", + tst_device->fs_type); + return; + } TEST(fsconfig(sfd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); - if (TST_RET < 0) - tst_brk(TBROK | TTERRNO, + if (TST_RET == -1) { + SAFE_CLOSE(sfd); + tst_res(TFAIL | TTERRNO, "fsconfig() failed to set source to %s", tst_device->dev); - tst_res(TPASS, "fsconfig() set source to %s", tst_device->dev); - + return; + } TEST(fsconfig(sfd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); - if (TST_RET < 0) - tst_brk(TBROK | TTERRNO, "fsconfig() created superblock"); - tst_res(TPASS, "fsconfig() created superblock"); + if (TST_RET == -1) { + SAFE_CLOSE(sfd); + tst_res(TFAIL | TTERRNO, "fsconfig() created superblock"); + return; + } - 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(mfd = fsmount(sfd, tc->flags, tc->attrs)); SAFE_CLOSE(sfd); + if (mfd == -1) { + tst_res(TFAIL | TTERRNO, + "fsmount() failed to create a mount object"); + return; + } + 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_is_mounted(MNTPOINT)) { - SAFE_UMOUNT(MNTPOINT); - is_mounted = 0; + if (TST_RET == -1) { + tst_res(TFAIL | TTERRNO, + "move_mount() failed to attach to the mount point"); + return; } + + if (tst_is_mounted(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 = fsopen_supported_by_kernel, .needs_root = 1, .mntpoint = MNTPOINT, .format_device = 1, From patchwork Thu Feb 27 05:14:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1245530 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=EMwoGoMq; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (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 48Sgqs14jnz9sPK for ; Thu, 27 Feb 2020 16:16:09 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 4BE543C21E9 for ; Thu, 27 Feb 2020 06:16:06 +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 7ABAA3C25C3 for ; Thu, 27 Feb 2020 06:15:06 +0100 (CET) Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) (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 1BAE51A00F0D for ; Thu, 27 Feb 2020 06:15:06 +0100 (CET) Received: by mail-pf1-x441.google.com with SMTP id p14so993551pfn.4 for ; Wed, 26 Feb 2020 21:15:06 -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=nz8ejQcOkPD1Cz0pgtihg9qjxAW5FHPOvnunWec1iNg=; b=EMwoGoMqNW5b2bSEtnTpfGFlyTE0TIHMN3U7LA/bxI1+2uK8Jtbx4YLal0fs6CkC5E w56qG38K947JyA7pV3zmnSPtuovH/tX8zM0m/SnfqTOWFrbFyfzPu0zIRqo/S7xx5c1J ZecENg7D+lxAVAAFo/J5CyR6RZ/nO32NQttOZglEpBvkuiKWLG+H8seDihzdWBvvsP5l k1DXBls6cGrWzB6H8zqU+inV58UmyofCnO62bSV630gTTT1HZsH5pMS1aR6qlWU7zSRh uOGGofnSQN589Wg0UohuLqDRmLG+t83FJPCeBJyJi7Y2i4TM4YUKF2YGJA8gL9+IVSqn Tpjg== 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=nz8ejQcOkPD1Cz0pgtihg9qjxAW5FHPOvnunWec1iNg=; b=A2r/HYt7lc8G98G0whS6RsVzbiAOy+5WKkfigwxKhL7BC82kzBgRbofy4+V/utfmPj fwOckaiZemrts9IXQt3/fXr9/J0LHh0d8r6DAD1ikQSgQVK6J1lg8N3xLtCsBxsH6/Jd Fe6kni0na/Ee26ZxZ6vgbY1shq1x5Z2+SgKXIRYd9QjK9Bm9hHb9zMk+WAO0SiWZkMP6 Ap9RwOZQ6EM04tU2r6m6ANsGK09EP0j2JxboONluJI8N+Mm8J4GdTkpxfKgy30Fshdak n707CAYqUVksHFOTJrKR7QWPGTdAl/ZPrw7+b/Rq465h25KUYylbfUcSS9aAD7jLIf9z zdHA== X-Gm-Message-State: APjAAAXTort3CuhUfmL1vup6TLtENHLs/y1FfIPDdjBJgQHyyxuTMSQx ldf+Cn73cA4oJqg7npovd39rmxS6vps= X-Google-Smtp-Source: APXvYqwP+oI4otNR+0kibPH7fId8rPIuACCPQ8DW6dQ2NSCLTTdquiZLUZ2aKG31xwAoyS5UQ2lAvw== X-Received: by 2002:aa7:864f:: with SMTP id a15mr2248293pfo.184.1582780504214; Wed, 26 Feb 2020 21:15:04 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id p21sm4791913pfn.103.2020.02.26.21.15.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Feb 2020 21:15:03 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Thu, 27 Feb 2020 10:44:35 +0530 Message-Id: <4e16d9ee8734fe9f532df99ac9db5bcaf1daee17.1582779464.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-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 V5 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. Acked-by: Li Wang Signed-off-by: Viresh Kumar --- runtest/syscalls | 1 + testcases/kernel/syscalls/fsmount/.gitignore | 1 + testcases/kernel/syscalls/fsmount/fsmount02.c | 80 +++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 testcases/kernel/syscalls/fsmount/fsmount02.c diff --git a/runtest/syscalls b/runtest/syscalls index 97c0fea2fe57..1ac8c84d2567 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..e3419200961c --- /dev/null +++ b/testcases/kernel/syscalls/fsmount/fsmount02.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * 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(fd = fsopen(tst_device->fs_type, 0)); + 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_res(TFAIL, "%s: fsmount() succeeded unexpectedly (index: %d)", + tc->name, n); + return; + } + + if (tc->exp_errno != TST_ERR) { + tst_res(TFAIL | TTERRNO, "%s: fsmount() should fail with %s", + tc->name, tst_strerrno(tc->exp_errno)); + return; + } + + 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 Thu Feb 27 05:14:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1245531 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=vXR7G1IM; 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 48Sgr41S7Qz9sPK for ; Thu, 27 Feb 2020 16:16:20 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id D1D243C253A for ; Thu, 27 Feb 2020 06:16:16 +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 [217.194.8.6]) by picard.linux.it (Postfix) with ESMTP id B6B9B3C25A7 for ; Thu, 27 Feb 2020 06:15:09 +0100 (CET) Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) (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 C63591401A6D for ; Thu, 27 Feb 2020 06:15:08 +0100 (CET) Received: by mail-pl1-x631.google.com with SMTP id y8so632859pll.13 for ; Wed, 26 Feb 2020 21:15:08 -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=FnO25o3S0imdAucNgO0kjKssn7bsk0mZ2lR9dEMNOMM=; b=vXR7G1IMRGGztMYcMy8VDegO3IKyxdaABJR/106vdBDiwkbfoTWvZjY8wfHM66pWuI X2NLXTKaOEwZUvzowSc7zyTQoZcsmYNWbOuUczuETz+i9Hm5UvLpJCrv2yvwywTpUi0g zq/SrDH99yBB7YS6bQ7NUyeXvN2Iul8Y+EChX2x5FR1eidMBMYph9R0NfB4tHLUh5EJ1 dcvkwX65Gto5dcZiaZL3TLXLyF4/d36vNddCx4a5sLkam7JhFGtg9qWBhBLqcNUwZ/Hb NpztUDr9lWLFCZ2MNgqp6tkVCFSQjAxFhtUPWdIvvR4JcJvUqkenFuiGWhUaVSOePFWi T+Aw== 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=FnO25o3S0imdAucNgO0kjKssn7bsk0mZ2lR9dEMNOMM=; b=V3Jw2ZkJQkG8u61oUbQL7VE+l/tZqBm3WcNnMbF7fOM+K48cX2ocCk3BeJG2sOCv1n YoGw+HZagY1lJNDjT6RqFRP82R3DuPqxSznonbZKRPs+3UIPD7VfC2LNfWIKoIwCZuRs Ifr329avuf2/wiriBn73rm2SIumOFcBK/+Xkq387eDA4ZFfow+SaXWO1hXt45V/86fTC NfD7kdZGxXLxYfpSCM5CZJ9WjPvlSz6+G6rBBH7/keWMjj00vjP7pxdhJunMjk2I+DCY kLWus3rKUzWGctFKoSzYJLgByjZomsWJBKHUhiKxS1q4vSldIe99dYqFcEEoBE7yory+ ShLA== X-Gm-Message-State: APjAAAVTtcMlNI+89h1H5qVJmoHhbmwKcp8Yj6FeanrntOFsoLshPHoP jVvXQLvgXA6mYBDatewL8aIo9OhZYn4= X-Google-Smtp-Source: APXvYqwzcKrdCEhjCJprt3T++f6lFEOwq1/Sp3WhE0jOQNEwJCpH86JX8E20oZjhvn2aICOAOROo6A== X-Received: by 2002:a17:90a:332e:: with SMTP id m43mr2925371pjb.107.1582780506862; Wed, 26 Feb 2020 21:15:06 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id r10sm1837879pgv.25.2020.02.26.21.15.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Feb 2020 21:15:06 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Thu, 27 Feb 2020 10:44:36 +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-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 V5 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. Acked-by: Li Wang 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 | 83 +++++++++++++++++ .../kernel/syscalls/move_mount/move_mount02.c | 92 +++++++++++++++++++ 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 1ac8c84d2567..32b3f36e4dcc 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..7f561718764a --- /dev/null +++ b/testcases/kernel/syscalls/move_mount/move_mount01.c @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Basic move_mount() test. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" + +#define MNTPOINT "mntpoint" + +#define TCASE_ENTRY(_flags) {.name = "Flag " #_flags, .flags = _flags} + +static struct tcase { + char *name; + unsigned int flags; +} tcases[] = { + TCASE_ENTRY(MOVE_MOUNT_F_SYMLINKS), + TCASE_ENTRY(MOVE_MOUNT_F_AUTOMOUNTS), + TCASE_ENTRY(MOVE_MOUNT_F_EMPTY_PATH), + TCASE_ENTRY(MOVE_MOUNT_T_SYMLINKS), + TCASE_ENTRY(MOVE_MOUNT_T_AUTOMOUNTS), + TCASE_ENTRY(MOVE_MOUNT_T_EMPTY_PATH), +}; + +static void run(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + int fsmfd, fd; + + TEST(fd = fsopen(tst_device->fs_type, 0)); + if (fd == -1) { + tst_res(TFAIL | TERRNO, "fsopen() failed"); + return; + } + + TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + return; + } + + TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + return; + } + + TEST(fsmfd = fsmount(fd, 0, 0)); + SAFE_CLOSE(fd); + + if (fsmfd == -1) { + tst_res(TFAIL | TERRNO, "fsmount() failed"); + return; + } + + TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT, + tc->flags | MOVE_MOUNT_F_EMPTY_PATH)); + SAFE_CLOSE(fsmfd); + + if (TST_RET == -1) { + tst_res(TFAIL | TERRNO, "move_mount() failed"); + return; + } + + if (tst_is_mounted(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 = fsopen_supported_by_kernel, + .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..dfb48a1b3dc6 --- /dev/null +++ b/testcases/kernel/syscalls/move_mount/move_mount02.c @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * 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 run(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + int fd; + + TEST(fd = fsopen(tst_device->fs_type, 0)); + if (fd == -1) { + tst_res(TFAIL | TERRNO, "fsopen() failed"); + return; + } + + TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + return; + } + + TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + return; + } + + TEST(fsmfd = fsmount(fd, 0, 0)); + SAFE_CLOSE(fd); + + if (fsmfd == -1) { + tst_res(TFAIL | TERRNO, "fsmount() failed"); + return; + } + + 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_res(TFAIL, "%s: move_mount() succeeded unexpectedly (index: %d)", + tc->name, n); + return; + } + + if (tc->exp_errno != TST_ERR) { + tst_res(TFAIL | TTERRNO, "%s: move_mount() should fail with %s", + tc->name, tst_strerrno(tc->exp_errno)); + return; + } + + tst_res(TPASS | TTERRNO, "%s: move_mount() failed as expected", tc->name); +} + +static struct tst_test test = { + .tcnt = ARRAY_SIZE(tcases), + .test = run, + .setup = fsopen_supported_by_kernel, + .needs_root = 1, + .format_device = 1, + .mntpoint = MNTPOINT, + .all_filesystems = 1, + .dev_fs_flags = TST_FS_SKIP_FUSE, +}; From patchwork Thu Feb 27 05:14:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1245532 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=WRiGtdU+; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (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 48SgrF2Bgsz9sPK for ; Thu, 27 Feb 2020 16:16:29 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 6836E3C2573 for ; Thu, 27 Feb 2020 06:16:26 +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 541A53C25D5 for ; Thu, 27 Feb 2020 06:15:12 +0100 (CET) Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) (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 801721A00EE9 for ; Thu, 27 Feb 2020 06:15:11 +0100 (CET) Received: by mail-pg1-x536.google.com with SMTP id h8so818028pgs.9 for ; Wed, 26 Feb 2020 21:15: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=UZTroJDjhYfx8UJ+i7amfx+h2T0rwIjicnC0mJv7l8Y=; b=WRiGtdU+aT1rZHcZAVHgtvoOCotHoqd5TFjYgw1Ra7yPw4jdWpjOLrbACuD0P0BM/J MV0gfsdRgDKrUOMdf5Io0W/Cwc5VlSTT9efGtnSBhGecfAm5u1kZx44gzmI35CClfD4e vuiXf+zS1OtVCnTEy1DExFdlErWXPbxsdioZML6uIonT9gEygDG3Eu3SIYR4bZYAS0xK ZPtxsqCUmwREOUfHB6M02aEFebsUMlbZE0h0T9GZiu7nyiI+QnKXTaRkdoPLKyYQ+Qk5 yTMfZVQSa0t2C24rfWQw6li361oA1CGuRQ7kWnCIaa5X21DyVtzVV4fnhF8BEUGBQTzA nmsg== 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=UZTroJDjhYfx8UJ+i7amfx+h2T0rwIjicnC0mJv7l8Y=; b=bv6vfYz8LxpbPQUGXdCgbRMGXALa3zqlhIywgk86pbQu3OYLAoo85B5D82sTJ9M0t+ Kjb1ju+3ikwpsIrlLXW9uLWYtjD5Wu2LR3VxaqwdjPsl8LKTt0sxb5cEjBW7gdWln0q0 UDOjFqzrhvLvW4GBpD9YOc4oAMr3G4UWYraLeF2fKpcIqzGStmc/dvw/+vQMK3B2qFWq 6PfHwe6fRoalWrvUKWfkEAqEUCpTulDMWPup2RiIYewTOUWB+K0FirGR3FfYC1mEmDoK NReP18vue803lzke0b9QQYaR93tQd0GJ2MfyxpNt8uP8MlJv1/D4coCmWL5dgGkzYqCN Qc/Q== X-Gm-Message-State: APjAAAVDSdR7OEdcg3CTXg0N2Muqk/AgOF7hMRTKP4lXhZvYD+Jxujd/ GRcVex1SZ60VexzXpasJJZLHXsPUcdw= X-Google-Smtp-Source: APXvYqwEwteHXSAGjmpyAr25re/xTuwW+RiD334fJzMMFsHIb8tbdru2wipyylIlCbGdapXkJNqPIw== X-Received: by 2002:aa7:95b0:: with SMTP id a16mr2157154pfk.253.1582780509536; Wed, 26 Feb 2020 21:15:09 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id c19sm5395039pfc.144.2020.02.26.21.15.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Feb 2020 21:15:08 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Thu, 27 Feb 2020 10:44:37 +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 V5 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. Acked-by: Li Wang Signed-off-by: Viresh Kumar --- runtest/syscalls | 3 + testcases/kernel/syscalls/fspick/.gitignore | 2 + testcases/kernel/syscalls/fspick/Makefile | 6 ++ testcases/kernel/syscalls/fspick/fspick.h | 60 ++++++++++++++++++++ testcases/kernel/syscalls/fspick/fspick01.c | 62 +++++++++++++++++++++ testcases/kernel/syscalls/fspick/fspick02.c | 54 ++++++++++++++++++ 6 files changed, 187 insertions(+) create mode 100644 testcases/kernel/syscalls/fspick/.gitignore create mode 100644 testcases/kernel/syscalls/fspick/Makefile create mode 100644 testcases/kernel/syscalls/fspick/fspick.h 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 32b3f36e4dcc..ce27f835c42e 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/fspick.h b/testcases/kernel/syscalls/fspick/fspick.h new file mode 100644 index 000000000000..62864355da06 --- /dev/null +++ b/testcases/kernel/syscalls/fspick/fspick.h @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + */ + +#ifndef FSPICK_H__ +#define FSPICK_H__ + +#define MNTPOINT "mntpoint" + +static int ismounted; + +static void cleanup(void) +{ + if (ismounted) + SAFE_UMOUNT(MNTPOINT); +} + +static void setup(void) +{ + int fd, fsmfd; + + fsopen_supported_by_kernel(); + + TEST(fd = fsopen(tst_device->fs_type, 0)); + 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(fsmfd = fsmount(fd, 0, 0)); + SAFE_CLOSE(fd); + + if (fsmfd == -1) + tst_brk(TBROK | TERRNO, "fsmount() failed"); + + 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_is_mounted(MNTPOINT)) + tst_brk(TBROK | TERRNO, "device not mounted"); +} + +#endif /* FSPICK_H__ */ diff --git a/testcases/kernel/syscalls/fspick/fspick01.c b/testcases/kernel/syscalls/fspick/fspick01.c new file mode 100644 index 000000000000..4e1daeaee14a --- /dev/null +++ b/testcases/kernel/syscalls/fspick/fspick01.c @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Basic fspick() test. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" +#include "fspick.h" + +#define TCASE_ENTRY(_flags) {.name = "Flag " #_flags, .flags = _flags} + +static struct tcase { + char *name; + unsigned int flags; +} tcases[] = { + TCASE_ENTRY(FSPICK_CLOEXEC), + TCASE_ENTRY(FSPICK_SYMLINK_NOFOLLOW), + TCASE_ENTRY(FSPICK_NO_AUTOMOUNT), + TCASE_ENTRY(FSPICK_EMPTY_PATH), +}; + +static void run(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + int fspick_fd; + + TEST(fspick_fd = fspick(AT_FDCWD, MNTPOINT, tc->flags)); + if (fspick_fd == -1) { + tst_res(TFAIL | TERRNO, "fspick() failed"); + return; + } + + TEST(fsconfig(fspick_fd, FSCONFIG_SET_STRING, "sync", "false", 0)); + if (TST_RET == -1) { + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + goto out; + } + + TEST(fsconfig(fspick_fd, FSCONFIG_SET_FLAG, "ro", NULL, 0)); + if (TST_RET == -1) { + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + goto out; + } + + tst_res(TPASS, "%s: fspick() passed", tc->name); + +out: + SAFE_CLOSE(fspick_fd); +} + +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..dc8f153ccc48 --- /dev/null +++ b/testcases/kernel/syscalls/fspick/fspick02.c @@ -0,0 +1,54 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Basic fspick() failure tests. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" +#include "fspick.h" + +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 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_res(TFAIL, "%s: fspick() succeeded unexpectedly (index: %d)", + tc->name, n); + return; + } + + if (tc->exp_errno != TST_ERR) { + tst_res(TFAIL | TTERRNO, "%s: fspick() should fail with %s", + tc->name, tst_strerrno(tc->exp_errno)); + return; + } + + 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 Thu Feb 27 05:14:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 1245533 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=T3Z3XQOZ; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (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 48SgrS3zBbz9sRY for ; Thu, 27 Feb 2020 16:16:40 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id B48FC3C2591 for ; Thu, 27 Feb 2020 06:16:37 +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 [217.194.8.6]) by picard.linux.it (Postfix) with ESMTP id 2CA0F3C25CE for ; Thu, 27 Feb 2020 06:15:15 +0100 (CET) Received: from mail-pg1-x52a.google.com (mail-pg1-x52a.google.com [IPv6:2607:f8b0:4864:20::52a]) (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 519261401A6D for ; Thu, 27 Feb 2020 06:15:14 +0100 (CET) Received: by mail-pg1-x52a.google.com with SMTP id h8so818082pgs.9 for ; Wed, 26 Feb 2020 21:15:14 -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=gCEIXlfKTLUbDUV+M75ZB4Q7DLtEGDsNB1TPB6iRtUc=; b=T3Z3XQOZid+0c2tLvUQulsDlMKmScdiGyFVXqXU7l2af9cAmQ2ZbeDAxXkdcD6DBvv oCYlVqbmRdrQyFskajArKEKkshDKjrRp7Q8FgqBZe/blfs9Ka3iMGp2V0IQW8T112v5E CZZBmWdU0oD64DeFrP+/UYtWZmX/M9vqT6sBvD1XZusxPutMaT5Eig5bCBHGJOeMSiXD dmcZtmFTjhp+i+lsW6LojZrNR8Lwue9Z793+SNmv372FzpYyIhkm+Ba2gOm2lLqZelVy yhDd/w8U3bw76K0mQvUS2CHF6u4XZGjIkNHnND6ni/PLVaxhe4eQ0SuYsG1m/6Zo9HMf VotQ== 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=gCEIXlfKTLUbDUV+M75ZB4Q7DLtEGDsNB1TPB6iRtUc=; b=AcgnBoCnW7tBkkbHvzqBcccTN3wnhdUReuLPGkSE2xroQE/X0pF5iDbWGb3twOCqMH lKeTg2cMXxvkp/LRBK0D/hyqDt8JOSYFquTwcXF+yGjumsy+HNEu8clRCbveC4TJZkK4 id8WzUw7XT3WodHdpv6sD1ADKddP99rF1ginEQNvawUQt5NjL3vHVHjRzyZ/vb2Hrvzg v0Fak0mroA1xC9CU4Gq2C3SF/3X2IfNGthSK6iP8PVJVP7hKg1ffwdX8zEhI3c5NRSw5 y5Ohrc8S8VHPtUjoUhnrB5lUtkZj549fTe5YbJoMenPw4lywaEnqmO6pGNBSdJSeQ/cZ kerw== X-Gm-Message-State: APjAAAUnZ+LRa1IS5pJv/l/8DGt23+PmDt9lKRGuy06+vtDS3TWQflc2 hvlH0J1ZbdcZFBMOJO/S9V4BdTkFP5E= X-Google-Smtp-Source: APXvYqxkWJ4c0wcE+lRza8H1TkRRVdJ72A3kQ+iCCWCMcLXrIqMHBrgpndf2m9oKFNzWQVFOPw8Y/w== X-Received: by 2002:a63:1d22:: with SMTP id d34mr2305395pgd.21.1582780512238; Wed, 26 Feb 2020 21:15:12 -0800 (PST) Received: from localhost ([223.226.55.170]) by smtp.gmail.com with ESMTPSA id a2sm5048413pfi.30.2020.02.26.21.15.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Feb 2020 21:15:11 -0800 (PST) From: Viresh Kumar To: ltp@lists.linux.it Date: Thu, 27 Feb 2020 10:44:38 +0530 Message-Id: <6732d20663a0d998b1e4d14ff2df48eeacffe946.1582779464.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 V5 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. Acked-by: Li Wang 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 | 108 ++++++++++++++++++ .../kernel/syscalls/open_tree/open_tree02.c | 105 +++++++++++++++++ 5 files changed, 224 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 ce27f835c42e..cf4b55e08262 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..b83dbab9df34 --- /dev/null +++ b/testcases/kernel/syscalls/open_tree/open_tree01.c @@ -0,0 +1,108 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * Basic open_tree() test. + */ +#include "tst_test.h" +#include "lapi/fsmount.h" + +#define MNTPOINT "mntpoint" +#define OT_MNTPOINT "ot_mntpoint" + +#define TCASE_ENTRY(_flags) {.name = "Flag " #_flags, .flags = _flags} + +static struct tcase { + char *name; + unsigned int flags; +} tcases[] = { + TCASE_ENTRY(OPEN_TREE_CLONE), + TCASE_ENTRY(OPEN_TREE_CLOEXEC) +}; + +static void setup(void) +{ + fsopen_supported_by_kernel(); + SAFE_MKDIR(OT_MNTPOINT, 0777); +} + +static void run(unsigned int n) +{ + struct tcase *tc = &tcases[n]; + int fd, fsmfd, otfd; + + TEST(fd = fsopen(tst_device->fs_type, 0)); + if (fd == -1) { + tst_res(TFAIL | TERRNO, "fsopen() failed"); + return; + } + + TEST(fsconfig(fd, FSCONFIG_SET_STRING, "source", tst_device->dev, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + return; + } + + TEST(fsconfig(fd, FSCONFIG_CMD_CREATE, NULL, NULL, 0)); + if (TST_RET == -1) { + SAFE_CLOSE(fd); + tst_res(TFAIL | TERRNO, "fsconfig() failed"); + return; + } + + TEST(fsmfd = fsmount(fd, 0, 0)); + SAFE_CLOSE(fd); + + if (fsmfd == -1) { + tst_res(TFAIL | TERRNO, "fsmount() failed"); + return; + } + + TEST(move_mount(fsmfd, "", AT_FDCWD, MNTPOINT, + MOVE_MOUNT_F_EMPTY_PATH)); + SAFE_CLOSE(fsmfd); + + if (TST_RET == -1) { + tst_res(TFAIL | TERRNO, "move_mount() failed"); + return; + } + + if (!tst_is_mounted(MNTPOINT)) { + tst_res(TFAIL | TERRNO, "device not mounted"); + goto out; + } + + TEST(otfd = open_tree(AT_FDCWD, MNTPOINT, tc->flags | OPEN_TREE_CLONE)); + if (otfd == -1) { + tst_res(TFAIL | TERRNO, "open_tree() failed"); + goto out; + } + + TEST(move_mount(otfd, "", AT_FDCWD, OT_MNTPOINT, + MOVE_MOUNT_F_EMPTY_PATH)); + SAFE_CLOSE(otfd); + + if (TST_RET == -1) { + tst_res(TFAIL | TERRNO, "move_mount() failed"); + goto out; + } + + if (tst_is_mounted(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, + .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..a7e3641d9537 --- /dev/null +++ b/testcases/kernel/syscalls/open_tree/open_tree02.c @@ -0,0 +1,105 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2020 Viresh Kumar + * + * 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(fd = fsopen(tst_device->fs_type, 0)); + 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(fsmfd = fsmount(fd, 0, 0)); + SAFE_CLOSE(fd); + + if (fsmfd == -1) + tst_brk(TBROK | TERRNO, "fsmount() failed"); + + 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_is_mounted(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_res(TFAIL, "%s: open_tree() succeeded unexpectedly (index: %d)", + tc->name, n); + return; + } + + if (tc->exp_errno != TST_ERR) { + tst_res(TFAIL | TTERRNO, "%s: open_tree() should fail with %s", + tc->name, tst_strerrno(tc->exp_errno)); + return; + } + + 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, +};