* [LTP] [PATCH v2] Rewrite getcontext01.c test using new LTP API
@ 2022-03-03 8:33 Andrea Cervesato
2022-03-09 15:19 ` Cyril Hrubis
0 siblings, 1 reply; 2+ messages in thread
From: Andrea Cervesato @ 2022-03-03 8:33 UTC (permalink / raw)
To: ltp
Removed old LTP API from getcontext01.c test and check if getcontext is
present in the current system. The check is useful in those systems
where musl is used by default.
Signed-off-by: Andrea Cervesato <andrea.cervesato@suse.de>
---
configure.ac | 1 +
.../kernel/syscalls/getcontext/getcontext01.c | 93 ++++---------------
2 files changed, 20 insertions(+), 74 deletions(-)
diff --git a/configure.ac b/configure.ac
index 49499704e..9b6d01f54 100644
--- a/configure.ac
+++ b/configure.ac
@@ -97,6 +97,7 @@ AC_CHECK_FUNCS_ONCE([ \
fspick \
fstatat \
getauxval \
+ getcontext \
getdents \
getdents64 \
io_pgetevents \
diff --git a/testcases/kernel/syscalls/getcontext/getcontext01.c b/testcases/kernel/syscalls/getcontext/getcontext01.c
index 48e78907f..7176a9035 100644
--- a/testcases/kernel/syscalls/getcontext/getcontext01.c
+++ b/testcases/kernel/syscalls/getcontext/getcontext01.c
@@ -1,89 +1,34 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
/*
* Copyright (c) Wipro Technologies Ltd, 2005. All Rights Reserved.
- * Author: Prashant P Yendigeri <prashant.yendigeri@wipro.com>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of version 2 of the GNU General Public License as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it would be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ * Author: Prashant P Yendigeri <prashant.yendigeri@wipro.com>
+ * Copyright (C) 2022 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com>
*/
-#include <features.h>
-
-#include <stdio.h>
-#include <unistd.h>
-#include <errno.h>
-#include <ucontext.h>
-
-#include "test.h"
-
-char *TCID = "getcontext01";
+/*\
+ * [Description]
+ *
+ * Test getting user context functionality.
+ */
-#if !defined(__UCLIBC__)
+#include "config.h"
+#include "tst_test.h"
-static void setup(void);
-static void cleanup(void);
+#ifdef HAVE_GETCONTEXT
-int TST_TOTAL = 1;
+#include <ucontext.h>
-static void test_getcontext(void)
+static void run(void)
{
ucontext_t ptr;
- TEST(getcontext(&ptr));
-
- if (TEST_RETURN == -1) {
- if (errno == ENOSYS)
- tst_resm(TCONF, "getcontext not implemented in libc");
- else
- tst_resm(TFAIL | TTERRNO, "getcontext failed");
- } else if (TEST_RETURN == 0) {
- tst_resm(TPASS, "getcontext passed");
- } else {
- tst_resm(TFAIL, "Unexpected return value %li", TEST_RETURN);
- }
-}
-
-int main(int ac, char **av)
-{
- int lc;
-
- tst_parse_opts(ac, av, NULL, NULL);
-
- setup();
-
- for (lc = 0; TEST_LOOPING(lc); lc++) {
-
- tst_count = 0;
-
- test_getcontext();
- }
-
- cleanup();
- tst_exit();
-}
-
-static void setup(void)
-{
- tst_sig(NOFORK, DEF_HANDLER, cleanup);
-
- TEST_PAUSE;
+ TST_EXP_PASS(getcontext(&ptr));
}
-static void cleanup(void)
-{
-}
+static struct tst_test test = {
+ .test_all = run,
+};
-#else /* systems that dont support obsolete getcontext */
-int main(void)
-{
- tst_brkm(TCONF, NULL, "system doesn't have getcontext support");
-}
+#else
+TST_TEST_TCONF("system doesn't have getcontext support");
#endif
--
2.35.1
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-03-09 15:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-03-03 8:33 [LTP] [PATCH v2] Rewrite getcontext01.c test using new LTP API Andrea Cervesato
2022-03-09 15:19 ` Cyril Hrubis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox