From patchwork Tue Feb 19 09:28:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 1044564 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) 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.b="pmXmgNpG"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 443b6D6Ym7z9s3l for ; Tue, 19 Feb 2019 20:29:24 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 20C9B294AA1 for ; Tue, 19 Feb 2019 10:29:22 +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 [217.194.8.7]) by picard.linux.it (Postfix) with ESMTP id BFD693EA37B for ; Tue, 19 Feb 2019 10:29:13 +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-7.smtp.seeweb.it (Postfix) with ESMTPS id 70384200D32 for ; Tue, 19 Feb 2019 10:29:09 +0100 (CET) Received: by mail-pf1-x441.google.com with SMTP id v21so6970886pfm.12 for ; Tue, 19 Feb 2019 01:29:09 -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; bh=5QvFDvM52ICo6DkVyvSKxlpIS7tDSllpvXRQVtAjopo=; b=pmXmgNpGBKZeW4evJOAAO2btMiQVI+ekdDprKYt51ejutG+VRxRNhxi/gz2FM7eLSo RmX1sQgTTO5JAGOP0fhuJa7yTfHM6sRz8NzNUNmR3krw0rY0g8oXgQTyU6YL/2JnaHjd FUU4QNVyVII6fBBZLcYgEos7YaKU0A/YQaOCOJVZh5uZoSxv93KL36eBJDrCmzxzHjPp ueIxzkQjWz+gVTGnl70Duh0e8He30FlXLdDExcUO4xiIa5cVutQolY03Y5Nw2xl62Uro 6wAao0FKNuG/bw3FrSq3mCWu1NjPcIj0/h83W6I7ggBS+1m5DWye+IJVg/MI+TCT99Hb LeJQ== 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; bh=5QvFDvM52ICo6DkVyvSKxlpIS7tDSllpvXRQVtAjopo=; b=O1I6ehQLxohqfJYE0ZZKFfd6L7b5JTeJvYp/Gob9Y/EATkiidDzm3lfLBPEX4gbQzt HvdJ4A47B2Be+cPIfO3zgcWa0ugHEgEjNO9lm8tJIQP1pAUNR3VX2mCAdGjN1mjinXmw dMLZt+FPnpXEY0wsKvGZSILa81ZsNdWhEWbfHUG2Zl9hfgPsfSZpB+6sPv0UWeO/m+jt hSdTw7Aj9iHhllhVwC2YLH/I4sNuNvNjBirLn/s1oZ7J+Lje9qV3y/2w4xagDAN01FtE IMBemkPrWPDErtcLe8t7V374PPoU9aHumqBpywrmZBaJnjHWwZ0yOzibnOY6wag8oCb+ l2kQ== X-Gm-Message-State: AHQUAuaL+vI14eXOuem9/IJznthxSLB29RgPDt1+D6lkJJvQRHjnn5ag HYZfINFhb8iPtOgsj7cO6tn8Hez5SjWfsA== X-Google-Smtp-Source: AHgI3Ib9yWTzjkdt94SRs3wJbj3iOFD29wCknTjacHoENuO2RYteCc9mhQp4vIGnQv0G+NvyTAwwmg== X-Received: by 2002:a63:4a4d:: with SMTP id j13mr23466568pgl.127.1550568547680; Tue, 19 Feb 2019 01:29:07 -0800 (PST) Received: from localhost.localdomain ([117.252.69.94]) by smtp.gmail.com with ESMTPSA id n19sm34442229pfg.67.2019.02.19.01.29.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Feb 2019 01:29:07 -0800 (PST) From: Sumit Garg To: ltp@lists.linux.it Date: Tue, 19 Feb 2019 14:58:15 +0530 Message-Id: <1550568500-10871-3-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550568500-10871-1-git-send-email-sumit.garg@linaro.org> References: <1550568500-10871-1-git-send-email-sumit.garg@linaro.org> 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_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-7.smtp.seeweb.it Cc: daniel.thompson@linaro.org Subject: [LTP] [PATCH v3 2/7] syscalls: add syncfs() sync device test-case X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" syncfs01 tests to sync filesystem having large dirty file pages to block device. Also, it tests all supported filesystems on a test block device. Signed-off-by: Sumit Garg --- configure.ac | 1 + include/lapi/syncfs.h | 21 ++++++++ m4/ltp-syncfs.m4 | 10 ++++ runtest/syscalls | 2 + testcases/kernel/syscalls/syncfs/.gitignore | 1 + testcases/kernel/syscalls/syncfs/Makefile | 8 ++++ testcases/kernel/syscalls/syncfs/check_syncfs.h | 19 ++++++++ testcases/kernel/syscalls/syncfs/syncfs01.c | 64 +++++++++++++++++++++++++ 8 files changed, 126 insertions(+) create mode 100644 include/lapi/syncfs.h create mode 100644 m4/ltp-syncfs.m4 create mode 100644 testcases/kernel/syscalls/syncfs/.gitignore create mode 100644 testcases/kernel/syscalls/syncfs/Makefile create mode 100644 testcases/kernel/syscalls/syncfs/check_syncfs.h create mode 100644 testcases/kernel/syscalls/syncfs/syncfs01.c diff --git a/configure.ac b/configure.ac index caea344..9122b6d 100644 --- a/configure.ac +++ b/configure.ac @@ -231,6 +231,7 @@ LTP_CHECK_TPACKET_V3 LTP_CHECK_RLIMIT64 LTP_DETECT_HOST_CPU LTP_CHECK_PERF_EVENT +LTP_CHECK_SYNCFS if test "x$with_numa" = xyes; then LTP_CHECK_SYSCALL_NUMA diff --git a/include/lapi/syncfs.h b/include/lapi/syncfs.h new file mode 100644 index 0000000..1341c6b --- /dev/null +++ b/include/lapi/syncfs.h @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Sumit Garg + */ + +#ifndef SYNCFS_H +#define SYNCFS_H + +#include +#include "config.h" +#include "lapi/syscalls.h" + +#if !defined(HAVE_SYNCFS) +int syncfs(int fd) +{ + return tst_syscall(__NR_syncfs, fd); +} +#endif + +#endif /* SYNCFS_H */ diff --git a/m4/ltp-syncfs.m4 b/m4/ltp-syncfs.m4 new file mode 100644 index 0000000..836a055 --- /dev/null +++ b/m4/ltp-syncfs.m4 @@ -0,0 +1,10 @@ +dnl SPDX-License-Identifier: GPL-2.0-or-later +dnl Copyright (c) 2019 Linaro Limited. All rights reserved. + +dnl +dnl LTP_CHECK_SYNCFS +dnl ---------------------------- +dnl +AC_DEFUN([LTP_CHECK_SYNCFS],[ +AC_CHECK_FUNCS(syncfs,,) +]) diff --git a/runtest/syscalls b/runtest/syscalls index 668c87c..9442740 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1346,6 +1346,8 @@ symlinkat01 symlinkat01 sync01 sync01 sync02 sync02 +syncfs01 syncfs01 + #testcases for sync_file_range sync_file_range01 sync_file_range01 diff --git a/testcases/kernel/syscalls/syncfs/.gitignore b/testcases/kernel/syscalls/syncfs/.gitignore new file mode 100644 index 0000000..6066295 --- /dev/null +++ b/testcases/kernel/syscalls/syncfs/.gitignore @@ -0,0 +1 @@ +syncfs01 diff --git a/testcases/kernel/syscalls/syncfs/Makefile b/testcases/kernel/syscalls/syncfs/Makefile new file mode 100644 index 0000000..3e6c2f4 --- /dev/null +++ b/testcases/kernel/syscalls/syncfs/Makefile @@ -0,0 +1,8 @@ +# Copyright (c) 2019 - Linaro Limited. All rights reserved. +# 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/syncfs/check_syncfs.h b/testcases/kernel/syscalls/syncfs/check_syncfs.h new file mode 100644 index 0000000..26991d2 --- /dev/null +++ b/testcases/kernel/syscalls/syncfs/check_syncfs.h @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Sumit Garg + */ + +#ifndef CHECK_SYNCFS_H +#define CHECK_SYNCFS_H + +void check_syncfs(void) +{ + int ret; + + ret = syncfs(-1); + if (ret == -1 && errno == EINVAL) + tst_brk(TCONF, "syncfs() not supported"); +} + +#endif /* CHECK_SYNCFS_H */ diff --git a/testcases/kernel/syscalls/syncfs/syncfs01.c b/testcases/kernel/syscalls/syncfs/syncfs01.c new file mode 100644 index 0000000..7c3efb0 --- /dev/null +++ b/testcases/kernel/syscalls/syncfs/syncfs01.c @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Sumit Garg + */ + +/* + * Test syncfs + * + * It basically tests syncfs() to sync filesystem having large dirty file + * pages to block device. Also, it tests all supported filesystems on a test + * block device. + */ + +#define _GNU_SOURCE +#include +#include +#include +#include "lapi/syncfs.h" +#include "tst_sync_device.h" +#include "tst_test.h" +#include "check_syncfs.h" + +#define MNTPOINT "mnt_point" +#define TST_FILE MNTPOINT"/test" +#define TST_FILE_SIZE_MB 32 + +static void verify_syncfs(void) +{ + int fd; + + fd = tst_sync_device_write(TST_FILE, TST_FILE_SIZE_MB); + + TEST(syncfs(fd)); + if (TST_RET != 0) + tst_brk(TFAIL | TTERRNO, "syncfs(fd) failed"); + + if (tst_sync_device_check(TST_FILE_SIZE_MB)) + tst_res(TPASS, "Test filesystem synced to device"); + else + tst_res(TFAIL, "Failed to sync test filesystem to device"); +} + +static void setup(void) +{ + check_syncfs(); + + tst_sync_device_init(tst_device->dev); +} + +static void cleanup(void) +{ + tst_sync_device_cleanup(); +} + +static struct tst_test test = { + .needs_root = 1, + .mount_device = 1, + .all_filesystems = 1, + .mntpoint = MNTPOINT, + .setup = setup, + .cleanup = cleanup, + .test_all = verify_syncfs, +};