Skip to content

Commit de5c208

Browse files
committed
Merge tag 'linux-kselftest-fixes-5.19-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull Kselftest fixes from Shuah Khan: "Compile time fixes and run-time resources leaks: - Fix clang cross compilation - Fix resource leak when return error - fix compile error for dma_map_benchmark - Fix regression - make use of GUP_TEST_FILE macro" * tag 'linux-kselftest-fixes-5.19-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: selftests: make use of GUP_TEST_FILE macro selftests: vm: Fix resource leak when return error selftests dma: fix compile error for dma_map_benchmark selftests: Fix clang cross compilation
2 parents 3abc3ae + 9b4d5c0 commit de5c208

File tree

5 files changed

+29
-5
lines changed

5 files changed

+29
-5
lines changed

tools/testing/selftests/dma/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# SPDX-License-Identifier: GPL-2.0
22
CFLAGS += -I../../../../usr/include/
3+
CFLAGS += -I../../../../include/
34

45
TEST_GEN_PROGS := dma_map_benchmark
56

tools/testing/selftests/dma/dma_map_benchmark.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#include <unistd.h>
1111
#include <sys/ioctl.h>
1212
#include <sys/mman.h>
13-
#include <linux/map_benchmark.h>
1413
#include <linux/types.h>
14+
#include <linux/map_benchmark.h>
1515

1616
#define NSEC_PER_MSEC 1000000L
1717

tools/testing/selftests/lib.mk

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,31 @@ else ifneq ($(filter -%,$(LLVM)),)
77
LLVM_SUFFIX := $(LLVM)
88
endif
99

10-
CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX)
10+
CLANG_TARGET_FLAGS_arm := arm-linux-gnueabi
11+
CLANG_TARGET_FLAGS_arm64 := aarch64-linux-gnu
12+
CLANG_TARGET_FLAGS_hexagon := hexagon-linux-musl
13+
CLANG_TARGET_FLAGS_m68k := m68k-linux-gnu
14+
CLANG_TARGET_FLAGS_mips := mipsel-linux-gnu
15+
CLANG_TARGET_FLAGS_powerpc := powerpc64le-linux-gnu
16+
CLANG_TARGET_FLAGS_riscv := riscv64-linux-gnu
17+
CLANG_TARGET_FLAGS_s390 := s390x-linux-gnu
18+
CLANG_TARGET_FLAGS_x86 := x86_64-linux-gnu
19+
CLANG_TARGET_FLAGS := $(CLANG_TARGET_FLAGS_$(ARCH))
20+
21+
ifeq ($(CROSS_COMPILE),)
22+
ifeq ($(CLANG_TARGET_FLAGS),)
23+
$(error Specify CROSS_COMPILE or add '--target=' option to lib.mk
24+
else
25+
CLANG_FLAGS += --target=$(CLANG_TARGET_FLAGS)
26+
endif # CLANG_TARGET_FLAGS
27+
else
28+
CLANG_FLAGS += --target=$(notdir $(CROSS_COMPILE:%-=%))
29+
endif # CROSS_COMPILE
30+
31+
CC := $(LLVM_PREFIX)clang$(LLVM_SUFFIX) $(CLANG_FLAGS) -fintegrated-as
1132
else
1233
CC := $(CROSS_COMPILE)gcc
13-
endif
34+
endif # LLVM
1435

1536
ifeq (0,$(MAKELEVEL))
1637
ifeq ($(OUTPUT),)

tools/testing/selftests/vm/gup_test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ int main(int argc, char **argv)
209209
if (write)
210210
gup.gup_flags |= FOLL_WRITE;
211211

212-
gup_fd = open("/sys/kernel/debug/gup_test", O_RDWR);
212+
gup_fd = open(GUP_TEST_FILE, O_RDWR);
213213
if (gup_fd == -1) {
214214
switch (errno) {
215215
case EACCES:
@@ -224,7 +224,7 @@ int main(int argc, char **argv)
224224
printf("check if CONFIG_GUP_TEST is enabled in kernel config\n");
225225
break;
226226
default:
227-
perror("failed to open /sys/kernel/debug/gup_test");
227+
perror("failed to open " GUP_TEST_FILE);
228228
break;
229229
}
230230
exit(KSFT_SKIP);

tools/testing/selftests/vm/ksm_tests.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ static int ksm_write_sysfs(const char *file_path, unsigned long val)
5454
}
5555
if (fprintf(f, "%lu", val) < 0) {
5656
perror("fprintf");
57+
fclose(f);
5758
return 1;
5859
}
5960
fclose(f);
@@ -72,6 +73,7 @@ static int ksm_read_sysfs(const char *file_path, unsigned long *val)
7273
}
7374
if (fscanf(f, "%lu", val) != 1) {
7475
perror("fscanf");
76+
fclose(f);
7577
return 1;
7678
}
7779
fclose(f);

0 commit comments

Comments
 (0)