[LTP] RFC:[PATCH v1] Added testcase to test mmap with MAP_SHARED_VALIDATE flag

Cyril Hrubis chrubis@suse.cz
Wed Feb 15 16:21:30 CET 2023


Hi!
> +static void test_mmap(void)
> +{
> + mapped_address = mmap(NULL, TEST_FILE_SIZE, PROT_READ | PROT_WRITE,
> +      (1 << 7) | (1 << 9) | MAP_SHARED_VALIDATE, fd_file, 0);
> + if (mapped_address != MAP_FAILED)
> + tst_res(TFAIL | TERRNO, "mmap() is successful, but it should have
> failed.");
> + else if (errno == EOPNOTSUPP)
> + tst_res(TPASS, "mmap() failed with errno set to EOPNOTSUPP.");
> + else
> + tst_res(TFAIL | TERRNO, "mmap() failed with unexpected error.");
> +}
> +
> +static struct tst_test test = {
> + .min_kver = "4.15",
> + .setup = setup,
> + .cleanup = cleanup,
> + .test_all = test_mmap,
> + .needs_tmpdir = 1,
> +};

First of all all the whitespaces are messed up and some of the lines are
wrapped, quite likely this was done by your email client. Please make
sure to send patches so that they do not get mangled like this.

See: https://www.kernel.org/doc/html/v4.17/process/email-clients.html

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list