getcontext function is implemented from libc-2.17 in ARM.
If libc version is less than 2.17, this testcase goes to TCONF.
lib/tst_libcvercmp.c: a new file for libc version comparison
Comparison code for libc version is added as a library.
Signed-off-by: Honggyu Kim <[email protected]>
---
include/test.h | 4 ++
lib/tst_libcvercmp.c | 65
++++++++++++++++++++
.../kernel/syscalls/getcontext/getcontext01.c | 16 +++++
3 files changed, 85 insertions(+)
create mode 100644 lib/tst_libcvercmp.c
diff --git a/include/test.h b/include/test.h
index d9eba31..47765c2 100644
--- a/include/test.h
+++ b/include/test.h
@@ -180,6 +180,10 @@ struct tst_kern_exv {
int tst_kvercmp2(int r1, int r2, int r3, struct tst_kern_exv *vers);
+/* lib/tst_libcvercmp.c */
+const char* tst_getlibcver(void);
+int tst_libcvercmp(const char *tst_exv);
+
/* lib/tst_is_cwd.c */
int tst_is_cwd_nfs(void);
int tst_is_cwd_v9fs(void);
diff --git a/lib/tst_libcvercmp.c b/lib/tst_libcvercmp.c
new file mode 100644
index 0000000..2a09ab8
--- /dev/null
+++ b/lib/tst_libcvercmp.c
@@ -0,0 +1,65 @@
+/*
+ *
+ * Copyright (c) LG Electronics Corp., 2013
+ *
+ * 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
+ */
+
+/*
+ *
+ * AUTHOR
+ * Honggyu Kim <[email protected]>
+ *
+ * DESCRIPTION
+ * Compare a given libc version against the current libc version.
+ * If they are the same - return 0
+ * If the argument is > current libc version - return positive int
+ * If the argument is < current libc version - return negative int
+ *
+ */
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/utsname.h>
+#include <gnu/libc-version.h>
+#include "test.h"
+
+static int tst_libcexvcmp(const char *tst_exv, const char *cur_ver)
+{
+ int c1 = 0, c2 = 0, c3 = 0;
+ int t1 = 0, t2 = 0, t3 = 0;
+ int ret;
+
+ sscanf(cur_ver, "%d.%d.%d", &c1, &c2, &c3);
+ sscanf(tst_exv, "%d.%d.%d", &t1, &t2, &t3);
+
+ if ((ret = c1 - t1))
+ return ret;
+ if ((ret = c2 - t2))
+ return ret;
+ return c3 - t3;
+}
+
+const char* tst_getlibcver(void)
+{
+ return gnu_get_libc_version();
+}
+
+int tst_libcvercmp(const char *tst_exv)
+{
+ const char* cur_ver = tst_getlibcver();
+ return tst_libcexvcmp(tst_exv, cur_ver);
+}
diff --git a/testcases/kernel/syscalls/getcontext/getcontext01.c
b/testcases/kernel/syscalls/getcontext/getcontext01.c
index 03b2df9..bf994c5 100644
--- a/testcases/kernel/syscalls/getcontext/getcontext01.c
+++ b/testcases/kernel/syscalls/getcontext/getcontext01.c
@@ -54,12 +54,28 @@ int TST_TOTAL = 1;
int exp_enos[] = { 0 }; /* must be a 0 terminated list */
+#ifdef __arm__
+#define LIBC_VER_GETCONTEXT_ARM_SUPPORT "2.17"
+#endif
+
int main(int ac, char **av)
{
int lc;
char *msg;
ucontext_t ptr;
+
+#ifdef __arm__
+ /* Disable test if the version of the libc is less than 2.17 in
ARM */
+ if ((tst_libcvercmp(LIBC_VER_GETCONTEXT_ARM_SUPPORT)) < 0) {
+ tst_resm(TCONF, "This test can only run with libc that
are ");
+ tst_resm(TCONF, "%s and higher (currently libc-%s
used)",
+ LIBC_VER_GETCONTEXT_ARM_SUPPORT,
+ tst_getlibcver());
+ tst_exit();
+ }
+#endif
+
if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
--
1.7.9.5
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135991&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list