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, }; From patchwork Fri Mar 1 08:28:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 159470 Delivered-To: patch@linaro.org Received: by 2002:a02:5cc1:0:0:0:0:0 with SMTP id w62csp440628jad; Fri, 1 Mar 2019 00:29:03 -0800 (PST) X-Google-Smtp-Source: APXvYqzbGgS1syIZt5qOAJOXFdkxxg7A7HahmeDtfPLgzRZvCNAgg124y9BT9auRG0o3hXudWsUh X-Received: by 2002:adf:9d13:: with SMTP id k19mr2619085wre.82.1551428942924; Fri, 01 Mar 2019 00:29:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551428942; cv=none; d=google.com; s=arc-20160816; b=m8596b6haITOiF6rur3bo74IYsQZBd+Ni0vwLyuDdQ5iMYwEnStUAe/jhizR8cWrmV Jsvu0l/f1lNSOgmWIlXeDICN9XvevFMdQfa2XnNup0TrirgdVM64p+LezGIb3/JdP17K kdzwFUUxw6aVTeVWid1RHUw+06xQ7zCOdIHDTPYt4AjThSdSRQ5HKSKVl2xiu9VOzVVO m2aApC/wLPeavqUaHazvi+Iu3gFVn8X+OQI4l4w0WAVJBF1dnjCRz24hw4o8uSzcJBPf ccrDOajWaA8tP75HfchlRJeyFxY5atHINMj/hTq4FBBVR5tw1+9Id76B7dlVjuaediVJ GGlg== 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:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=y/BKAHUY6MCiochhF0RN4Ife2Jjz5CefMKMB+ssB/wc=; b=vSkFZOxG9TeFyrfA9XKb8y6Fisud8vEKHy/EKUsHkFiRbd0QQ6bmFLCxudpNyRJVpN XBP2EJzcjTaHZ72yASWCc86G3zCUfmydL3vPQtXoEpZNuomGkdiGbn32IvX5/hUfZhHn rABArrd7KkM+PPI952mCYIAwvoukUTDSqV2XlneYWwM6DexWD++zGkk7dKgNTHB17DFU 2ywO7BlOgpzEDf+thpZ1g+GqKDsTBPX6/ogUKro2+xvzv+hnu1HAq8JSuTKrJUlyxrQK efG84L5syPYmVv6GxH9PEnnJUzKUk3gbg9SNXQyJKvGFEVmrurRpr5j9L3nxW23b5EEV FSkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=WqxdRjhw; 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 z188si4510430wmb.189.2019.03.01.00.29.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 01 Mar 2019 00:29:02 -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=WqxdRjhw; 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 7971B3EAD1A for ; Fri, 1 Mar 2019 09:29:02 +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 4C14B3EAABE for ; Fri, 1 Mar 2019 09:28:55 +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-3.smtp.seeweb.it (Postfix) with ESMTPS id 950931A01CE9 for ; Fri, 1 Mar 2019 09:28:54 +0100 (CET) Received: by mail-pg1-x543.google.com with SMTP id h8so10583904pgp.6 for ; Fri, 01 Mar 2019 00:28:54 -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=Pd+s854KAONHXfonFYvjgwBHqWtxRinnbvczDfpLPcM=; b=WqxdRjhwDs4H7IHlMjNEgRsbuf9BeuxuA6LEgg9j6oyCmQkuf/Fp9jnb1oxXugCPFk VciP/cTLK5p17AjhJ05xqUePhZq0+xS/1yjCGn0lc/F7wl9QmCtVDb9aXuYfNe9VZCNp bWVmQRp8Rjd1giGnbMSEvhy1IucIo94ifOFPAQWN44RFK8ApOHfDlUgt9P/l6xCX1UNu n6u/Vzl7ZTjbOEJSj07QklU01qKN2zDgkb7U+lzRMsI7Vk9G9hialyL3N/fTuZvI7aLX v4d1sLka5mAeqN4jsdYFPOTgk007avQMXx5rO5c/EZyjK6/Jh7Ix36SQIsoyeSVbQPV0 jeaA== 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=Pd+s854KAONHXfonFYvjgwBHqWtxRinnbvczDfpLPcM=; b=me4OdZktp8sEXHntMSh7k35WlWhw5LM04e5YPTlulxx0Q2hJd8ZR9dIz8vJsJAbjO1 2+PqC0zx/KwcQen0+C2csGpeJ5Qk53oWyNj2FDFdJkts6J6KTZnn3J2f87PKZvE+zHft WhRKtdrfVIEi4TB9Vd3FlJ4Bam/8B2sQuCMCGqCC+vrPgj9JRVbtpkkjtAnw2oLXcwXY riwec9zVMxD69OYy8vSBS3KXIx+ARLIgTdlnTBi7yo6ccITcOebJyLFRpIMWPnnf93jS 0agJzDfTDFbzT3Iiq2FOiX5h4jueAPuUk4dUxeqDLN22rbmht08TkihLhXXt3bG0R1NF beBw== X-Gm-Message-State: AHQUAubmFNmnpU6J09w61Yr4k+AxQzp/f1Y7sG5IQ2zPHU+XmFdJBOtZ jWnrrHDWS6kMwCn8+cdLYZ409KwiHfklKg== X-Received: by 2002:a62:ae04:: with SMTP id q4mr4276904pff.213.1551428932778; Fri, 01 Mar 2019 00:28:52 -0800 (PST) Received: from localhost.localdomain ([117.252.69.94]) by smtp.gmail.com with ESMTPSA id h75sm34821720pfd.150.2019.03.01.00.28.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 01 Mar 2019 00:28:52 -0800 (PST) From: Sumit Garg To: ltp@lists.linux.it Date: Fri, 1 Mar 2019 13:58:21 +0530 Message-Id: <1551428901-30162-2-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1551428901-30162-1-git-send-email-sumit.garg@linaro.org> References: <1551428901-30162-1-git-send-email-sumit.garg@linaro.org> 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 Subject: [LTP] [PATCH 2/2] doc: document new library functions 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" Document following library functions: 1. tst_fill_file() 2. tst_fill_fd() 3. tst_dev_bytes_written() Signed-off-by: Sumit Garg --- doc/test-writing-guidelines.txt | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt index f2f72c4..a5fe589 100644 --- a/doc/test-writing-guidelines.txt +++ b/doc/test-writing-guidelines.txt @@ -1033,6 +1033,16 @@ results in 'umount(2)' failing with 'EBUSY'. IMPORTANT: All testcases should use 'tst_umount()' instead of 'umount(2)' to umount filesystems. +[source,c] +------------------------------------------------------------------------------- +#include "tst_test.h" + +unsigned long tst_dev_bytes_written(const char *dev); +------------------------------------------------------------------------------- + +This function reads test block device stat file (/sys/block//stat) and +returns the bytes written since the last invocation of this function. + 2.2.15 Formatting a device with a filesystem ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1142,6 +1152,24 @@ Returns non-zero if directory is empty and zero otherwise. Directory is considered empty if it contains only '.' and '..'. +[source,c] +------------------------------------------------------------------------------- +#include "tst_test.h" + +int tst_fill_fd(int fd, char pattern, size_t bs, size_t bcount); +------------------------------------------------------------------------------- + +Fill a file with specified pattern using file descriptor. + +[source,c] +------------------------------------------------------------------------------- +#include "tst_test.h" + +int tst_fill_file(const char *path, char pattern, size_t bs, size_t bcount); +------------------------------------------------------------------------------- + +Creates/ovewrites a file with specified pattern using file path. + 2.2.18 Getting an unused PID number ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^