public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH v3 7/7] syscalls/sync_file_range: add sync device test-case
Date: Tue, 19 Feb 2019 15:20:58 +0100	[thread overview]
Message-ID: <20190219142058.GF32031@rei.lan> (raw)
In-Reply-To: <1550568500-10871-8-git-send-email-sumit.garg@linaro.org>

Hi!
> 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 <sumit.garg@linaro.org>
> ---
>  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 <sumit.garg@linaro.org>
> + */
> +
> +/*
> + * 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 <errno.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <sys/types.h>
> +#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");

This check is supposed to be in the test setup, right?

> +	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,
> +};
> -- 
> 2.7.4
> 

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2019-02-19 14:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-19  9:28 [LTP] [PATCH v3 0/7] syscalls: add sync device test-cases Sumit Garg
2019-02-19  9:28 ` [LTP] [PATCH v3 1/7] lib: Add library functions for sync related syscalls Sumit Garg
2019-02-19 14:06   ` Cyril Hrubis
2019-02-20  7:57     ` Sumit Garg
2019-02-20 12:03       ` Cyril Hrubis
2019-02-20 12:08         ` Sumit Garg
2019-02-19  9:28 ` [LTP] [PATCH v3 2/7] syscalls: add syncfs() sync device test-case Sumit Garg
2019-02-19  9:28 ` [LTP] [PATCH v3 3/7] syscalls/sync: add " Sumit Garg
2019-02-19 14:09   ` Cyril Hrubis
2019-02-20  8:20     ` Sumit Garg
2019-02-19  9:28 ` [LTP] [PATCH v3 4/7] syscalls/fsync: " Sumit Garg
2019-02-19  9:28 ` [LTP] [PATCH v3 5/7] syscalls/fdatasync: " Sumit Garg
2019-02-19  9:28 ` [LTP] [PATCH v3 6/7] syscalls/sync_file_range: Use C library wrapper if present Sumit Garg
2019-02-19 14:19   ` Cyril Hrubis
2019-02-20  8:27     ` Sumit Garg
2019-02-19  9:28 ` [LTP] [PATCH v3 7/7] syscalls/sync_file_range: add sync device test-case Sumit Garg
2019-02-19 14:20   ` Cyril Hrubis [this message]
2019-02-20  8:34     ` Sumit Garg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190219142058.GF32031@rei.lan \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox