From patchwork Thu Feb 21 09:00:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 158883 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp243095jaa; Thu, 21 Feb 2019 01:01:23 -0800 (PST) X-Google-Smtp-Source: AHgI3Iay2CqqkeGFOxZbUQX67zDCmFxCHLGdjsNvDyqhYsJbSke3EhtmoGadkeX4jS7oom1qq+r7 X-Received: by 2002:a50:a622:: with SMTP id d31mr31757540edc.228.1550739683884; Thu, 21 Feb 2019 01:01:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550739683; cv=none; d=google.com; s=arc-20160816; b=dZi6+v15umiU5N0dnPJ6MF/Tl1VRBQxvW84dUx0r2M73V6qc36tIc8rnqLUdYmDz48 R6Vfn6QaMPNtwHYzQXpu6E0osemr0vAUZufDSRfINQ6qyBN6MpaqVBnhxqxJsY/wM79v qUHDtmONIkzeU8wBZPUavk1m3Dz6qg/5yQ08KDcphrJk8IrABgIft0LFTdQ908ao1kxW lEGjaJsuS02bqCJ/vwl6MRj8fQsZ4SNpX3oP9n+Mx0o+k174VxJ1BTyan2L3O5n2PzNh hry/6RhQjF8igVJMFA7vSvGFNjshdguJU+1wI5tunqUA0862ZD6Ny4Pv+t4aDotJYZp2 9gFQ== 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=1oFsZgV6It2I/jUtVRFl2x0/y9h0809fDxd+kpI+4PQ=; b=zF+eVX+GK580lgFiU7DJ8CIbSFUnP9CNibUrm1aQuOtL1bngsBas05LzF1w4R1BgwU dntK6jSHoiRP2DCSHS/hb0JlHAvN7indvqsYJjDs446KUBrHBd2d90bAKrBbLbYxAsHR ovGrwdvMzG8VYAcJA523NXlKqxO/nUwE9+BHvjp1aOOhgIshEBiqz9EzrrrtpZg4K5gl CTr0FxiBYIa5KC0e//+fAmxUUt/AY0bkxTAvDjIOPGHD/V1Jvd2AMIDR+tjy2FqL1gdA qlt2ZA6n73ZAWVcqKfQXqtQ8SV0eTobjqQfkaMfKx62frrrCD9Ubobh4HrWaa6NOBgli KSzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="HyycqY/3"; 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 p37si7838759edc.272.2019.02.21.01.01.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 01:01:23 -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="HyycqY/3"; 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 E7F93294AEF for ; Thu, 21 Feb 2019 10:01:21 +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 [217.194.8.5]) by picard.linux.it (Postfix) with ESMTP id 7A7493EA20B for ; Thu, 21 Feb 2019 10:01:10 +0100 (CET) Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) (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 BDBB4603453 for ; Thu, 21 Feb 2019 10:01:10 +0100 (CET) Received: by mail-pf1-x42c.google.com with SMTP id g6so13417444pfh.13 for ; Thu, 21 Feb 2019 01:01: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=kf7JgvHXw82F8Uw2a5AQUPKBZR0XwFJP0TUSBj2BawI=; b=HyycqY/3L9TsPnAMZ/6sO2AZniLwU/dicm3NChhWLkC+LuNNYe3R/io0HRodgNTTT9 GDbmuTIwBM9wAYsf9BttKc29kfH6LvJi4nl+C1GRWNQxuDV5PoQhZk2r6DrZXhCtEe6t EKWuL+D/uOACUSpPB8SK2pAERzXjiqHhGqPn/POmzBDLM77wDW8ZBh1U67ZpZeCQ1Uhh 1bmFDdPnxq4kxd08UQOOspHdYll8s8bcMPjLemcGKmwjbGS8sxAdNMDqBa+Lnvr/zBfY 9h49t9DaQISYnI7M6M78IamK8QkG+NZOzyj8SaS4/4TLzIE3wTbddtrRha3I4ODQUp8Y faSA== 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=kf7JgvHXw82F8Uw2a5AQUPKBZR0XwFJP0TUSBj2BawI=; b=Vayy3sbKu5z5Fz5wAZYxtS5jNxjI9lyZGd3EzdYaLQMFDGdpmx7q73aTukBFUdnCZL 1yImY7iP6CCaf2yu8mHIXdduUrmo5I3kAKhaDCAtSyUa6/Ndkc3XUv/MPudZG0/ngKuy CIwLYf1w1VfEE0LtVkbCwLDEn2WIwj62SaXALle7fVSfQ0LdABNIMzr7IUgslaRf2mje iTcTTOwkNIS2gurLXOMo7cKjqMnOyRnTXUeW5rzQVir+QiYcN/AslE+ebpVTAzq5kEVG AqVD2ipVhKtfGUEMhG2kfb+v7EMunkET/xoRZrdB+DJHCVZxalGQrf6Lke9t8kayVvQ+ z6dA== X-Gm-Message-State: AHQUAuYZMyz4GB71JsY4R42rEZrPGvlOtXzpZqMezmUJJ04Ox3ZPNyOP ttTrqanN448im2VWZ9jjhEb+Uw== X-Received: by 2002:a63:d846:: with SMTP id k6mr33947931pgj.251.1550739668111; Thu, 21 Feb 2019 01:01:08 -0800 (PST) Received: from localhost.localdomain ([117.252.69.94]) by smtp.gmail.com with ESMTPSA id v4sm27703948pff.77.2019.02.21.01.01.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Feb 2019 01:01:07 -0800 (PST) From: Sumit Garg To: chrubis@suse.cz, ltp@lists.linux.it Date: Thu, 21 Feb 2019 14:30:13 +0530 Message-Id: <1550739616-24054-7-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-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_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-5.smtp.seeweb.it Cc: daniel.thompson@linaro.org Subject: [LTP] [PATCH v4 6/9] syscalls/fsync: add 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" fsync04 tests to sync file having large dirty file pages to block device. Also, it tests all supported filesystems on a test block device. Signed-off-by: Sumit Garg --- runtest/syscalls | 1 + testcases/kernel/syscalls/fsync/.gitignore | 1 + testcases/kernel/syscalls/fsync/fsync04.c | 60 ++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 testcases/kernel/syscalls/fsync/fsync04.c diff --git a/runtest/syscalls b/runtest/syscalls index dba0dee..0d09509 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -347,6 +347,7 @@ fstatfs02_64 fstatfs02_64 fsync01 fsync01 fsync02 fsync02 fsync03 fsync03 +fsync04 fsync04 ftruncate01 ftruncate01 ftruncate01_64 ftruncate01_64 diff --git a/testcases/kernel/syscalls/fsync/.gitignore b/testcases/kernel/syscalls/fsync/.gitignore index 3c694a4..4b5ea83 100644 --- a/testcases/kernel/syscalls/fsync/.gitignore +++ b/testcases/kernel/syscalls/fsync/.gitignore @@ -1,3 +1,4 @@ /fsync01 /fsync02 /fsync03 +/fsync04 diff --git a/testcases/kernel/syscalls/fsync/fsync04.c b/testcases/kernel/syscalls/fsync/fsync04.c new file mode 100644 index 0000000..4b5b586 --- /dev/null +++ b/testcases/kernel/syscalls/fsync/fsync04.c @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Sumit Garg + */ + +/* + * fsync04 + * + * It basically tests fsync() to sync test file 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 +#include "tst_test.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_fsync(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(fsync(fd)); + + if (TST_RET) + tst_brk(TFAIL | TTERRNO, "fsync(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 file synced to device"); + else + tst_res(TFAIL, "Failed to sync test file to device"); +} + +static struct tst_test test = { + .needs_root = 1, + .mount_device = 1, + .all_filesystems = 1, + .mntpoint = MNTPOINT, + .test_all = verify_fsync, +};