From patchwork Thu Feb 21 09:00:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 158881 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp242890jaa; Thu, 21 Feb 2019 01:01:13 -0800 (PST) X-Google-Smtp-Source: AHgI3IbwsF0tDg77S8wd/AU7DVwAB1zWjQSnG9kj/Y68WidgYa91IWzGLu4jP3xV3W3sjw30EYw5 X-Received: by 2002:a50:9e0a:: with SMTP id z10mr29319222ede.39.1550739673622; Thu, 21 Feb 2019 01:01:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550739673; cv=none; d=google.com; s=arc-20160816; b=bCN7mCegVEhUEgcdB1Zulo4eRTA2QayFy7cvXTsDlmXruaKJa2nVvsEnv37KoPM1wr SHMBJ3KQgswscePSfKg4lGGk7UhaqvZ7znUYe7gzwVJgNlZ+8RRjD37tMrq/Cgc4XDy3 k5InykJvla5uGsNrho2aUsN/89FXvU6PgvUfDeB7qAbXOEdvft41+HJgzX3fmXxLioER EdkND7NGDVzpgLkN+Ipq+MlAFiHPHGYipMMFYdLmYyUGTNEqSVSnB5Fse/G+FAaZsm2Q 3GftQbQd7HbcHmHoXhlvnPFhDjCo8S5Qm3YBQl70SjFoscYHRjAs7qYZ83sqyAo8gKnU O1Og== 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=TfDJFXUhQ6VfNwr6i0aPxzDy6//i1D50diidxwiZxUI=; b=BRj7Zc5GaoPLtaIL1AZ/4h6W9KboeYEx74jRTXM1uANB15rVNOpPiy+TVUoMrZgurg eO0WY4U5epF4Mvkf06NUrxVq/x+B2uae7OjJah8qlSAJjSbDfWFJsps+Mgx4f8IAiZ3/ wVbtUUCa1rbaE4AzH8qF0nvsyzP/HvTtrO+I5G4qC/OrMt3H4GoqPC6zo0BR1TWoqarx 0/PJC5VaIbYd9LXYrtZ7xUBFv0GGmP3TV7CeGKufN47rXpiaAUvnFgXhZEl4Nz38MFHh 5skINzNXceL8lHAZzjhCPWnRqv50Q01VvxDKsieZjWLdXYG+NI+7hdROme07vdNX0Grv 1A4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=gIBes8sa; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 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. [2001:1418:10:5::2]) by mx.google.com with ESMTPS id p1si2530956eja.16.2019.02.21.01.01.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 01:01:13 -0800 (PST) Received-SPF: pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 as permitted sender) client-ip=2001:1418:10:5::2; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=gIBes8sa; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 2001:1418:10:5::2 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 33C38294AEC for ; Thu, 21 Feb 2019 10:01:13 +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 B21E0294ABC for ; Thu, 21 Feb 2019 10:01:05 +0100 (CET) Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (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 A89B714060CE for ; Thu, 21 Feb 2019 10:01:01 +0100 (CET) Received: by mail-pf1-x442.google.com with SMTP id i19so419050pfd.0 for ; Thu, 21 Feb 2019 01:01:01 -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=U2pa7TA3bk4YVlWvqiVBiXnjF1vDDfcWhaSu4nF0rAc=; b=gIBes8sa1eV/Z/ubXYexxsT27G2cTQSZlP3w6L5Cr/odJFwC7atdmbiFvOLDIhsH7E GPYCTzf8tAbsxfFxJiNlOcsXHZ7Ip7laiCZdiQ93LqpDNz+pRdOrquEd5pSnOr5PxNdl FB/8PQ8hfu4I8lSPZ+ulfjXMaOWiE5/EAPAFMO9C1eBl67Cr57dYw3D35y2QEdOIP4m+ bEKHYuSrG+NhhsqhoCEsHR8OaQPpvEYDQ20owhPlD7Ia36hHKPhkpNa7fv1hf/CeC+zq 6W5TnrL6XUNxJ3B+NIgF0efk7xWZvbp6sx9oXlNbR3HB6Fud10tHoOu8BqAbBej+mJCa A3jQ== 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=U2pa7TA3bk4YVlWvqiVBiXnjF1vDDfcWhaSu4nF0rAc=; b=RitXwQ2puwqNvnSXj1M1OGU9gGpguzcv8O9y/HeLBcV6LNZVShEr6TBaVbKaQA5Bmu vb6dr53IM1EJbtdIezN6xCLVk4o7uEX6yQfVoWOtf8NFmpoo2efwtRP97TG3cZ8wcyuK mTWnfYnBRyCepw1F4cf5RA8U8gk4sZYk+qPoyan6eeC6jOpNyRnGgU/NStP0hN8Xknon zyf2J4wFA2ptAfkrmMMeUaykNZSRGw9x3E2z1PgN997ky5roquT1mmr6Ikg7q/TN/YA1 uCkfZ1uZ7GKLRMDn2tSGYsKCXGlRh++oNEHZEqlTEyTsBC2uvFg00j6G69iVdK8W1IE2 AjKQ== X-Gm-Message-State: AHQUAuasynoPHg03mF6hJRb0PLrbFQzXKOWcGrXcwgVe2IIUK2Eyw6KV CccOCLjY73miNAlhXbAPEvin8g== X-Received: by 2002:a63:fe58:: with SMTP id x24mr33585121pgj.255.1550739660214; Thu, 21 Feb 2019 01:01:00 -0800 (PST) Received: from localhost.localdomain ([117.252.69.94]) by smtp.gmail.com with ESMTPSA id v4sm27703948pff.77.2019.02.21.01.00.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Feb 2019 01:00:59 -0800 (PST) From: Sumit Garg To: chrubis@suse.cz, ltp@lists.linux.it Date: Thu, 21 Feb 2019 14:30:11 +0530 Message-Id: <1550739616-24054-5-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550739616-24054-1-git-send-email-sumit.garg@linaro.org> References: <1550739616-24054-1-git-send-email-sumit.garg@linaro.org> 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_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-6.smtp.seeweb.it Cc: daniel.thompson@linaro.org Subject: [LTP] [PATCH v4 4/9] 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 | 67 +++++++++++++++++++++++++ 8 files changed, 129 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..4382a34 --- /dev/null +++ b/testcases/kernel/syscalls/syncfs/syncfs01.c @@ -0,0 +1,67 @@ +// 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_test.h" +#include "check_syncfs.h" + +#define MNTPOINT "mnt_point" +#define TST_FILE MNTPOINT"/test" +#define TST_FILE_SIZE_MB 32 +#define SIZE_MB (1024*1024) +#define MODE 0644 + +static void verify_syncfs(void) +{ + int fd; + unsigned long written; + + fd = SAFE_OPEN(TST_FILE, O_RDWR|O_CREAT, MODE); + + tst_dev_bytes_written(tst_device->dev); + + tst_fill_fd(fd, 0, SIZE_MB, TST_FILE_SIZE_MB); + + TEST(syncfs(fd)); + + if (TST_RET) + tst_brk(TFAIL | TTERRNO, "syncfs(fd) failed"); + + written = tst_dev_bytes_written(tst_device->dev); + + SAFE_CLOSE(fd); + + if (written >= SIZE_MB * 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(); +} + +static struct tst_test test = { + .needs_root = 1, + .mount_device = 1, + .all_filesystems = 1, + .mntpoint = MNTPOINT, + .setup = setup, + .test_all = verify_syncfs, +};