Skip to content
This repository was archived by the owner on Nov 8, 2023. It is now read-only.

Commit 920bc84

Browse files
committed
Merge tag 'linux_kselftest-fixes-6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull kselftest fixes from Shuah Khan "Fixes to clang build failures to timerns, vDSO tests and fixes to vDSO makefile" * tag 'linux_kselftest-fixes-6.10' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: selftests/vDSO: remove duplicate compiler invocations from Makefile selftests/vDSO: remove partially duplicated "all:" target in Makefile selftests/vDSO: fix clang build errors and warnings selftest/timerns: fix clang build failures for abs() calls
2 parents b5efb63 + 66cde33 commit 920bc84

File tree

7 files changed

+46
-31
lines changed

7 files changed

+46
-31
lines changed

tools/testing/selftests/timens/exec.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ int main(int argc, char *argv[])
3030

3131
for (i = 0; i < 2; i++) {
3232
_gettime(CLOCK_MONOTONIC, &tst, i);
33-
if (abs(tst.tv_sec - now.tv_sec) > 5)
33+
if (labs(tst.tv_sec - now.tv_sec) > 5)
3434
return pr_fail("%ld %ld\n", now.tv_sec, tst.tv_sec);
3535
}
3636
return 0;
@@ -50,7 +50,7 @@ int main(int argc, char *argv[])
5050

5151
for (i = 0; i < 2; i++) {
5252
_gettime(CLOCK_MONOTONIC, &tst, i);
53-
if (abs(tst.tv_sec - now.tv_sec) > 5)
53+
if (labs(tst.tv_sec - now.tv_sec) > 5)
5454
return pr_fail("%ld %ld\n",
5555
now.tv_sec, tst.tv_sec);
5656
}
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
7070
/* Check that a child process is in the new timens. */
7171
for (i = 0; i < 2; i++) {
7272
_gettime(CLOCK_MONOTONIC, &tst, i);
73-
if (abs(tst.tv_sec - now.tv_sec - OFFSET) > 5)
73+
if (labs(tst.tv_sec - now.tv_sec - OFFSET) > 5)
7474
return pr_fail("%ld %ld\n",
7575
now.tv_sec + OFFSET, tst.tv_sec);
7676
}

tools/testing/selftests/timens/timer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ int run_test(int clockid, struct timespec now)
5656
return pr_perror("timerfd_gettime");
5757

5858
elapsed = new_value.it_value.tv_sec;
59-
if (abs(elapsed - 3600) > 60) {
59+
if (llabs(elapsed - 3600) > 60) {
6060
ksft_test_result_fail("clockid: %d elapsed: %lld\n",
6161
clockid, elapsed);
6262
return 1;

tools/testing/selftests/timens/timerfd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ int run_test(int clockid, struct timespec now)
6161
return pr_perror("timerfd_gettime(%d)", clockid);
6262

6363
elapsed = new_value.it_value.tv_sec;
64-
if (abs(elapsed - 3600) > 60) {
64+
if (llabs(elapsed - 3600) > 60) {
6565
ksft_test_result_fail("clockid: %d elapsed: %lld\n",
6666
clockid, elapsed);
6767
return 1;

tools/testing/selftests/timens/vfork_exec.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ static void *tcheck(void *_args)
3232

3333
for (i = 0; i < 2; i++) {
3434
_gettime(CLOCK_MONOTONIC, &tst, i);
35-
if (abs(tst.tv_sec - now->tv_sec) > 5) {
35+
if (labs(tst.tv_sec - now->tv_sec) > 5) {
3636
pr_fail("%s: in-thread: unexpected value: %ld (%ld)\n",
3737
args->tst_name, tst.tv_sec, now->tv_sec);
3838
return (void *)1UL;
@@ -64,7 +64,7 @@ static int check(char *tst_name, struct timespec *now)
6464

6565
for (i = 0; i < 2; i++) {
6666
_gettime(CLOCK_MONOTONIC, &tst, i);
67-
if (abs(tst.tv_sec - now->tv_sec) > 5)
67+
if (labs(tst.tv_sec - now->tv_sec) > 5)
6868
return pr_fail("%s: unexpected value: %ld (%ld)\n",
6969
tst_name, tst.tv_sec, now->tv_sec);
7070
}

tools/testing/selftests/vDSO/Makefile

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,30 @@
11
# SPDX-License-Identifier: GPL-2.0
2-
include ../lib.mk
3-
42
uname_M := $(shell uname -m 2>/dev/null || echo not)
53
ARCH ?= $(shell echo $(uname_M) | sed -e s/i.86/x86/ -e s/x86_64/x86/)
64

7-
TEST_GEN_PROGS := $(OUTPUT)/vdso_test_gettimeofday $(OUTPUT)/vdso_test_getcpu
8-
TEST_GEN_PROGS += $(OUTPUT)/vdso_test_abi
9-
TEST_GEN_PROGS += $(OUTPUT)/vdso_test_clock_getres
5+
TEST_GEN_PROGS := vdso_test_gettimeofday
6+
TEST_GEN_PROGS += vdso_test_getcpu
7+
TEST_GEN_PROGS += vdso_test_abi
8+
TEST_GEN_PROGS += vdso_test_clock_getres
109
ifeq ($(ARCH),$(filter $(ARCH),x86 x86_64))
11-
TEST_GEN_PROGS += $(OUTPUT)/vdso_standalone_test_x86
10+
TEST_GEN_PROGS += vdso_standalone_test_x86
1211
endif
13-
TEST_GEN_PROGS += $(OUTPUT)/vdso_test_correctness
12+
TEST_GEN_PROGS += vdso_test_correctness
1413

1514
CFLAGS := -std=gnu99
16-
CFLAGS_vdso_standalone_test_x86 := -nostdlib -fno-asynchronous-unwind-tables -fno-stack-protector
17-
LDFLAGS_vdso_test_correctness := -ldl
15+
1816
ifeq ($(CONFIG_X86_32),y)
1917
LDLIBS += -lgcc_s
2018
endif
2119

22-
all: $(TEST_GEN_PROGS)
20+
include ../lib.mk
2321
$(OUTPUT)/vdso_test_gettimeofday: parse_vdso.c vdso_test_gettimeofday.c
2422
$(OUTPUT)/vdso_test_getcpu: parse_vdso.c vdso_test_getcpu.c
2523
$(OUTPUT)/vdso_test_abi: parse_vdso.c vdso_test_abi.c
2624
$(OUTPUT)/vdso_test_clock_getres: vdso_test_clock_getres.c
25+
2726
$(OUTPUT)/vdso_standalone_test_x86: vdso_standalone_test_x86.c parse_vdso.c
28-
$(CC) $(CFLAGS) $(CFLAGS_vdso_standalone_test_x86) \
29-
vdso_standalone_test_x86.c parse_vdso.c \
30-
-o $@
27+
$(OUTPUT)/vdso_standalone_test_x86: CFLAGS +=-nostdlib -fno-asynchronous-unwind-tables -fno-stack-protector
28+
3129
$(OUTPUT)/vdso_test_correctness: vdso_test_correctness.c
32-
$(CC) $(CFLAGS) \
33-
vdso_test_correctness.c \
34-
-o $@ \
35-
$(LDFLAGS_vdso_test_correctness)
30+
$(OUTPUT)/vdso_test_correctness: LDFLAGS += -ldl

tools/testing/selftests/vDSO/parse_vdso.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,20 @@ static struct vdso_info
5555
ELF(Verdef) *verdef;
5656
} vdso_info;
5757

58-
/* Straight from the ELF specification. */
59-
static unsigned long elf_hash(const unsigned char *name)
58+
/*
59+
* Straight from the ELF specification...and then tweaked slightly, in order to
60+
* avoid a few clang warnings.
61+
*/
62+
static unsigned long elf_hash(const char *name)
6063
{
6164
unsigned long h = 0, g;
62-
while (*name)
65+
const unsigned char *uch_name = (const unsigned char *)name;
66+
67+
while (*uch_name)
6368
{
64-
h = (h << 4) + *name++;
65-
if (g = h & 0xf0000000)
69+
h = (h << 4) + *uch_name++;
70+
g = h & 0xf0000000;
71+
if (g)
6672
h ^= g >> 24;
6773
h &= ~g;
6874
}

tools/testing/selftests/vDSO/vdso_standalone_test_x86.c

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
#include "parse_vdso.h"
2020

21-
/* We need a libc functions... */
21+
/* We need some libc functions... */
2222
int strcmp(const char *a, const char *b)
2323
{
2424
/* This implementation is buggy: it never returns -1. */
@@ -34,6 +34,20 @@ int strcmp(const char *a, const char *b)
3434
return 0;
3535
}
3636

37+
/*
38+
* The clang build needs this, although gcc does not.
39+
* Stolen from lib/string.c.
40+
*/
41+
void *memcpy(void *dest, const void *src, size_t count)
42+
{
43+
char *tmp = dest;
44+
const char *s = src;
45+
46+
while (count--)
47+
*tmp++ = *s++;
48+
return dest;
49+
}
50+
3751
/* ...and two syscalls. This is x86-specific. */
3852
static inline long x86_syscall3(long nr, long a0, long a1, long a2)
3953
{
@@ -70,7 +84,7 @@ void to_base10(char *lastdig, time_t n)
7084
}
7185
}
7286

73-
__attribute__((externally_visible)) void c_main(void **stack)
87+
void c_main(void **stack)
7488
{
7589
/* Parse the stack */
7690
long argc = (long)*stack;

0 commit comments

Comments
 (0)