1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 2f08c3bdfSopenharmony_ci/* 3f08c3bdfSopenharmony_ci * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved. 4f08c3bdfSopenharmony_ci * Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz> 5f08c3bdfSopenharmony_ci * Copyright (c) Linux Test Project, 2017-2020 6f08c3bdfSopenharmony_ci * Author: Sowmya Adiga <sowmya.adiga@wipro.com> 7f08c3bdfSopenharmony_ci * 8f08c3bdfSopenharmony_ci * This is a basic test for the socketcall(2) system call. 9f08c3bdfSopenharmony_ci */ 10f08c3bdfSopenharmony_ci 11f08c3bdfSopenharmony_ci#include <unistd.h> 12f08c3bdfSopenharmony_ci#include <errno.h> 13f08c3bdfSopenharmony_ci#include <sys/types.h> 14f08c3bdfSopenharmony_ci#include <sys/socket.h> 15f08c3bdfSopenharmony_ci#include <linux/net.h> 16f08c3bdfSopenharmony_ci#include <sys/un.h> 17f08c3bdfSopenharmony_ci#include <netinet/in.h> 18f08c3bdfSopenharmony_ci 19f08c3bdfSopenharmony_ci#include "tst_test.h" 20f08c3bdfSopenharmony_ci#include "lapi/syscalls.h" 21f08c3bdfSopenharmony_ci 22f08c3bdfSopenharmony_cistruct test_case_t { 23f08c3bdfSopenharmony_ci int call; 24f08c3bdfSopenharmony_ci unsigned long args[3]; 25f08c3bdfSopenharmony_ci char *desc; 26f08c3bdfSopenharmony_ci} TC[] = { 27f08c3bdfSopenharmony_ci {SYS_SOCKET, {PF_INET, SOCK_STREAM, 0}, "TCP stream"}, 28f08c3bdfSopenharmony_ci {SYS_SOCKET, {PF_UNIX, SOCK_DGRAM, 0}, "unix domain dgram"}, 29f08c3bdfSopenharmony_ci {SYS_SOCKET, {AF_INET, SOCK_RAW, 6}, "Raw socket"}, 30f08c3bdfSopenharmony_ci {SYS_SOCKET, {PF_INET, SOCK_DGRAM, 17}, "UDP dgram"} 31f08c3bdfSopenharmony_ci}; 32f08c3bdfSopenharmony_ci 33f08c3bdfSopenharmony_civoid verify_socketcall(unsigned int i) 34f08c3bdfSopenharmony_ci{ 35f08c3bdfSopenharmony_ci TEST(tst_syscall(__NR_socketcall, TC[i].call, TC[i].args)); 36f08c3bdfSopenharmony_ci 37f08c3bdfSopenharmony_ci if (TST_RET < 0) { 38f08c3bdfSopenharmony_ci tst_res(TFAIL | TTERRNO, "socketcall() for %s failed with %li", 39f08c3bdfSopenharmony_ci TC[i].desc, TST_RET); 40f08c3bdfSopenharmony_ci return; 41f08c3bdfSopenharmony_ci } 42f08c3bdfSopenharmony_ci 43f08c3bdfSopenharmony_ci tst_res(TPASS, "socketcall() for %s", TC[i].desc); 44f08c3bdfSopenharmony_ci 45f08c3bdfSopenharmony_ci SAFE_CLOSE(TST_RET); 46f08c3bdfSopenharmony_ci} 47f08c3bdfSopenharmony_ci 48f08c3bdfSopenharmony_cistatic struct tst_test test = { 49f08c3bdfSopenharmony_ci .test = verify_socketcall, 50f08c3bdfSopenharmony_ci .tcnt = ARRAY_SIZE(TC), 51f08c3bdfSopenharmony_ci .needs_root = 1, 52f08c3bdfSopenharmony_ci}; 53