socketcall01: Use tst_syscall() instead of custom syscall support detection
PATCH 1/2 socketcall01: Use tst_syscall() instead of custom syscall support detection
Besides it's always better to use API functions instead of reimplementing a wheel it's also needed to fix regression in detecting socketcall() syscall support for archs which does not support it (e.g. x86_64, ARM):
socketcall01.c:42: FAIL: socketcall() for TCP stream failed with -1: ENOSYS (38) socketcall01.c:42: FAIL: socketcall() for unix domain dgram failed with -1: ENOSYS (38) socketcall01.c:42: FAIL: socketcall() for Raw socket failed with -1: ENOSYS (38) socketcall01.c:42: FAIL: socketcall() for UDP dgram failed with -1: ENOSYS (38)
--- .../kernel/syscalls/socketcall/socketcall01.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-)
testcases/kernel/syscalls/socketcall/socketcall01.c +4 -13
@@ -1,8 +1,9 @@// SPDX-License-Identifier: GPL-2.0-or-later /* * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved. -* AUTHOR : sowmya adiga<[email protected]> +* Author: sowmya adiga <[email protected]> * Copyright (c) 2016 Cyril Hrubis <[email protected]> +* Copyright (c) Linux Test Project, 2017-2020 */ /* * This is a basic test for the socketcall(2) system call.
@@ -11,16 +12,12 @@#include <errno.h> #include <sys/types.h> #include <sys/socket.h> -#include <sys/syscall.h> #include <linux/net.h> #include <sys/un.h> #include <netinet/in.h> #include "tst_test.h" - -#ifdef __NR_socketcall - -#define socketcall(call, args) syscall(__NR_socketcall, call, args) +#include "lapi/syscalls.h" struct test_case_t {int call;
@@ -35,7 +32,7 @@ struct test_case_t {void verify_socketcall (unsigned int i) { -TEST (socketcall (TC [i].call,TC [i].args)); +TEST (tst_syscall (__NR_socketcall,TC [i].call,TC [i].args));if (TST_RET <0 ) { tst_res(TFAIL | TTERRNO, "socketcall() for %s failed with %li",
@@ -53,9 +50,3 @@ static struct tst_test test = { .tcnt = ARRAY_SIZE(TC), .needs_root = 1, }; - -#else - -TST_TEST_TCONF ("The socketcall() syscall is not supported" ); - -#endif
Signature · 1 line
2.24.1
PATCH 1/2 socketcall01: Use tst_syscall() instead of custom syscall support detection
Hi,
slightly modified version of this one merged after release. Thanks a lot to all for review.
Kind regards,
Petr
PATCH 2/2 tst_device: Move tst_dev_sync() into from header to source file
In reply to Petr VorelWhile socketcall01.c was already fixed by previous commit and we expect nothing else was broken by 9e83513eb, it's still better not include lapi/syscalls.h to everything which uses new C API.
---
Feel free to reject this one.
Kind regards,
Petr
include/tst_device.h | 6 +----- lib/tst_device.c | 6 ++++++ 2 files changed, 7 insertions(+), 5 deletions(-)
include/tst_device.h +1 -5
@@ -19,7 +19,6 @@#define TST_DEVICE_H__ #include <unistd.h> -#include "lapi/syscalls.h" struct tst_device {const char *dev;
@@ -76,10 +75,7 @@ int tst_detach_device(const char *dev_path);* simply before the tst_dev_bytes_written invocation. For easy to use, * we create this inline function tst_dev_sync. */ -static inline int tst_dev_sync (int fd) -{ -return syscall (__NR_syncfs, fd); -} +static int tst_dev_sync (int fd);/* * Reads test block device stat file and returns the bytes written since the
lib/tst_device.c +6 -0
@@ -31,6 +31,7 @@#include <linux/loop.h> #include <stdint.h> #include <inttypes.h> +#include "lapi/syscalls.h" #include "test.h" #include "safe_macros.h"
@@ -222,6 +223,11 @@ int tst_detach_device(const char *dev)return 1 ; } +static int tst_dev_sync (int fd) +{ +return syscall (__NR_syncfs, fd); +} +const char *tst_acquire_device__ (unsigned int size) {int fd;
Signature · 1 line
2.24.1
PATCH 2/2 tst_device: Move tst_dev_sync() into from header to source file
Hi,
...
include/tst_device.h int tst_detach_device(const char *dev_path); · line 78
Quoted 5 lines
include/tst_device.h +1
-4-static inline int tst_dev_sync (int fd) -{ -return syscall (__NR_syncfs, fd); -} +static int tst_dev_sync (int fd);
This is obviously wrong.
Quoted 1 line
lib/tst_device.c +0
-0
...
Quoted 1 line
+static int
tst_dev_sync(int fd)
And here as well.
lib/tst_device.c int tst_detach_device(const char *dev) · line 229
Quoted 3 lines
lib/tst_device.c +3
-0+{ +return syscall (__NR_syncfs, fd); +}
Sorry for wrong patch.
Kind regards,
Petr
PATCH 2/2 tst_device: Move tst_dev_sync() into from header to source file
Hi!
Quoted 1 line
Sorry for wrong patch.
Besides of that we need either of the two patches to fix the problem, now I do wonder which one should we apply before the release.
I guess that moving the function to the library code is a bit more conservative move after all, so we may as well apply that and fix the socketcall test after the release.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 2/2 tst_device: Move tst_dev_sync() into from header to source file
Hi,
Quoted 6 lines
Besides of that we need either of the two patches to fix the problem, now I do wonder which one should we apply before the release.
I guess that moving the function to the library code is a bit more conservative move after all, so we may as well apply that and fix the socketcall test after the release.
+1.
Kind regards,
Petr