All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/2] socketcall01: Use tst_syscall() instead of custom syscall support detection
@ 2020-01-20 13:36 Petr Vorel
  2020-01-20 13:36 ` [LTP] [PATCH 2/2] tst_device: Move tst_dev_sync() into from header to source file Petr Vorel
  2020-01-20 19:10 ` [LTP] [PATCH 1/2] socketcall01: Use tst_syscall() instead of custom syscall support detection Petr Vorel
  0 siblings, 2 replies; 6+ messages in thread
From: Petr Vorel @ 2020-01-20 13:36 UTC (permalink / raw)
  To: ltp

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)

Fixes: 9e83513eb "tst_device.h: Use lapi/syscalls.h instead of <sys/syscall.h>"
Fixes: #634

Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
 .../kernel/syscalls/socketcall/socketcall01.c   | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/testcases/kernel/syscalls/socketcall/socketcall01.c b/testcases/kernel/syscalls/socketcall/socketcall01.c
index a8f6649a6..48e818846 100644
--- a/testcases/kernel/syscalls/socketcall/socketcall01.c
+++ b/testcases/kernel/syscalls/socketcall/socketcall01.c
@@ -1,8 +1,9 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
- *    AUTHOR : sowmya adiga<sowmya.adiga@wipro.com>
+ * Author: sowmya adiga <sowmya.adiga@wipro.com>
  * Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz>
+ * 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
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 2/2] tst_device: Move tst_dev_sync() into from header to source file
  2020-01-20 13:36 [LTP] [PATCH 1/2] socketcall01: Use tst_syscall() instead of custom syscall support detection Petr Vorel
@ 2020-01-20 13:36 ` Petr Vorel
  2020-01-20 13:52   ` Petr Vorel
  2020-01-20 19:10 ` [LTP] [PATCH 1/2] socketcall01: Use tst_syscall() instead of custom syscall support detection Petr Vorel
  1 sibling, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2020-01-20 13:36 UTC (permalink / raw)
  To: ltp

While 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.

Fixes: 9e83513eb "tst_device.h: Use lapi/syscalls.h instead of <sys/syscall.h>"

Suggested-by: Martin Doucha <mdoucha@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
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(-)

diff --git a/include/tst_device.h b/include/tst_device.h
index 13d92ee54..64ea77768 100644
--- a/include/tst_device.h
+++ b/include/tst_device.h
@@ -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
diff --git a/lib/tst_device.c b/lib/tst_device.c
index e78549c94..ade6fdd52 100644
--- a/lib/tst_device.c
+++ b/lib/tst_device.c
@@ -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;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 2/2] tst_device: Move tst_dev_sync() into from header to source file
  2020-01-20 13:36 ` [LTP] [PATCH 2/2] tst_device: Move tst_dev_sync() into from header to source file Petr Vorel
@ 2020-01-20 13:52   ` Petr Vorel
  2020-01-20 13:55     ` Cyril Hrubis
  0 siblings, 1 reply; 6+ messages in thread
From: Petr Vorel @ 2020-01-20 13:52 UTC (permalink / raw)
  To: ltp

Hi,

...
> -static inline int tst_dev_sync(int fd)
> -{
> -	return syscall(__NR_syncfs, fd);
> -}
> +static int tst_dev_sync(int fd);
This is obviously wrong.

> diff --git a/lib/tst_device.c b/lib/tst_device.c
...
> +static int tst_dev_sync(int fd)
And here as well.
> +{
> +	return syscall(__NR_syncfs, fd);
> +}

Sorry for wrong patch.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 2/2] tst_device: Move tst_dev_sync() into from header to source file
  2020-01-20 13:52   ` Petr Vorel
@ 2020-01-20 13:55     ` Cyril Hrubis
  2020-01-20 14:05       ` Petr Vorel
  0 siblings, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2020-01-20 13:55 UTC (permalink / raw)
  To: ltp

Hi!
> 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.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 2/2] tst_device: Move tst_dev_sync() into from header to source file
  2020-01-20 13:55     ` Cyril Hrubis
@ 2020-01-20 14:05       ` Petr Vorel
  0 siblings, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2020-01-20 14:05 UTC (permalink / raw)
  To: ltp

Hi,

> 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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [LTP] [PATCH 1/2] socketcall01: Use tst_syscall() instead of custom syscall support detection
  2020-01-20 13:36 [LTP] [PATCH 1/2] socketcall01: Use tst_syscall() instead of custom syscall support detection Petr Vorel
  2020-01-20 13:36 ` [LTP] [PATCH 2/2] tst_device: Move tst_dev_sync() into from header to source file Petr Vorel
@ 2020-01-20 19:10 ` Petr Vorel
  1 sibling, 0 replies; 6+ messages in thread
From: Petr Vorel @ 2020-01-20 19:10 UTC (permalink / raw)
  To: ltp

Hi,

slightly modified version of this one merged after release.
Thanks a lot to all for review.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-01-20 19:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-20 13:36 [LTP] [PATCH 1/2] socketcall01: Use tst_syscall() instead of custom syscall support detection Petr Vorel
2020-01-20 13:36 ` [LTP] [PATCH 2/2] tst_device: Move tst_dev_sync() into from header to source file Petr Vorel
2020-01-20 13:52   ` Petr Vorel
2020-01-20 13:55     ` Cyril Hrubis
2020-01-20 14:05       ` Petr Vorel
2020-01-20 19:10 ` [LTP] [PATCH 1/2] socketcall01: Use tst_syscall() instead of custom syscall support detection Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.