build: add CI for OpenBSD and FreeBSD (#3548)

Fixes: https://github.com/libuv/libuv/issues/3510
This commit is contained in:
James McCoy 2023-01-21 07:52:36 -05:00 committed by GitHub
parent 67063ead60
commit 2638237e1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 73 additions and 17 deletions

View File

@ -150,3 +150,36 @@ jobs:
- name: Test
run: |
${{ matrix.config.qemu }} build/uv_run_tests_a
build-bsd:
timeout-minutes: 30
runs-on: ${{ matrix.config.runner }}
name: build-${{ matrix.config.os }}-${{ matrix.config.version }}
strategy:
fail-fast: false
matrix:
config:
# The OS versions supported are specific to the version of the action
# https://github.com/cross-platform-actions/action/blob/master/changelog.md
- { os: freebsd, version: '13.1', runner: 'ubuntu-latest', install: 'pkg install -y' }
- { os: openbsd, version: '7.2', runner: 'macos-11', install: 'pkg_add -I' }
steps:
- uses: actions/checkout@v2
- uses: cross-platform-actions/action@v0.9.0
with:
operating_system: ${{ matrix.config.os }}
version: ${{ matrix.config.version }}
run: |
sudo ${{ matrix.config.install }} cmake ninja
sudo hostname -s ci-host
mkdir build
cd build
cmake .. -DBUILD_TESTING=ON -G Ninja
cmake --build .
ls -lh
./uv_run_tests platform_output
./uv_run_tests_a platform_output
ctest -V

View File

@ -72,8 +72,8 @@ extern char** environ;
# include <sys/filio.h>
# include <sys/wait.h>
# include <sys/param.h>
# include <sys/cpuset.h>
# if defined(__FreeBSD__)
# include <sys/cpuset.h>
# define uv__accept4 accept4
# endif
# if defined(__NetBSD__)
@ -1490,7 +1490,7 @@ uv_pid_t uv_os_getppid(void) {
}
int uv_cpumask_size(void) {
#if defined(__linux__) || defined(__FreeBSD__)
#if UV__CPU_AFFINITY_SUPPORTED
return CPU_SETSIZE;
#else
return UV_ENOTSUP;

View File

@ -425,5 +425,10 @@ uv__fs_copy_file_range(int fd_in,
unsigned int flags);
#endif
#if defined(__linux__) || (defined(__FreeBSD__) && __FreeBSD_version >= 1301000)
#define UV__CPU_AFFINITY_SUPPORTED 1
#else
#define UV__CPU_AFFINITY_SUPPORTED 0
#endif
#endif /* UV_UNIX_INTERNAL_H_ */

View File

@ -295,7 +295,7 @@ int uv_thread_create_ex(uv_thread_t* tid,
return UV__ERR(err);
}
#if defined(__linux__) || defined(__FreeBSD__)
#if UV__CPU_AFFINITY_SUPPORTED
int uv_thread_setaffinity(uv_thread_t* tid,
char* cpumask,
@ -383,7 +383,7 @@ int uv_thread_getaffinity(uv_thread_t* tid,
#endif /* defined(__linux__) || defined(UV_BSD_H) */
int uv_thread_getcpu(void) {
#if defined(__linux__) || defined(__FreeBSD__)
#if UV__CPU_AFFINITY_SUPPORTED
int cpu;
cpu = sched_getcpu();

View File

@ -371,7 +371,7 @@ UNUSED static int can_ipv6(void) {
#endif
#if !defined(__linux__) && \
!defined(__FreeBSD__) && \
!(defined(__FreeBSD__) && __FreeBSD_version >= 1301000) && \
!defined(_WIN32)
# define NO_CPU_AFFINITY \
"affinity not supported on this platform."

View File

@ -2788,8 +2788,8 @@ TEST_IMPL(fs_lutime) {
loop = uv_default_loop();
unlink(path);
r = uv_fs_open(NULL, &req, path, O_RDWR | O_CREAT, S_IWUSR | S_IRUSR, NULL);
ASSERT(r >= 0);
ASSERT(req.result >= 0);
ASSERT_GE(r, 0);
ASSERT_GE(req.result, 0);
uv_fs_req_cleanup(&req);
uv_fs_close(loop, &req, r, NULL);
@ -2805,8 +2805,8 @@ TEST_IMPL(fs_lutime) {
"Symlink creation requires elevated console (with admin rights)");
}
#endif
ASSERT(s == 0);
ASSERT(req.result == 0);
ASSERT_EQ(s, 0);
ASSERT_EQ(req.result, 0);
uv_fs_req_cleanup(&req);
/* Test the synchronous version. */
@ -2820,12 +2820,12 @@ TEST_IMPL(fs_lutime) {
r = uv_fs_lutime(NULL, &req, symlink_path, atime, mtime, NULL);
#if (defined(_AIX) && !defined(_AIX71)) || \
defined(__MVS__)
ASSERT(r == UV_ENOSYS);
ASSERT_EQ(r, UV_ENOSYS);
RETURN_SKIP("lutime is not implemented for z/OS and AIX versions below 7.1");
#endif
ASSERT(r == 0);
ASSERT_EQ(r, 0);
lutime_cb(&req);
ASSERT(lutime_cb_count == 1);
ASSERT_EQ(lutime_cb_count, 1);
/* Test the asynchronous version. */
atime = mtime = 1291404900; /* 2010-12-03 20:35:00 */
@ -2835,9 +2835,9 @@ TEST_IMPL(fs_lutime) {
checkme.path = symlink_path;
r = uv_fs_lutime(loop, &req, symlink_path, atime, mtime, lutime_cb);
ASSERT(r == 0);
ASSERT_EQ(r, 0);
uv_run(loop, UV_RUN_DEFAULT);
ASSERT(lutime_cb_count == 2);
ASSERT_EQ(lutime_cb_count, 2);
/* Cleanup. */
unlink(path);

View File

@ -35,6 +35,9 @@ TEST_IMPL(get_currentexe) {
#if defined(__QEMU__)
RETURN_SKIP("Test does not currently work in QEMU");
#endif
#if defined(__OpenBSD__)
RETURN_SKIP("Test does not currently work in OpenBSD");
#endif
char buffer[PATHMAX];
char path[PATHMAX];

View File

@ -43,7 +43,7 @@ TEST_IMPL(gethostname) {
enobufs_size = 1;
buf[0] = '\0';
r = uv_os_gethostname(buf, &enobufs_size);
ASSERT(r == UV_ENOBUFS);
ASSERT_EQ(r, UV_ENOBUFS);
ASSERT(buf[0] == '\0');
ASSERT(enobufs_size > 1);

View File

@ -47,6 +47,9 @@ static void timer_spin_cb(uv_timer_t* handle) {
TEST_IMPL(metrics_idle_time) {
#if defined(__OpenBSD__)
RETURN_SKIP("Test does not currently work in OpenBSD");
#endif
const uint64_t timeout = 1000;
uv_timer_t timer;
uint64_t idle_time;
@ -65,8 +68,8 @@ TEST_IMPL(metrics_idle_time) {
idle_time = uv_metrics_idle_time(uv_default_loop());
/* Permissive check that the idle time matches within the timeout ±500 ms. */
ASSERT((idle_time <= (timeout + 500) * UV_NS_TO_MS) &&
(idle_time >= (timeout - 500) * UV_NS_TO_MS));
ASSERT_LE(idle_time, (timeout + 500) * UV_NS_TO_MS);
ASSERT_GE(idle_time, (timeout - 500) * UV_NS_TO_MS);
MAKE_VALGRIND_HAPPY();
return 0;

View File

@ -76,6 +76,9 @@ static void connect_cb(uv_connect_t *req, int status) {
* RST. Test checks that uv_guess_handle still works on a reset TCP handle.
*/
TEST_IMPL(tcp_rst) {
#if defined(__OpenBSD__)
RETURN_SKIP("Test does not currently work in OpenBSD");
#endif
#ifndef _WIN32
struct sockaddr_in server_addr;
int r;

View File

@ -98,6 +98,9 @@ static void sv_recv_cb(uv_udp_t* handle,
TEST_IMPL(udp_connect) {
#if defined(__OpenBSD__)
RETURN_SKIP("Test does not currently work in OpenBSD");
#endif
uv_udp_send_t req;
struct sockaddr_in ext_addr;
struct sockaddr_in tmp_addr;

View File

@ -98,6 +98,9 @@ static void sv_recv_cb(uv_udp_t* handle,
TEST_IMPL(udp_connect6) {
#if defined(__OpenBSD__)
RETURN_SKIP("Test does not currently work in OpenBSD");
#endif
uv_udp_send_t req;
struct sockaddr_in6 ext_addr;
struct sockaddr_in6 tmp_addr;

View File

@ -138,6 +138,9 @@ static void cl_recv_cb(uv_udp_t* handle,
TEST_IMPL(udp_multicast_join) {
#if defined(__OpenBSD__)
RETURN_SKIP("Test does not currently work in OpenBSD");
#endif
int r;
struct sockaddr_in addr;