Skip to content

Commit f5e20e9

Browse files
authored
Merge pull request #108 from CESNET/github-actions-freebsd
Add FreeBSD into CI, fix minor FreeBSD build issues
2 parents b26fda4 + 099bc27 commit f5e20e9

File tree

7 files changed

+127
-2
lines changed

7 files changed

+127
-2
lines changed

.github/workflows/freebsd.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build and tests (FreeBSD)
2+
3+
on:
4+
# Ignore changes in extra plugins (as they are not tested here)
5+
push:
6+
paths-ignore:
7+
- 'extra_plugins/**'
8+
pull_request:
9+
paths-ignore:
10+
- 'extra_plugins/**'
11+
12+
jobs:
13+
test:
14+
runs-on: ubuntu-latest
15+
name: Build and run tests on FreeBSD
16+
steps:
17+
- uses: actions/checkout@v4
18+
- name: Build on FreeBSD 14.2
19+
uses: vmactions/freebsd-vm@v1
20+
with:
21+
release: "14.2"
22+
usesh: true
23+
run: |
24+
set -euox pipefail
25+
26+
# install dependencies
27+
pkg install -y \
28+
git \
29+
devel/cmake-core \
30+
devel/ninja \
31+
devel/pkgconf \
32+
textproc/py-docutils \
33+
archivers/liblz4 \
34+
archivers/zstd \
35+
textproc/libxml2 \
36+
net/librdkafka \
37+
devel/libepoll-shim
38+
39+
# clone libfds
40+
git clone --branch master https://github.com/CESNET/libfds.git libfds_build
41+
42+
# build libfds
43+
cd libfds_build
44+
mkdir build
45+
cd build
46+
cmake .. -DCMAKE_INSTALL_PREFIX=/usr
47+
make
48+
make install
49+
cd ../..
50+
51+
# build ipfixcol2
52+
mkdir build
53+
cd build
54+
cmake .. -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=1
55+
make
56+
make install
57+
58+
# run ipfixcol2 tests
59+
make test
60+
61+
# try to run ipfixcol2
62+
ipfixcol2 -V
63+
ipfixcol2 -h
64+
ipfixcol2 -L -v

CMakeModules/FindLibLz4.cmake

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# LIBLZ4_FOUND - System has LZ4
2+
# LIBLZ4_INCLUDE_DIRS - The LZ4 include directories
3+
# LIBLZ4_LIBRARIES - The libraries needed to use LZ4
4+
5+
find_path(
6+
LZ4_INCLUDE_DIR lz4.h
7+
PATH_SUFFIXES include
8+
)
9+
10+
find_library(
11+
LZ4_LIBRARY
12+
NAMES lz4 liblz4
13+
PATH_SUFFIXES lib lib64
14+
)
15+
16+
set(LZ4_HEADER_FILE "${LZ4_INCLUDE_DIR}/lz4.h")
17+
if (LZ4_INCLUDE_DIR AND EXISTS ${LZ4_HEADER_FILE})
18+
# Try to extract library version from the header file
19+
file(STRINGS ${LZ4_HEADER_FILE} lz4_major_define
20+
REGEX "^#define[\t ]+LZ4_VERSION_MAJOR[\t ]+[0-9]+"
21+
LIMIT_COUNT 1
22+
)
23+
file(STRINGS ${LZ4_HEADER_FILE} lz4_minor_define
24+
REGEX "^#define[\t ]+LZ4_VERSION_MINOR[\t ]+[0-9]+"
25+
LIMIT_COUNT 1
26+
)
27+
file(STRINGS ${LZ4_HEADER_FILE} lz4_release_define
28+
REGEX "^#define[\t ]+LZ4_VERSION_RELEASE[\t ]+[0-9]+"
29+
LIMIT_COUNT 1
30+
)
31+
32+
string(REGEX REPLACE "^#define[\t ]+LZ4_VERSION_MAJOR[\t ]+([0-9]+).*" "\\1"
33+
lz4_major_num ${lz4_major_define})
34+
string(REGEX REPLACE "^#define[\t ]+LZ4_VERSION_MINOR[\t ]+([0-9]+).*" "\\1"
35+
lz4_minor_num ${lz4_minor_define})
36+
string(REGEX REPLACE "^#define[\t ]+LZ4_VERSION_RELEASE[\t ]+([0-9]+).*" "\\1"
37+
lz4_release_num ${lz4_release_define})
38+
39+
set(LZ4_VERSION_STRING "${lz4_major_num}.${lz4_minor_num}.${lz4_release_num}")
40+
endif()
41+
unset(LZ4_HEADER_FILE)
42+
43+
# Handle the REQUIRED arguments and set LIBLZ4_FOUND to TRUE if all listed
44+
# variables are TRUE
45+
include(FindPackageHandleStandardArgs)
46+
find_package_handle_standard_args(LibLz4
47+
REQUIRED_VARS LZ4_LIBRARY LZ4_INCLUDE_DIR
48+
VERSION_VAR LZ4_VERSION_STRING
49+
)
50+
51+
set(LIBLZ4_LIBRARIES ${LZ4_LIBRARY})
52+
set(LIBLZ4_INCLUDE_DIRS ${LZ4_INCLUDE_DIR})
53+
mark_as_advanced(LZ4_INCLUDE_DIR LZ4_LIBRARY)

src/plugins/input/tcp/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ add_library(tcp-input MODULE
1515
src/IpxPlugin.cpp
1616
)
1717

18+
find_package(LibLz4 REQUIRED)
19+
include_directories(${LIBLZ4_INCLUDE_DIRS})
20+
target_link_libraries(tcp-input ${LIBLZ4_LIBRARIES})
21+
1822
if (CMAKE_HOST_SYSTEM_NAME STREQUAL "FreeBSD" OR CMAKE_HOST_SYSTEM_NAME STREQUAL "OpenBSD")
1923
find_package(LibEpollShim REQUIRED)
2024
include_directories(

src/plugins/input/tcp/src/Epoll.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
#include <cerrno> // errno, EINTR
1515
#include <string> // string
1616

17-
#include <sys/epoll.h> // epoll_event, epoll_create, EPOLLIN, EPOLL_CT_ADD, epoll_ctl, EPOLL_CTL_DEL
18-
1917
#include <ipfixcol2.h> // ipx_strerror
2018

2119
#include "UniqueFd.hpp" // UniqueFd

src/plugins/input/tcp/src/Epoll.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
#pragma once
1212

1313
#include <sys/epoll.h> // epoll_event
14+
#undef close // fix FreeBSD build: (tcp_in::Connection has own close(),
15+
// but preprocesor changes it for epoll_shim_close())
1416

1517
#include "UniqueFd.hpp" // UniqueFd
1618

tests/unit/core/netflow/tools/MsgGen.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include <stdexcept>
55
#include <iomanip>
66
#include <iostream>
7+
#include <netinet/in.h>
8+
#include <sys/socket.h>
79

810
#include <core/netflow2ipfix/netflow_structs.h>
911

tests/unit/core/parser/tools/MsgGen.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <libfds/ipfix_structs.h>
1010
#include <iomanip>
1111
#include <iostream>
12+
#include <netinet/in.h>
13+
#include <sys/socket.h>
1214

1315

1416
#include "MsgGen.h"

0 commit comments

Comments
 (0)