Skip to content

Commit

Permalink
socketcall01: Use tst_syscall() instead of custom syscall support det…
Browse files Browse the repository at this point in the history
…ection

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: 9e83513 "tst_device.h: Use lapi/syscalls.h instead of <sys/syscall.h>"
Fixes: linux-test-project#634

Suggested-by: Cyril Hrubis <chrubis@suse.cz>
Signed-off-by: Petr Vorel <pvorel@suse.cz>
  • Loading branch information
pevik committed Jan 20, 2020
1 parent 185a54d commit a091f4c
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions testcases/kernel/syscalls/socketcall/socketcall01.c
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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;
Expand All @@ -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",
Expand All @@ -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

0 comments on commit a091f4c

Please sign in to comment.