From patchwork Thu Feb 21 09:00:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 158882 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp242984jaa; Thu, 21 Feb 2019 01:01:19 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia/1+ubEuWF86gZR2F9oDRKLlXNnkjFgoDFc8BcJAFIwvJpPCt2U96ljY4+c702LGfoG+62 X-Received: by 2002:a50:8bf9:: with SMTP id n54mr29739819edn.197.1550739678927; Thu, 21 Feb 2019 01:01:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550739678; cv=none; d=google.com; s=arc-20160816; b=0MrN0FyXygSjh8iRpNvgl49iJq6EpBwEVw3xdtg743xruNSL8qjx228gHkZ3ORdisL ntnTCW2WIhbQJPj61nNO7veg3VZ1R8MMw1yIeXUszafW8CKEWDhSUz3ozq0RSmBOinxi PWbHJPOJV3xV2ZB36vB/elG9KR8B79Y0wvDy5hUjFMZEK1zg/3tTsTXcL7k/OpfTEgGo R07pmmLwh4WM1d5mPMw+gc8s3r8liUfhHI1OGK3/BvThylWm/x5fvmJPgga9snnlPvC7 jjVWHbcImQnoezeuvtGWU6H388OQR0ICdfEVYVc8UPamdKg1BYRgc8x5lG0iUksg4kcY Whbw== 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=8uo2SY+T6UYra+UXXzBDeo1/vQOHQO2XB/eJ4P8f3+M=; b=zJDNKNf/PIYq1yV8GdwnjT6AOkvG+0um6cATz1IbPpIdJ/qaxc3cR6jEysYC8oCUce UR3BkvRjYSpvZhOiP19qCCSgg+wE1GXav/VrnNGxeErFiZuon6ttwbQ7SDfslEfAvK5u wg1S/vAVGJMN+iApAdBmfbBU8o3GzNzVTAtq+Od/e6lKlmrYtzGSi7qh5tHVL8OQGM1m uGlGamslYfhoAXuaYdQ8Jtp5tP0fh0gohnD5mBKeG+rfRg/mzM9kAH+mWlW+UOhZkwJH aL/7bu73TObXrrkSaa20gwMMGMkls0PLFvNAcmqDlI388BXg5/v3hEgSSigrg5QuK4QQ lijw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ONKzi9Rj; 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 e2si2257527ejs.33.2019.02.21.01.01.18 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 01:01:18 -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=ONKzi9Rj; 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 3E137294AC1 for ; Thu, 21 Feb 2019 10:01:18 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-7.smtp.seeweb.it (in-7.smtp.seeweb.it [IPv6:2001:4b78:1:20::7]) by picard.linux.it (Postfix) with ESMTP id AD724294AD5 for ; Thu, 21 Feb 2019 10:01:06 +0100 (CET) Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-7.smtp.seeweb.it (Postfix) with ESMTPS id 9C09220157A for ; Thu, 21 Feb 2019 10:01:05 +0100 (CET) Received: by mail-pl1-x634.google.com with SMTP id s1so13836781plp.9 for ; Thu, 21 Feb 2019 01:01:05 -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=2q9SLiu/LSR9DP7ZEVFCQ84x3EbPsdW8j8twBELQXoI=; b=ONKzi9RjdD6zdpbRs76LBI5b7X+zOj4EVESjLqM4xOFUCxIMR/fl9U7pFwYoGVwf+l DihIQQvTbxfOQP4reRFfeHiyqaD/Th8EYeHhuX0uMgIDExQQxXmR1+sEJGkNnNabzC4V YCJVHMCoteDwspUqmU2KJtr+A+RoGmLXdKvNxAtkM5GmZ32mtc8x8fDD+VBqjjbjTzl6 U5b2/+9lD5tDHxprFDYBBsqBEZTpZUYJ2YCYlbcF0klDfkWVBz2taywQ9ylCNVKOpbUf tIrH/aqa0JbKsPa2G2qO4tXkKfrpVnqUDHlcBpYZAwrlfZDhd0UNTcY/qZjmpBp2jNzm Q9Tg== 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=2q9SLiu/LSR9DP7ZEVFCQ84x3EbPsdW8j8twBELQXoI=; b=KiC2bJH8Dq30JpzmUM+sh6IgAsxNwyVhWGHZJznoEj3EWPPNvjpgG/mXsQv8dwql3+ GAtQPZQa3Je5WrKANn8WVcJ2Gkn1trGAwkeQsiFm5iCCA7HyglNj/xfSnO/v5bKbIXfR 7ZJZzjQDMrKW1fSGcX6x6tdeGDygP5yRYgkwnV3pBlRuYKMnbni2zrNdCDUJFtYidupT VYdaRN86MmZkxwwGAOYIn41MYTjoT2Yfk5LuDqJxoGAuiWgXkdxyMb618ua0pO1O3GIy orA6xcMB5cpUNdit7rxrmKvvBb/0yul/Dmf1Qkj2JGaAmf1a4iraS1FcGjhnvJ45lVpq vXyA== X-Gm-Message-State: AHQUAubiGiV17QNjrCz7GkwxN3fpAAc5iAjw1z7B+i8IyVOdeevI6Wga RvjKsjzWOGAjfsAZaicsfQhgCA== X-Received: by 2002:a17:902:bc89:: with SMTP id bb9mr41613828plb.212.1550739664229; Thu, 21 Feb 2019 01:01:04 -0800 (PST) Received: from localhost.localdomain ([117.252.69.94]) by smtp.gmail.com with ESMTPSA id v4sm27703948pff.77.2019.02.21.01.01.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 21 Feb 2019 01:01:03 -0800 (PST) From: Sumit Garg To: chrubis@suse.cz, ltp@lists.linux.it Date: Thu, 21 Feb 2019 14:30:12 +0530 Message-Id: <1550739616-24054-6-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-7.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-7.smtp.seeweb.it Cc: daniel.thompson@linaro.org Subject: [LTP] [PATCH v4 5/9] syscalls/sync: 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" sync03 tests to sync file having large dirty file pages to block device. It tests all supported filesystems on a test block device. Signed-off-by: Sumit Garg --- runtest/syscalls | 1 + testcases/kernel/syscalls/sync/.gitignore | 1 + testcases/kernel/syscalls/sync/sync03.c | 60 +++++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 testcases/kernel/syscalls/sync/sync03.c diff --git a/runtest/syscalls b/runtest/syscalls index 9442740..dba0dee 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1345,6 +1345,7 @@ symlinkat01 symlinkat01 sync01 sync01 sync02 sync02 +sync03 sync03 syncfs01 syncfs01 diff --git a/testcases/kernel/syscalls/sync/.gitignore b/testcases/kernel/syscalls/sync/.gitignore index d8d304d..04f4710 100644 --- a/testcases/kernel/syscalls/sync/.gitignore +++ b/testcases/kernel/syscalls/sync/.gitignore @@ -1,2 +1,3 @@ /sync01 /sync02 +/sync03 diff --git a/testcases/kernel/syscalls/sync/sync03.c b/testcases/kernel/syscalls/sync/sync03.c new file mode 100644 index 0000000..4dc2ff6 --- /dev/null +++ b/testcases/kernel/syscalls/sync/sync03.c @@ -0,0 +1,60 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Sumit Garg + */ + +/* + * sync03 + * + * It basically tests sync() 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_sync(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_VOID(sync()); + + if (TST_RET) + tst_brk(TFAIL | TTERRNO, "sync() 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_sync, +};