Skip to contentSkip to conversation

getcontext01: fix to check libc version for ARM

PATCH In review Honggyu Kim 2 participants 3 messages Oct 23, 2013 1 message not in the archive Library code

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 getcontext01: fix to check libc version for ARM

getcontext function is implemented from libc-2.17 in ARM. Currently, getcontext01 goes to TFAIL because getcontext just returns -1 in the previous libc for ARM.
This patch makes getcontext01 as TCONF when libc version is less than 2.17.

lib/tst_libcvercmp.c: a new file for libc version comparison Comparison code for libc version is added as a library.

---
 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
include/test.h +4 -0
index d9eba31..47765c2 100644
@@ -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);
lib/tst_libcvercmp.c new file +17 -0
new file mode 100644
index 0000000..2a09ab8
@@ -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);
+}

(quoted diff) +0 -0

b/testcases/kernel/syscalls/getcontext/getcontext01.c index 03b2df9..bf994c5 100644

testcases/kernel/syscalls/getcontext/getcontext01.c +7 -0
@@ -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);

Signature · 14 lines
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
#1 lore raw

Hi!

Quoted 5 lines

getcontext function is implemented from libc-2.17 in ARM. Currently, getcontext01 goes to TFAIL because getcontext just returns -1 in the previous libc for ARM.
This patch makes getcontext01 as TCONF when libc version is less than 2.17.

Does the setcontext() set errno to ENOSYS after the failure? If so it would be much easier (and more general solution) to just add a test for errno == ENOSYS and return TCONF if so.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
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

A message that is not in the archive (sent off-list or not yet received): [email protected]@lge.com

#3 lore raw

Hi!

Quoted 7 lines

You're right.
Current getcontext returns -1 after setting errno as ENOSYS. The solution has become easier and simpler. I just tested and verified it.

I will submit a new patch soon after changing the title and commit messages. If you think that we need a feature for libc version comparison for the future usage, I will submit it too as an extra patch.

I tend not to add functiontality that is not used (as that only adds unneded complexity and code that will break sooner or later). So let's go just with the errno == ENOSYS patch fow now.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
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