2020-10-08 12:28:21

by Tommi Rantala

[permalink] [raw]
Subject: [PATCH 00/13] selftests fixes

Hi, small fixes to issues I hit with selftests.

Tommi Rantala (13):
selftests: filter kselftest headers from command in lib.mk
selftests: pidfd: fix compilation errors due to wait.h
selftests: add vmaccess to .gitignore
selftests/harness: prettify SKIP message whitespace again
selftests: pidfd: use ksft_test_result_skip() when skipping test
selftests: pidfd: skip test on kcmp() ENOSYS
selftests: pidfd: add CONFIG_CHECKPOINT_RESTORE=y to config
selftests: pidfd: drop needless linux/kcmp.h inclusion in
pidfd_setns_test.c
selftests: android: fix multiple definition of sock_name
selftests: proc: fix warning: _GNU_SOURCE redefined
selftests: core: use SKIP instead of XFAIL in close_range_test.c
selftests: clone3: use SKIP instead of XFAIL
selftests: binderfs: use SKIP instead of XFAIL

tools/testing/selftests/android/ion/ipcsocket.c | 1 +
tools/testing/selftests/android/ion/ipcsocket.h | 2 --
.../selftests/clone3/clone3_cap_checkpoint_restore.c | 2 +-
tools/testing/selftests/core/close_range_test.c | 8 ++++----
.../selftests/filesystems/binderfs/binderfs_test.c | 8 ++++----
tools/testing/selftests/kselftest_harness.h | 2 +-
tools/testing/selftests/lib.mk | 2 +-
tools/testing/selftests/pidfd/config | 1 +
tools/testing/selftests/pidfd/pidfd_getfd_test.c | 5 ++++-
tools/testing/selftests/pidfd/pidfd_open_test.c | 1 -
tools/testing/selftests/pidfd/pidfd_poll_test.c | 1 -
tools/testing/selftests/pidfd/pidfd_setns_test.c | 1 -
tools/testing/selftests/pidfd/pidfd_test.c | 2 +-
tools/testing/selftests/proc/proc-loadavg-001.c | 1 -
tools/testing/selftests/proc/proc-self-syscall.c | 1 -
tools/testing/selftests/proc/proc-uptime-002.c | 1 -
tools/testing/selftests/ptrace/.gitignore | 1 +
17 files changed, 19 insertions(+), 21 deletions(-)

--
2.26.2


2020-10-08 12:28:29

by Tommi Rantala

[permalink] [raw]
Subject: [PATCH 01/13] selftests: filter kselftest headers from command in lib.mk

Commit 1056d3d2c97e ("selftests: enforce local header dependency in
lib.mk") added header dependency to the rule, but as the rule uses $^,
the headers are added to the compiler command line.

This can cause unexpected precompiled header files being generated when
compilation fails:

$ echo { >> openat2_test.c

$ make
gcc -Wall -O2 -g -fsanitize=address -fsanitize=undefined openat2_test.c
tools/testing/selftests/kselftest_harness.h tools/testing/selftests/kselftest.h helpers.c
-o tools/testing/selftests/openat2/openat2_test
openat2_test.c:313:1: error: expected identifier or ‘(’ before ‘{’ token
313 | {
| ^
make: *** [../lib.mk:140: tools/testing/selftests/openat2/openat2_test] Error 1

$ file openat2_test*
openat2_test: GCC precompiled header (version 014) for C
openat2_test.c: C source, ASCII text

Fix it by filtering out the headers, so that we'll only pass the actual
*.c files in the compiler command line.

Fixes: 1056d3d2c97e ("selftests: enforce local header dependency in lib.mk")
Signed-off-by: Tommi Rantala <[email protected]>
---
tools/testing/selftests/lib.mk | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
index 7a17ea815736..66f3317dc365 100644
--- a/tools/testing/selftests/lib.mk
+++ b/tools/testing/selftests/lib.mk
@@ -137,7 +137,7 @@ endif
ifeq ($(OVERRIDE_TARGETS),)
LOCAL_HDRS := $(selfdir)/kselftest_harness.h $(selfdir)/kselftest.h
$(OUTPUT)/%:%.c $(LOCAL_HDRS)
- $(LINK.c) $^ $(LDLIBS) -o $@
+ $(LINK.c) $(filter-out $(LOCAL_HDRS),$^) $(LDLIBS) -o $@

$(OUTPUT)/%.o:%.S
$(COMPILE.S) $^ -o $@
--
2.26.2

2020-10-08 12:28:36

by Tommi Rantala

[permalink] [raw]
Subject: [PATCH 03/13] selftests: add vmaccess to .gitignore

Commit 2de4e82318c7 ("selftests/ptrace: add test cases for dead-locks")
added vmaccess testcase, add the binary to .gitignore

Fixes: 2de4e82318c7 ("selftests/ptrace: add test cases for dead-locks")
Signed-off-by: Tommi Rantala <[email protected]>
---
tools/testing/selftests/ptrace/.gitignore | 1 +
1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/ptrace/.gitignore b/tools/testing/selftests/ptrace/.gitignore
index 7bebf9534a86..792318aaa30c 100644
--- a/tools/testing/selftests/ptrace/.gitignore
+++ b/tools/testing/selftests/ptrace/.gitignore
@@ -1,3 +1,4 @@
# SPDX-License-Identifier: GPL-2.0-only
get_syscall_info
peeksiginfo
+vmaccess
--
2.26.2

2020-10-08 12:28:49

by Tommi Rantala

[permalink] [raw]
Subject: [PATCH 05/13] selftests: pidfd: use ksft_test_result_skip() when skipping test

There's planned tests != run tests in pidfd_test when some test is
skipped:

$ ./pidfd_test
TAP version 13
1..8
[...]
# pidfd_send_signal signal recycled pid test: Skipping test
# Planned tests != run tests (8 != 7)
# Totals: pass:7 fail:0 xfail:0 xpass:0 skip:0 error:0

Fix by using ksft_test_result_skip():

$ ./pidfd_test
TAP version 13
1..8
[...]
ok 8 # SKIP pidfd_send_signal signal recycled pid test: Unsharing pid namespace not permitted
# Totals: pass:7 fail:0 xfail:0 xpass:0 skip:1 error:0

Signed-off-by: Tommi Rantala <[email protected]>
---
tools/testing/selftests/pidfd/pidfd_test.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/pidfd/pidfd_test.c b/tools/testing/selftests/pidfd/pidfd_test.c
index c585aaa2acd8..529eb700ac26 100644
--- a/tools/testing/selftests/pidfd/pidfd_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_test.c
@@ -330,7 +330,7 @@ static int test_pidfd_send_signal_recycled_pid_fail(void)
ksft_exit_fail_msg("%s test: Failed to recycle pid %d\n",
test_name, PID_RECYCLE);
case PIDFD_SKIP:
- ksft_print_msg("%s test: Skipping test\n", test_name);
+ ksft_test_result_skip("%s test: Skipping test\n", test_name);
ret = 0;
break;
case PIDFD_XFAIL:
--
2.26.2

2020-10-08 12:28:56

by Tommi Rantala

[permalink] [raw]
Subject: [PATCH 11/13] selftests: core: use SKIP instead of XFAIL in close_range_test.c

XFAIL is gone since 9847d24af95c ("selftests/harness: Refactor XFAIL
into SKIP"), use SKIP instead.

Fixes: 9847d24af95c ("selftests/harness: Refactor XFAIL into SKIP")
Signed-off-by: Tommi Rantala <[email protected]>
---
tools/testing/selftests/core/close_range_test.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/core/close_range_test.c b/tools/testing/selftests/core/close_range_test.c
index c99b98b0d461..575b391ddc78 100644
--- a/tools/testing/selftests/core/close_range_test.c
+++ b/tools/testing/selftests/core/close_range_test.c
@@ -44,7 +44,7 @@ TEST(close_range)
fd = open("/dev/null", O_RDONLY | O_CLOEXEC);
ASSERT_GE(fd, 0) {
if (errno == ENOENT)
- XFAIL(return, "Skipping test since /dev/null does not exist");
+ SKIP(return, "Skipping test since /dev/null does not exist");
}

open_fds[i] = fd;
@@ -52,7 +52,7 @@ TEST(close_range)

EXPECT_EQ(-1, sys_close_range(open_fds[0], open_fds[100], -1)) {
if (errno == ENOSYS)
- XFAIL(return, "close_range() syscall not supported");
+ SKIP(return, "close_range() syscall not supported");
}

EXPECT_EQ(0, sys_close_range(open_fds[0], open_fds[50], 0));
@@ -108,7 +108,7 @@ TEST(close_range_unshare)
fd = open("/dev/null", O_RDONLY | O_CLOEXEC);
ASSERT_GE(fd, 0) {
if (errno == ENOENT)
- XFAIL(return, "Skipping test since /dev/null does not exist");
+ SKIP(return, "Skipping test since /dev/null does not exist");
}

open_fds[i] = fd;
@@ -197,7 +197,7 @@ TEST(close_range_unshare_capped)
fd = open("/dev/null", O_RDONLY | O_CLOEXEC);
ASSERT_GE(fd, 0) {
if (errno == ENOENT)
- XFAIL(return, "Skipping test since /dev/null does not exist");
+ SKIP(return, "Skipping test since /dev/null does not exist");
}

open_fds[i] = fd;
--
2.26.2

2020-10-08 12:28:57

by Tommi Rantala

[permalink] [raw]
Subject: [PATCH 13/13] selftests: binderfs: use SKIP instead of XFAIL

XFAIL is gone since 9847d24af95c ("selftests/harness: Refactor XFAIL
into SKIP"), use SKIP instead.

Fixes: 9847d24af95c ("selftests/harness: Refactor XFAIL into SKIP")
Signed-off-by: Tommi Rantala <[email protected]>
---
.../selftests/filesystems/binderfs/binderfs_test.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
index 1d27f52c61e6..477cbb042f5b 100644
--- a/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
+++ b/tools/testing/selftests/filesystems/binderfs/binderfs_test.c
@@ -74,7 +74,7 @@ static int __do_binderfs_test(struct __test_metadata *_metadata)
ret = mount(NULL, binderfs_mntpt, "binder", 0, 0);
EXPECT_EQ(ret, 0) {
if (errno == ENODEV)
- XFAIL(goto out, "binderfs missing");
+ SKIP(goto out, "binderfs missing");
TH_LOG("%s - Failed to mount binderfs", strerror(errno));
goto rmdir;
}
@@ -475,10 +475,10 @@ TEST(binderfs_stress)
TEST(binderfs_test_privileged)
{
if (geteuid() != 0)
- XFAIL(return, "Tests are not run as root. Skipping privileged tests");
+ SKIP(return, "Tests are not run as root. Skipping privileged tests");

if (__do_binderfs_test(_metadata))
- XFAIL(return, "The Android binderfs filesystem is not available");
+ SKIP(return, "The Android binderfs filesystem is not available");
}

TEST(binderfs_test_unprivileged)
@@ -511,7 +511,7 @@ TEST(binderfs_test_unprivileged)
ret = wait_for_pid(pid);
if (ret) {
if (ret == 2)
- XFAIL(return, "The Android binderfs filesystem is not available");
+ SKIP(return, "The Android binderfs filesystem is not available");
ASSERT_EQ(ret, 0) {
TH_LOG("wait_for_pid() failed");
}
--
2.26.2

2020-10-08 12:29:55

by Tommi Rantala

[permalink] [raw]
Subject: [PATCH 12/13] selftests: clone3: use SKIP instead of XFAIL

XFAIL is gone since 9847d24af95c ("selftests/harness: Refactor XFAIL
into SKIP"), use SKIP instead.

Fixes: 9847d24af95c ("selftests/harness: Refactor XFAIL into SKIP")
Signed-off-by: Tommi Rantala <[email protected]>
---
tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c b/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c
index 9562425aa0a9..614091de4c54 100644
--- a/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c
+++ b/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c
@@ -145,7 +145,7 @@ TEST(clone3_cap_checkpoint_restore)
test_clone3_supported();

EXPECT_EQ(getuid(), 0)
- XFAIL(return, "Skipping all tests as non-root\n");
+ SKIP(return, "Skipping all tests as non-root");

memset(&set_tid, 0, sizeof(set_tid));

--
2.26.2

2020-10-08 12:30:23

by Tommi Rantala

[permalink] [raw]
Subject: [PATCH 04/13] selftests/harness: prettify SKIP message whitespace again

Commit 9847d24af95c ("selftests/harness: Refactor XFAIL into SKIP")
replaced XFAIL with SKIP in the output. Add one more space to make the
output aligned and pretty again.

Fixes: 9847d24af95c ("selftests/harness: Refactor XFAIL into SKIP")
Signed-off-by: Tommi Rantala <[email protected]>
---
tools/testing/selftests/kselftest_harness.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
index 4f78e4805633..d8f44f4bdb3f 100644
--- a/tools/testing/selftests/kselftest_harness.h
+++ b/tools/testing/selftests/kselftest_harness.h
@@ -126,7 +126,7 @@
snprintf(_metadata->results->reason, \
sizeof(_metadata->results->reason), fmt, ##__VA_ARGS__); \
if (TH_LOG_ENABLED) { \
- fprintf(TH_LOG_STREAM, "# SKIP %s\n", \
+ fprintf(TH_LOG_STREAM, "# SKIP %s\n", \
_metadata->results->reason); \
} \
_metadata->passed = 1; \
--
2.26.2

2020-10-08 12:30:42

by Tommi Rantala

[permalink] [raw]
Subject: [PATCH 02/13] selftests: pidfd: fix compilation errors due to wait.h

Drop unneeded <linux/wait.h> header inclusion to fix pidfd compilation
errors seen in Fedora 32:

In file included from pidfd_open_test.c:9:
../../../../usr/include/linux/wait.h:17:16: error: expected identifier before numeric constant
17 | #define P_ALL 0
| ^

Signed-off-by: Tommi Rantala <[email protected]>
---
tools/testing/selftests/pidfd/pidfd_open_test.c | 1 -
tools/testing/selftests/pidfd/pidfd_poll_test.c | 1 -
2 files changed, 2 deletions(-)

diff --git a/tools/testing/selftests/pidfd/pidfd_open_test.c b/tools/testing/selftests/pidfd/pidfd_open_test.c
index b9fe75fc3e51..8a59438ccc78 100644
--- a/tools/testing/selftests/pidfd/pidfd_open_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_open_test.c
@@ -6,7 +6,6 @@
#include <inttypes.h>
#include <limits.h>
#include <linux/types.h>
-#include <linux/wait.h>
#include <sched.h>
#include <signal.h>
#include <stdbool.h>
diff --git a/tools/testing/selftests/pidfd/pidfd_poll_test.c b/tools/testing/selftests/pidfd/pidfd_poll_test.c
index 4b115444dfe9..610811275357 100644
--- a/tools/testing/selftests/pidfd/pidfd_poll_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_poll_test.c
@@ -3,7 +3,6 @@
#define _GNU_SOURCE
#include <errno.h>
#include <linux/types.h>
-#include <linux/wait.h>
#include <poll.h>
#include <signal.h>
#include <stdbool.h>
--
2.26.2

2020-10-08 12:31:28

by Tommi Rantala

[permalink] [raw]
Subject: [PATCH 07/13] selftests: pidfd: add CONFIG_CHECKPOINT_RESTORE=y to config

kcmp syscall is used in pidfd_getfd_test.c, so add
CONFIG_CHECKPOINT_RESTORE=y to config to ensure kcmp is available.

Signed-off-by: Tommi Rantala <[email protected]>
---
tools/testing/selftests/pidfd/config | 1 +
1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/pidfd/config b/tools/testing/selftests/pidfd/config
index bb11de90c0c9..f6f2965e17af 100644
--- a/tools/testing/selftests/pidfd/config
+++ b/tools/testing/selftests/pidfd/config
@@ -4,3 +4,4 @@ CONFIG_USER_NS=y
CONFIG_PID_NS=y
CONFIG_NET_NS=y
CONFIG_CGROUPS=y
+CONFIG_CHECKPOINT_RESTORE=y
--
2.26.2

2020-10-08 12:31:44

by Tommi Rantala

[permalink] [raw]
Subject: [PATCH 10/13] selftests: proc: fix warning: _GNU_SOURCE redefined

Makefile already contains -D_GNU_SOURCE, so we can remove it from the
*.c files.

Signed-off-by: Tommi Rantala <[email protected]>
---
tools/testing/selftests/proc/proc-loadavg-001.c | 1 -
tools/testing/selftests/proc/proc-self-syscall.c | 1 -
tools/testing/selftests/proc/proc-uptime-002.c | 1 -
3 files changed, 3 deletions(-)

diff --git a/tools/testing/selftests/proc/proc-loadavg-001.c b/tools/testing/selftests/proc/proc-loadavg-001.c
index 471e2aa28077..fb4fe9188806 100644
--- a/tools/testing/selftests/proc/proc-loadavg-001.c
+++ b/tools/testing/selftests/proc/proc-loadavg-001.c
@@ -14,7 +14,6 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/* Test that /proc/loadavg correctly reports last pid in pid namespace. */
-#define _GNU_SOURCE
#include <errno.h>
#include <sched.h>
#include <sys/types.h>
diff --git a/tools/testing/selftests/proc/proc-self-syscall.c b/tools/testing/selftests/proc/proc-self-syscall.c
index 9f6d000c0245..8511dcfe67c7 100644
--- a/tools/testing/selftests/proc/proc-self-syscall.c
+++ b/tools/testing/selftests/proc/proc-self-syscall.c
@@ -13,7 +13,6 @@
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-#define _GNU_SOURCE
#include <unistd.h>
#include <sys/syscall.h>
#include <sys/types.h>
diff --git a/tools/testing/selftests/proc/proc-uptime-002.c b/tools/testing/selftests/proc/proc-uptime-002.c
index 30e2b7849089..e7ceabed7f51 100644
--- a/tools/testing/selftests/proc/proc-uptime-002.c
+++ b/tools/testing/selftests/proc/proc-uptime-002.c
@@ -15,7 +15,6 @@
*/
// Test that values in /proc/uptime increment monotonically
// while shifting across CPUs.
-#define _GNU_SOURCE
#undef NDEBUG
#include <assert.h>
#include <unistd.h>
--
2.26.2

2020-10-08 12:32:20

by Tommi Rantala

[permalink] [raw]
Subject: [PATCH 08/13] selftests: pidfd: drop needless linux/kcmp.h inclusion in pidfd_setns_test.c

kcmp is not used in pidfd_setns_test.c, so do not include <linux/kcmp.h>

Signed-off-by: Tommi Rantala <[email protected]>
---
tools/testing/selftests/pidfd/pidfd_setns_test.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/pidfd/pidfd_setns_test.c b/tools/testing/selftests/pidfd/pidfd_setns_test.c
index 7dca1aa4672d..3f3dc7a02a01 100644
--- a/tools/testing/selftests/pidfd/pidfd_setns_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_setns_test.c
@@ -16,7 +16,6 @@
#include <unistd.h>
#include <sys/socket.h>
#include <sys/stat.h>
-#include <linux/kcmp.h>

#include "pidfd.h"
#include "../clone3/clone3_selftests.h"
--
2.26.2

2020-10-08 12:32:34

by Tommi Rantala

[permalink] [raw]
Subject: [PATCH 06/13] selftests: pidfd: skip test on kcmp() ENOSYS

Skip test if kcmp() is not available, for example if kernel is compiled
without CONFIG_CHECKPOINT_RESTORE=y.

Signed-off-by: Tommi Rantala <[email protected]>
---
tools/testing/selftests/pidfd/pidfd_getfd_test.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/pidfd/pidfd_getfd_test.c b/tools/testing/selftests/pidfd/pidfd_getfd_test.c
index 7758c98be015..0930e2411dfb 100644
--- a/tools/testing/selftests/pidfd/pidfd_getfd_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_getfd_test.c
@@ -204,7 +204,10 @@ TEST_F(child, fetch_fd)
fd = sys_pidfd_getfd(self->pidfd, self->remote_fd, 0);
ASSERT_GE(fd, 0);

- EXPECT_EQ(0, sys_kcmp(getpid(), self->pid, KCMP_FILE, fd, self->remote_fd));
+ ret = sys_kcmp(getpid(), self->pid, KCMP_FILE, fd, self->remote_fd);
+ if (ret < 0 && errno == ENOSYS)
+ SKIP(return, "kcmp() syscall not supported");
+ EXPECT_EQ(ret, 0);

ret = fcntl(fd, F_GETFD);
ASSERT_GE(ret, 0);
--
2.26.2

2020-10-08 15:52:01

by Tommi Rantala

[permalink] [raw]
Subject: [PATCH 09/13] selftests: android: fix multiple definition of sock_name

Fix multiple definition of sock_name compilation error:

tools/testing/selftests/android/ion/ipcsocket.h:8: multiple definition of `sock_name'

Signed-off-by: Tommi Rantala <[email protected]>
---
tools/testing/selftests/android/ion/ipcsocket.c | 1 +
tools/testing/selftests/android/ion/ipcsocket.h | 2 --
2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/testing/selftests/android/ion/ipcsocket.c b/tools/testing/selftests/android/ion/ipcsocket.c
index 7dc521002095..67ec69410d2e 100644
--- a/tools/testing/selftests/android/ion/ipcsocket.c
+++ b/tools/testing/selftests/android/ion/ipcsocket.c
@@ -10,6 +10,7 @@

#include "ipcsocket.h"

+static char sock_name[MAX_SOCK_NAME_LEN];

int opensocket(int *sockfd, const char *name, int connecttype)
{
diff --git a/tools/testing/selftests/android/ion/ipcsocket.h b/tools/testing/selftests/android/ion/ipcsocket.h
index b3e84498a8a1..ec5efb23e7b0 100644
--- a/tools/testing/selftests/android/ion/ipcsocket.h
+++ b/tools/testing/selftests/android/ion/ipcsocket.h
@@ -5,8 +5,6 @@

#define MAX_SOCK_NAME_LEN 64

-char sock_name[MAX_SOCK_NAME_LEN];
-
/* This structure is responsible for holding the IPC data
* data: hold the buffer fd
* len: just the length of 32-bit integer fd
--
2.26.2

2020-10-08 21:33:16

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 03/13] selftests: add vmaccess to .gitignore

On Thu, Oct 08, 2020 at 03:26:23PM +0300, Tommi Rantala wrote:
> Commit 2de4e82318c7 ("selftests/ptrace: add test cases for dead-locks")
> added vmaccess testcase, add the binary to .gitignore
>
> Fixes: 2de4e82318c7 ("selftests/ptrace: add test cases for dead-locks")
> Signed-off-by: Tommi Rantala <[email protected]>

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook

2020-10-08 21:34:10

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 12/13] selftests: clone3: use SKIP instead of XFAIL

On Thu, Oct 08, 2020 at 03:26:32PM +0300, Tommi Rantala wrote:
> XFAIL is gone since 9847d24af95c ("selftests/harness: Refactor XFAIL
> into SKIP"), use SKIP instead.
>
> Fixes: 9847d24af95c ("selftests/harness: Refactor XFAIL into SKIP")
> Signed-off-by: Tommi Rantala <[email protected]>

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook

2020-10-08 21:34:26

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 02/13] selftests: pidfd: fix compilation errors due to wait.h

On Thu, Oct 08, 2020 at 03:26:22PM +0300, Tommi Rantala wrote:
> Drop unneeded <linux/wait.h> header inclusion to fix pidfd compilation
> errors seen in Fedora 32:
>
> In file included from pidfd_open_test.c:9:
> ../../../../usr/include/linux/wait.h:17:16: error: expected identifier before numeric constant
> 17 | #define P_ALL 0
> | ^
>
> Signed-off-by: Tommi Rantala <[email protected]>

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook

2020-10-08 21:34:40

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 11/13] selftests: core: use SKIP instead of XFAIL in close_range_test.c

On Thu, Oct 08, 2020 at 03:26:31PM +0300, Tommi Rantala wrote:
> XFAIL is gone since 9847d24af95c ("selftests/harness: Refactor XFAIL
> into SKIP"), use SKIP instead.
>
> Fixes: 9847d24af95c ("selftests/harness: Refactor XFAIL into SKIP")
> Signed-off-by: Tommi Rantala <[email protected]>

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook

2020-10-08 21:36:18

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 13/13] selftests: binderfs: use SKIP instead of XFAIL

On Thu, Oct 08, 2020 at 03:26:33PM +0300, Tommi Rantala wrote:
> XFAIL is gone since 9847d24af95c ("selftests/harness: Refactor XFAIL
> into SKIP"), use SKIP instead.
>
> Fixes: 9847d24af95c ("selftests/harness: Refactor XFAIL into SKIP")
> Signed-off-by: Tommi Rantala <[email protected]>

Reviewed-by: Kees Cook <[email protected]>

--
Kees Cook

2020-10-08 22:53:58

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 01/13] selftests: filter kselftest headers from command in lib.mk

On Thu, Oct 08, 2020 at 03:26:21PM +0300, Tommi Rantala wrote:
> Commit 1056d3d2c97e ("selftests: enforce local header dependency in
> lib.mk") added header dependency to the rule, but as the rule uses $^,
> the headers are added to the compiler command line.
>
> This can cause unexpected precompiled header files being generated when
> compilation fails:
>
> $ echo { >> openat2_test.c
>
> $ make
> gcc -Wall -O2 -g -fsanitize=address -fsanitize=undefined openat2_test.c
> tools/testing/selftests/kselftest_harness.h tools/testing/selftests/kselftest.h helpers.c
> -o tools/testing/selftests/openat2/openat2_test
> openat2_test.c:313:1: error: expected identifier or ‘(’ before ‘{’ token
> 313 | {
> | ^
> make: *** [../lib.mk:140: tools/testing/selftests/openat2/openat2_test] Error 1
>
> $ file openat2_test*
> openat2_test: GCC precompiled header (version 014) for C
> openat2_test.c: C source, ASCII text
>
> Fix it by filtering out the headers, so that we'll only pass the actual
> *.c files in the compiler command line.
>
> Fixes: 1056d3d2c97e ("selftests: enforce local header dependency in lib.mk")
> Signed-off-by: Tommi Rantala <[email protected]>

Ah yes, thanks!

Acked-by: Kees Cook <[email protected]>


--
Kees Cook

2020-10-08 22:54:01

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH 04/13] selftests/harness: prettify SKIP message whitespace again

On Thu, Oct 08, 2020 at 03:26:24PM +0300, Tommi Rantala wrote:
> Commit 9847d24af95c ("selftests/harness: Refactor XFAIL into SKIP")
> replaced XFAIL with SKIP in the output. Add one more space to make the
> output aligned and pretty again.
>
> Fixes: 9847d24af95c ("selftests/harness: Refactor XFAIL into SKIP")
> Signed-off-by: Tommi Rantala <[email protected]>

Nice catch!

Acked-by: Kees Cook <[email protected]>


--
Kees Cook

2020-10-09 12:29:22

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH 02/13] selftests: pidfd: fix compilation errors due to wait.h

On Thu, Oct 08, 2020 at 03:26:22PM +0300, Tommi Rantala wrote:
> Drop unneeded <linux/wait.h> header inclusion to fix pidfd compilation
> errors seen in Fedora 32:
>
> In file included from pidfd_open_test.c:9:
> ../../../../usr/include/linux/wait.h:17:16: error: expected identifier before numeric constant
> 17 | #define P_ALL 0
> | ^
>
> Signed-off-by: Tommi Rantala <[email protected]>
> ---

Thanks!
Acked-by: Christian Brauner <[email protected]>

2020-10-09 13:02:10

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH 07/13] selftests: pidfd: add CONFIG_CHECKPOINT_RESTORE=y to config

On Thu, Oct 08, 2020 at 03:26:27PM +0300, Tommi Rantala wrote:
> kcmp syscall is used in pidfd_getfd_test.c, so add
> CONFIG_CHECKPOINT_RESTORE=y to config to ensure kcmp is available.
>
> Signed-off-by: Tommi Rantala <[email protected]>
> ---

Good catch, thanks!
Acked-by: Christian Brauner <[email protected]>

2020-10-09 13:02:11

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH 04/13] selftests/harness: prettify SKIP message whitespace again

On Thu, Oct 08, 2020 at 03:26:24PM +0300, Tommi Rantala wrote:
> Commit 9847d24af95c ("selftests/harness: Refactor XFAIL into SKIP")
> replaced XFAIL with SKIP in the output. Add one more space to make the
> output aligned and pretty again.
>
> Fixes: 9847d24af95c ("selftests/harness: Refactor XFAIL into SKIP")
> Signed-off-by: Tommi Rantala <[email protected]>
> ---

Thanks!
Reviewed-by: Christian Brauner <[email protected]>

2020-10-09 13:03:18

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH 01/13] selftests: filter kselftest headers from command in lib.mk

On Thu, Oct 08, 2020 at 03:26:21PM +0300, Tommi Rantala wrote:
> Commit 1056d3d2c97e ("selftests: enforce local header dependency in
> lib.mk") added header dependency to the rule, but as the rule uses $^,
> the headers are added to the compiler command line.
>
> This can cause unexpected precompiled header files being generated when
> compilation fails:
>
> $ echo { >> openat2_test.c
>
> $ make
> gcc -Wall -O2 -g -fsanitize=address -fsanitize=undefined openat2_test.c
> tools/testing/selftests/kselftest_harness.h tools/testing/selftests/kselftest.h helpers.c
> -o tools/testing/selftests/openat2/openat2_test
> openat2_test.c:313:1: error: expected identifier or ‘(’ before ‘{’ token
> 313 | {
> | ^
> make: *** [../lib.mk:140: tools/testing/selftests/openat2/openat2_test] Error 1
>
> $ file openat2_test*
> openat2_test: GCC precompiled header (version 014) for C
> openat2_test.c: C source, ASCII text
>
> Fix it by filtering out the headers, so that we'll only pass the actual
> *.c files in the compiler command line.
>
> Fixes: 1056d3d2c97e ("selftests: enforce local header dependency in lib.mk")
> Signed-off-by: Tommi Rantala <[email protected]>
> ---

Thanks!
Reviewed-by: Christian Brauner <[email protected]>

2020-10-09 17:14:45

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH 13/13] selftests: binderfs: use SKIP instead of XFAIL

On Thu, Oct 08, 2020 at 03:26:33PM +0300, Tommi Rantala wrote:
> XFAIL is gone since 9847d24af95c ("selftests/harness: Refactor XFAIL
> into SKIP"), use SKIP instead.
>
> Fixes: 9847d24af95c ("selftests/harness: Refactor XFAIL into SKIP")
> Signed-off-by: Tommi Rantala <[email protected]>
> ---

Thanks!
Acked-by: Christian Brauner <[email protected]>

2020-10-09 17:37:45

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH 12/13] selftests: clone3: use SKIP instead of XFAIL

On Thu, Oct 08, 2020 at 03:26:32PM +0300, Tommi Rantala wrote:
> XFAIL is gone since 9847d24af95c ("selftests/harness: Refactor XFAIL
> into SKIP"), use SKIP instead.
>
> Fixes: 9847d24af95c ("selftests/harness: Refactor XFAIL into SKIP")
> Signed-off-by: Tommi Rantala <[email protected]>
> ---

Thanks!
Acked-by: Christian Brauner <[email protected]>

2020-10-09 17:39:35

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH 11/13] selftests: core: use SKIP instead of XFAIL in close_range_test.c

On Thu, Oct 08, 2020 at 03:26:31PM +0300, Tommi Rantala wrote:
> XFAIL is gone since 9847d24af95c ("selftests/harness: Refactor XFAIL
> into SKIP"), use SKIP instead.
>
> Fixes: 9847d24af95c ("selftests/harness: Refactor XFAIL into SKIP")
> Signed-off-by: Tommi Rantala <[email protected]>
> ---

Thanks!
Acked-by: Christian Brauner <[email protected]>

2020-10-09 18:35:02

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH 06/13] selftests: pidfd: skip test on kcmp() ENOSYS

On Thu, Oct 08, 2020 at 03:26:26PM +0300, Tommi Rantala wrote:
> Skip test if kcmp() is not available, for example if kernel is compiled
> without CONFIG_CHECKPOINT_RESTORE=y.
>
> Signed-off-by: Tommi Rantala <[email protected]>
> ---

Good catch, thanks!
Acked-by: Christian Brauner <[email protected]>

2020-10-09 18:35:02

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH 05/13] selftests: pidfd: use ksft_test_result_skip() when skipping test

On Thu, Oct 08, 2020 at 03:26:25PM +0300, Tommi Rantala wrote:
> There's planned tests != run tests in pidfd_test when some test is
> skipped:
>
> $ ./pidfd_test
> TAP version 13
> 1..8
> [...]
> # pidfd_send_signal signal recycled pid test: Skipping test
> # Planned tests != run tests (8 != 7)
> # Totals: pass:7 fail:0 xfail:0 xpass:0 skip:0 error:0
>
> Fix by using ksft_test_result_skip():
>
> $ ./pidfd_test
> TAP version 13
> 1..8
> [...]
> ok 8 # SKIP pidfd_send_signal signal recycled pid test: Unsharing pid namespace not permitted
> # Totals: pass:7 fail:0 xfail:0 xpass:0 skip:1 error:0
>
> Signed-off-by: Tommi Rantala <[email protected]>
> ---

Thanks, I never got around to fixing this myself.
Acked-by: Christian Brauner <[email protected]>

2020-10-09 18:35:03

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH 00/13] selftests fixes

On Thu, Oct 08, 2020 at 03:26:20PM +0300, Tommi Rantala wrote:
> Hi, small fixes to issues I hit with selftests.
>
> Tommi Rantala (13):
> selftests: filter kselftest headers from command in lib.mk
> selftests: pidfd: fix compilation errors due to wait.h
> selftests: add vmaccess to .gitignore
> selftests/harness: prettify SKIP message whitespace again
> selftests: pidfd: use ksft_test_result_skip() when skipping test
> selftests: pidfd: skip test on kcmp() ENOSYS
> selftests: pidfd: add CONFIG_CHECKPOINT_RESTORE=y to config
> selftests: pidfd: drop needless linux/kcmp.h inclusion in
> pidfd_setns_test.c
> selftests: android: fix multiple definition of sock_name
> selftests: proc: fix warning: _GNU_SOURCE redefined
> selftests: core: use SKIP instead of XFAIL in close_range_test.c
> selftests: clone3: use SKIP instead of XFAIL
> selftests: binderfs: use SKIP instead of XFAIL

This mostly deals with stuff I maintain but it can go via the selftest
tree, thanks!

Christian

2020-10-09 18:36:42

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH 09/13] selftests: android: fix multiple definition of sock_name

On Thu, Oct 08, 2020 at 03:26:29PM +0300, Tommi Rantala wrote:
> Fix multiple definition of sock_name compilation error:
>
> tools/testing/selftests/android/ion/ipcsocket.h:8: multiple definition of `sock_name'
>
> Signed-off-by: Tommi Rantala <[email protected]>
> ---

Ion will be removed from the kernel soon but this seems like an ok
bugfix.
Thanks!
Acked-by: Christian Brauner <[email protected]>

2020-10-09 18:53:47

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH 08/13] selftests: pidfd: drop needless linux/kcmp.h inclusion in pidfd_setns_test.c

On Thu, Oct 08, 2020 at 03:26:28PM +0300, Tommi Rantala wrote:
> kcmp is not used in pidfd_setns_test.c, so do not include <linux/kcmp.h>
>
> Signed-off-by: Tommi Rantala <[email protected]>
> ---

Thanks!
Acked-by: Christian Brauner <[email protected]>

2020-10-09 18:53:47

by Christian Brauner

[permalink] [raw]
Subject: Re: [PATCH 03/13] selftests: add vmaccess to .gitignore

On Thu, Oct 08, 2020 at 03:26:23PM +0300, Tommi Rantala wrote:
> Commit 2de4e82318c7 ("selftests/ptrace: add test cases for dead-locks")
> added vmaccess testcase, add the binary to .gitignore
>
> Fixes: 2de4e82318c7 ("selftests/ptrace: add test cases for dead-locks")
> Signed-off-by: Tommi Rantala <[email protected]>
> ---

Thanks!
Reviewed-by: Christian Brauner <[email protected]>

2020-10-28 21:42:33

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH 00/13] selftests fixes

Tommi Rantala <[email protected]> writes:
> Hi, small fixes to issues I hit with selftests.
>
> Tommi Rantala (13):
> selftests: filter kselftest headers from command in lib.mk
> selftests: pidfd: fix compilation errors due to wait.h
> selftests: add vmaccess to .gitignore
> selftests/harness: prettify SKIP message whitespace again
> selftests: pidfd: use ksft_test_result_skip() when skipping test
> selftests: pidfd: skip test on kcmp() ENOSYS
> selftests: pidfd: add CONFIG_CHECKPOINT_RESTORE=y to config
> selftests: pidfd: drop needless linux/kcmp.h inclusion in
> pidfd_setns_test.c
> selftests: android: fix multiple definition of sock_name
> selftests: proc: fix warning: _GNU_SOURCE redefined
> selftests: core: use SKIP instead of XFAIL in close_range_test.c
> selftests: clone3: use SKIP instead of XFAIL
> selftests: binderfs: use SKIP instead of XFAIL

This series doesn't seem to have been picked up?

cheers

2020-10-28 21:42:36

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 00/13] selftests fixes

On 10/8/20 6:26 AM, Tommi Rantala wrote:
> Hi, small fixes to issues I hit with selftests.
>
> Tommi Rantala (13):
> selftests: filter kselftest headers from command in lib.mk
> selftests: pidfd: fix compilation errors due to wait.h
> selftests: add vmaccess to .gitignore
> selftests/harness: prettify SKIP message whitespace again
> selftests: pidfd: use ksft_test_result_skip() when skipping test
> selftests: pidfd: skip test on kcmp() ENOSYS
> selftests: pidfd: add CONFIG_CHECKPOINT_RESTORE=y to config
> selftests: pidfd: drop needless linux/kcmp.h inclusion in
> pidfd_setns_test.c
> selftests: android: fix multiple definition of sock_name
> selftests: proc: fix warning: _GNU_SOURCE redefined
> selftests: core: use SKIP instead of XFAIL in close_range_test.c
> selftests: clone3: use SKIP instead of XFAIL
> selftests: binderfs: use SKIP instead of XFAIL
>
> tools/testing/selftests/android/ion/ipcsocket.c | 1 +
> tools/testing/selftests/android/ion/ipcsocket.h | 2 --
> .../selftests/clone3/clone3_cap_checkpoint_restore.c | 2 +-
> tools/testing/selftests/core/close_range_test.c | 8 ++++----
> .../selftests/filesystems/binderfs/binderfs_test.c | 8 ++++----
> tools/testing/selftests/kselftest_harness.h | 2 +-
> tools/testing/selftests/lib.mk | 2 +-
> tools/testing/selftests/pidfd/config | 1 +
> tools/testing/selftests/pidfd/pidfd_getfd_test.c | 5 ++++-
> tools/testing/selftests/pidfd/pidfd_open_test.c | 1 -
> tools/testing/selftests/pidfd/pidfd_poll_test.c | 1 -
> tools/testing/selftests/pidfd/pidfd_setns_test.c | 1 -
> tools/testing/selftests/pidfd/pidfd_test.c | 2 +-
> tools/testing/selftests/proc/proc-loadavg-001.c | 1 -
> tools/testing/selftests/proc/proc-self-syscall.c | 1 -
> tools/testing/selftests/proc/proc-uptime-002.c | 1 -
> tools/testing/selftests/ptrace/.gitignore | 1 +
> 17 files changed, 19 insertions(+), 21 deletions(-)
>

Thanks for fixing these.

Applied all except 03/13 which is already fixed.

thanks,
-- Shuah

2020-10-29 08:04:53

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 00/13] selftests fixes

On 10/27/20 7:37 PM, Michael Ellerman wrote:
> Tommi Rantala <[email protected]> writes:
>> Hi, small fixes to issues I hit with selftests.
>>
>> Tommi Rantala (13):
>> selftests: filter kselftest headers from command in lib.mk
>> selftests: pidfd: fix compilation errors due to wait.h
>> selftests: add vmaccess to .gitignore
>> selftests/harness: prettify SKIP message whitespace again
>> selftests: pidfd: use ksft_test_result_skip() when skipping test
>> selftests: pidfd: skip test on kcmp() ENOSYS
>> selftests: pidfd: add CONFIG_CHECKPOINT_RESTORE=y to config
>> selftests: pidfd: drop needless linux/kcmp.h inclusion in
>> pidfd_setns_test.c
>> selftests: android: fix multiple definition of sock_name
>> selftests: proc: fix warning: _GNU_SOURCE redefined
>> selftests: core: use SKIP instead of XFAIL in close_range_test.c
>> selftests: clone3: use SKIP instead of XFAIL
>> selftests: binderfs: use SKIP instead of XFAIL
>
> This series doesn't seem to have been picked up?
>
> cheers
>

I applied them to linux-kselftest fixes yesterday.

thanks,
-- Shuah

2020-10-30 06:18:37

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH 00/13] selftests fixes

Shuah Khan <[email protected]> writes:
> On 10/27/20 7:37 PM, Michael Ellerman wrote:
>> Tommi Rantala <[email protected]> writes:
>>> Hi, small fixes to issues I hit with selftests.
>>>
>>> Tommi Rantala (13):
>>> selftests: filter kselftest headers from command in lib.mk
>>> selftests: pidfd: fix compilation errors due to wait.h
>>> selftests: add vmaccess to .gitignore
>>> selftests/harness: prettify SKIP message whitespace again
>>> selftests: pidfd: use ksft_test_result_skip() when skipping test
>>> selftests: pidfd: skip test on kcmp() ENOSYS
>>> selftests: pidfd: add CONFIG_CHECKPOINT_RESTORE=y to config
>>> selftests: pidfd: drop needless linux/kcmp.h inclusion in
>>> pidfd_setns_test.c
>>> selftests: android: fix multiple definition of sock_name
>>> selftests: proc: fix warning: _GNU_SOURCE redefined
>>> selftests: core: use SKIP instead of XFAIL in close_range_test.c
>>> selftests: clone3: use SKIP instead of XFAIL
>>> selftests: binderfs: use SKIP instead of XFAIL
>>
>> This series doesn't seem to have been picked up?
>>
>
> I applied them to linux-kselftest fixes yesterday.

Thanks.

cheers

2020-11-05 17:17:57

by Shuah Khan

[permalink] [raw]
Subject: Re: [PATCH 09/13] selftests: android: fix multiple definition of sock_name

On 10/9/20 6:05 AM, Christian Brauner wrote:
> On Thu, Oct 08, 2020 at 03:26:29PM +0300, Tommi Rantala wrote:
>> Fix multiple definition of sock_name compilation error:
>>
>> tools/testing/selftests/android/ion/ipcsocket.h:8: multiple definition of `sock_name'
>>
>> Signed-off-by: Tommi Rantala <[email protected]>
>> ---
>
> Ion will be removed from the kernel soon but this seems like an ok
> bugfix.
> Thanks!
> Acked-by: Christian Brauner <[email protected]>
>

ion is already gone. I am dropping this from linux-kselftest fixes
now. This is also causing conflict with ion removal commit

thanks,
-- Shuah