From patchwork Tue Feb 19 09:28:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 1044569 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=213.254.12.146; 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="i1yJ9mUH"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 443b6n4Q22z9rxp for ; Tue, 19 Feb 2019 20:29:53 +1100 (AEDT) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 51159294B58 for ; Tue, 19 Feb 2019 10:29:44 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id 448003EA4B8 for ; Tue, 19 Feb 2019 10:29:30 +0100 (CET) Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id 7C2766019E6 for ; Tue, 19 Feb 2019 10:29:29 +0100 (CET) Received: by mail-pg1-x543.google.com with SMTP id s198so9874912pgs.2 for ; Tue, 19 Feb 2019 01:29:29 -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=bxL/oP1KA0gXoVBkLDKzvMA4t+5/xsQztxcF8Ln+0dc=; b=i1yJ9mUHUd6eFD20raP9PwGb030Smg1fF4MLWQT+v/EG0QOg593vG3Fu86dXNX8dub pxF2s5hv7Z8cy7RVG9DflrPpIfyI6/ZDE/6tT6KSbYfZOz5j9NHzmIy2lxw8jKuyRA9C K8CXECZNSK4gROITDBNEyCR0qgaKX6Va1jm7+zs+95Ewx3T8ylOCTOMf16NAqvshnOyf ZFu4Got/h9Y0WcfSv1TLPjiFbpTJpf8bYPF9ehzvhVhzJRY8+hilNmBiI931fDDRKdL5 dPiZBGkz3Eg8wjhORm1Yuk9UytZ6YqeUU1t4WIhuJV6oDENImTvVo0jtd+VqSQxYmh9i zbRw== 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=bxL/oP1KA0gXoVBkLDKzvMA4t+5/xsQztxcF8Ln+0dc=; b=WaP/5Jllc8WYzKFV06lppCbHaRyfILEXL84Fnwr+HmR4ML3LUtR/b0aZoNCumwtN9M Da6yfzE9ZlWZvv/GZQHPr4Poc9IEWcbcqGuZilKiUQFxIqgTu9CMgV4Xlg5t9bvS3WCf i7eGQ1PicJbaEqIrU/6cRZqZS1sC2WlSeymbzN9UU7l762CZKQEQXE3BuqGA8PdIqIct XD9rwlfMlaUQA7Onh2U2j9R4/TR88chRSF2iKZx7x+Y2V1Gi/EO4nORsI92U3PnevJ4j T14pnJ4NtFFddEX1f+51VowSz+7wra+3tcwD9+fU/dLYJXP8PSksqCbD6oV2HsnRFgmq VC5w== X-Gm-Message-State: AHQUAubjIiJMMYHVB4lcU2DzfwiprIFFSGVxRxHp8rU2CuN9ncO2gNMt pbFqt/6yEJ7d8msxvks8775fIJLh2BcAmQ== X-Google-Smtp-Source: AHgI3IZiQVAs4aelkCrHinEjQlo7N03HfVw2baoAhqvDujXs2dXLejrWhKPDd27HsXSWCAjXnX3tPA== X-Received: by 2002:a63:cc41:: with SMTP id q1mr23272780pgi.323.1550568567797; Tue, 19 Feb 2019 01:29:27 -0800 (PST) Received: from localhost.localdomain ([117.252.69.94]) by smtp.gmail.com with ESMTPSA id n19sm34442229pfg.67.2019.02.19.01.29.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Feb 2019 01:29:27 -0800 (PST) From: Sumit Garg To: ltp@lists.linux.it Date: Tue, 19 Feb 2019 14:58:20 +0530 Message-Id: <1550568500-10871-8-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-2.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-2.smtp.seeweb.it Cc: daniel.thompson@linaro.org Subject: [LTP] [PATCH v3 7/7] 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+incoming=patchwork.ozlabs.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 | 70 ++++++++++++++++++++++ 3 files changed, 72 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..fb7a5f7 --- /dev/null +++ b/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c @@ -0,0 +1,70 @@ +// 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_sync_device.h" +#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) + +static void verify_sync_file_range(void) +{ + int fd; + + fd = tst_sync_device_write(TST_FILE, 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 != 0) + tst_brk(TFAIL | TTERRNO, "sync_file_range() failed"); + + if (tst_sync_device_check(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) +{ + tst_sync_device_init(tst_device->dev); +} + +static void cleanup(void) +{ + if (!check_sync_file_range()) + tst_brk(TCONF, "sync_file_range() not supported"); + + 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_sync_file_range, +};