From patchwork Fri Mar 1 08: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: 159469 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp440562jad; Fri, 1 Mar 2019 00:28:57 -0800 (PST) X-Google-Smtp-Source: APXvYqz0fhh0HpD/OD5Jf093v91faw6klkRUH/4Wl6lFNoPTuFMjfxb1C6FgkvVeaTn0zSbzdcyz X-Received: by 2002:adf:d08d:: with SMTP id y13mr2230992wrh.99.1551428937802; Fri, 01 Mar 2019 00:28:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551428937; cv=none; d=google.com; s=arc-20160816; b=uHO0pDoiMaonPm2r5K13U3n0mz1pbHcaMLQ13FpJ21h01uZDttbRAQw8V7rYB1QfeL nj1cjyb3PbqFKTOjsOIEk4DMm4cARAqw1ee0FFhP1enceP8HdLwOIoLeLOy1c++IYUj7 XOWQMcPuISb6WjXtdRSkK78osIleg3/Kw+Qo1RPBf9MW4C7pwIOgXluIBxDdhooHQXg3 gn/5ILPADprmyfWd50IE/LICYbDB/gokdU78ijNUlOO3Y8nsiBUA3yk66RunXkZCvOYc ojNKZWmbX68CYVDVXKtzOHOILWmp8SL7kqOaUUyskekJQ8o/PJXgQ4omOw/VUL5KpMeK 22Qw== 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:message-id:date:to:from:dkim-signature :delivered-to; bh=+C8TNv2dbZ+Wn8XgY/Rxctj3KQZhhlDV3qqNT3Dv+3A=; b=UTpCZR6gFydFdpx91jPgGKR4sUaJetttDHQPseyAMCryzt1b4HTG3cFnkOxYcWfgyC UcAQZT0uzSJ3NR6ABjyEhUI1w+38mGjuXZBxu8da6l+rzwjkxQr8WEa966W7ra6LqdwM eB2ZsHIPYsG8D8I4TSuapY0D7XkSgYxrSE/2qm2t9ka3qeks75YJRSVTeuUdPLDWO6IP SzoJqZYDJyLBCKHQbP2o4mN5vEHco7UitLopQMt6N44mc7sDaFkXqT6A+wi7FaU+78aV Ek/o91pUpozTYeWJXGccdWfeAXEhRsutO3xKHtHukX3KPMndrhxrPWbEWcS/90pAEGG+ QYMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b="o5aqY/QP"; 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 d11si10888950wrj.133.2019.03.01.00.28.57 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Mar 2019 00:28:57 -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="o5aqY/QP"; 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 5BF593EAA68 for ; Fri, 1 Mar 2019 09:28:57 +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 1D68A3EAA5F for ; Fri, 1 Mar 2019 09:28:52 +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-6.smtp.seeweb.it (Postfix) with ESMTPS id B25B81401716 for ; Fri, 1 Mar 2019 09:28:51 +0100 (CET) Received: by mail-pf1-x441.google.com with SMTP id a3so11071089pff.11 for ; Fri, 01 Mar 2019 00:28:51 -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=SJCvFHPw69fo0ZrknnVF88UsDQI+1D5Q8coSsKKYO2c=; b=o5aqY/QPCCMYXo++8Sw77ceN+6JPqXucE2x7bNIT4gWMRL2asjJj7bcYNWoeVt4gvm QN7HWdiu30hXkMTKXu7CMIZOTEZzcCof+fBT8UQYsY/ahyXX9SR4hxKwZQHr85wSDJHH wvm72e2EqMu34GkGA3cHBEY5Y+iHs3qLLYRtQOEdHRS7sM+vFeMr4IkZgMlBIRp6DuGy 9lzCGLcgekvaIA+wec5dFcFHQ3WdjdjZVwwVqAguDOHkzWYD6rmD/MYCS4zgvp4BIkxg /Pkqud1cF5NhINLwPuMpEfY0oWNIn1OUD6jWGB3XIbcYM6STw5ydzQHxCtL7I/c/dJgH 8QOQ== 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=SJCvFHPw69fo0ZrknnVF88UsDQI+1D5Q8coSsKKYO2c=; b=DHLPMCAC4HGDRnyWE4bunou5HKgl1hC4IR8jeubdIh9QHY3RiVN+SEA/ydLI8EJsZY CO6L93jqv2+llQS3CnMiPU76dT1XwmUOG2YvUnSQTQ54/ON6VMSzD/pQooYnC2aVIZC6 +/JgF7KP5mm/mjcguGrNWHKDBU51Nb4U0quvW2HlM88fBraldNMGFilZmZlTYi4+dZK6 SlD0gTaE4HsIk6/6tCQuexSrY68YuI7zo+QenY99UyTcwsybzjCsl05mriNQfXLz0e71 diB3IX5S1EKf8+5tyBq2jTq/n0Y08dSqd4Jmgjp9TqYfOp0+f5FLdbwCkBkD7pYP7tis jtyg== X-Gm-Message-State: AHQUAuYxIfwhJCLkYFoZtYsLx5vWdIUOY+MzZd9xeMcrBjcxtxPl4lAg ghHGr4PmHYxno9KrQ89Um+se1yOGCQkq9w== X-Received: by 2002:a62:48c1:: with SMTP id q62mr4351091pfi.113.1551428929876; Fri, 01 Mar 2019 00:28:49 -0800 (PST) Received: from localhost.localdomain ([117.252.69.94]) by smtp.gmail.com with ESMTPSA id h75sm34821720pfd.150.2019.03.01.00.28.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Mar 2019 00:28:49 -0800 (PST) From: Sumit Garg To: ltp@lists.linux.it Date: Fri, 1 Mar 2019 13:58:20 +0530 Message-Id: <1551428901-30162-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-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 Subject: [LTP] [PATCH 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 --- .../syscalls/sync_file_range/sync_file_range02.c | 49 +++++++++++++++++++++- 1 file changed, 47 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..23240c0 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,50 @@ 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); + + lseek(fd, FILE_SIZE/4, SEEK_SET); + + tst_dev_bytes_written(tst_device->dev); + + tst_fill_fd(fd, 0xff, TST_MB, FILE_SIZE_MB/2); + + 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 +107,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, };