Skip to contentSkip to conversation

getcontext01: check getcontext function in libc

PATCH Superseded Honggyu Kim 2 participants 2 messages Oct 23, 2013

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 getcontext01: check getcontext function in libc

getcontext function is implemented depends on libc version and arch. Some libc version for specific arch does not implement getcontext yet. In that case, getcontext just sets errno to ENOSYS and returns -1. For example, getcontext is not implemented before libc-2.17 in ARM. Current test goes to TFAIL when lower version of libc is used in ARM.

This patch sets the test as TCONF if libc does not implement getcontext. If ENOSYS is not set, it goes to TFAIL as it was.

---
 .../kernel/syscalls/getcontext/getcontext01.c      |   27
++++++++++++--------
 1 file changed, 17 insertions(+), 10 deletions(-)
(quoted diff) +0 -0

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

testcases/kernel/syscalls/getcontext/getcontext01.c +9 -0
@@ -54,12 +54,27 @@ int TST_TOTAL = 1;
 
 int exp_enos[] = { 0 };		/* must be a 0 terminated list */
 
+static void test_getcontext(void)
+{
+	ucontext_t ptr;
+
+	TEST(getcontext(&ptr));
+
+	if (TEST_RETURN == -1) {
+		if (errno == ENOSYS)
+			tst_resm(TCONF, "getcontext is not implemented in

libc");
+ else
+ tst_resm(TFAIL | TTERRNO, "getcontext failed");
+ }
+ else if (TEST_RETURN >= 0)
+ tst_resm(TPASS, "getcontext passed");
+}
+
int main(int ac, char **av)
{
int lc;
char *msg;

- ucontext_t ptr;
if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);

@@ -68,16 +83,8 @@ int main(int ac, char **av)
TEST_EXP_ENOS(exp_enos);

for (lc = 0; TEST_LOOPING(lc); lc++) {
-
tst_count = 0;
-
- TEST(getcontext(&ptr));
-
- if (TEST_RETURN == -1)
- tst_resm(TFAIL | TTERRNO, "getcontext failed");
- else if (TEST_RETURN >= 0)
- tst_resm(TPASS, "getcontext passed");
-
+ test_getcontext();
}

cleanup();

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

getcontext function is implemented depends on libc version and arch. Some libc version for specific arch does not implement getcontext yet. In that case, getcontext just sets errno to ENOSYS and returns -1. For example, getcontext is not implemented before libc-2.17 in ARM. Current test goes to TFAIL when lower version of libc is used in ARM.

This patch sets the test as TCONF if libc does not implement getcontext. If ENOSYS is not set, it goes to TFAIL as it was.

---
 .../kernel/syscalls/getcontext/getcontext01.c      |   27
++++++++++++--------
 1 file changed, 17 insertions(+), 10 deletions(-)
testcases/kernel/syscalls/getcontext/getcontext01.c +0 -0
index 03b2df9..34724ac 100644
@@ -54,12 +54,27 @@ int TST_TOTAL = 1;
 
 int exp_enos[] = { 0 };		/* must be a 0 terminated list */
 

testcases/kernel/syscalls/getcontext/getcontext01.c int TST_TOTAL = 1; · line 66

Quoted 10 lines
testcases/kernel/syscalls/getcontext/getcontext01.c +9 -0
+static void test_getcontext(void)
+{
+	ucontext_t ptr;
+
+	TEST(getcontext(&ptr));
+
+	if (TEST_RETURN == -1) {
+		if (errno == ENOSYS)
+			tst_resm(TCONF, "getcontext is not implemented in
 libc");

This line looks like it's line wrapped by your mail client (which corrupts the patch). Try turning off line wrapping and/or add the patch attached as a file.

testcases/kernel/syscalls/getcontext/getcontext01.c int TST_TOTAL = 1; · line 72

Quoted 6 lines
testcases/kernel/syscalls/getcontext/getcontext01.c +6 -0
+		else
+			tst_resm(TFAIL | TTERRNO, "getcontext failed");
+	}
+	else if (TEST_RETURN >= 0)
+		tst_resm(TPASS, "getcontext passed");
+}

The prefered style is to have the else on the same line as the closing curly brace.

As LTP has adopted LKML coding style, you can use chechpatch.pl (which is shipped in scripts dir with Linux kernel sources) to theck your patches before submission.

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