From patchwork Tue Mar 5 07:14:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 159641 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp4650891jad; Mon, 4 Mar 2019 23:14:55 -0800 (PST) X-Google-Smtp-Source: APXvYqxj3Un0YDh3OVlGAom3E9nU7dZD0bIP1+gYnvvdblUkshHveqzuXbeIsPLEP+O38qPE54kh X-Received: by 2002:a17:906:6a43:: with SMTP id n3mr15404661ejs.0.1551770094911; Mon, 04 Mar 2019 23:14:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551770094; cv=none; d=google.com; s=arc-20160816; b=t32pDL8Pn2TWifSeYdwh1YXCHbRL/BDzizkrB0OVHQA/Q+0Hynpo5iz+qIm5jibKSh lCpZUp8KV1S8RmVlVjNrjphZ8H9k2GpZ2WRet/BXDVg6HD9IaDaedco/JMd1URrHvJeN 8h5oqd0dQxrxYGNk1lKjvC2pUGazLMagWLRRYCh5kfhVxNJvnRZuJhCutKfmYYnmqjDC MyoycrsH5phGJZOu6dufD72Tw+LLP5Y2dziixtbMhMq/5FvE6+5siPqP09Xk9fAhGJDf NY0oxC6FOojCAFMrPdGQ2o/X15I1i1gIyooLGZ4c57+WnPmjCA3NtVg67wtQc1Ytm3LY o8sQ== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=/4kDnEQOJKSzgj3+6YTlsnEFv3yO89s3SdBu1he1SD0=; b=ygAmMrSFnIH62jgi7XwBo4/XjR7vnJSbzT0XmyGncqYZL13Bh+VyhwzR2o6M1RrjS9 ItQyVCCnnD4n1jhVSNRrSJqRrKb6HfM5JhHeFsPlSWACqOOsnmgcxCdtTM17eplNNHAK NNYUvQouXTChJn58VrdbvCd1m+GX0J1Q9M1PicS3LvWsY+Z93WxsGlE/vRWDtLFHreiE oGZmU/b0/Jc9QbaS77viqaTeDjWGlOxDYb8xlM686vncW6uhg6WNt2r7m1zaQZpUAer5 C2RoLZ3W9GsHTjkN7npAjrWgPkJUv/gs8QPWvRy/kQbRIMM1aoMZVthNiKtVf1qnqtAV bqxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=OFIUDv9v; 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 o15si367764ejj.271.2019.03.04.23.14.54 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Mar 2019 23:14:54 -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=OFIUDv9v; 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 6F26A294ABC for ; Tue, 5 Mar 2019 08:14:54 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) by picard.linux.it (Postfix) with ESMTP id 21DE43EA293 for ; Tue, 5 Mar 2019 08:14:49 +0100 (CET) Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id D44E71A00E0B for ; Tue, 5 Mar 2019 08:14:48 +0100 (CET) Received: by mail-pf1-x441.google.com with SMTP id s22so5009278pfh.4 for ; Mon, 04 Mar 2019 23:14:48 -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; bh=Hg7RyoqmmFs11oHVMwmV/4k4UXLuxywe6/eAtLbD/dg=; b=OFIUDv9vOOPkbFFkVoK/aLiba9ZAV8FtLF4GIxAJx7wL882uvkf7v3yjk+B7tlPkH4 sZiCSoif9luUMiqzUq9/K5eP9Nz53F09m8L7zMZD2H9qbzeYlahUAeRjQcr6OZfryPkV 14fKYI8eRjJd6+TCNamJ8t1n5Uc49Ocu7Um1XOqgAiIg1syNBITuSnbrnGqc3SUKlwF/ Td6rvmPmxkB2NtsHgNyf5CFaShRRZ05zME4walBi2/a+BunBAdPwrBjqAFg5SeECJC4L 6z8KsMYes8oOPKskPhFBUtzcLq7gXqxW78lk/R7QR7yGYpTOwh3sJIZwOTrmtXshRBrZ NBXg== 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; bh=Hg7RyoqmmFs11oHVMwmV/4k4UXLuxywe6/eAtLbD/dg=; b=LB9cNPdLaUT6k/tfHphVFafor+nrH8Ft8K2bHMJUu8EJtoHfh7i3rVDaPKGE8rHlIF mdyOnDmxSg2JMaaZdP0y0xdSCJAvDhsVFOYmULZiq10LAWXHyyqJj9Ay6SUOj/4eSpVF n33HC1YgNzW7NvOHJobHg+lJq2DhUCCY0obZAP2U3ceZCAFN401e4E0XyRgleqiNs0Ut yjP1mLKPPV24LFcvCj9PWUvXKyN2rA4hjqqzOZb59wPiv2l4WWzi9yUYS/Fq66zPfsm7 RTGqKmcob2NRHq3Vz0UCskHNTG+oMLYd58tAZQejEHQRbZAGGv6WrO0NZK2Jd0B5iO7N bwGA== X-Gm-Message-State: APjAAAWOhZzWMNHHl7BJ222FYIioG0qVrQmWwpVxq8Z3CB9csh2WWMyv VUCh55hKZumev+DXPMxlDdyLug== X-Received: by 2002:a63:2907:: with SMTP id p7mr158858pgp.161.1551770087288; Mon, 04 Mar 2019 23:14:47 -0800 (PST) Received: from localhost.localdomain ([117.252.64.200]) by smtp.gmail.com with ESMTPSA id a66sm14877349pfj.153.2019.03.04.23.14.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 04 Mar 2019 23:14:46 -0800 (PST) From: Sumit Garg To: chrubis@suse.cz Date: Tue, 5 Mar 2019 12:44:25 +0530 Message-Id: <1551770065-20444-1-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: clamav-milter 0.99.2 at in-3.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-3.smtp.seeweb.it Cc: ltp@lists.linux.it Subject: [LTP] [PATCH v2 1/2] syscalls/sync_file_range: add partial file sync 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" Add partial file sync test as part of sync_file_range02 test-case. Signed-off-by: Sumit Garg --- Changes in v2: 1. Do full file write instead of partial and test sync partial file. .../syscalls/sync_file_range/sync_file_range02.c | 47 +++++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c b/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c index 82d77f7..2d2ed2f 100644 --- a/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c +++ b/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c @@ -27,7 +27,7 @@ #define FILE_SIZE (FILE_SIZE_MB * TST_MB) #define MODE 0644 -static void verify_sync_file_range(void) +static void verify_sync_full_file(void) { int fd; unsigned long written; @@ -56,6 +56,48 @@ static void verify_sync_file_range(void) tst_res(TFAIL, "Synced %li, expected %i", written, FILE_SIZE); } +static void verify_sync_partial_file(void) +{ + int fd; + unsigned long written; + + fd = SAFE_OPEN(FNAME, O_RDWR|O_CREAT, MODE); + + tst_dev_bytes_written(tst_device->dev); + + tst_fill_fd(fd, 0xff, TST_MB, FILE_SIZE_MB); + + TEST(sync_file_range(fd, FILE_SIZE/4, FILE_SIZE/2, + 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 >= FILE_SIZE/2) + tst_res(TPASS, "Test file range synced to device"); + else + tst_res(TFAIL, "Synced %li, expected %i", written, + FILE_SIZE/2); +} + +static struct tcase { + void (*tfunc)(void); +} tcases[] = { + {&verify_sync_full_file}, + {&verify_sync_partial_file} +}; + +static void run(unsigned int i) +{ + tcases[i].tfunc(); +} + static void setup(void) { if (!check_sync_file_range()) @@ -63,10 +105,11 @@ static void setup(void) } static struct tst_test test = { + .tcnt = ARRAY_SIZE(tcases), .needs_root = 1, .mount_device = 1, .all_filesystems = 1, .mntpoint = MNTPOINT, .setup = setup, - .test_all = verify_sync_file_range, + .test = run, };