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: 158699 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3447260jaa; Tue, 19 Feb 2019 01:29:24 -0800 (PST) X-Google-Smtp-Source: AHgI3IbaE+bfBT5Sa+hERyhwkjclnCNLqcgOfv4edGEMXZ+6i9V5pXvS9RVm1QjaA+XbkbxAS5eb X-Received: by 2002:a50:a8c3:: with SMTP id k61mr22341482edc.296.1550568564669; Tue, 19 Feb 2019 01:29:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550568564; cv=none; d=google.com; s=arc-20160816; b=fLIV3yOZ1Qc9h28VYKrDFC+7IdNDhu/Xb7/H2YGBKHBKZJrBh6LW3tDUBpECnmZSEB uO13kXSc807bhLjuMQdnlH3lav4Y6Elrb8b2E4yCRbYeEh+MyZNS6sYfXD60zK435uV5 8OVOAqD7GzAAtVAZkniklVGBxII0dqSnSc6Kjzy7yJlEsNN/lFI9+AeZ2UI8shYCvzSY arGCGUvi0Kj3oKax/+/z+277hIt2mVrqt7KOGB7sqikQefzOVg/yDn6MCl5+4uC2Pfju EEIsqwolqO+zKYG4fegr7PfV0yL5EB9bq2fhQgloYnDzLwl7WtjMkvciXNBwBT4NhXNq HZAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:cc:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=mmiyfzGh3Kiz3GyYXNVAJ1equOQO9YMG+lWtDQG4PRs=; b=vc1LOf/BCXrKiV8DFnOQlqsOHbILJ2q7Hnv8BXAUiE4rYilq8FqccT+L1sraCN1hHQ d/m6RqPjKen6GiIYNk7/0xj/2atV8iqpmk0QPPiGytZY/iaV2Vh2NFbNB+xF/jNx7LWy b8TB1jQ2Fh/g6MG0otO3ZqtQiqyHhZyp8zCHFvlJmcADLgy5UlWsTFUFpIhuHpTZootX cRA5vD1p0hkgch6LNSMbxPqAo/VinxSHMiXIRTmjIocf0CUvS3sUpL8gpAD36a9VQsF0 rjNv88MIgreYSiEuIRh4KBb1o78lFGkgj1kA6j7O7F0g12bPG/5e1igH8UIqjeUcAEDV GAPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=pmXmgNpG; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from picard.linux.it (picard.linux.it. [213.254.12.146]) by mx.google.com with ESMTPS id k30si759941edb.244.2019.02.19.01.29.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Feb 2019 01:29:24 -0800 (PST) Received-SPF: pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) client-ip=213.254.12.146; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=pmXmgNpG; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) smtp.mailfrom="ltp-bounces+patch=linaro.org@lists.linux.it"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 3BDA93EA37D for ; Tue, 19 Feb 2019 10:29:24 +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-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+patch=linaro.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, +};