Skip to contentSkip to conversation

kselftest/vm: override TARGETS from arguments

PATCH In review Chengming Zhou 2 participants 5 messages Feb 27, 2022 – Mar 4, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 kselftest/vm: override TARGETS from arguments

We can specify which testcases to build using TARGETS argument, for example: make -C tools/testing/selftests TARGETS=vm, cause the ordinary assignment of TARGETS in Makefile will be ignored. So we need to use override directive to change that.

---
 tools/testing/selftests/vm/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/vm/Makefile +1 -1
index 1607322a112c..0b330a5b1840 100644
@@ -53,7 +53,7 @@ CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_32bit_progra
 CAN_BUILD_X86_64 := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_64bit_program.c)
 CAN_BUILD_WITH_NOPIE := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_program.c -no-pie)
 
-TARGETS := protection_keys
+override TARGETS := protection_keys
 BINARIES_32 := $(TARGETS:%=%_32)
 BINARIES_64 := $(TARGETS:%=%_64)
 
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/2 kselftest/vm: fix tests build with old libc

The error message when I build vm tests on debian10 (GLIBC 2.28):

userfaultfd.c: In function ‘userfaultfd_pagemap_test’:
userfaultfd.c:1393:37: error: ‘MADV_PAGEOUT’ undeclared (first use in this function); did you mean ‘MADV_RANDOM’?
if (madvise(area_dst, test_pgsize, MADV_PAGEOUT))

                                     ^~~~~~~~~~~~
                                     MADV_RANDOM

This patch includes these newer definitions from UAPI linux/mman.h, is useful to fix tests build on systems without these definitions in glibc sys/mman.h.

---
 tools/testing/selftests/vm/userfaultfd.c | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/vm/userfaultfd.c +1 -0
index 2f49c9af1b58..3fc1d2ee2948 100644
@@ -46,6 +46,7 @@
 #include <signal.h>
 #include <poll.h>
 #include <string.h>
+#include <linux/mman.h>
 #include <sys/mman.h>
 #include <sys/syscall.h>
 #include <sys/ioctl.h>
Signature · 1 line
2.20.1
maintainer Reviewed-by on v1 2/2
#2 lore raw

Re: [PATCH 2/2] kselftest/vm: fix tests build with old libc

Quoted 24 lines · Chengming Zhou

The error message when I build vm tests on debian10 (GLIBC 2.28):

userfaultfd.c: In function ‘userfaultfd_pagemap_test’:
userfaultfd.c:1393:37: error: ‘MADV_PAGEOUT’ undeclared (first use in this function); did you mean ‘MADV_RANDOM’?
if (madvise(area_dst, test_pgsize, MADV_PAGEOUT))

                                      ^~~~~~~~~~~~
                                      MADV_RANDOM

This patch includes these newer definitions from UAPI linux/mman.h, is useful to fix tests build on systems without these definitions in glibc sys/mman.h.

---
  tools/testing/selftests/vm/userfaultfd.c | 1 +
  1 file changed, 1 insertion(+)
tools/testing/selftests/vm/userfaultfd.c +0 -0
index 2f49c9af1b58..3fc1d2ee2948 100644

tools/testing/selftests/vm/userfaultfd.c line 52

Quoted 7 lines
tools/testing/selftests/vm/userfaultfd.c +1 -0
@@ -46,6 +46,7 @@
  #include <signal.h>
  #include <poll.h>
  #include <string.h>
+#include <linux/mman.h>
  #include <sys/mman.h>
  #include <sys/syscall.h>
  #include <sys/ioctl.h>

Looks good to me.

Andrew,

If you want to take this through your tree or I can apply it.

thanks,
-- Shuah

maintainer
#3 lore raw
In reply to Chengming Zhou
Quoted 16 lines · Chengming Zhou

We can specify which testcases to build using TARGETS argument, for example: make -C tools/testing/selftests TARGETS=vm, cause the ordinary assignment of TARGETS in Makefile will be ignored. So we need to use override directive to change that.

---
  tools/testing/selftests/vm/Makefile | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/vm/Makefile +0 -0
index 1607322a112c..0b330a5b1840 100644

tools/testing/selftests/vm/Makefile CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_32bit_progra · line 59

Quoted 8 lines
tools/testing/selftests/vm/Makefile +1 -1
@@ -53,7 +53,7 @@ CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_32bit_progra
  CAN_BUILD_X86_64 := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_64bit_program.c)
  CAN_BUILD_WITH_NOPIE := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_program.c -no-pie)
 
-TARGETS := protection_keys
+override TARGETS := protection_keys
  BINARIES_32 := $(TARGETS:%=%_32)
  BINARIES_64 := $(TARGETS:%=%_64)
 

Let's not override TARGETS - rename TARGETS in this file. VM_TARGETS?

thanks,
-- Shuah

#4 lore raw
Quoted 11 lines · Shuah Khan
Quoted 10 lines · Chengming Zhou

We can specify which testcases to build using TARGETS argument, for example: make -C tools/testing/selftests TARGETS=vm, cause the ordinary assignment of TARGETS in Makefile will be ignored. So we need to use override directive to change that.

---
  tools/testing/selftests/vm/Makefile | 2 +-

  1 file changed, 1 insertion(+), 1 deletion(-)
Quoted 15 lines
Quoted 7 lines
tools/testing/selftests/vm/Makefile +0 -0
index 1607322a112c..0b330a5b1840 100644
@@ -53,7 +53,7 @@ CAN_BUILD_I386 := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_32bit_progra
   CAN_BUILD_X86_64 := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_64bit_program.c)
   CAN_BUILD_WITH_NOPIE := $(shell ./../x86/check_cc.sh $(CC) ../x86/trivial_program.c -no-pie)
Quoted 5 lines

  -TARGETS := protection_keys
+override TARGETS := protection_keys
  BINARIES_32 := $(TARGETS:%=%_32)
  BINARIES_64 := $(TARGETS:%=%_64)

Let's not override TARGETS - rename TARGETS in this file. VM_TARGETS?

Looks like Andrew has already added this patch to the -mm tree. I think both way is ok to solve this problem. Should I rename to VM_TARGETS and send another patch?

Thanks.

Quoted 3 lines

thanks,
-- Shuah