All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] pathconf01: Use TMPDIR instead of "/tmp" if set
@ 2018-06-22 21:57 Alistair Strachan
  2018-06-22 21:57 ` [LTP] [PATCH] ksm05: Fix build warning/error with -Wnull-dereference Alistair Strachan
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Alistair Strachan @ 2018-06-22 21:57 UTC (permalink / raw)
  To: ltp

Enable this test to work in environments without a /tmp directory.

Signed-off-by: Alistair Strachan <astrachan@google.com>
---
 testcases/kernel/syscalls/pathconf/pathconf01.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/pathconf/pathconf01.c b/testcases/kernel/syscalls/pathconf/pathconf01.c
index ddbe87f7a..362bae94f 100644
--- a/testcases/kernel/syscalls/pathconf/pathconf01.c
+++ b/testcases/kernel/syscalls/pathconf/pathconf01.c
@@ -154,7 +154,8 @@ int main(int ac, char **av)
 	tst_parse_opts(ac, av, options, &help);
 
 	if (!lflag) {
-		path = strdup("/tmp");
+		tst_tmpdir();
+		path = tst_get_tmpdir();
 	}
     /***************************************************************
      * perform global setup for test
@@ -221,7 +222,10 @@ void setup(void)
  ***************************************************************/
 void cleanup(void)
 {
-
+	if (!lflag) {
+		tst_rmdir();
+		free(path);
+	}
 }
 
 /***************************************************************

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [PATCH] ksm05: Fix build warning/error with -Wnull-dereference
  2018-06-22 21:57 [LTP] [PATCH] pathconf01: Use TMPDIR instead of "/tmp" if set Alistair Strachan
@ 2018-06-22 21:57 ` Alistair Strachan
  2018-06-25 14:10   ` Petr Vorel
  2018-06-22 21:57 ` [LTP] [PATCH] {rt_, }sigsuspend01: Fix build for non-glibc platforms Alistair Strachan
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: Alistair Strachan @ 2018-06-22 21:57 UTC (permalink / raw)
  To: ltp

Using the Android clang build, which uses -Werror -Wnull-dereference,
the following error is seen:

testcases/kernel/mem/ksm/ksm05.c:81:3: error: indirection of
non-volatile null pointer will be deleted, not trap
[-Werror,-Wnull-dereference]
  *(char *)NULL = 0;      /* SIGSEGV occurs as expected. */
  ^~~~~~~~~~~~~
testcases/kernel/mem/ksm/ksm05.c:81:3: note: consider using
__builtin_trap() or qualifying pointer with 'volatile'
1 error generated.

Change it to "volatile char *" which avoids this build issue, without
negatively affecting the test.

Signed-off-by: Alistair Strachan <astrachan@google.com>
---
 testcases/kernel/mem/ksm/ksm05.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/testcases/kernel/mem/ksm/ksm05.c b/testcases/kernel/mem/ksm/ksm05.c
index f3bfbf4fa..7c3530b28 100644
--- a/testcases/kernel/mem/ksm/ksm05.c
+++ b/testcases/kernel/mem/ksm/ksm05.c
@@ -78,7 +78,7 @@ static void test_ksm(void)
 		ptr = SAFE_MEMALIGN(ps, ps);
 		if (madvise(ptr, ps, MADV_MERGEABLE) < 0)
 			tst_brk(TBROK | TERRNO, "madvise");
-		*(char *)NULL = 0;	/* SIGSEGV occurs as expected. */
+		*(volatile char *)NULL = 0; /* SIGSEGV occurs as expected. */
 	}
 	SAFE_WAITPID(pid, &status, WUNTRACED | WCONTINUED);
 	if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [PATCH] {rt_, }sigsuspend01: Fix build for non-glibc platforms
  2018-06-22 21:57 [LTP] [PATCH] pathconf01: Use TMPDIR instead of "/tmp" if set Alistair Strachan
  2018-06-22 21:57 ` [LTP] [PATCH] ksm05: Fix build warning/error with -Wnull-dereference Alistair Strachan
@ 2018-06-22 21:57 ` Alistair Strachan
  2018-07-03  8:25   ` Petr Vorel
  2018-06-22 21:57 ` [LTP] [PATCH] abs01: Switch from <values.h> to <limits.h> Alistair Strachan
  2018-07-11  8:08 ` [LTP] [PATCH] pathconf01: Use TMPDIR instead of "/tmp" if set Jan Stancek
  3 siblings, 1 reply; 8+ messages in thread
From: Alistair Strachan @ 2018-06-22 21:57 UTC (permalink / raw)
  To: ltp

The tests dig inside the sigset_t to check if the kernel reverted any
changes made to the signal mask. This is done by comparing the first
32 signal flag bits by dereferencing the sigset_t and reading __val[0],
which is an unsigned long. If the field is not called __val (with
Android's bionic it is called '__bits' instead) the build breaks.

Change the tests to use memcmp for the first sizeof(unsigned long) bits,
which should be equivalent. This makes the test more portable.

Signed-off-by: Alistair Strachan <astrachan@google.com>
---
 testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c | 4 +++-
 testcases/kernel/syscalls/sigsuspend/sigsuspend01.c       | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
index 19e2eb66a..c8c228a47 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
+++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
@@ -26,6 +26,7 @@
 #include <stdio.h>
 #include <signal.h>
 #include <errno.h>
+#include <string.h>
 
 #include "test.h"
 #include "lapi/syscalls.h"
@@ -91,7 +92,8 @@ int main(int ac, char **av)
 			if (TEST_RETURN == -1) {
 				tst_brkm(TFAIL | TTERRNO, cleanup,
 					 "rt_sigprocmask failed");
-			} else if (set1.__val[0] != set2.__val[0]) {
+			} else if (memcmp(&set1, &set2,
+				   sizeof(unsigned long))) {
 				tst_brkm(TFAIL | TTERRNO, cleanup,
 					 "rt_sigsuspend failed to "
 					 "preserve signal mask");
diff --git a/testcases/kernel/syscalls/sigsuspend/sigsuspend01.c b/testcases/kernel/syscalls/sigsuspend/sigsuspend01.c
index b9542e705..a846f6330 100644
--- a/testcases/kernel/syscalls/sigsuspend/sigsuspend01.c
+++ b/testcases/kernel/syscalls/sigsuspend/sigsuspend01.c
@@ -121,7 +121,8 @@ int main(int ac, char **av)
 				tst_resm(TFAIL, "sigprocmask() Failed "
 					 "to get previous signal mask "
 					 "of process");
-			} else if (sigset2.__val[0] != sigset1.__val[0]) {
+			} else if (memcmp(&sigset1, &sigset2,
+				   sizeof(unsigned long))) {
 				tst_resm(TFAIL, "sigsuspend failed to "
 					 "preserve signal mask");
 			} else {

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [PATCH] abs01: Switch from <values.h> to <limits.h>
  2018-06-22 21:57 [LTP] [PATCH] pathconf01: Use TMPDIR instead of "/tmp" if set Alistair Strachan
  2018-06-22 21:57 ` [LTP] [PATCH] ksm05: Fix build warning/error with -Wnull-dereference Alistair Strachan
  2018-06-22 21:57 ` [LTP] [PATCH] {rt_, }sigsuspend01: Fix build for non-glibc platforms Alistair Strachan
@ 2018-06-22 21:57 ` Alistair Strachan
  2018-06-25 13:37   ` Petr Vorel
  2018-07-11  8:08 ` [LTP] [PATCH] pathconf01: Use TMPDIR instead of "/tmp" if set Jan Stancek
  3 siblings, 1 reply; 8+ messages in thread
From: Alistair Strachan @ 2018-06-22 21:57 UTC (permalink / raw)
  To: ltp

The <values.h> is an obsolete glibc interface that wraps <limits.h> and
<float.h>. The abs01 test only uses it for MININT, which can be
switched over to <limits.h> and INT_MIN, for increased portability.

Signed-off-by: Alistair Strachan <astrachan@google.com>
---
 testcases/misc/math/abs/abs01.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/testcases/misc/math/abs/abs01.c b/testcases/misc/math/abs/abs01.c
index c0659fa6d..c62bf0303 100644
--- a/testcases/misc/math/abs/abs01.c
+++ b/testcases/misc/math/abs/abs01.c
@@ -42,7 +42,7 @@
 #include <ctype.h>
 #include <math.h>
 #include <errno.h>
-#include <values.h>
+#include <limits.h>
 
 /*****	LTP Port	*****/
 
@@ -72,7 +72,7 @@ int main(int argc, char *argv[])
 /*--------------------------------------------------------------*/
 	blenter();
 
-	i = llabs(MININT) + (long long)MININT;
+	i = llabs(INT_MIN) + (long long)INT_MIN;
 
 	if (i != 0) {
 		fprintf(temp, "abs of minimum integer failed.");

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [PATCH] abs01: Switch from <values.h> to <limits.h>
  2018-06-22 21:57 ` [LTP] [PATCH] abs01: Switch from <values.h> to <limits.h> Alistair Strachan
@ 2018-06-25 13:37   ` Petr Vorel
  0 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2018-06-25 13:37 UTC (permalink / raw)
  To: ltp

Hi Alistair,

> The <values.h> is an obsolete glibc interface that wraps <limits.h> and
> <float.h>. The abs01 test only uses it for MININT, which can be
> switched over to <limits.h> and INT_MIN, for increased portability.

> Signed-off-by: Alistair Strachan <astrachan@google.com>

Pushed, thanks!


Kind regards,
Petr

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH] ksm05: Fix build warning/error with -Wnull-dereference
  2018-06-22 21:57 ` [LTP] [PATCH] ksm05: Fix build warning/error with -Wnull-dereference Alistair Strachan
@ 2018-06-25 14:10   ` Petr Vorel
  0 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2018-06-25 14:10 UTC (permalink / raw)
  To: ltp

Hi Alistair,

> Using the Android clang build, which uses -Werror -Wnull-dereference,
> the following error is seen:

> testcases/kernel/mem/ksm/ksm05.c:81:3: error: indirection of
> non-volatile null pointer will be deleted, not trap
> [-Werror,-Wnull-dereference]
>   *(char *)NULL = 0;      /* SIGSEGV occurs as expected. */
>   ^~~~~~~~~~~~~
> testcases/kernel/mem/ksm/ksm05.c:81:3: note: consider using
> __builtin_trap() or qualifying pointer with 'volatile'
> 1 error generated.

> Change it to "volatile char *" which avoids this build issue, without
> negatively affecting the test.

> Signed-off-by: Alistair Strachan <astrachan@google.com>

Pushed, thanks for your patch.


Kind regards,
Petr

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH] {rt_, }sigsuspend01: Fix build for non-glibc platforms
  2018-06-22 21:57 ` [LTP] [PATCH] {rt_, }sigsuspend01: Fix build for non-glibc platforms Alistair Strachan
@ 2018-07-03  8:25   ` Petr Vorel
  0 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2018-07-03  8:25 UTC (permalink / raw)
  To: ltp

Hi Alistair,

> The tests dig inside the sigset_t to check if the kernel reverted any
> changes made to the signal mask. This is done by comparing the first
> 32 signal flag bits by dereferencing the sigset_t and reading __val[0],
> which is an unsigned long. If the field is not called __val (with
> Android's bionic it is called '__bits' instead) the build breaks.

> Change the tests to use memcmp for the first sizeof(unsigned long) bits,
> which should be equivalent. This makes the test more portable.

> Signed-off-by: Alistair Strachan <astrachan@google.com>

Thanks for your patch, merged.


Kind regards,
Petr

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH] pathconf01: Use TMPDIR instead of "/tmp" if set
  2018-06-22 21:57 [LTP] [PATCH] pathconf01: Use TMPDIR instead of "/tmp" if set Alistair Strachan
                   ` (2 preceding siblings ...)
  2018-06-22 21:57 ` [LTP] [PATCH] abs01: Switch from <values.h> to <limits.h> Alistair Strachan
@ 2018-07-11  8:08 ` Jan Stancek
  3 siblings, 0 replies; 8+ messages in thread
From: Jan Stancek @ 2018-07-11  8:08 UTC (permalink / raw)
  To: ltp


----- Original Message -----
> Enable this test to work in environments without a /tmp directory.

Pushed.

Thanks,
Jan

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-07-11  8:08 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-22 21:57 [LTP] [PATCH] pathconf01: Use TMPDIR instead of "/tmp" if set Alistair Strachan
2018-06-22 21:57 ` [LTP] [PATCH] ksm05: Fix build warning/error with -Wnull-dereference Alistair Strachan
2018-06-25 14:10   ` Petr Vorel
2018-06-22 21:57 ` [LTP] [PATCH] {rt_, }sigsuspend01: Fix build for non-glibc platforms Alistair Strachan
2018-07-03  8:25   ` Petr Vorel
2018-06-22 21:57 ` [LTP] [PATCH] abs01: Switch from <values.h> to <limits.h> Alistair Strachan
2018-06-25 13:37   ` Petr Vorel
2018-07-11  8:08 ` [LTP] [PATCH] pathconf01: Use TMPDIR instead of "/tmp" if set Jan Stancek

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.