Skip to content

Commit

Permalink
Merge tag 'linux-kselftest-next-5.17-rc1' of git://git.kernel.org/pub…
Browse files Browse the repository at this point in the history
…/scm/linux/kernel/git/shuah/linux-kselftest

Pull Kselftest update from Shuah Khan:
 "Fixes to build errors, false negatives, and several code cleanups,
  including the ARRAY_SIZE cleanup that removes 25+ duplicates
  ARRAY_SIZE defines from individual tests"

* tag 'linux-kselftest-next-5.17-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest:
  selftests/vm: remove ARRAY_SIZE define from individual tests
  selftests/timens: remove ARRAY_SIZE define from individual tests
  selftests/sparc64: remove ARRAY_SIZE define from adi-test
  selftests/seccomp: remove ARRAY_SIZE define from seccomp_benchmark
  selftests/rseq: remove ARRAY_SIZE define from individual tests
  selftests/net: remove ARRAY_SIZE define from individual tests
  selftests/landlock: remove ARRAY_SIZE define from common.h
  selftests/ir: remove ARRAY_SIZE define from ir_loopback.c
  selftests/core: remove ARRAY_SIZE define from close_range_test.c
  selftests/cgroup: remove ARRAY_SIZE define from cgroup_util.h
  selftests/arm64: remove ARRAY_SIZE define from vec-syscfg.c
  tools: fix ARRAY_SIZE defines in tools and selftests hdrs
  selftests: cgroup: build error multiple outpt files
  selftests/move_mount_set_group remove unneeded conversion to bool
  selftests/mount: remove unneeded conversion to bool
  selftests: harness: avoid false negatives if test has no ASSERTs
  selftests/ftrace: make kprobe profile testcase description unique
  selftests: clone3: clone3: add case CLONE3_ARGS_NO_TEST
  selftests: timers: Remove unneeded semicolon
  kselftests: timers:Remove unneeded semicolon
  • Loading branch information
torvalds committed Jan 10, 2022
2 parents ca1a46d + e899082 commit 4369b3c
Show file tree
Hide file tree
Showing 31 changed files with 49 additions and 57 deletions.
2 changes: 2 additions & 0 deletions tools/include/linux/kernel.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ int vscnprintf(char *buf, size_t size, const char *fmt, va_list args);
int scnprintf(char * buf, size_t size, const char * fmt, ...);
int scnprintf_pad(char * buf, size_t size, const char * fmt, ...);

#ifndef ARRAY_SIZE
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
#endif

#define current_gfp_context(k) 0
#define synchronize_rcu()
Expand Down
2 changes: 0 additions & 2 deletions tools/testing/selftests/arm64/fp/vec-syscfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
#include "../../kselftest.h"
#include "rdvl.h"

#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))

#define ARCH_MIN_VL SVE_VL_MIN

struct vec_data {
Expand Down
12 changes: 7 additions & 5 deletions tools/testing/selftests/cgroup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ TEST_GEN_PROGS += test_core
TEST_GEN_PROGS += test_freezer
TEST_GEN_PROGS += test_kill

LOCAL_HDRS += $(selfdir)/clone3/clone3_selftests.h $(selfdir)/pidfd/pidfd.h

include ../lib.mk

$(OUTPUT)/test_memcontrol: cgroup_util.c ../clone3/clone3_selftests.h
$(OUTPUT)/test_kmem: cgroup_util.c ../clone3/clone3_selftests.h
$(OUTPUT)/test_core: cgroup_util.c ../clone3/clone3_selftests.h
$(OUTPUT)/test_freezer: cgroup_util.c ../clone3/clone3_selftests.h
$(OUTPUT)/test_kill: cgroup_util.c ../clone3/clone3_selftests.h ../pidfd/pidfd.h
$(OUTPUT)/test_memcontrol: cgroup_util.c
$(OUTPUT)/test_kmem: cgroup_util.c
$(OUTPUT)/test_core: cgroup_util.c
$(OUTPUT)/test_freezer: cgroup_util.c
$(OUTPUT)/test_kill: cgroup_util.c
4 changes: 2 additions & 2 deletions tools/testing/selftests/cgroup/cgroup_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
#include <stdbool.h>
#include <stdlib.h>

#define PAGE_SIZE 4096
#include "../kselftest.h"

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#define PAGE_SIZE 4096

#define MB(x) (x << 20)

Expand Down
6 changes: 6 additions & 0 deletions tools/testing/selftests/clone3/clone3.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ static int call_clone3(uint64_t flags, size_t size, enum test_mode test_mode)
size = sizeof(struct __clone_args);

switch (test_mode) {
case CLONE3_ARGS_NO_TEST:
/*
* Uses default 'flags' and 'SIGCHLD'
* assignment.
*/
break;
case CLONE3_ARGS_ALL_0:
args.flags = 0;
args.exit_signal = 0;
Expand Down
4 changes: 0 additions & 4 deletions tools/testing/selftests/core/close_range_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ static inline int sys_close_range(unsigned int fd, unsigned int max_fd,
return syscall(__NR_close_range, fd, max_fd, flags);
}

#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif

TEST(core_close_range)
{
int i, ret;
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/ftrace/test.d/kprobe/profile.tc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh
# SPDX-License-Identifier: GPL-2.0
# description: Kprobe dynamic event - adding and removing
# description: Kprobe profile
# requires: kprobe_events

! grep -q 'myevent' kprobe_profile
Expand Down
1 change: 0 additions & 1 deletion tools/testing/selftests/ir/ir_loopback.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "../kselftest.h"

#define TEST_SCANCODES 10
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#define SYSFS_PATH_MAX 256
#define DNAME_PATH_MAX 256

Expand Down
4 changes: 4 additions & 0 deletions tools/testing/selftests/kselftest.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@
#include <stdarg.h>
#include <stdio.h>

#ifndef ARRAY_SIZE
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif

/* define kselftest exit codes */
#define KSFT_PASS 0
#define KSFT_FAIL 1
Expand Down
4 changes: 3 additions & 1 deletion tools/testing/selftests/kselftest_harness.h
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,9 @@
#define EXPECT_STRNE(expected, seen) \
__EXPECT_STR(expected, seen, !=, 0)

#ifndef ARRAY_SIZE
#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#endif

/* Support an optional handler after and ASSERT_* or EXPECT_*. The approach is
* not thread-safe, but it should be fine in most sane test scenarios.
Expand Down Expand Up @@ -969,7 +971,7 @@ void __run_test(struct __fixture_metadata *f,
t->passed = 1;
t->skip = 0;
t->trigger = 0;
t->step = 0;
t->step = 1;
t->no_print = 0;
memset(t->results->reason, 0, sizeof(t->results->reason));

Expand Down
4 changes: 0 additions & 4 deletions tools/testing/selftests/landlock/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@

#include "../kselftest_harness.h"

#ifndef ARRAY_SIZE
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif

/*
* TEST_F_FORK() is useful when a test drop privileges but the corresponding
* FIXTURE_TEARDOWN() requires them (e.g. to remove files from a directory
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/lib.mk
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ endif
# Selftest makefiles can override those targets by setting
# OVERRIDE_TARGETS = 1.
ifeq ($(OVERRIDE_TARGETS),)
LOCAL_HDRS := $(selfdir)/kselftest_harness.h $(selfdir)/kselftest.h
LOCAL_HDRS += $(selfdir)/kselftest_harness.h $(selfdir)/kselftest.h
$(OUTPUT)/%:%.c $(LOCAL_HDRS)
$(LINK.c) $(filter-out $(LOCAL_HDRS),$^) $(LDLIBS) -o $@

Expand Down
4 changes: 2 additions & 2 deletions tools/testing/selftests/mount/unprivileged-remount-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ bool test_unpriv_remount(const char *fstype, const char *mount_options,
if (!WIFEXITED(status)) {
die("child did not terminate cleanly\n");
}
return WEXITSTATUS(status) == EXIT_SUCCESS ? true : false;
return WEXITSTATUS(status) == EXIT_SUCCESS;
}

create_and_enter_userns();
Expand Down Expand Up @@ -282,7 +282,7 @@ static bool test_priv_mount_unpriv_remount(void)
if (!WIFEXITED(status)) {
die("child did not terminate cleanly\n");
}
return WEXITSTATUS(status) == EXIT_SUCCESS ? true : false;
return WEXITSTATUS(status) == EXIT_SUCCESS;
}

orig_mnt_flags = read_mnt_flags(orig_path);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ static bool is_shared_mount(const char *path)
#define SET_GROUP_FROM "/tmp/move_mount_set_group_supported_from"
#define SET_GROUP_TO "/tmp/move_mount_set_group_supported_to"

static int move_mount_set_group_supported(void)
static bool move_mount_set_group_supported(void)
{
int ret;

Expand Down Expand Up @@ -222,7 +222,7 @@ static int move_mount_set_group_supported(void)
AT_FDCWD, SET_GROUP_TO, MOVE_MOUNT_SET_GROUP);
umount2("/tmp", MNT_DETACH);

return ret < 0 ? false : true;
return ret >= 0;
}

FIXTURE(move_mount_set_group) {
Expand All @@ -232,7 +232,7 @@ FIXTURE(move_mount_set_group) {

FIXTURE_SETUP(move_mount_set_group)
{
int ret;
bool ret;

ASSERT_EQ(prepare_unpriv_mountns(), 0);

Expand All @@ -254,7 +254,7 @@ FIXTURE_SETUP(move_mount_set_group)

FIXTURE_TEARDOWN(move_mount_set_group)
{
int ret;
bool ret;

ret = move_mount_set_group_supported();
ASSERT_GE(ret, 0);
Expand Down Expand Up @@ -348,7 +348,7 @@ TEST_F(move_mount_set_group, complex_sharing_copying)
.shared = false,
};
pid_t pid;
int ret;
bool ret;

ret = move_mount_set_group_supported();
ASSERT_GE(ret, 0);
Expand Down
3 changes: 2 additions & 1 deletion tools/testing/selftests/net/gro.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@
#include <string.h>
#include <unistd.h>

#include "../kselftest.h"

#define DPORT 8000
#define SPORT 1500
#define PAYLOAD_LEN 100
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#define NUM_PACKETS 4
#define START_SEQ 100
#define START_ACK 100
Expand Down
1 change: 0 additions & 1 deletion tools/testing/selftests/net/ipsec.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

#define pr_err(fmt, ...) printk(fmt ": %m", ##__VA_ARGS__)

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))

#define IPV4_STR_SZ 16 /* xxx.xxx.xxx.xxx is longest + \0 */
Expand Down
4 changes: 1 addition & 3 deletions tools/testing/selftests/net/reuseport_bpf.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
#include <sys/resource.h>
#include <unistd.h>

#ifndef ARRAY_SIZE
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif
#include "../kselftest.h"

struct test_params {
int recv_family;
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/net/rxtimestamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <linux/net_tstamp.h>
#include <linux/errqueue.h>

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#include "../kselftest.h"

struct options {
int so_timestamp;
Expand Down
3 changes: 2 additions & 1 deletion tools/testing/selftests/net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <sys/socket.h>
#include <netinet/in.h>

#include "../kselftest.h"

struct socket_testcase {
int domain;
int type;
Expand All @@ -31,7 +33,6 @@ static struct socket_testcase tests[] = {
{ AF_INET, SOCK_STREAM, IPPROTO_UDP, -EPROTONOSUPPORT, 1 },
};

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#define ERR_STRING_SZ 64

static int run_tests(void)
Expand Down
6 changes: 2 additions & 4 deletions tools/testing/selftests/net/tcp_fastopen_backup_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <fcntl.h>
#include <time.h>

#include "../kselftest.h"

#ifndef TCP_FASTOPEN_KEY
#define TCP_FASTOPEN_KEY 33
#endif
Expand All @@ -34,10 +36,6 @@
#define PROC_FASTOPEN_KEY "/proc/sys/net/ipv4/tcp_fastopen_key"
#define KEY_LENGTH 16

#ifndef ARRAY_SIZE
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#endif

static bool do_ipv6;
static bool do_sockopt;
static bool do_rotate;
Expand Down
3 changes: 1 addition & 2 deletions tools/testing/selftests/rseq/basic_percpu_ops_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@
#include <string.h>
#include <stddef.h>

#include "../kselftest.h"
#include "rseq.h"

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))

struct percpu_lock_entry {
intptr_t v;
} __attribute__((aligned(128)));
Expand Down
3 changes: 1 addition & 2 deletions tools/testing/selftests/rseq/rseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@
#include <signal.h>
#include <limits.h>

#include "../kselftest.h"
#include "rseq.h"

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))

__thread volatile struct rseq __rseq_abi = {
.cpu_id = RSEQ_CPU_ID_UNINITIALIZED,
};
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/seccomp/seccomp_benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include <sys/syscall.h>
#include <sys/types.h>

#define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0]))
#include "../kselftest.h"

unsigned long long timing(clockid_t clk_id, unsigned long long samples)
{
Expand Down
4 changes: 0 additions & 4 deletions tools/testing/selftests/sparc64/drivers/adi-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@
#define DEBUG_LEVEL_4_BIT (0x0008)
#define DEBUG_TIMING_BIT (0x1000)

#ifndef ARRAY_SIZE
# define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#endif

/* bit mask of enabled bits to print */
#define DEBUG 0x0001

Expand Down
2 changes: 0 additions & 2 deletions tools/testing/selftests/timens/procfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#define DAY_IN_SEC (60*60*24)
#define TEN_DAYS_IN_SEC (10*DAY_IN_SEC)

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))

static int child_ns, parent_ns;

static int switch_ns(int fd)
Expand Down
2 changes: 0 additions & 2 deletions tools/testing/selftests/timens/timens.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
#define DAY_IN_SEC (60*60*24)
#define TEN_DAYS_IN_SEC (10*DAY_IN_SEC)

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))

struct test_clock {
clockid_t id;
char *name;
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/timers/alarmtimer-suspend.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ char *clockstring(int clockid)
return "CLOCK_BOOTTIME_ALARM";
case CLOCK_TAI:
return "CLOCK_TAI";
};
}
return "UNKNOWN_CLOCKID";
}

Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/timers/inconsistency-check.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ char *clockstring(int clockid)
return "CLOCK_BOOTTIME_ALARM";
case CLOCK_TAI:
return "CLOCK_TAI";
};
}
return "UNKNOWN_CLOCKID";
}

Expand Down
1 change: 0 additions & 1 deletion tools/testing/selftests/vm/mremap_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#define VALIDATION_DEFAULT_THRESHOLD 4 /* 4MB */
#define VALIDATION_NO_THRESHOLD 0 /* Verify the entire region */

#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define MIN(X, Y) ((X) < (Y) ? (X) : (Y))

struct config {
Expand Down
3 changes: 2 additions & 1 deletion tools/testing/selftests/vm/pkey-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <ucontext.h>
#include <sys/mman.h>

#include "../kselftest.h"

/* Define some kernel-like types */
#define u8 __u8
#define u16 __u16
Expand Down Expand Up @@ -175,7 +177,6 @@ static inline void __pkey_write_allow(int pkey, int do_allow_write)
dprintf4("pkey_reg now: %016llx\n", read_pkey_reg());
}

#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
#define ALIGN_UP(x, align_to) (((x) + ((align_to)-1)) & ~((align_to)-1))
#define ALIGN_DOWN(x, align_to) ((x) & ~((align_to)-1))
#define ALIGN_PTR_UP(p, ptr_align_to) \
Expand Down
2 changes: 1 addition & 1 deletion tools/testing/selftests/vm/va_128TBswitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <sys/mman.h>
#include <string.h>

#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#include "../kselftest.h"

#ifdef __powerpc64__
#define PAGE_SIZE (64 << 10)
Expand Down

0 comments on commit 4369b3c

Please sign in to comment.