From patchwork Tue Feb 19 09:28: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: 158700 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3447326jaa; Tue, 19 Feb 2019 01:29:30 -0800 (PST) X-Google-Smtp-Source: AHgI3Ia/vNzxROJm1NQnHtze8zN+3EuEQcfXY5+AzWz5WmUOx5ua0U9Fp/Y5IOYmJAVnVlJBtBQ8 X-Received: by 2002:a50:90e8:: with SMTP id d37mr20669463eda.252.1550568570461; Tue, 19 Feb 2019 01:29:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550568570; cv=none; d=google.com; s=arc-20160816; b=CWjcShdoRnq2/0ATncpUSYoXEjmRO9t+Y+nmFvtjvxkfpcEEoid0cbuHI040h5u4vR jLpM2YJb/mb2xGHixqgv+p60FLcrU5sc0nkW36oPt0RGAqHz0tAApnCNQQzLaFzdFfTp qW6kKG1sdfDT+wXHmscuh/EoYJ1HaneMkVB6oiT07GSur7u4m7LdLAfy0YgM4qn6xkVg FOPE2HI2ZAHkz9zBVRFwA0PqrI0nladFD6/tu2bmNrMadTg+k6cObhMTpLVcauPCNAco mVFowzByjzNlOI/hAL/Hf0TF7N4HbDJp8etmI12gw2Hpo7lubRHSo0xexGiNv5i4AAiB 358A== 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=CWn37OAkzihZ6Y/+A7kkR3CjLqzP6+4ImmJOMw92IHU=; b=zPFswKDOxTsg0UzdHoStAQoNnEtnHJL5+G+c9TopN5N186ecYeS0g0X+JkgCIBmKFg E2rL2TQWgolK7DAbihhPI7nfU+KcNAID5x2ASV5nd3topajLrItr72U2KWgrtgRJ6lb8 hBCfZpCuyEVGkmYa4DAvzMOkCZ4JR3WSt/0/50KEnapsOJX7GzjHkqR4CEkpk6UDWYos ctB5BO8hH/3Yh5eHSCNe/TzFMgVpMC7FLwL5Xa5SqAoaelYTw/xNepjJ9KiMLoDpJANi g5NZnq74EPhiMg/RRMjzO+9WRVFZtrSHcxNwTaM3r/nGuiKm6M048X24Q+jB4VQOmBpB Qt/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NPqoJASC; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 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. [213.254.12.146]) by mx.google.com with ESMTPS id v14si1813869ejq.191.2019.02.19.01.29.30 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Feb 2019 01:29:30 -0800 (PST) Received-SPF: pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 as permitted sender) client-ip=213.254.12.146; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=NPqoJASC; spf=pass (google.com: domain of ltp-bounces+patch=linaro.org@lists.linux.it designates 213.254.12.146 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 662EF3EA410 for ; Tue, 19 Feb 2019 10:29:29 +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 587343EA33E for ; Tue, 19 Feb 2019 10:29:14 +0100 (CET) Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) (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 803D61400FA8 for ; Tue, 19 Feb 2019 10:29:13 +0100 (CET) Received: by mail-pg1-x541.google.com with SMTP id u9so6333339pgo.7 for ; Tue, 19 Feb 2019 01:29:13 -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=oiyxSyTpVqLzIFlDW5GJ+y90KITUWbzAtGN3pa1RvcA=; b=NPqoJASC0HkFBzg2GMlYUW1p8Bj2Hm0DVLO7z8qveez4OyBOwOdYv865MlPpwnUElp 8PVK7B9skeYzaCgw1ZJYQ4aElRjpg7+L/86oNhCvS5JdaCl3scbgToMBtN81N1nxDqwW IdjQtWEJdLCLcTJrKJ8raiAJiKVEnnBV+bVo3rXzG1Q5IxhCCysXzVijK6bYeG9a1AS5 3evhdurCFivzzgaxrYkXIcypESPQ+qzAnmirRbpXLA0gk2kfdtBuPY2Vnp6ki+uo+ARd rRINZU3OrIO0aQhTD4aO+LNE9jnG/iWyu/B8H+vGGxC6C9DKa92h9dV9CMRf6QTEAFkn /jWQ== 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=oiyxSyTpVqLzIFlDW5GJ+y90KITUWbzAtGN3pa1RvcA=; b=gy96bvQpKr4QnU70cpgKHfo3MgVY7eWyg9gW3saCDQCajxg7NZiK1LpuTwlpWeD78d OxhnsI45e+4IMCX3FUQBKW0Ls/LQ77qGq29jUBB0ss5lMhbQfs2UqiVEsgRfmfE2NPF1 L8+NaHczVvBem/t5uKIAe0iVy//MNR91X9h2n6JQAtDj7KPVHMC4AWZ9rwAJl4CvXWNt 7eUafJqQDbRIlYLscTHz4ZjlwCLn2Ul2qv8y2ax5jCqJwASts0gVsWX0s0KUXlnrhN6v a7bYUtn8iWI7UA3M0YnYndvYvRfglbA15yMKXLeHAnrV8xDh4YuowT7MsXwk13cbGqd5 p7GA== X-Gm-Message-State: AHQUAuY+I05PDJ5n3z8YqYMWOEMStXS3ANjgI97vDKa8IMFgxe/is/GM yH8ADIf4wdBn6fPtQu2BeQEBp3+D/ERJpw== X-Received: by 2002:a62:e704:: with SMTP id s4mr28458835pfh.94.1550568551859; Tue, 19 Feb 2019 01:29:11 -0800 (PST) Received: from localhost.localdomain ([117.252.69.94]) by smtp.gmail.com with ESMTPSA id n19sm34442229pfg.67.2019.02.19.01.29.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Feb 2019 01:29:11 -0800 (PST) From: Sumit Garg To: ltp@lists.linux.it Date: Tue, 19 Feb 2019 14:58:16 +0530 Message-Id: <1550568500-10871-4-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-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 v3 3/7] 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. Also define TEST_VOID macro in tst_test.h. Signed-off-by: Sumit Garg --- include/tst_test.h | 7 ++++ runtest/syscalls | 1 + testcases/kernel/syscalls/sync/.gitignore | 1 + testcases/kernel/syscalls/sync/sync03.c | 59 +++++++++++++++++++++++++++++++ 4 files changed, 68 insertions(+) create mode 100644 testcases/kernel/syscalls/sync/sync03.c diff --git a/include/tst_test.h b/include/tst_test.h index 12dda2e..03c88e3 100644 --- a/include/tst_test.h +++ b/include/tst_test.h @@ -216,6 +216,13 @@ void tst_reinit(void); TST_ERR = errno; \ } while (0) +#define TEST_VOID(SCALL) \ + do { \ + errno = 0; \ + SCALL; \ + TST_ERR = errno; \ + } while (0) + extern long TST_RET; extern int TST_ERR; 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..419f9b9 --- /dev/null +++ b/testcases/kernel/syscalls/sync/sync03.c @@ -0,0 +1,59 @@ +// 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_sync_device.h" +#include "tst_test.h" + +#define MNTPOINT "mnt_point" +#define TST_FILE MNTPOINT"/test" +#define TST_FILE_SIZE_MB 32 + +static void verify_sync(void) +{ + tst_sync_device_write(TST_FILE, TST_FILE_SIZE_MB); + + TEST_VOID(sync()); + if (TST_RET != 0) + tst_brk(TFAIL | TTERRNO, "sync() failed"); + + if (tst_sync_device_check(TST_FILE_SIZE_MB)) + tst_res(TPASS, "Test file synced to device"); + else + tst_res(TFAIL, "Failed to sync test file to device"); +} + +static void setup(void) +{ + tst_sync_device_init(tst_device->dev); +} + +static void cleanup(void) +{ + 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, +};