Skip to contentSkip to conversation

pathconf01: Use TMPDIR instead of "/tmp" if set

PATCH New Alistair Strachan 3 participants 8 messages Jun 22, 2018 – Jul 11, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pathconf01: Use TMPDIR instead of "/tmp" if set

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

---
 testcases/kernel/syscalls/pathconf/pathconf01.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/pathconf/pathconf01.c +6 -2
index ddbe87f7a..362bae94f 100644
@@ -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);
+	}
 }
 
 /***************************************************************
#1 lore raw

PATCH 1/1 ksm05: Fix build warning/error with -Wnull-dereference

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.

---
 testcases/kernel/mem/ksm/ksm05.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
testcases/kernel/mem/ksm/ksm05.c +1 -1
index f3bfbf4fa..7c3530b28 100644
@@ -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)
#2 lore raw

PATCH 1/1 ksm05: Fix build warning/error with -Wnull-dereference

Hi Alistair,

Quoted 12 lines

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.

Quoted 4 lines

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

Pushed, thanks for your patch.

Kind regards,
Petr

#3 lore raw

PATCH 1/1 {rt_, }sigsuspend01: Fix build for non-glibc platforms

In reply to Alistair Strachan

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.

---
 testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c | 4 +++-
 testcases/kernel/syscalls/sigsuspend/sigsuspend01.c       | 3 ++-
 2 files changed, 5 insertions(+), 2 deletions(-)
testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c +3 -1
index 19e2eb66a..c8c228a47 100644
@@ -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");
testcases/kernel/syscalls/sigsuspend/sigsuspend01.c +2 -1
index b9542e705..a846f6330 100644
@@ -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 {
#4 lore raw

PATCH 1/1 {rt_, }sigsuspend01: Fix build for non-glibc platforms

Hi Alistair,

Quoted 10 lines

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.

Thanks for your patch, merged.

Kind regards,
Petr

#5 lore raw

PATCH 1/1 abs01: Switch from <values.h> to <limits.h>

In reply to Alistair Strachan

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.

---
 testcases/misc/math/abs/abs01.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
testcases/misc/math/abs/abs01.c +2 -2
index c0659fa6d..c62bf0303 100644
@@ -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.");
#6 lore raw

PATCH 1/1 abs01: Switch from <values.h> to <limits.h>

Hi Alistair,

Quoted 5 lines

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.

Pushed, thanks!

Kind regards,
Petr

#7 lore raw

PATCH 1/1 pathconf01: Use TMPDIR instead of "/tmp" if set

In reply to Alistair Strachan

----- Original Message -----

Quoted 1 line

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

Pushed.

Thanks,
Jan