From nobody Mon Nov 20 22:37:19 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SZ2Sb3p6Zz51CLt; Mon, 20 Nov 2023 22:37:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SZ2Sb3JFKz4MpZ; Mon, 20 Nov 2023 22:37:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700519839; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3ylFFmRZZk7nNhSsB9t0990KdYQJ9UVUdxfMgxWU9q0=; b=Px1aK6AMW0FQUzFP6HVzkt5VeYUhCFhyPSiP6VAdE6zNmQO55d0xOd5jCepw6Jh3YfIBhD qM+fJSbBwxdg4KFM8RYYjqfs8TWSA2sqcxphkVMsavkX2EBg0hZdy8zqWN0HRwR1gAkRNN fvPQWfyvzwJwqaKVViSYtpKOP6+HJQDkRimcOAVDZzabOl5tp+AsaTVBUsfZZp3ULTdPNV vOvNf9FZgfcCE5e0Yrp7JbVRoASzLZFk96c1GYB/c1fA1yeyMegUwP18fCTJ7uj4oUbv2t FQxqVaZsHVKuLwgK/RU4l0XL27UXgBG4kFqLtAYLe/tuipbtDKiNhr4MsZZXqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700519839; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3ylFFmRZZk7nNhSsB9t0990KdYQJ9UVUdxfMgxWU9q0=; b=acznmg2hOXyZ7oY6xdzf99GsLpGo7Tc7jj/IN+3K5YagDr/3cOKJZpQdjuz1IbBfwTgTN5 rBczHfOsdkGPjcgqciSAAvGw1amf/g5RswY7V78JrYmxDnL45f+Zq+JkrX4wKSUt7A35+z lcSJ07423TynI3Di6uDwtcMDTDuz8ro4dDxEU8mD1DucJKLLZCva0Tsd7vX7jqgppP8DgW 1+6Qq4sHoX18t7FGWjz/de9TRVJ+o9Mbx//PbWuRfaPUz5n2vbpsi1EOgpOakbUESk3nUd X6HlugS/uNNpCWR2Hg03FuZaW6HwM/5oKkzc7V+5nisTQvX3F7Wf27akx/oj3Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700519839; a=rsa-sha256; cv=none; b=iSoTgThsT0tEqqP48Y9l8vWijwrXde9LxTICyIMbk+L4ceuaa10/LLySSKian9aCJKkHoN Z6JplPS0v6zX0P7+nAiXiHixUhUqzaD6eNzp+BCboyOXmJkMmM1LdWupIwLruWzCkhqBjg C3qw5Cv6CCqhcmp5k+slzFZCdStia8vZri31VqGEatSSGx6WYftTnb3M9pIRvJbIiTlwXo 3HZ8naGxPIm9XJ6aT2PeXrqFLoFrH55AlQVP6Zqq7p/pj6jm6Z/lsWmgVRWp6AZV6eNr4D 7buUipYbrac+9TqB/Qei7Dg7J3ga35tVKI9KdgL9zibb2wBkTdIsiqHljbG+RA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SZ2Sb2MNCz18Gd; Mon, 20 Nov 2023 22:37:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AKMbJ8f041368; Mon, 20 Nov 2023 22:37:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AKMbJDv041365; Mon, 20 Nov 2023 22:37:19 GMT (envelope-from git) Date: Mon, 20 Nov 2023 22:37:19 GMT Message-Id: <202311202237.3AKMbJDv041365@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 367e8adb4be9 - main - tests/netgraph: start ng_socket test suite List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 367e8adb4be91ca3c0d40c085eaf47467d0ad25d Auto-Submitted: auto-generated The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=367e8adb4be91ca3c0d40c085eaf47467d0ad25d commit 367e8adb4be91ca3c0d40c085eaf47467d0ad25d Author: Gleb Smirnoff AuthorDate: 2023-11-20 22:36:58 +0000 Commit: Gleb Smirnoff CommitDate: 2023-11-20 22:36:58 +0000 tests/netgraph: start ng_socket test suite Just one check now, check node name. --- tests/sys/netgraph/Makefile | 2 ++ tests/sys/netgraph/socket.c | 69 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) diff --git a/tests/sys/netgraph/Makefile b/tests/sys/netgraph/Makefile index 74e4046482ef..8bf91c68ad6b 100644 --- a/tests/sys/netgraph/Makefile +++ b/tests/sys/netgraph/Makefile @@ -14,11 +14,13 @@ TEST_METADATA.ng_macfilter_test+= required_programs="perl" ATF_TESTS_C+= basic \ bridge \ hub \ + socket \ vlan_rotate \ SRCS.basic= basic.c util.c SRCS.bridge= bridge.c util.c SRCS.hub= hub.c util.c +SRCS.socket= socket.c SRCS.vlan_rotate=vlan_rotate.c util.c LIBADD+= netgraph diff --git a/tests/sys/netgraph/socket.c b/tests/sys/netgraph/socket.c new file mode 100644 index 000000000000..b5216dcc2c39 --- /dev/null +++ b/tests/sys/netgraph/socket.c @@ -0,0 +1,69 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2023 Gleb Smirnoff + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#include +#include +#include + +#include + +#include + +ATF_TC_WITHOUT_HEAD(getsockname); +ATF_TC_BODY(getsockname, tc) +{ + struct sockaddr_ng sg; + socklen_t len = sizeof(struct sockaddr_ng); +#define NAME "0123456789012345678901234567891" /* 31 chars */ + char name[NG_NODESIZ] = NAME; + int cs; + +#if 0 + /* Unnamed node. */ + ATF_REQUIRE(NgMkSockNode(NULL, &cs, NULL) == 0); + ATF_REQUIRE(getsockname(cs, (struct sockaddr *)&sg, &len) == 0); + close(cs); + /* Unnamed node doesn't return any name/ID now. */ +#endif + + /* Named node. */ + ATF_REQUIRE(NgMkSockNode(name, &cs, NULL) == 0); + ATF_REQUIRE(getsockname(cs, (struct sockaddr *)&sg, &len) == 0); +#if 0 + /* sockaddr_ng truncates name now. */ + ATF_REQUIRE(strcmp(sg.sg_data, NAME) == 0); +#else + ATF_REQUIRE(strncmp(sg.sg_data, NAME, sizeof(sg.sg_data)) == 0); +#endif +} + +ATF_TP_ADD_TCS(tp) +{ + ATF_TP_ADD_TC(tp, getsockname); + + return (atf_no_error()); +}