Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freebsd workflow #2002

Merged
merged 6 commits into from
Dec 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions .github/workflows/freebsd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: freebsd

on:
push:
paths-ignore: ["docs/**", "**.adoc", "**.md"]
pull_request:
paths-ignore: ["docs/**", "**.adoc", "**.md"]

jobs:
test:
runs-on: ubuntu-latest
name: NNG test on FreeBSD via Qemu
env:
NNG_UDP_PASS_RATE: 10
steps:
- uses: actions/checkout@v4
- name: Test NNG in FreeBSD
id: test
uses: vmactions/freebsd-vm@v1
with:
usesh: true
envs: NNG_UDP_PASS_RATE
prepare: |
pkg install -y lang/gcc
pkg install -y devel/cmake
pkg install -y devel/ninja
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Debug -G Ninja -DNNG_TOOLS=OFF ..
ninja
ctest --output-on-failure
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Linux Status](https://img.shields.io/github/actions/workflow/status/nanomsg/nng/linux.yml?branch=main&logoColor=grey&logo=ubuntu&label=)](https://github.com/nanomsg/nng/actions)
[![Windows Status](https://img.shields.io/github/actions/workflow/status/nanomsg/nng/windows.yml?branch=main&logoColor=grey&logo=data:image/svg%2bxml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA0ODc1IDQ4NzUiPjxwYXRoIGZpbGw9ImdyZXkiIGQ9Ik0wIDBoMjMxMXYyMzEwSDB6bTI1NjQgMGgyMzExdjIzMTBIMjU2NHpNMCAyNTY0aDIzMTF2MjMxMUgwem0yNTY0IDBoMjMxMXYyMzExSDI1NjQiLz48L3N2Zz4=&label=)](https://github.com/nanomsg/nng/actions)
[![macOS Status](https://img.shields.io/github/actions/workflow/status/nanomsg/nng/darwin.yml?branch=main&logoColor=grey&logo=apple&label=)](https://github.com/nanomsg/nng/actions)
[![FreeBSD Status](https://img.shields.io/github/actions/workflow/status/nanomsg/nng/freebsd.yml?branch=main&logoColor=grey&logo=freebsd&label=)](https://github.com/nanomsg/nng/actions)
[![Coverage](https://img.shields.io/codecov/c/github/nanomsg/nng/branch/main?logo=codecov&logoColor=grey&label=)](https://codecov.io/gh/nanomsg/nng/tree/main)
[![Discord](https://img.shields.io/discord/639573728212156478?label=&logo=discord)](https://discord.gg/Xnac6b9)
[![Manual](https://img.shields.io/static/v1?label=&message=docs&logo=asciidoctor&logoColor=silver&color=blue)](https://nng.nanomsg.org/man)
Expand Down
6 changes: 3 additions & 3 deletions src/platform/files_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ test_permissions(void)
char *file;
void *data;
size_t n;
temp = nni_plat_temp_dir();
NUTS_TRUE(temp != NULL);
file = nni_file_join(temp, "nng_files_perms_test");
if (geteuid() == 0) {
NUTS_SKIP("Cannot test permissions as root");
return;
}
temp = nni_plat_temp_dir();
NUTS_TRUE(temp != NULL);
file = nni_file_join(temp, "nng_files_perms_test");
NUTS_PASS(nni_file_put(file, "abc", 4));
chmod(file, 0);
NUTS_FAIL(nni_file_get(file, &data, &n), NNG_EPERM);
Expand Down
1 change: 1 addition & 0 deletions src/platform/posix/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ if (NNG_PLATFORM_POSIX)
nng_check_sym(atomic_flag_test_and_set stdatomic.h NNG_HAVE_STDATOMIC)
nng_check_sym(socketpair sys/socket.h NNG_HAVE_SOCKETPAIR)
nng_check_sym(AF_INET6 netinet/in.h NNG_HAVE_INET6)
nng_check_sym(AF_INET6 netinet6/in6.h NNG_HAVE_INET6_BSD)
nng_check_sym(timespec_get time.h NNG_HAVE_TIMESPEC_GET)
nng_check_sym(getentropy sys/random.h NNG_HAVE_SYS_RANDOM)

Expand Down
5 changes: 5 additions & 0 deletions src/platform/posix/posix_resolv_gai.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,13 @@
#endif

#ifndef NNG_HAVE_INET6
#ifdef HAVE_NNG_HAVE_INET6_BSD
#define NNG_HAVE_INET6
#include <netinet6/in6.h>
#else
#undef NNG_ENABLE_IPV6
#endif
#endif

static nni_mtx resolv_mtx = NNI_MTX_INITIALIZER;
static nni_cv resolv_cv = NNI_CV_INITIALIZER(&resolv_mtx);
Expand Down
5 changes: 5 additions & 0 deletions src/platform/posix/posix_sockaddr.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@
#include <sys/un.h>

#ifndef NNG_HAVE_INET6
#ifdef HAVE_NNG_HAVE_INET6_BSD
#define NNG_HAVE_INET6
#include <netinet6/in6.h>
#else
#undef NNG_ENABLE_IPV6
#endif
#endif

size_t
nni_posix_nn2sockaddr(void *sa, const nni_sockaddr *na)
Expand Down
5 changes: 5 additions & 0 deletions src/platform/posix/posix_tcpdial.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,13 @@
#include "posix_tcp.h"

#ifndef NNG_HAVE_INET6
#ifdef HAVE_NNG_HAVE_INET6_BSD
#define NNG_HAVE_INET6
#include <netinet6/in6.h>
#else
#undef NNG_ENABLE_IPV6
#endif
#endif

// Dialer stuff.
int
Expand Down
5 changes: 5 additions & 0 deletions src/platform/posix/posix_tcplisten.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@
#endif

#ifndef NNG_HAVE_INET6
#ifdef HAVE_NNG_HAVE_INET6_BSD
#define NNG_HAVE_INET6
#include <netinet6/in6.h>
#else
#undef NNG_ENABLE_IPV6
#endif
#endif

#include "posix_tcp.h"

Expand Down
18 changes: 17 additions & 1 deletion src/platform/posix/posix_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,13 @@
#endif

#ifndef NNG_HAVE_INET6
#ifdef HAVE_NNG_HAVE_INET6_BSD
#define NNG_HAVE_INET6
#include <netinet6/in6.h>
#else
#undef NNG_ENABLE_IPV6
#endif
#endif

// Linux has IPV6_ADD_MEMBERSHIP and IPV6_DROP_MEMBERSHIP
#ifndef IPV6_JOIN_GROUP
Expand Down Expand Up @@ -215,9 +220,20 @@ nni_plat_udp_open(nni_plat_udp **upp, nni_sockaddr *bindaddr)
struct sockaddr_storage sa;
int rv;

if ((salen = nni_posix_nn2sockaddr(&sa, bindaddr)) < 1) {
if (bindaddr == NULL) {
return (NNG_EADDRINVAL);
}
switch (bindaddr->s_family) {
case NNG_AF_INET:
#ifdef NNG_ENABLE_IPV6
case NNG_AF_INET6:
#endif
break;
default:
return (NNG_EADDRINVAL);
}
salen = nni_posix_nn2sockaddr(&sa, bindaddr);
NNI_ASSERT(salen > 1);

// UDP opens can actually run synchronously.
if ((udp = NNI_ALLOC_STRUCT(udp)) == NULL) {
Expand Down
1 change: 1 addition & 0 deletions src/platform/udp_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ test_udp_bogus_bind(void)
// Some platforms reject IPC addresses altogether (Windows),
// whereas others just say it's not supported with UDP.
NUTS_ASSERT((rv == NNG_ENOTSUP) || (rv == NNG_EADDRINVAL));
NUTS_MSG("Result was %d %s", rv, nng_strerror(rv));

// NULL address also bad.
NUTS_FAIL(nng_udp_open(&u, NULL), NNG_EADDRINVAL);
Expand Down
Loading