From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 1/2] syscalls/tkill: Convert tkill01 to the new API
Date: Mon, 26 Apr 2021 12:31:58 +0200 [thread overview]
Message-ID: <YIaWnt5ksxVyBvxk@pevik> (raw)
In-Reply-To: <20210422065732.61222-2-xieziyao@huawei.com>
Hi,
> 1. Convert tkill01 to the new API;
> 2. Capture signals to verify success, while the previous code
> didn't make it work.
Generally LGTM, with comments below.
Reviewed-by: Petr Vorel <pvorel@suse.cz>
> #include <stdio.h>
> #include <stdlib.h>
> @@ -48,59 +24,37 @@
> #include <linux/unistd.h>
> #include <sys/types.h>
I removed these as not needed. The only one which is still relevant is <signal.h>
(I kept it although it's not needed to be included, as it's included in
tst_safe_macros.h which are included in tst_test.h).
> -#include "test.h"
> #include "lapi/syscalls.h"
> +#include "tst_test.h"
> +int sig_flag = 0;
It should be
static int sig_flag;
...
> +static void run(void)
...
> + SAFE_SIGNAL(SIGUSR1, sighandler);
> + TEST(tid = tst_syscall(__NR_gettid));
> + if (TST_RET == -1)
> + tst_res(TFAIL | TTERRNO, "tst_syscall(__NR_gettid) failed");
gettid() manpage says "ERRORS: This call is alway successful". I suppose this is
true also for raw syscall. And it's certainly true for tst_syscall(__NR_gettid).
BTW if it really needed to be checked, tst_brk() or tst_res() with return would
need to be used.
> +
> + TEST(tst_syscall(__NR_tkill, tid, SIGUSR1));
> + if (TST_RET == 0) {
> + while (!sig_flag);
Not sure why you required this.
> + tst_res(TPASS, "tst_syscall(__NR_tkill, %d, SIGUSR1)", tid);
> + } else {
> + tst_res(TFAIL | TTERRNO,
> + "tst_syscall(__NR_tkill, %d, SIGUSR1)", tid);
> }
> - cleanup();
> - tst_exit();
> }
> +
> +static struct tst_test test = {
> + .needs_tmpdir = 1,
> + .test_all = run,
> +};
In the end going to merge code below.
Kind regards,
Petr
// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) Linux Test Project, 2009-2021
* Copyright (c) Crackerjack Project., 2007
* Ported from Crackerjack to LTP by Manas Kumar Nayak maknayak@in.ibm.com>
*/
/*\
* [Description]
*
* Basic tests for the tkill syscall.
*
* [Algorithm]
*
* Calls tkill and capture signals to verify success.
*/
#include <signal.h>
#include "lapi/syscalls.h"
#include "tst_test.h"
static int sig_flag;
static void sighandler(int sig)
{
if (sig == SIGUSR1)
sig_flag = 1;
}
static void run(void)
{
int tid;
SAFE_SIGNAL(SIGUSR1, sighandler);
tid = tst_syscall(__NR_gettid);
TST_EXP_PASS(tst_syscall(__NR_tkill, tid, SIGUSR1));
}
static struct tst_test test = {
.needs_tmpdir = 1,
.test_all = run,
};
next prev parent reply other threads:[~2021-04-26 10:31 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-22 6:57 [LTP] [PATCH 0/2] syscalls/tkill: Convert tkill{01, 02} to the new API Xie Ziyao
2021-04-22 6:57 ` [LTP] [PATCH 1/2] syscalls/tkill: Convert tkill01 " Xie Ziyao
2021-04-26 10:31 ` Petr Vorel [this message]
2021-04-26 11:24 ` xieziyao
2021-04-26 12:55 ` Petr Vorel
2021-04-27 1:49 ` xieziyao
2021-04-28 12:11 ` Cyril Hrubis
2021-04-28 18:04 ` Petr Vorel
2021-04-29 2:02 ` xieziyao
2021-04-22 6:57 ` [LTP] [PATCH 2/2] syscalls/tkill: Convert tkill02 " Xie Ziyao
2021-04-26 11:12 ` Petr Vorel
2021-04-26 11:35 ` xieziyao
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=YIaWnt5ksxVyBvxk@pevik \
--to=pvorel@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