All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 3/3] syscalls/kcmp03.c: Add new testcase
Date: Tue, 19 Jul 2016 16:21:19 +0200	[thread overview]
Message-ID: <20160719142119.GG6409@rei.lan> (raw)
In-Reply-To: <1467803450-11622-3-git-send-email-yangx.jy@cn.fujitsu.com>

Hi!
> +#ifndef CLONE_SYSVSEM
> +#define CLONE_SYSVSEM	0x00040000
> +#endif
> +
> +#ifndef CLONE_IO
> +#define CLONE_IO	0x80000000
> +#endif

These should rather go to the lapi/namespaces_constants.h

> +#define STACK_SIZE	(1024*1024)
> +
> +static int pid1;
> +static int pid2;
> +
> +static struct tcase {
> +	int clone_type;
> +	int kcmp_type;
> +} tcases[] = {
> +	{CLONE_VM, KCMP_VM},
> +	{CLONE_FS, KCMP_FS},
> +	{CLONE_IO, KCMP_IO},
> +	{CLONE_SYSVSEM, KCMP_SYSVSEM}
> +};
> +
> +static int do_child(void *arg)
> +{
> +	pid2 = getpid();
> +
> +	TEST(kcmp(pid1, pid2, *(int *)arg, 0, 0));
> +
> +	if (TEST_RETURN == -1) {
> +		tst_res(TFAIL | TTERRNO, "kcmp() failed unexpectedly");
> +		return 1;
> +	}
> +
> +	if (TEST_RETURN == 0) {
> +		tst_res(TPASS, "kcmp() returned the expected value");
> +	} else {
> +		tst_res(TFAIL, "kcmp() returned the unexpected value");
> +		return 1;

Why do we do the return 1 here if the value is not used at all? Why
don't we just fall down to the return 0; below?

> +	}
> +
> +	return 0;
> +}
> +
> +static void verify_kcmp(unsigned int n)
> +{
> +	int res;
> +	void *stack;
> +
> +	struct tcase *tc = &tcases[n];
> +
> +	pid1 = getpid();
> +
> +	stack = SAFE_MALLOC(STACK_SIZE);

Well, the stack could be allocated once in the test setup and freed in
the test cleanup.

> +	res = ltp_clone(tc->clone_type | SIGCHLD, do_child, &tc->kcmp_type,
> +			STACK_SIZE, stack);
> +	if (res == -1)
> +		tst_res(TFAIL | TERRNO, "clone() Failed");
> +
> +	SAFE_WAIT(NULL);
> +
> +	free(stack);
> +}
> +
> +static struct tst_test test = {
> +	.tid = "kcmp03",
> +	.tcnt = ARRAY_SIZE(tcases),
> +	.test = verify_kcmp,
> +	.min_kver = "3.5.0"
> +};

The rest is fine.

-- 
Cyril Hrubis
chrubis@suse.cz

  reply	other threads:[~2016-07-19 14:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-06 11:10 [LTP] [PATCH 1/3] syscall/kcmp*: Convert to new API Xiao Yang
2016-07-06 11:10 ` [LTP] [PATCH 2/3] lib/cloner.c: Add tst_clone.h for " Xiao Yang
2016-07-19 14:09   ` Cyril Hrubis
2016-07-06 11:10 ` [LTP] [PATCH 3/3] syscalls/kcmp03.c: Add new testcase Xiao Yang
2016-07-19 14:21   ` Cyril Hrubis [this message]
2016-07-19 13:53 ` [LTP] [PATCH 1/3] syscall/kcmp*: Convert to new API Cyril Hrubis
2016-07-20  8:21   ` [LTP] [PATCH v2 1/3] syscalls/kcmp*: " Xiao Yang
2016-07-20  8:21     ` [LTP] [PATCH v2 2/3] lib/cloner.c: Add tst_clone.h for " Xiao Yang
2016-07-25 15:13       ` Cyril Hrubis
2016-07-20  8:21     ` [LTP] [PATCH v2 3/3] syscalls/kcmp03.c: Add new testcase Xiao Yang
2016-07-25 15:27       ` Cyril Hrubis
2016-07-25 13:55     ` [LTP] [PATCH v2 1/3] syscalls/kcmp*: Convert to new API Cyril Hrubis
  -- strict thread matches above, loose matches on Subject: below --
2016-07-06 10:48 [LTP] [PATCH 1/3] syscall/kcmp*: " Xiao Yang
2016-07-06 10:48 ` [LTP] [PATCH 3/3] syscalls/kcmp03.c: Add new testcase Xiao Yang

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=20160719142119.GG6409@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.