From patchwork Tue Feb 19 09:28:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 158697 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3447132jaa; Tue, 19 Feb 2019 01:29:13 -0800 (PST) X-Google-Smtp-Source: AHgI3IZHkSdte/eLTK6HwQSmt6fHuaJiYYDOpGANRYI6P0H8aIP7gMau2/hZWz7ZpkYjVTxQnSz8 X-Received: by 2002:a50:97b3:: with SMTP id e48mr22778724edb.159.1550568553542; Tue, 19 Feb 2019 01:29:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550568553; cv=none; d=google.com; s=arc-20160816; b=UbpaSq5mn5rMz/EUiUZLHmLg6IRSMuGnwoRBv+qVxobDV26PPG8jA+2Oq4CZe3Wu88 Yqi3MNCP20KMqYrstAkkZvtjOtx18hBbw+qzrNHpv6dfINT3Vqe6n/A388FeP/DUTQ9i OoPfrmSn2isJo2PFWqT1SuU8CPIEI244msoeqF2BPA98RnATaYCsawOSQo2F8iMjUNrW MK2zuVoc3GarNaR1Qm1nvLQYgPPeCM5RjfiZfpqoJLgUXZlk2BBqp5es9cL1+bVlno17 9TlM+Gt/NPyslvDM0ZM7CcKNJAdPRmRt/I2WhO60UcVnDwqmw2QhyYX1cVHc94weFH8G fjBA== 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=+5LzyJphNiidctnL6B3H2TeaRZ3yfmm/+Qz0FtbwdIE=; b=k18dyYaPhwgDI4SdNnclrhCM+YELrEdR8tIS41upuo5HDU+EsEQM3tzjh43Q6ofxvI A3q+MXg97lSAZXfgGoxTTyUsBcpizch6CBjG91TwS0W8xOHTah3dPfM8PTiZLsrKpqMx MnueWWDRLNMLFrmZNeNmhYzQzBrY3jLRXbY23VOaEyvkMF3LoKUawz6AcAVqGnibjJj7 aLfywY/v7cy2o0v7IlgRzip/JPDkXA9TR/ps6pl9aNEhQPF3Wtn4HMI+bIF+InsGW9yG jYMvl01JGVYs+qs+LcDX4IwdbxuYskrgQ5W/GpWjJT/hU8ouBY6O6TrFbCwOEhutWHu3 iJ5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=IQFCeqdJ; 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 d46si1994957ede.307.2019.02.19.01.29.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Feb 2019 01:29:13 -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=IQFCeqdJ; 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 18C6A3EA2E4 for ; Tue, 19 Feb 2019 10:29:13 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) by picard.linux.it (Postfix) with ESMTP id 00A9C3EA2E4 for ; Tue, 19 Feb 2019 10:29:06 +0100 (CET) Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id D46C01000C5A for ; Tue, 19 Feb 2019 10:29:04 +0100 (CET) Received: by mail-pl1-x641.google.com with SMTP id p8so10171319plo.2 for ; Tue, 19 Feb 2019 01:29: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=t1afbiXeu5gtjQqQBxXTHGBQTys8Jwl1Stg/ONboF9A=; b=IQFCeqdJ3k66MqZXHuiE2iPQJoBTP/wSDjMsoztvpRY5GFJSK63PgA3TQQjZqYKtTz wAP3bURzX0a4VhX1MrZfiUBauzxD8+hXp4h1H2shXnkcHiO115wZ1skWjF7QHiGXJ986 UC52JYdJCRrlkCnWYfYbY1axjMMC3ZGwTf3Wvmwch9++HTIqWEoLREQPJKipxdj98FkF eOtjT6YXs39HmC+ksGS/iibzsSnJxduYsz5H8TySnQxYc4MSnY+G5CCyorO1aL0gJdWT b0urn54AdQ4m6OEVx2O4/0oTcxfZtY/faqYipk1JkxjFAxwfAeUAyAPkJ78gPQbwWuaR akRw== 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=t1afbiXeu5gtjQqQBxXTHGBQTys8Jwl1Stg/ONboF9A=; b=MqGYYqwU8uyplfXGTictYV+TTnQLn+67R0LFVvFPaa5MJ79Vt6jj65vawmKh0JbRPu q0NVlBcnoc6cNP97AXg3BTU+uI1xGLr/BUOtHRabgPvNfSScw/VYVPCXfSEhBHHbbGW4 gh9iF/BudYBGLJKPqlHKyS4VZvY+7iPWHRjaavoE7HD4DiulERvZNnBCFnlKp2EE2wSg QVWExeVMM1dzLHAafn0zE7qvJwvHuon7hnbiixsBu1uX0NjwJPLTq3QNMUqfPeSMzNVX 6W5aIEMcNGzYz/W6NLGQ+hxT5edHkrLR0q5x84Nj9CSx02uA6yG6urKfs5sMDGPFbvlI YHaQ== X-Gm-Message-State: AHQUAuZYuU/KfRVuQ69Aoebqwp6H8v1iyOcPaCDQGD6t/zzCmSOv9cCP 1kmw1HugqT6UlRw3Sz9yM4Tilo7cYcE/Pw== X-Received: by 2002:a17:902:f24:: with SMTP id 33mr30090481ply.65.1550568544205; Tue, 19 Feb 2019 01:29:04 -0800 (PST) Received: from localhost.localdomain ([117.252.69.94]) by smtp.gmail.com with ESMTPSA id n19sm34442229pfg.67.2019.02.19.01.29.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Feb 2019 01:29:03 -0800 (PST) From: Sumit Garg To: ltp@lists.linux.it Date: Tue, 19 Feb 2019 14:58:14 +0530 Message-Id: <1550568500-10871-2-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-4.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-4.smtp.seeweb.it Cc: daniel.thompson@linaro.org Subject: [LTP] [PATCH v3 1/7] lib: Add library functions for sync related syscalls 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" These library functions are used to add common test for minimal sectors written on device for various sync related syscalls. Signed-off-by: Sumit Garg --- include/tst_sync_device.h | 17 ++++++++++ lib/tst_sync_device.c | 80 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 include/tst_sync_device.h create mode 100644 lib/tst_sync_device.c diff --git a/include/tst_sync_device.h b/include/tst_sync_device.h new file mode 100644 index 0000000..b07c490 --- /dev/null +++ b/include/tst_sync_device.h @@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Sumit Garg + */ + +#ifndef TST_SYNC_DEVICE_H__ +#define TST_SYNC_DEVICE_H__ + +#include + +void tst_sync_device_init(const char *dev); +int tst_sync_device_write(const char *file, unsigned int size_mb); +bool tst_sync_device_check(unsigned int size_mb); +void tst_sync_device_cleanup(void); + +#endif diff --git a/lib/tst_sync_device.c b/lib/tst_sync_device.c new file mode 100644 index 0000000..5a0a17c --- /dev/null +++ b/lib/tst_sync_device.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Sumit Garg + */ + +#include +#include +#include + +#define TST_NO_DEFAULT_MAIN +#include "tst_test.h" +#include "lapi/stat.h" +#include "tst_sync_device.h" + +#define SIZE_MB (1024*1024) +#define MODE 0644 + +static char dev_stat_path[1024]; +static char *buffer; +static int fd; +static unsigned long prev_write_sec; + +void tst_sync_device_init(const char *dev) +{ + struct stat st; + + snprintf(dev_stat_path, sizeof(dev_stat_path), "/sys/block/%s/stat", + strrchr(dev, '/') + 1); + + if (stat(dev_stat_path, &st) != 0) + tst_brk(TCONF, "Test device stat file: %s not found", + dev_stat_path); + + buffer = SAFE_MALLOC(SIZE_MB); + + memset(buffer, 0, SIZE_MB); +} + +int tst_sync_device_write(const char *file, unsigned int size_mb) +{ + unsigned int counter; + + SAFE_FILE_SCANF(dev_stat_path, "%*s %*s %*s %*s %*s %*s %lu", + &prev_write_sec); + + fd = SAFE_OPEN(file, O_RDWR|O_CREAT, MODE); + + /* Filling the test file */ + for (counter = 0; counter < size_mb; counter++) + SAFE_WRITE(1, fd, buffer, SIZE_MB); + + return fd; +} + +bool tst_sync_device_check(unsigned int size_mb) +{ + unsigned long write_sec = 0; + bool res = false; + + SAFE_FILE_SCANF(dev_stat_path, "%*s %*s %*s %*s %*s %*s %lu", + &write_sec); + + if ((write_sec - prev_write_sec) * 512 >= + (size_mb * SIZE_MB)) + res = true; + + SAFE_CLOSE(fd); + + return res; +} + +void tst_sync_device_cleanup(void) +{ + if (buffer) + free(buffer); + + if (fd > 0) + SAFE_CLOSE(fd); +} From patchwork Tue Feb 19 09:28:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 158699 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3447260jaa; Tue, 19 Feb 2019 01:29:24 -0800 (PST) X-Google-Smtp-Source: AHgI3IbaE+bfBT5Sa+hERyhwkjclnCNLqcgOfv4edGEMXZ+6i9V5pXvS9RVm1QjaA+XbkbxAS5eb X-Received: by 2002:a50:a8c3:: with SMTP id k61mr22341482edc.296.1550568564669; Tue, 19 Feb 2019 01:29:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550568564; cv=none; d=google.com; s=arc-20160816; b=fLIV3yOZ1Qc9h28VYKrDFC+7IdNDhu/Xb7/H2YGBKHBKZJrBh6LW3tDUBpECnmZSEB uO13kXSc807bhLjuMQdnlH3lav4Y6Elrb8b2E4yCRbYeEh+MyZNS6sYfXD60zK435uV5 8OVOAqD7GzAAtVAZkniklVGBxII0dqSnSc6Kjzy7yJlEsNN/lFI9+AeZ2UI8shYCvzSY arGCGUvi0Kj3oKax/+/z+277hIt2mVrqt7KOGB7sqikQefzOVg/yDn6MCl5+4uC2Pfju EEIsqwolqO+zKYG4fegr7PfV0yL5EB9bq2fhQgloYnDzLwl7WtjMkvciXNBwBT4NhXNq HZAg== 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=mmiyfzGh3Kiz3GyYXNVAJ1equOQO9YMG+lWtDQG4PRs=; b=vc1LOf/BCXrKiV8DFnOQlqsOHbILJ2q7Hnv8BXAUiE4rYilq8FqccT+L1sraCN1hHQ d/m6RqPjKen6GiIYNk7/0xj/2atV8iqpmk0QPPiGytZY/iaV2Vh2NFbNB+xF/jNx7LWy b8TB1jQ2Fh/g6MG0otO3ZqtQiqyHhZyp8zCHFvlJmcADLgy5UlWsTFUFpIhuHpTZootX cRA5vD1p0hkgch6LNSMbxPqAo/VinxSHMiXIRTmjIocf0CUvS3sUpL8gpAD36a9VQsF0 rjNv88MIgreYSiEuIRh4KBb1o78lFGkgj1kA6j7O7F0g12bPG/5e1igH8UIqjeUcAEDV GAPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=pmXmgNpG; 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 k30si759941edb.244.2019.02.19.01.29.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Feb 2019 01:29:24 -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=pmXmgNpG; 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 3BDA93EA37D for ; Tue, 19 Feb 2019 10:29:24 +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 [217.194.8.7]) by picard.linux.it (Postfix) with ESMTP id BFD693EA37B for ; Tue, 19 Feb 2019 10:29:13 +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-7.smtp.seeweb.it (Postfix) with ESMTPS id 70384200D32 for ; Tue, 19 Feb 2019 10:29:09 +0100 (CET) Received: by mail-pf1-x441.google.com with SMTP id v21so6970886pfm.12 for ; Tue, 19 Feb 2019 01:29:09 -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=5QvFDvM52ICo6DkVyvSKxlpIS7tDSllpvXRQVtAjopo=; b=pmXmgNpGBKZeW4evJOAAO2btMiQVI+ekdDprKYt51ejutG+VRxRNhxi/gz2FM7eLSo RmX1sQgTTO5JAGOP0fhuJa7yTfHM6sRz8NzNUNmR3krw0rY0g8oXgQTyU6YL/2JnaHjd FUU4QNVyVII6fBBZLcYgEos7YaKU0A/YQaOCOJVZh5uZoSxv93KL36eBJDrCmzxzHjPp ueIxzkQjWz+gVTGnl70Duh0e8He30FlXLdDExcUO4xiIa5cVutQolY03Y5Nw2xl62Uro 6wAao0FKNuG/bw3FrSq3mCWu1NjPcIj0/h83W6I7ggBS+1m5DWye+IJVg/MI+TCT99Hb LeJQ== 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=5QvFDvM52ICo6DkVyvSKxlpIS7tDSllpvXRQVtAjopo=; b=O1I6ehQLxohqfJYE0ZZKFfd6L7b5JTeJvYp/Gob9Y/EATkiidDzm3lfLBPEX4gbQzt HvdJ4A47B2Be+cPIfO3zgcWa0ugHEgEjNO9lm8tJIQP1pAUNR3VX2mCAdGjN1mjinXmw dMLZt+FPnpXEY0wsKvGZSILa81ZsNdWhEWbfHUG2Zl9hfgPsfSZpB+6sPv0UWeO/m+jt hSdTw7Aj9iHhllhVwC2YLH/I4sNuNvNjBirLn/s1oZ7J+Lje9qV3y/2w4xagDAN01FtE IMBemkPrWPDErtcLe8t7V374PPoU9aHumqBpywrmZBaJnjHWwZ0yOzibnOY6wag8oCb+ l2kQ== X-Gm-Message-State: AHQUAuaL+vI14eXOuem9/IJznthxSLB29RgPDt1+D6lkJJvQRHjnn5ag HYZfINFhb8iPtOgsj7cO6tn8Hez5SjWfsA== X-Received: by 2002:a63:4a4d:: with SMTP id j13mr23466568pgl.127.1550568547680; Tue, 19 Feb 2019 01:29:07 -0800 (PST) Received: from localhost.localdomain ([117.252.69.94]) by smtp.gmail.com with ESMTPSA id n19sm34442229pfg.67.2019.02.19.01.29.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Feb 2019 01:29:07 -0800 (PST) From: Sumit Garg To: ltp@lists.linux.it Date: Tue, 19 Feb 2019 14:58:15 +0530 Message-Id: <1550568500-10871-3-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-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 v3 2/7] syscalls: add syncfs() 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" syncfs01 tests to sync filesystem having large dirty file pages to block device. Also, it tests all supported filesystems on a test block device. Signed-off-by: Sumit Garg --- configure.ac | 1 + include/lapi/syncfs.h | 21 ++++++++ m4/ltp-syncfs.m4 | 10 ++++ runtest/syscalls | 2 + testcases/kernel/syscalls/syncfs/.gitignore | 1 + testcases/kernel/syscalls/syncfs/Makefile | 8 ++++ testcases/kernel/syscalls/syncfs/check_syncfs.h | 19 ++++++++ testcases/kernel/syscalls/syncfs/syncfs01.c | 64 +++++++++++++++++++++++++ 8 files changed, 126 insertions(+) create mode 100644 include/lapi/syncfs.h create mode 100644 m4/ltp-syncfs.m4 create mode 100644 testcases/kernel/syscalls/syncfs/.gitignore create mode 100644 testcases/kernel/syscalls/syncfs/Makefile create mode 100644 testcases/kernel/syscalls/syncfs/check_syncfs.h create mode 100644 testcases/kernel/syscalls/syncfs/syncfs01.c diff --git a/configure.ac b/configure.ac index caea344..9122b6d 100644 --- a/configure.ac +++ b/configure.ac @@ -231,6 +231,7 @@ LTP_CHECK_TPACKET_V3 LTP_CHECK_RLIMIT64 LTP_DETECT_HOST_CPU LTP_CHECK_PERF_EVENT +LTP_CHECK_SYNCFS if test "x$with_numa" = xyes; then LTP_CHECK_SYSCALL_NUMA diff --git a/include/lapi/syncfs.h b/include/lapi/syncfs.h new file mode 100644 index 0000000..1341c6b --- /dev/null +++ b/include/lapi/syncfs.h @@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Sumit Garg + */ + +#ifndef SYNCFS_H +#define SYNCFS_H + +#include +#include "config.h" +#include "lapi/syscalls.h" + +#if !defined(HAVE_SYNCFS) +int syncfs(int fd) +{ + return tst_syscall(__NR_syncfs, fd); +} +#endif + +#endif /* SYNCFS_H */ diff --git a/m4/ltp-syncfs.m4 b/m4/ltp-syncfs.m4 new file mode 100644 index 0000000..836a055 --- /dev/null +++ b/m4/ltp-syncfs.m4 @@ -0,0 +1,10 @@ +dnl SPDX-License-Identifier: GPL-2.0-or-later +dnl Copyright (c) 2019 Linaro Limited. All rights reserved. + +dnl +dnl LTP_CHECK_SYNCFS +dnl ---------------------------- +dnl +AC_DEFUN([LTP_CHECK_SYNCFS],[ +AC_CHECK_FUNCS(syncfs,,) +]) diff --git a/runtest/syscalls b/runtest/syscalls index 668c87c..9442740 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1346,6 +1346,8 @@ symlinkat01 symlinkat01 sync01 sync01 sync02 sync02 +syncfs01 syncfs01 + #testcases for sync_file_range sync_file_range01 sync_file_range01 diff --git a/testcases/kernel/syscalls/syncfs/.gitignore b/testcases/kernel/syscalls/syncfs/.gitignore new file mode 100644 index 0000000..6066295 --- /dev/null +++ b/testcases/kernel/syscalls/syncfs/.gitignore @@ -0,0 +1 @@ +syncfs01 diff --git a/testcases/kernel/syscalls/syncfs/Makefile b/testcases/kernel/syscalls/syncfs/Makefile new file mode 100644 index 0000000..3e6c2f4 --- /dev/null +++ b/testcases/kernel/syscalls/syncfs/Makefile @@ -0,0 +1,8 @@ +# Copyright (c) 2019 - Linaro Limited. All rights reserved. +# SPDX-License-Identifier: GPL-2.0-or-later + +top_srcdir ?= ../../../.. + +include $(top_srcdir)/include/mk/testcases.mk + +include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/kernel/syscalls/syncfs/check_syncfs.h b/testcases/kernel/syscalls/syncfs/check_syncfs.h new file mode 100644 index 0000000..26991d2 --- /dev/null +++ b/testcases/kernel/syscalls/syncfs/check_syncfs.h @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Sumit Garg + */ + +#ifndef CHECK_SYNCFS_H +#define CHECK_SYNCFS_H + +void check_syncfs(void) +{ + int ret; + + ret = syncfs(-1); + if (ret == -1 && errno == EINVAL) + tst_brk(TCONF, "syncfs() not supported"); +} + +#endif /* CHECK_SYNCFS_H */ diff --git a/testcases/kernel/syscalls/syncfs/syncfs01.c b/testcases/kernel/syscalls/syncfs/syncfs01.c new file mode 100644 index 0000000..7c3efb0 --- /dev/null +++ b/testcases/kernel/syscalls/syncfs/syncfs01.c @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Sumit Garg + */ + +/* + * Test syncfs + * + * It basically tests syncfs() to sync filesystem 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 "lapi/syncfs.h" +#include "tst_sync_device.h" +#include "tst_test.h" +#include "check_syncfs.h" + +#define MNTPOINT "mnt_point" +#define TST_FILE MNTPOINT"/test" +#define TST_FILE_SIZE_MB 32 + +static void verify_syncfs(void) +{ + int fd; + + fd = tst_sync_device_write(TST_FILE, TST_FILE_SIZE_MB); + + TEST(syncfs(fd)); + if (TST_RET != 0) + tst_brk(TFAIL | TTERRNO, "syncfs(fd) failed"); + + if (tst_sync_device_check(TST_FILE_SIZE_MB)) + tst_res(TPASS, "Test filesystem synced to device"); + else + tst_res(TFAIL, "Failed to sync test filesystem to device"); +} + +static void setup(void) +{ + check_syncfs(); + + 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_syncfs, +}; 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, +}; From patchwork Tue Feb 19 09:28:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 158701 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3447394jaa; Tue, 19 Feb 2019 01:29:37 -0800 (PST) X-Google-Smtp-Source: AHgI3IZM/Nco/y14tT2kNfNhhzIiStECVXUMLDQGzjMOFdTcr1jex+Iq2dwM55Y9Gg78eaiFmJ8W X-Received: by 2002:a50:9938:: with SMTP id k53mr17660904edb.134.1550568576887; Tue, 19 Feb 2019 01:29:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550568576; cv=none; d=google.com; s=arc-20160816; b=0T6uxQh9qdHUKpsICJbPgjjaUU0CQeK6Xib5mk55CQgjaBr1YOwV2SWQuZCkyJx3V7 wwKDfGzSbQ6gUYtOodxKMlALcYRoJFwdram0CwnmofwLVDbkQcogtCOjBPJel3PZXo8R p847F/e/r2DeM09/ziMtlinzmfrN82x5qJNtGj29onQYclHOJoSD+BmANGY4XV6TcezD 9Vuqu8Ki7cPc3Il/46FwfePjVRZNtxapTptm8FLFNqrNq/dlQaEpKSsfQWHh0II6uuo+ T3Q54io7RxF8wR/t4MY8SK9vCfclXlCuiND6NV5jM2b8EtGuq32Z0u4333ra12Lwy11C GFXA== 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=/bpgNFEEEHFp3I4MMXNQdyMCGOvS5iUmikjSLkbeKh4=; b=D62Jv3/MPdur5IME9a8DZmwuK/3sraosYwzJVBf3EpKEbI68Wfu77S1vF9E4G0i5K8 e7TOwUXvlyIK+/FnuUKlELo/PPeVEvjBX28Jc+zFk0ZCUKbHW6PWPN19kS8qjMPFCWTc 1E8Lg54amejWo++aKg7MGTGb1QB554V3ykyYRRgFstq7Rr/SOy5x4r4ZgzhDyTx4CeCv GmGYuQNILi7EUiPr5rdNuU1an93wxyYaS9NREaZl3ZAy7ZjsHpISSZVR++tnlV4KZf8y 325jvC9Aap4x4o7tNYoDb/JInRc0n0bD3ossTu0vuSJLymSTsEwwfQjbKVnBcUVs+Dce lg5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=d0DoqJqE; 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 k22si243432ejz.317.2019.02.19.01.29.36 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Feb 2019 01:29:36 -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=d0DoqJqE; 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 CCC7C294AA7 for ; Tue, 19 Feb 2019 10:29:33 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-5.smtp.seeweb.it (in-5.smtp.seeweb.it [IPv6:2001:4b78:1:20::5]) by picard.linux.it (Postfix) with ESMTP id 5A8E73EA38B for ; Tue, 19 Feb 2019 10:29:18 +0100 (CET) Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-5.smtp.seeweb.it (Postfix) with ESMTPS id 99BA2600BD5 for ; Tue, 19 Feb 2019 10:29:18 +0100 (CET) Received: by mail-pg1-x531.google.com with SMTP id r124so9870882pgr.3 for ; Tue, 19 Feb 2019 01:29:17 -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=LD/rTB9YoyOFPue5glYjkELhJJhqNxQ+N3hMvoqVil4=; b=d0DoqJqE/KTFSNErIE72nA1a/ltvrpeXwZ/GMUtYusAwt46uopCt5ba3kX8e/ZiOII SmXiIeVYdpP57UboPbjZNoM45Yc5HSXGlI6P5bmvHSimet2uMW8CUbHs3CUq39xNkOM5 2/5d8cAhXcqFdUjNqOX9ayon/tl91SbVtaLdW61/42fgMngDE+jw8ADTmNNEkTKYmL9n h2j9LryQERqKhyKpqRq46rhoJX5GqQ4eDCqvKL7yQ6fSvh6X94xfG2NQ6gCic1gEKAop 3Hd6bH19EPT8rycv7Peb9tJfg/N0WOOF+5qoHztGmHTCJBGTRhkHqtUKOUtsrG+9TU4X YGpQ== 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=LD/rTB9YoyOFPue5glYjkELhJJhqNxQ+N3hMvoqVil4=; b=H2xNBRFsqLN9csH1chuZNGCMLxk4VMNXy/3D2pn4Mh0nUiiw9/ect4doYwD/AKlfk9 nPIpsNzoExMBcErCnTuPly45fe5Rsz1bpuwudHRCffmZUt4QsccEEnx6KV/Jm0uQHElR Z7z2hTnrQE5cW1mwA9Fl+xKx8gIT0c5tmyEuPaitncppq+KOTGD9kZkKoJdB6LySTunA 2pty9IDS3lQBmQZQTHZnYZantstkMDZVUzNaq1yGZHVNq0tYn9MY5gVJKwbpH/hXzLjs Fk+l6fHvzMelhma2agenaVuwUMt9FgUbClxfwOh9ukwSpqIUtwgiRx+QpZC9fjZvlTiU 54Gg== X-Gm-Message-State: AHQUAuaoBf6Vsx/ze4kH4/QtrlWsXqsJuZskyED1UY3QZ7gugegleTIx WjBfZi/kAQ3dlw4bfpArQ7xerlyNyYb/pA== X-Received: by 2002:a63:4e1d:: with SMTP id c29mr23537957pgb.433.1550568555794; Tue, 19 Feb 2019 01:29:15 -0800 (PST) Received: from localhost.localdomain ([117.252.69.94]) by smtp.gmail.com with ESMTPSA id n19sm34442229pfg.67.2019.02.19.01.29.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Feb 2019 01:29:15 -0800 (PST) From: Sumit Garg To: ltp@lists.linux.it Date: Tue, 19 Feb 2019 14:58:17 +0530 Message-Id: <1550568500-10871-5-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-5.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-5.smtp.seeweb.it Cc: daniel.thompson@linaro.org Subject: [LTP] [PATCH v3 4/7] syscalls/fsync: 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" fsync04 tests to sync file having large dirty file pages to block device. Also, it tests all supported filesystems on a test block device. Signed-off-by: Sumit Garg --- runtest/syscalls | 1 + testcases/kernel/syscalls/fsync/.gitignore | 1 + testcases/kernel/syscalls/fsync/fsync04.c | 61 ++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 testcases/kernel/syscalls/fsync/fsync04.c diff --git a/runtest/syscalls b/runtest/syscalls index dba0dee..0d09509 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -347,6 +347,7 @@ fstatfs02_64 fstatfs02_64 fsync01 fsync01 fsync02 fsync02 fsync03 fsync03 +fsync04 fsync04 ftruncate01 ftruncate01 ftruncate01_64 ftruncate01_64 diff --git a/testcases/kernel/syscalls/fsync/.gitignore b/testcases/kernel/syscalls/fsync/.gitignore index 3c694a4..4b5ea83 100644 --- a/testcases/kernel/syscalls/fsync/.gitignore +++ b/testcases/kernel/syscalls/fsync/.gitignore @@ -1,3 +1,4 @@ /fsync01 /fsync02 /fsync03 +/fsync04 diff --git a/testcases/kernel/syscalls/fsync/fsync04.c b/testcases/kernel/syscalls/fsync/fsync04.c new file mode 100644 index 0000000..72c73ce --- /dev/null +++ b/testcases/kernel/syscalls/fsync/fsync04.c @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Sumit Garg + */ + +/* + * fsync04 + * + * It basically tests fsync() 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_fsync(void) +{ + int fd; + + fd = tst_sync_device_write(TST_FILE, TST_FILE_SIZE_MB); + + TEST(fsync(fd)); + if (TST_RET != 0) + tst_brk(TFAIL | TTERRNO, "fsync(fd) 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_fsync, +}; From patchwork Tue Feb 19 09:28:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 158702 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3447468jaa; Tue, 19 Feb 2019 01:29:42 -0800 (PST) X-Google-Smtp-Source: AHgI3IbdBwoY+TA5cm3nuc7rzv4t/kSRwouPMYEya/WT3gmLTx+mpm6P+M/4b68fwGQs5zwNHskX X-Received: by 2002:a50:ad1d:: with SMTP id y29mr12897431edc.225.1550568582539; Tue, 19 Feb 2019 01:29:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550568582; cv=none; d=google.com; s=arc-20160816; b=GRGgmRd0t3usNk5GBXi4nsVzYx0fFH/oMBWWV36+tTs0844FCCD5LwSu7cGKwAquO2 N+tt8xbcO/CPE6ZUzHTUTr4kEXNAq2esCSuz/gyl7wSVU2QGn4iB3SO3LWlbDu3ev+t2 e4MZcokn8Td8Q4f3fVQjp8srzNn5+nSdYS1fXFhFvP5mbDUXW7FJqcPVV+0IQBqQVDXe ryPyt37U1xPDPfCxI28oLwkdGiVmLuF6mJDQP5yU5F+Qsii4tBi0faFUJp3+MdkEN7Ph sNk+75X5/n3d6Jpb7M9hhHMh87vlsCWqpE0ZtB6Tv4hMnMRXPQWpQm6cvgPUutOroU30 LguA== 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=YE0jVa7qcw49E5dD/oePcxgPdOLhpxu8KyBrDn8zgws=; b=TwYWE0t/yFHkEftnCDcDpUuLcBACWHKG4+5H3BxsMS+kcFy2iQ/Z+apmF4T7LRElUO vIU8U5+GWGeaiwb1w/OUmMhb/Y7o21nAtWYBD8mNADIzxInbuC4MFAijsPfvg5OHptrk xWWcmnK9zaHmkpMnzT1iXYVNtx2oGHG0B3kLrq4jNMWD/cPhgc1XKu8W2VL9QKbOaOvn TOlZww588dR/2Nos8Ma86/AcCTSL4zq8//bDY2n+SO2xGGNTzGjbwU7I/WjK5e9lTO9l U77PBIa66enYxv2Vi/VlhdsPxuChW0oic0E0YxcaE8OV8YZRCr43mS7cenDDB0b2AFZ7 UXGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=ivfCS04e; 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 l26si1470122ejs.214.2019.02.19.01.29.42 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Feb 2019 01:29:42 -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=ivfCS04e; 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 BA864294B3C for ; Tue, 19 Feb 2019 10:29:37 +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 [217.194.8.3]) by picard.linux.it (Postfix) with ESMTP id 427B6294AC6 for ; Tue, 19 Feb 2019 10:29:22 +0100 (CET) Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) (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 53DB11A0110D for ; Tue, 19 Feb 2019 10:29:21 +0100 (CET) Received: by mail-pf1-x42b.google.com with SMTP id a3so153073pff.11 for ; Tue, 19 Feb 2019 01:29:21 -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=wmr1/qCZ1lLEStQ3wRm8H/9TmqZUeN/r7DaqN3B+hU8=; b=ivfCS04eKN1K2jZ/QYzLW/aFJY0xggXeyGP2z5Ajte9qOGoToBI0su2BcHkVnG/+A2 v5Ub1PwbgAGbGUn0NzxKYT8n9pqi++QzV551N5rj2lfHUfBCpIWnun9SFtvum2GgZJC3 TPTY0rOnB+fLvvFgQdeK/67t2Tb9Qen9rsVVF9FJ/aqR+Uvdu90Lp+gyDr3mLG0PTY7o +B9uVuwspgkLH4kB3zNqpecH4eVht6mNjfWI68c+GeNLgUmny12a7DwI7Mxfc69OAX9m wRVb0PH4WD2CqdnNj/dvgxtLSG6u3fS/fEJtcVotV1oQkmjUiPu7TXHSTxSCNlB0J5Du ochg== 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=wmr1/qCZ1lLEStQ3wRm8H/9TmqZUeN/r7DaqN3B+hU8=; b=tMu72U538eNOZlQcYLvO+wgJRnoCP+MhtuGwXNwtjnlNnkb5ZFKxI4mCZHBMXrHGdi lPQsIde4pvz5SCIJ8oMh+Lry00Ke48SBvLypAT5wfxVWPclpEv20YeG2RwpHh6Zdfyvp MGXAJ0uTTvNBDoQP7STEHafUpZyjGhqPakUa5Bc53FXsK3XsCWuPatqAUqqoR/dpZ7UJ QGA/feG5xVQozu3uhvpkYQSfWNk5xiRwc2GpGrsVMPD7MUYzX2W0CPDBx1Z1Cy1jIPPd SQnPI0Is5K1VMb5wZ0PlyP+twavzu1nHW4DieZ++MEQ4ODo96eOl1PhDCbr2EvkHqAUS DbuQ== X-Gm-Message-State: AHQUAubs0J04txa0XSg3ofjU1wDTVRmt8Pm1IumLEVb30VOBWsWiih3B 7daiQQo/psUoWnPaS94yDExvV8X4Z7ujqg== X-Received: by 2002:a63:f201:: with SMTP id v1mr21870484pgh.232.1550568559643; Tue, 19 Feb 2019 01:29:19 -0800 (PST) Received: from localhost.localdomain ([117.252.69.94]) by smtp.gmail.com with ESMTPSA id n19sm34442229pfg.67.2019.02.19.01.29.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Feb 2019 01:29:19 -0800 (PST) From: Sumit Garg To: ltp@lists.linux.it Date: Tue, 19 Feb 2019 14:58:18 +0530 Message-Id: <1550568500-10871-6-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-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: daniel.thompson@linaro.org Subject: [LTP] [PATCH v3 5/7] syscalls/fdatasync: 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" fdatasync03 tests to sync file data having large dirty file pages to block device. Also, it tests all supported filesystems on a test block device. Signed-off-by: Sumit Garg --- runtest/syscalls | 1 + testcases/kernel/syscalls/fdatasync/.gitignore | 1 + testcases/kernel/syscalls/fdatasync/fdatasync03.c | 61 +++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 testcases/kernel/syscalls/fdatasync/fdatasync03.c diff --git a/runtest/syscalls b/runtest/syscalls index 0d09509..aaad651 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -291,6 +291,7 @@ fcntl36_64 fcntl36_64 fdatasync01 fdatasync01 fdatasync02 fdatasync02 +fdatasync03 fdatasync03 fgetxattr01 fgetxattr01 fgetxattr02 fgetxattr02 diff --git a/testcases/kernel/syscalls/fdatasync/.gitignore b/testcases/kernel/syscalls/fdatasync/.gitignore index d1d3cba..dc56ad7 100644 --- a/testcases/kernel/syscalls/fdatasync/.gitignore +++ b/testcases/kernel/syscalls/fdatasync/.gitignore @@ -1,2 +1,3 @@ /fdatasync01 /fdatasync02 +/fdatasync03 diff --git a/testcases/kernel/syscalls/fdatasync/fdatasync03.c b/testcases/kernel/syscalls/fdatasync/fdatasync03.c new file mode 100644 index 0000000..3a4f694 --- /dev/null +++ b/testcases/kernel/syscalls/fdatasync/fdatasync03.c @@ -0,0 +1,61 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Sumit Garg + */ + +/* + * fdatasync03 + * + * It basically tests fdatasync() to sync test file data 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_fdatasync(void) +{ + int fd; + + fd = tst_sync_device_write(TST_FILE, TST_FILE_SIZE_MB); + + TEST(fdatasync(fd)); + if (TST_RET != 0) + tst_brk(TFAIL | TTERRNO, "fdatasync(fd) failed"); + + if (tst_sync_device_check(TST_FILE_SIZE_MB)) + tst_res(TPASS, "Test file data synced to device"); + else + tst_res(TFAIL, "Failed to sync test file data 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_fdatasync, +}; From patchwork Tue Feb 19 09:28:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 158703 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3447526jaa; Tue, 19 Feb 2019 01:29:47 -0800 (PST) X-Google-Smtp-Source: AHgI3IYBwvnFP8SHHrxrotguufiz01KmBiGf8q7w7TUYNjQkFWI0MITkPH/FsxFcNx3HX5hkJmD3 X-Received: by 2002:a17:906:4595:: with SMTP id t21mr11570098ejq.120.1550568587689; Tue, 19 Feb 2019 01:29:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550568587; cv=none; d=google.com; s=arc-20160816; b=ETm7Dm7HwDBscUdCuLH/ovA0N9weUiEdrkVAl7mzqvl1BR0KdOjiTRmOjkVXGlGuBc 0Ow5G0FQHJKIjPlVbrSa9XVuFZaZS9Pp0GTPYNpmPTFesx77knwY8hFXUswjmZ052Fyt qa5aT/ghZfgZpnlbUo9tQexHtgZlwplI70f3Yau1nw59as+qFrFygtxg+SCGJoLb00gk 6fF3jnQilTMy1+RARX3J/1w5h/5lwZK1GV3jabuTY8b/t3VH77Nq9MMxP9LFw0+1brMJ xf6PNJZqxHAxFjtR2onxWUnlSwImVTLHNcCduEKsTw7uoOoT9FPI2PMHWZqqLfSlL44+ advA== 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=/Q37++CKeyo5LOah7tsSLtcewFkWKnxGcPHziUgwmGQ=; b=oFA5nANXgRPg/QKeYoF4teL5nDBC57dDO/G9fZsxaWesu6uftAf/O7HnG7Jp6lqKr3 WGpQ1ByGthYv6MvozS4Hia6jSla9TpWTP4c/cGS0ETKYNBDF/nkzrUTn8M+1n/Tp+3Kd CWvYu7dloVjGLxFz2NS2NHUKBzuKkovb98RDjC86xzldO+XPZHn2/ORCHSUgF/7dzyJS oNkdm7WFT4AUDNOhKZSI9nYhkvppTGqD+fUzJxFYzVQuprDKDRYRF2/9r7qiTmBff15s O45Ur8PfzRTsdbBw2pYgMLEqB7xNWpUdIgo2UvrEQx+nG287+jCRjre3aRIwUPXI9vnl dO2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=J+Dvw8Ac; 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 t29si1493794edt.450.2019.02.19.01.29.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Feb 2019 01:29:47 -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=J+Dvw8Ac; 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 3AA8D3EA37C for ; Tue, 19 Feb 2019 10:29:41 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) by picard.linux.it (Postfix) with ESMTP id E1E093EA469 for ; Tue, 19 Feb 2019 10:29:26 +0100 (CET) Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 4C15A1000D09 for ; Tue, 19 Feb 2019 10:29:24 +0100 (CET) Received: by mail-pg1-x542.google.com with SMTP id u9so6333613pgo.7 for ; Tue, 19 Feb 2019 01:29:25 -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=xrJPZVZPVkPf9eAXCvb6K4lwL+3WNWEF1qx7slYUZX0=; b=J+Dvw8Ac0fgyZ9zuQ8w0vwf5bIrtEbIcOY/ssgwCiHjkZu3mdUfbuJTIwdxWWiCqRj nAxt3DKvlUyYhogF8oyIUai1vB9swvfYI2SGildAIY7hrzPkJaKTbhel+Wcx4H4/5R4+ lppWc+U3CisWGBF9M8D9/vyKioq+YY8zUSa53104+Ce8zi4DFRZQJ+O4kOE84W/AcDSl X2kWbGvfaGX44R0a/2rZQ/+5wtoJMXEc6p5y+/vVTFhA+9vGaRBNYNkED1++Bk6Vuz0x 8GhG+5/ECnAVZuJ/phtpmvw3+D/axxNdjSuw/90CC7lDN5zWvC8GQTNl+0frz8VrJAvT dt6A== 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=xrJPZVZPVkPf9eAXCvb6K4lwL+3WNWEF1qx7slYUZX0=; b=HpDCV9M1YIT2m6USCGKAQOIL7h6NVBhrbHjDHVxDPJaMSAO6cWpHcHzyAlMb9n0pzm qfh+a+Q1X3h21TAZV/cPPIEhgXKrtmtAqm0VpGxXOajDf+wU1jQJzdf8uRkwGddovM9N ODXY2rwvfTbnNmcblyBJ7wLKZVtquL5VHjmbdmVw6+sBGuut6kkp6YBvrF4ceV4PAFZ8 v+LBLNpJmH13KqRRu57yjzFO/rU3RKcAKaRCM0sjJ36GriJplZ6HQGFxPPPdZCYG5GRO jyAQuuedmmygLd2U0KhJfQMhmePVnHxci4PnD+5Fxl9al9wb00DFZzi7a3KnB0gz/uay 0f6g== X-Gm-Message-State: AHQUAubPsFtolCDl10SDYCkM3b/fzthfSd0YlVcDKYVmjlMwuRcAeMsH uw5yA6boog6JVYnooXWSLYaJhrwkkqK8Hw== X-Received: by 2002:a63:c40a:: with SMTP id h10mr23251296pgd.131.1550568563603; Tue, 19 Feb 2019 01:29:23 -0800 (PST) Received: from localhost.localdomain ([117.252.69.94]) by smtp.gmail.com with ESMTPSA id n19sm34442229pfg.67.2019.02.19.01.29.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Feb 2019 01:29:23 -0800 (PST) From: Sumit Garg To: ltp@lists.linux.it Date: Tue, 19 Feb 2019 14:58:19 +0530 Message-Id: <1550568500-10871-7-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-4.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-4.smtp.seeweb.it Cc: daniel.thompson@linaro.org Subject: [LTP] [PATCH v3 6/7] syscalls/sync_file_range: Use C library wrapper if present 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 config check for C library wrapper for sync_file_range() syscall. Also, check for sync_file_range() presence via dummy call rather than kernel version check. And move fallback api to: include/lapi/sync_file_range.h Signed-off-by: Sumit Garg --- configure.ac | 1 + include/lapi/sync_file_range.h | 64 ++++++++++++++++++++++ m4/ltp-sync_file_range.m4 | 10 ++++ .../sync_file_range/check_sync_file_range.h | 23 ++++++++ .../syscalls/sync_file_range/sync_file_range01.c | 62 ++------------------- 5 files changed, 103 insertions(+), 57 deletions(-) create mode 100644 include/lapi/sync_file_range.h create mode 100644 m4/ltp-sync_file_range.m4 create mode 100644 testcases/kernel/syscalls/sync_file_range/check_sync_file_range.h diff --git a/configure.ac b/configure.ac index 9122b6d..d15bff3 100644 --- a/configure.ac +++ b/configure.ac @@ -232,6 +232,7 @@ LTP_CHECK_RLIMIT64 LTP_DETECT_HOST_CPU LTP_CHECK_PERF_EVENT LTP_CHECK_SYNCFS +LTP_CHECK_SYNC_FILE_RANGE if test "x$with_numa" = xyes; then LTP_CHECK_SYSCALL_NUMA diff --git a/include/lapi/sync_file_range.h b/include/lapi/sync_file_range.h new file mode 100644 index 0000000..7b0ef69 --- /dev/null +++ b/include/lapi/sync_file_range.h @@ -0,0 +1,64 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) International Business Machines Corp., 2008 + */ + +#ifndef SYNC_FILE_RANGE_H +#define SYNC_FILE_RANGE_H + +#include +#include "config.h" +#include "lapi/syscalls.h" + +#if !defined(HAVE_SYNC_FILE_RANGE) + +#ifdef TST_TEST_H__ +# define TST_SYSCALL tst_syscall +#else +# define TST_SYSCALL ltp_syscall +#endif + +/***************************************************************************** + * Wraper function to call sync_file_range system call + ******************************************************************************/ +static inline long sync_file_range(int fd, off64_t offset, off64_t nbytes, + unsigned int flags) +{ +/* arm and powerpc */ +#if (defined(__arm__) || defined(__powerpc__) || defined(__powerpc64__)) +#if (__WORDSIZE == 32) +#if __BYTE_ORDER == __BIG_ENDIAN + return TST_SYSCALL(__NR_sync_file_range2, fd, flags, + (int)(offset >> 32), (int)offset, (int)(nbytes >> 32), + (int)nbytes); +#elif __BYTE_ORDER == __LITTLE_ENDIAN + return TST_SYSCALL(__NR_sync_file_range2, fd, flags, (int)offset, + (int)(offset >> 32), nbytes, (int)(nbytes >> 32)); +#endif +#else + return TST_SYSCALL(__NR_sync_file_range2, fd, flags, offset, nbytes); +#endif + +/* s390 */ +#elif (defined(__s390__) || defined(__s390x__)) && __WORDSIZE == 32 + return TST_SYSCALL(__NR_sync_file_range, fd, (int)(offset >> 32), + (int)offset, (int)(nbytes >> 32), (int)nbytes, flags); + +/* mips */ +#elif defined(__mips__) && __WORDSIZE == 32 +#if __BYTE_ORDER == __BIG_ENDIAN + return TST_SYSCALL(__NR_sync_file_range, fd, 0, (int)(offset >> 32), + (int)offset, (int)(nbytes >> 32), (int)nbytes, flags); +#elif __BYTE_ORDER == __LITTLE_ENDIAN + return TST_SYSCALL(__NR_sync_file_range, fd, 0, (int)offset, + (int)(offset >> 32), (int)nbytes, (int)(nbytes >> 32), flags); +#endif + +/* other */ +#else + return TST_SYSCALL(__NR_sync_file_range, fd, offset, nbytes, flags); +#endif +} +#endif + +#endif /* SYNC_FILE_RANGE_H */ diff --git a/m4/ltp-sync_file_range.m4 b/m4/ltp-sync_file_range.m4 new file mode 100644 index 0000000..b47a091 --- /dev/null +++ b/m4/ltp-sync_file_range.m4 @@ -0,0 +1,10 @@ +dnl SPDX-License-Identifier: GPL-2.0-or-later +dnl Copyright (c) 2019 Linaro Limited. All rights reserved. + +dnl +dnl LTP_CHECK_SYNC_FILE_RANGE +dnl ---------------------------- +dnl +AC_DEFUN([LTP_CHECK_SYNC_FILE_RANGE],[ +AC_CHECK_FUNCS(sync_file_range,,) +]) diff --git a/testcases/kernel/syscalls/sync_file_range/check_sync_file_range.h b/testcases/kernel/syscalls/sync_file_range/check_sync_file_range.h new file mode 100644 index 0000000..3d932f6 --- /dev/null +++ b/testcases/kernel/syscalls/sync_file_range/check_sync_file_range.h @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Sumit Garg + */ + +#ifndef CHECK_SYNC_FILE_RANGE_H +#define CHECK_SYNC_FILE_RANGE_H + +#include + +bool check_sync_file_range(void) +{ + int ret; + + ret = sync_file_range(-1, 0, 0, 0); + if (ret == -1 && errno == EINVAL) + return false; + + return true; +} + +#endif /* CHECK_SYNC_FILE_RANGE_H */ diff --git a/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c b/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c index cebb919..3a97183 100644 --- a/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c +++ b/testcases/kernel/syscalls/sync_file_range/sync_file_range01.c @@ -92,7 +92,8 @@ #include #include "test.h" -#include "lapi/syscalls.h" +#include "lapi/sync_file_range.h" +#include "check_sync_file_range.h" #ifndef SYNC_FILE_RANGE_WAIT_BEFORE #define SYNC_FILE_RANGE_WAIT_BEFORE 1 @@ -190,48 +191,6 @@ void setup(void) sfd = open(spl_file, O_RDWR | O_CREAT, 0700); } -/***************************************************************************** - * Wraper function to call sync_file_range system call - ******************************************************************************/ -static inline long syncfilerange(int fd, off64_t offset, off64_t nbytes, - unsigned int flags) -{ -/* arm and powerpc */ -#if (defined(__arm__) || defined(__powerpc__) || defined(__powerpc64__)) -#if (__WORDSIZE == 32) -#if __BYTE_ORDER == __BIG_ENDIAN - return ltp_syscall(__NR_sync_file_range2, fd, flags, - (int)(offset >> 32), (int)offset, (int)(nbytes >> 32), - (int)nbytes); -#elif __BYTE_ORDER == __LITTLE_ENDIAN - return ltp_syscall(__NR_sync_file_range2, fd, flags, (int)offset, - (int)(offset >> 32), nbytes, (int)(nbytes >> 32)); -#endif -#else - return ltp_syscall(__NR_sync_file_range2, fd, flags, offset, nbytes); -#endif - -/* s390 */ -#elif (defined(__s390__) || defined(__s390x__)) && __WORDSIZE == 32 - return ltp_syscall(__NR_sync_file_range, fd, (int)(offset >> 32), - (int)offset, (int)(nbytes >> 32), (int)nbytes, flags); - -/* mips */ -#elif defined(__mips__) && __WORDSIZE == 32 -#if __BYTE_ORDER == __BIG_ENDIAN - return ltp_syscall(__NR_sync_file_range, fd, 0, (int)(offset >> 32), - (int)offset, (int)(nbytes >> 32), (int)nbytes, flags); -#elif __BYTE_ORDER == __LITTLE_ENDIAN - return ltp_syscall(__NR_sync_file_range, fd, 0, (int)offset, - (int)(offset >> 32), (int)nbytes, (int)(nbytes >> 32), flags); -#endif - -/* other */ -#else - return ltp_syscall(__NR_sync_file_range, fd, offset, nbytes, flags); -#endif -} - /******************************************************************************/ /* */ /* Function: main */ @@ -258,24 +217,13 @@ int main(int ac, char **av) tst_parse_opts(ac, av, NULL, NULL); -#if defined(__powerpc__) || defined(__powerpc64__) /* for PPC, kernel version > 2.6.21 needed */ - if (tst_kvercmp(2, 16, 22) < 0) { - tst_brkm(TCONF, NULL, - "System doesn't support execution of the test"); - } -#else - /* For other archs, need kernel version > 2.6.16 */ - - if (tst_kvercmp(2, 6, 17) < 0) { - tst_brkm(TCONF, NULL, - "System doesn't support execution of the test"); - } -#endif + if (!check_sync_file_range()) + tst_brkm(TCONF, NULL, "sync_file_range() not supported"); setup(); for (test_index = 0; test_index < TST_TOTAL; test_index++) { - TEST(syncfilerange + TEST(sync_file_range (*(test_data[test_index].fd), test_data[test_index].offset, test_data[test_index].nbytes, From patchwork Tue Feb 19 09: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: 158704 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3447577jaa; Tue, 19 Feb 2019 01:29:53 -0800 (PST) X-Google-Smtp-Source: AHgI3IYsEWc4EP9YaTVrHIe9ay6Cc096WhwTgF79lws9b+BTcoeILLNcsF1fInzYdoRoxbw/Emjf X-Received: by 2002:a50:d643:: with SMTP id c3mr21785718edj.178.1550568593711; Tue, 19 Feb 2019 01:29:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550568593; cv=none; d=google.com; s=arc-20160816; b=hzySz05qPLNW55GqAfcaLvyY11t2e3n2S8cgjYdk4l9ODdOQvE+VZjyL+h+YFnvDUQ g9YilSfi3ETZJCaDItYSxm+yaQb/OVbIolcWMiO+wfDe65HO72KqC5L5T2Z0TUUrzxZx fw6TZb/UvRrvV6sT9DssA7YLdmxSKropb9IpLCjDz3vz379xgBrhIcK0HI1/5v5n6r2Y 0Y8wJkYCerQBM/hN5+3AlH1Fsfmo7Dn8T1gpSYVYnBJM0IW1gWNtbf/cJrLm96u74DHF ji+g0emmryWrq6AAR35jrAoXoNGOHHN7HDctqE5f+l3R7S3bwQfIY7MeWE6K1t8Nn1hC VM/Q== 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=+gHUWfjU38gvvNBu7qiK4El5XNYwRKy3X6xGNhc/FIA=; b=FAcBH4R5Pjdmijw8Ic6uMvQtc8q1tlUqwPtAUvAxhx6AIUnKpQ/L1ZyPlR24K1Y39r YOhB7nN22FK1PKyeU18FXvsWSyVzfekIMXL+C4+98bIMpxW/BhO+W7dShXZbxtIen5cW n5ELxVE/qGFlV4CcsaKGTuFKV8JruHsdhPOS8fJv0gNNBl/SVxlsOmv4F0js3Tn0quGR 6XJZ+CbSNzpL/K5wjcSkdtZeBPnbUGhtJVKbEhAhsnifFBFExrwTCDhHL+Pa/WWMsREo 0VqTB9soVHOPJpzuAwcdxyDqqV/7vE5g6UDgGxvybcKO7qMt0gcxhMWQITnMwiDopq0E C/oQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=i1yJ9mUH; 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 f26si1799529ejb.21.2019.02.19.01.29.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Feb 2019 01:29:53 -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=i1yJ9mUH; 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 9BF71294AA6 for ; Tue, 19 Feb 2019 10:29:45 +0100 (CET) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [217.194.8.2]) by picard.linux.it (Postfix) with ESMTP id 448003EA4B8 for ; Tue, 19 Feb 2019 10:29:30 +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-2.smtp.seeweb.it (Postfix) with ESMTPS id 7C2766019E6 for ; Tue, 19 Feb 2019 10:29:29 +0100 (CET) Received: by mail-pg1-x543.google.com with SMTP id s198so9874912pgs.2 for ; Tue, 19 Feb 2019 01:29:29 -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=bxL/oP1KA0gXoVBkLDKzvMA4t+5/xsQztxcF8Ln+0dc=; b=i1yJ9mUHUd6eFD20raP9PwGb030Smg1fF4MLWQT+v/EG0QOg593vG3Fu86dXNX8dub pxF2s5hv7Z8cy7RVG9DflrPpIfyI6/ZDE/6tT6KSbYfZOz5j9NHzmIy2lxw8jKuyRA9C K8CXECZNSK4gROITDBNEyCR0qgaKX6Va1jm7+zs+95Ewx3T8ylOCTOMf16NAqvshnOyf ZFu4Got/h9Y0WcfSv1TLPjiFbpTJpf8bYPF9ehzvhVhzJRY8+hilNmBiI931fDDRKdL5 dPiZBGkz3Eg8wjhORm1Yuk9UytZ6YqeUU1t4WIhuJV6oDENImTvVo0jtd+VqSQxYmh9i zbRw== 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=bxL/oP1KA0gXoVBkLDKzvMA4t+5/xsQztxcF8Ln+0dc=; b=WaP/5Jllc8WYzKFV06lppCbHaRyfILEXL84Fnwr+HmR4ML3LUtR/b0aZoNCumwtN9M Da6yfzE9ZlWZvv/GZQHPr4Poc9IEWcbcqGuZilKiUQFxIqgTu9CMgV4Xlg5t9bvS3WCf i7eGQ1PicJbaEqIrU/6cRZqZS1sC2WlSeymbzN9UU7l762CZKQEQXE3BuqGA8PdIqIct XD9rwlfMlaUQA7Onh2U2j9R4/TR88chRSF2iKZx7x+Y2V1Gi/EO4nORsI92U3PnevJ4j T14pnJ4NtFFddEX1f+51VowSz+7wra+3tcwD9+fU/dLYJXP8PSksqCbD6oV2HsnRFgmq VC5w== X-Gm-Message-State: AHQUAubjIiJMMYHVB4lcU2DzfwiprIFFSGVxRxHp8rU2CuN9ncO2gNMt pbFqt/6yEJ7d8msxvks8775fIJLh2BcAmQ== X-Received: by 2002:a63:cc41:: with SMTP id q1mr23272780pgi.323.1550568567797; Tue, 19 Feb 2019 01:29:27 -0800 (PST) Received: from localhost.localdomain ([117.252.69.94]) by smtp.gmail.com with ESMTPSA id n19sm34442229pfg.67.2019.02.19.01.29.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 19 Feb 2019 01:29:27 -0800 (PST) From: Sumit Garg To: ltp@lists.linux.it Date: Tue, 19 Feb 2019 14:58:20 +0530 Message-Id: <1550568500-10871-8-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-2.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-2.smtp.seeweb.it Cc: daniel.thompson@linaro.org Subject: [LTP] [PATCH v3 7/7] syscalls/sync_file_range: 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" sync_file_range02 tests to sync file data range having large dirty file pages to block device. Also, it tests all supported filesystems on a test block device. Signed-off-by: Sumit Garg --- runtest/syscalls | 1 + .../kernel/syscalls/sync_file_range/.gitignore | 1 + .../syscalls/sync_file_range/sync_file_range02.c | 70 ++++++++++++++++++++++ 3 files changed, 72 insertions(+) create mode 100644 testcases/kernel/syscalls/sync_file_range/sync_file_range02.c diff --git a/runtest/syscalls b/runtest/syscalls index aaad651..70d3561 100644 --- a/runtest/syscalls +++ b/runtest/syscalls @@ -1353,6 +1353,7 @@ syncfs01 syncfs01 #testcases for sync_file_range sync_file_range01 sync_file_range01 +sync_file_range02 sync_file_range02 syscall01 syscall01 diff --git a/testcases/kernel/syscalls/sync_file_range/.gitignore b/testcases/kernel/syscalls/sync_file_range/.gitignore index 3f6bd75..e6485f7 100644 --- a/testcases/kernel/syscalls/sync_file_range/.gitignore +++ b/testcases/kernel/syscalls/sync_file_range/.gitignore @@ -1 +1,2 @@ /sync_file_range01 +/sync_file_range02 diff --git a/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c b/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c new file mode 100644 index 0000000..fb7a5f7 --- /dev/null +++ b/testcases/kernel/syscalls/sync_file_range/sync_file_range02.c @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2019 Linaro Limited. All rights reserved. + * Author: Sumit Garg + */ + +/* + * sync_file_range02 + * + * It basically tests sync_file_range() to sync test file range 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" +#include "lapi/sync_file_range.h" +#include "check_sync_file_range.h" + +#define MNTPOINT "mnt_point" +#define TST_FILE MNTPOINT"/test" +#define TST_FILE_SIZE_MB 32 +#define SIZE_MB (1024*1024) + +static void verify_sync_file_range(void) +{ + int fd; + + fd = tst_sync_device_write(TST_FILE, TST_FILE_SIZE_MB); + + TEST(sync_file_range(fd, 0, TST_FILE_SIZE_MB * SIZE_MB, + SYNC_FILE_RANGE_WAIT_BEFORE | + SYNC_FILE_RANGE_WRITE | + SYNC_FILE_RANGE_WAIT_AFTER)); + if (TST_RET != 0) + tst_brk(TFAIL | TTERRNO, "sync_file_range() failed"); + + if (tst_sync_device_check(TST_FILE_SIZE_MB)) + tst_res(TPASS, "Test file range synced to device"); + else + tst_res(TFAIL, "Failed to sync test file range to device"); +} + +static void setup(void) +{ + tst_sync_device_init(tst_device->dev); +} + +static void cleanup(void) +{ + if (!check_sync_file_range()) + tst_brk(TCONF, "sync_file_range() not supported"); + + 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_file_range, +};