From patchwork Thu Feb 21 09:00:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 158886 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp243367jaa; Thu, 21 Feb 2019 01:01:36 -0800 (PST) X-Google-Smtp-Source: AHgI3IYe3ZzHSvzJN9ob4Xm80tZnIz95z3m+RqZCuAdZzYz+ENRJ30J8GOTotzKYVOVjB71szQZR X-Received: by 2002:a50:ad13:: with SMTP id y19mr9322390edc.86.1550739696526; Thu, 21 Feb 2019 01:01:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550739696; cv=none; d=google.com; s=arc-20160816; b=Yhiy6XvrXNMo+AyHeI0G8SdgIscJ/YJuO/+fuMWkFl5QSvPaymIm6xLEHo67X2kI1N OYRpnaWq34zs1jY3WEdxpaTKQtLxM0VleSMZW0d3htdi3l2qNQd2mzIvlvEsdM2MIfl8 pqiM+Mjvk/WVFopF5f//BiuE0Z9wnBFGvhT9ZCuyY3/1pOoVhobJUg8BS2yuBGFFkVY5 VUeeTZSfcIbbZZ7BpbQaE7ytFjL3XdvpH3k9xaebV0/gSsU+4bke+XfPhIzuesx408ug UqoVFKumS5jMKyH2tSfxLZo0Lq0naoesIsjXhz2L9zYIB4m28OYmXzIZNwbC3Jbm39Le DkNw== 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=WUslyZugxCFUdQmL4PwhGVyz7N5TUlQawkQ35OcI28w=; b=ynJHwdKvW3DBx55MNijZrHgpLjgVNa8cGtWcshtAUOi7N1S1qVumR1CauKW5+IMC7T 9SA47fxDKcXpyUr+Bm5K2s4H1UwvXyfdBSIDwHUqukm0i7SU/k0aSP1dEz0gLjUFAlzE HKwcc8rlDgqVALftcCRN4PB872KL8qgAMcAvEg0AJdh4ifOdQmDcJsP4GswuoY6Uq4Rb RnamI/mZacOg0PS+oAtW5QUSrv6Qr2HQptOc9PD+CNkdrDhUCxtyXS59HygJUPXLcf/l ROC9SyGXHTIE/l3M1slOwSrNvhhp5nSMu/0QxL/CqcrsO1o/ytNtFC5QUsVt3jNvm+vF dTTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OZuBh9xK; 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 s18si3664397eju.94.2019.02.21.01.01.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 01:01:36 -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=OZuBh9xK; 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 B7A7F294AF5 for ; Thu, 21 Feb 2019 10:01:33 +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 [217.194.8.6]) by picard.linux.it (Postfix) with ESMTP id EE414294AD0 for ; Thu, 21 Feb 2019 10:01:22 +0100 (CET) Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) (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 3373314060C4 for ; Thu, 21 Feb 2019 10:01:22 +0100 (CET) Received: by mail-pf1-x434.google.com with SMTP id g6so13417744pfh.13 for ; Thu, 21 Feb 2019 01:01:22 -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=F92beSL+Zz4DDHhLrK1rfCKy0tQb83IJc8nXkg/yPf4=; b=OZuBh9xKCahbdn6g441ui7AeGoaZDRUZLf2YyQ3+90JQpCAuVpemC8jhCIzqs6bRlx TC2aWJWik++OgrOD59769lTBf+LO2h2TOgRB4xo9SpNbUyEeyiIDeOLGuH7SnC9BwQUE BU+MJPiRDWvM3zzh9Kly9H82GzQmPRif7QjCrSaJhHwFj5xQO+4+NnKbm5EQHvRdmQyj Qe3fX0BltSzZDm+fGNGENYpi6h5CcpHLS63Aqrj497XhbhhVnYGKgjY0b1rLH3uL+Yzd 30uRVYuQfdAnrD6F1h3DxnI+GK2W5ZoNaK9nJHzmxfgWn3+sdCGt4BanKYpyMqWlh95R GADQ== 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=F92beSL+Zz4DDHhLrK1rfCKy0tQb83IJc8nXkg/yPf4=; b=PIIfiFUJV2YjibTrEj95c//NAOBWjlg9LqcCNgjMjD3UW3kkPEKzRslTIZY5khBTou 8E2Rssf2h4b+swvbd1CeS3/Yf1bL9sE+SaTYvcteu3jPpqDh53BJpMZTtLUZ+C+z8kl4 Jcdc/vQ9hD8s3KsoGHeVQnVIvdYXK2Nq6FW9v/IIs8zjcgPJ6KI9gX2jaaBYRqDOv8jM Rn0OScOD2ITu9EzA8npRgRzTqSzMZjmdQN0nobCAD2XnKhv8veCcy5AiagpfohATEzkH zO/lmf6eSwtuQkgZVbdy/yLFqh6Me7/HVVdE6zIsMbAen83UCygpk/0sEc43Wi2pvK0b ZjZw== X-Gm-Message-State: AHQUAuY7L1gzaQsR7ONmlO5FTxU7nek3R2+Thn2pyX4rJT6Ri7Fg38wR XNIJQN+IT5qnc92HWSPbX2BdO8Hww7aqng== X-Received: by 2002:aa7:9255:: with SMTP id 21mr6317759pfp.8.1550739680488; Thu, 21 Feb 2019 01:01:20 -0800 (PST) Received: from localhost.localdomain ([117.252.69.94]) by smtp.gmail.com with ESMTPSA id v4sm27703948pff.77.2019.02.21.01.01.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Feb 2019 01:01:19 -0800 (PST) From: Sumit Garg To: chrubis@suse.cz, ltp@lists.linux.it Date: Thu, 21 Feb 2019 14:30:16 +0530 Message-Id: <1550739616-24054-10-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 9/9] syscalls/sync_file_range: 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" sync_file_range02 tests to sync file data range 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 + .../kernel/syscalls/sync_file_range/.gitignore | 1 + .../syscalls/sync_file_range/sync_file_range02.c | 72 ++++++++++++++++++++++ 3 files changed, 74 insertions(+) create mode 100644 testcases/kernel/syscalls/sync_file_range/sync_file_range02.c diff --git a/runtest/syscalls b/runtest/syscalls index aaad651..70d3561 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1353,6 +1353,7 @@ syncfs01 syncfs01 #testcases for sync_file_range sync_file_range01 sync_file_range01 +sync_file_range02 sync_file_range02 syscall01 syscall01 diff --git a/testcases/kernel/syscalls/sync_file_range/.gitignore b/testcases/kernel/syscalls/sync_file_range/.gitignore index 3f6bd75..e6485f7 100644 --- a/testcases/kernel/syscalls/sync_file_range/.gitignore +++ b/testcases/kernel/syscalls/sync_file_range/.gitignore @@ -1 +1,2 @@ /sync_file_range01 +/sync_file_range02 diff --git a/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c b/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c new file mode 100644 index 0000000..37ea68a --- /dev/null +++ b/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Sumit Garg + */ + +/* + * sync_file_range02 + * + * It basically tests sync_file_range() to sync test file range 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" +#include "lapi/sync_file_range.h" +#include "check_sync_file_range.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_sync_file_range(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(sync_file_range(fd, 0, TST_FILE_SIZE_MB * SIZE_MB, + SYNC_FILE_RANGE_WAIT_BEFORE | + SYNC_FILE_RANGE_WRITE | + SYNC_FILE_RANGE_WAIT_AFTER)); + + if (TST_RET) + tst_brk(TFAIL | TTERRNO, "sync_file_range() 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 range synced to device"); + else + tst_res(TFAIL, "Failed to sync test file range to device"); +} + +static void setup(void) +{ + if (!check_sync_file_range()) + tst_brk(TCONF, "sync_file_range() not supported"); +} + +static struct tst_test test = { + .needs_root = 1, + .mount_device = 1, + .all_filesystems = 1, + .mntpoint = MNTPOINT, + .setup = setup, + .test_all = verify_sync_file_range, +};