* [LTP] [PATCH] gettid:Convert gettid01 to new API
@ 2021-08-31 2:46 Wang Kunfeng
2021-08-31 4:15 ` Xie Ziyao
2021-09-01 12:57 ` Cyril Hrubis
0 siblings, 2 replies; 4+ messages in thread
From: Wang Kunfeng @ 2021-08-31 2:46 UTC (permalink / raw)
To: ltp
Convert gettid01 to new API
Signed-off-by: Wang Kunfeng <threefifteen.wangkunfeng@huawei.com>
---
testcases/kernel/syscalls/gettid/gettid01.c | 95 ++++-----------------
1 file changed, 15 insertions(+), 80 deletions(-)
diff --git a/testcases/kernel/syscalls/gettid/gettid01.c b/testcases/kernel/syscalls/gettid/gettid01.c
index 7e5b6b175..2e45be588 100644
--- a/testcases/kernel/syscalls/gettid/gettid01.c
+++ b/testcases/kernel/syscalls/gettid/gettid01.c
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
/*
* Crackerjack Project
*
@@ -6,91 +7,25 @@
* Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
* Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>
*
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * $Id: gettid01.c,v 1.5 2009/10/26 14:55:47 subrata_modak Exp $
- *
+ * Porting from Crackerjack to LTP is done
+ * by Masatake YAMATO <yamato@redhat.com>
*/
-/* Porting from Crackerjack to LTP is done
- by Masatake YAMATO <yamato@redhat.com> */
+/*\
+ * [Description]
+ *
+ * Basic test for gettid() function.
+ */
#include <sys/types.h>
-#include <linux/unistd.h>
-#include <errno.h>
-
-#include "test.h"
-
-void setup();
-void cleanup();
-
-char *TCID = "gettid01";
-
-int TST_TOTAL = 1;
-
-pid_t my_gettid(void)
-{
- return (pid_t) syscall(__NR_gettid);
-}
-
-int main(int ac, char **av)
-{
- int lc;
-
- tst_parse_opts(ac, av, NULL, NULL);
+#include "tst_test.h"
+#include "lapi/syscalls.h"
- setup();
-
- /*
- * The following loop checks looping state if -c option given
- */
- for (lc = 0; TEST_LOOPING(lc); lc++) {
-
- tst_count = 0;
-
- TEST(my_gettid());
-
- if (TEST_RETURN == -1) {
- tst_resm(TFAIL, "gettid() Failed, errno=%d: %s",
- TEST_ERRNO, strerror(TEST_ERRNO));
- } else {
- tst_resm(TPASS, "gettid() returned %ld",
- TEST_RETURN);
- }
- }
-
- cleanup();
- tst_exit();
-}
-
-/*
- * setup() - performs all ONE TIME setup for this test.
- */
-void setup(void)
+static void verify_gettid(void)
{
-
- tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
- TEST_PAUSE;
-
+ TST_EXP_POSITIVE(tst_syscall(__NR_gettid), "gettid()");
}
-/*
- * cleanup() - performs all ONE TIME cleanup for this test at
- * completion or premature exit.
- */
-void cleanup(void)
-{
-}
+static struct tst_test test = {
+ .test_all = verify_gettid,
+};
--
2.17.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [LTP] [PATCH] gettid:Convert gettid01 to new API
2021-08-31 2:46 [LTP] [PATCH] gettid:Convert gettid01 to new API Wang Kunfeng
@ 2021-08-31 4:15 ` Xie Ziyao
2021-08-31 4:19 ` Xie Ziyao
2021-09-01 12:57 ` Cyril Hrubis
1 sibling, 1 reply; 4+ messages in thread
From: Xie Ziyao @ 2021-08-31 4:15 UTC (permalink / raw)
To: ltp
Hi, Kunfeng,
> Convert gettid01 to new API
>
> Signed-off-by: Wang Kunfeng <threefifteen.wangkunfeng@huawei.com>
> ---
> testcases/kernel/syscalls/gettid/gettid01.c | 95 ++++-----------------
> 1 file changed, 15 insertions(+), 80 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/gettid/gettid01.c b/testcases/kernel/syscalls/gettid/gettid01.c
> index 7e5b6b175..2e45be588 100644
> --- a/testcases/kernel/syscalls/gettid/gettid01.c
> +++ b/testcases/kernel/syscalls/gettid/gettid01.c
> @@ -1,3 +1,4 @@
> +// SPDX-License-Identifier: GPL-2.0
The license here should be GPL-2.0-later.
> /*
> * Crackerjack Project
> *
> @@ -6,91 +7,25 @@
> * Yumiko Sugita <yumiko.sugita.yf@hitachi.com>,
> * Satoshi Fujiwara <sa-fuji@sdl.hitachi.co.jp>
> *
> - * This program is free software; you can redistribute it and/or
> - * modify it under the terms of the GNU General Public License
> - * as published by the Free Software Foundation; either version 2
> - * of the License, or (at your option) any later version.
> - *
> - * This program is distributed in the hope that it will be useful,
> - * but WITHOUT ANY WARRANTY; without even the implied warranty of
> - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> - * GNU General Public License for more details.
> - *
> - * You should have received a copy of the GNU General Public License
> - * along with this program; if not, write to the Free Software
> - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
> - *
> - * $Id: gettid01.c,v 1.5 2009/10/26 14:55:47 subrata_modak Exp $
> - *
> + * Porting from Crackerjack to LTP is done
> + * by Masatake YAMATO <yamato@redhat.com>
> */
>
> -/* Porting from Crackerjack to LTP is done
> - by Masatake YAMATO <yamato@redhat.com> */
> +/*\
> + * [Description]
> + *
> + * Basic test for gettid() function.
> + */
>
> #include <sys/types.h>
> -#include <linux/unistd.h>
> -#include <errno.h>
> -
> -#include "test.h"
> -
> -void setup();
> -void cleanup();
> -
> -char *TCID = "gettid01";
> -
> -int TST_TOTAL = 1;
> -
> -pid_t my_gettid(void)
> -{
> - return (pid_t) syscall(__NR_gettid);
> -}
> -
> -int main(int ac, char **av)
> -{
> - int lc;
> -
> - tst_parse_opts(ac, av, NULL, NULL);
> +#include "tst_test.h"
> +#include "lapi/syscalls.h"
>
> - setup();
> -
> - /*
> - * The following loop checks looping state if -c option given
> - */
> - for (lc = 0; TEST_LOOPING(lc); lc++) {
> -
> - tst_count = 0;
> -
> - TEST(my_gettid());
> -
> - if (TEST_RETURN == -1) {
> - tst_resm(TFAIL, "gettid() Failed, errno=%d: %s",
> - TEST_ERRNO, strerror(TEST_ERRNO));
> - } else {
> - tst_resm(TPASS, "gettid() returned %ld",
> - TEST_RETURN);
> - }
> - }
> -
> - cleanup();
> - tst_exit();
> -}
> -
> -/*
> - * setup() - performs all ONE TIME setup for this test.
> - */
> -void setup(void)
> +static void verify_gettid(void)
> {
> -
> - tst_sig(NOFORK, DEF_HANDLER, cleanup);
> -
> - TEST_PAUSE;
> -
> + TST_EXP_POSITIVE(tst_syscall(__NR_gettid), "gettid()");
> }
>
> -/*
> - * cleanup() - performs all ONE TIME cleanup for this test at
> - * completion or premature exit.
> - */
> -void cleanup(void)
> -{
> -}
> +static struct tst_test test = {
> + .test_all = verify_gettid,
> +};
> --
> 2.17.1
>
>
--
Best Regards,
Xie Ziyao
E-mail: ziyaoxie@outlook.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH] gettid:Convert gettid01 to new API
2021-08-31 4:15 ` Xie Ziyao
@ 2021-08-31 4:19 ` Xie Ziyao
0 siblings, 0 replies; 4+ messages in thread
From: Xie Ziyao @ 2021-08-31 4:19 UTC (permalink / raw)
To: ltp
>> --- a/testcases/kernel/syscalls/gettid/gettid01.c
>> +++ b/testcases/kernel/syscalls/gettid/gettid01.c
>> @@ -1,3 +1,4 @@
>> +// SPDX-License-Identifier: GPL-2.0
> The license here should be GPL-2.0-later.
Sorry, GPL-2.0-or-later.
>> ? /*
>> ?? * Crackerjack Project
>> ?? *
--
Best Regards,
Xie Ziyao
E-mail: ziyaoxie@outlook.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* [LTP] [PATCH] gettid:Convert gettid01 to new API
2021-08-31 2:46 [LTP] [PATCH] gettid:Convert gettid01 to new API Wang Kunfeng
2021-08-31 4:15 ` Xie Ziyao
@ 2021-09-01 12:57 ` Cyril Hrubis
1 sibling, 0 replies; 4+ messages in thread
From: Cyril Hrubis @ 2021-09-01 12:57 UTC (permalink / raw)
To: ltp
Hi!
Looks good, apart from the license.
Also we should try to validate the tid. I guess that we can do that by
sending a signal and making sure that it has arrived. That could be done
by something as tgkill(getpid(), TST_RET, SIGUSR1); after setting up an
handler for SIGUSR1 that sets a flag if called and then checking if the
flag has been set after we have send the signal.
Also I guess that in the simple case that the process runs a single
thread the pid is the same as tid. We would have to clone a new process
with CLONE_THREAD and run the test from the cloned thread in order to
have the tid different from the pid in order to test the getpid() !=
gettid() case.
--
Cyril Hrubis
chrubis@suse.cz
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-09-01 12:57 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-31 2:46 [LTP] [PATCH] gettid:Convert gettid01 to new API Wang Kunfeng
2021-08-31 4:15 ` Xie Ziyao
2021-08-31 4:19 ` Xie Ziyao
2021-09-01 12:57 ` Cyril Hrubis
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.