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: 1045890 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="HyycqY/3"; 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 444pP02xKBz9sBr for ; Thu, 21 Feb 2019 20:01:24 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 5F64E294B1A for ; Thu, 21 Feb 2019 10:01:20 +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-Google-Smtp-Source: AHgI3IabPk9B8Gyh+yGIze5PvGGXBrG2ZBlNr+VqXMfnlwtFxlvFo6J7t46inkQugfKIcuwxuyHe9g== 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+incoming=patchwork.ozlabs.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, +};