Skip to content

Commit

Permalink
Fix existing workflows
Browse files Browse the repository at this point in the history
Signed-off-by: Ioannis Konstantelias <ikonstadel@gmail.com>
  • Loading branch information
gon1332 committed Feb 8, 2025
1 parent a1673f1 commit 8b4df11
Show file tree
Hide file tree
Showing 14 changed files with 181 additions and 134 deletions.
35 changes: 14 additions & 21 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Install dependencies
run: sudo apt install cmake ninja-build
run: sudo apt install cmake ninja-build libsnmp-dev
- uses: actions/checkout@v4
- name: Build on Ubuntu
run: |
Expand All @@ -21,30 +21,25 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Build on OpenBSD, x86-64, 7.4
uses: cross-platform-actions/action@v0.25.0
env:
AUTOCONF_VERSION: 2.71
AUTOMAKE_VERSION: 1.16
uses: cross-platform-actions/action@v0.27.0
with:
operating_system: openbsd
architecture: x86-64
version: '7.4'
memory: 4G
sync_files: runner-to-vm
environment_variables: AUTOCONF_VERSION AUTOMAKE_VERSION
shell: bash
run: |
sudo pkg_add autoconf-$AUTOCONF_VERSION automake-$AUTOMAKE_VERSION.5 libtool
autoreconf -vfi
./configure
make
sudo pkg_add cmake ninja
cmake --preset package
cmake --build --preset package
freebsd:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build on FreeBSD
uses: cross-platform-actions/action@v0.25.0
uses: cross-platform-actions/action@v0.27.0
with:
operating_system: freebsd
architecture: x86-64
Expand All @@ -53,17 +48,16 @@ jobs:
sync_files: runner-to-vm
shell: bash
run: |
sudo pkg install -y autoconf automake libtool
autoreconf -vfi
./configure
make
sudo pkg install -y cmake ninja
cmake --preset package
cmake --build --preset package
netbsd:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build on NetBSD
uses: cross-platform-actions/action@v0.25.0
uses: cross-platform-actions/action@v0.27.0
with:
operating_system: netbsd
architecture: x86-64
Expand All @@ -72,16 +66,15 @@ jobs:
sync_files: runner-to-vm
shell: bash
run: |
sudo pkgin -y install autoconf automake libtool
autoreconf -vfi
./configure
make
sudo pkgin -y install cmake ninja-build
cmake --preset package
cmake --build --preset package
macos:
runs-on: macos-latest
steps:
- name: Install dependencies
run: sudo apt install cmake ninja-build
run: brew install cmake ninja net-snmp
- uses: actions/checkout@v4
- name: Build on macOS
run: |
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/system_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Run docker-compose
uses: hoverkraft-tech/compose-action@v2.0.1
with:
up-flags: "-d"

- name: Execute tests in the running services
- name: Execute tests
run: |
docker compose up -d
./scripts/wait_for.sh 'docker logs ptpd-slave 2>&1 | grep -q "(slv) Received Peer Delay Interval"' 120
21 changes: 6 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,19 @@
cmake_minimum_required(VERSION 3.21)
project(ptpd LANGUAGES C ASM)

option(STATISTICS "Enable statistics" ON)
option(SNMP "Enable SNMP" OFF)
option(STATISTICS "Enable statistics" OFF)

set(PACKAGE_NAME "ptpd")
set(PACKAGE_VERSION "2.3.2")

# Compatibility Configuration
include(CheckIncludeFiles)
check_include_files(net/ethernet.h HAVE_NET_ETHERNET_H)
check_include_files(netinet/ether.h HAVE_NETINET_ETHER_H)
check_include_files(netdb.h HAVE_NETDB_H)
check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
check_include_files(sys/types.h HAVE_SYS_TYPES_H)
include(CheckFunctionExists)
check_function_exists(gethostbyname2 HAVE_GETHOSTBYNAME2)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config_cmake.h.in ${CMAKE_CURRENT_BINARY_DIR}/config_cmake.h)

include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_compile_definitions(HAVE_CONFIG_H)

if (${TESTING})
include(CTest)
add_subdirectory(external/Unity)
else ()
include(scripts/utils.cmake)
generate_configuration(${CMAKE_CURRENT_SOURCE_DIR}/ptpd_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/ptpd_config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
endif ()

add_subdirectory(src)
4 changes: 1 addition & 3 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_C_COMPILER": "clang",
"TESTING": "ON"
}
},
Expand All @@ -33,8 +32,7 @@
}
},
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Release",
"CMAKE_C_COMPILER": "clang"
"CMAKE_BUILD_TYPE": "Release"
}
}
],
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ FROM ubuntu:22.04

RUN apt-get update && apt-get install -y \
build-essential \
autoconf \
automake \
libtool \
cmake \
ninja-build \
libsnmp-dev \
&& rm -rf /var/lib/apt/lists/*

COPY . /project
WORKDIR /project

RUN autoreconf -fi && ./configure && make
RUN cmake --preset package && cmake --build --preset package

ENTRYPOINT ["src/ptpd2"]
ENTRYPOINT ["cmake-build-package/src/ptpd2"]

35 changes: 19 additions & 16 deletions config_cmake.h.in → ptpd_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
#undef HAVE_ARPA_INET_H

/* Define to 1 if you have the `clock_gettime' function. */
#undef HAVE_CLOCK_GETTIME
#cmakedefine HAVE_CLOCK_GETTIME

/* Define to 1 if you have the declaration of `MSG_ERRQUEUE', and to 0 if you
don't. */
#undef HAVE_DECL_MSG_ERRQUEUE
#cmakedefine HAVE_DECL_MSG_ERRQUEUE

/* Define to 1 if you have the declaration of `POSIX_TIMERS_SUPPORTED', and to
0 if you don't. */
#undef HAVE_DECL_POSIX_TIMERS_SUPPORTED
#cmakedefine HAVE_DECL_POSIX_TIMERS_SUPPORTED

/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
Expand All @@ -33,7 +33,7 @@
#undef HAVE_ENDIAN_H

/* Define to 1 if you have the `endutent' function. */
#undef HAVE_ENDUTENT
#cmakedefine HAVE_ENDUTENT

/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
Expand All @@ -45,10 +45,10 @@
#cmakedefine HAVE_GETHOSTBYNAME2

/* Define to 1 if you have the <getopt.h> header file. */
#undef HAVE_GETOPT_H
#cmakedefine HAVE_GETOPT_H

/* Define to 1 if you have the `getopt_long' function. */
#undef HAVE_GETOPT_LONG
#cmakedefine HAVE_GETOPT_LONG

/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
Expand All @@ -75,7 +75,7 @@
#undef HAVE_LINUX_NET_TSTAMP_H

/* Define to 1 if you have the <linux/rtc.h> header file. */
#undef HAVE_LINUX_RTC_H
#cmakedefine HAVE_LINUX_RTC_H

/* Define to 1 if you have the <machine/endian.h> header file. */
#undef HAVE_MACHINE_ENDIAN_H
Expand All @@ -87,6 +87,9 @@
/* Define to 1 if you have the <math.h> header file. */
#undef HAVE_MATH_H

/* Define to 1 if you have the `timer_t' symbol. */
#cmakedefine HAVE_POSIX_TIMER

/* Define to 1 if you have the `memset' function. */
#undef HAVE_MEMSET

Expand All @@ -97,23 +100,23 @@
#cmakedefine HAVE_NETINET_ETHER_H

/* Define to 1 if you have the <netinet/if_ether.h> header file. */
#undef HAVE_NETINET_IF_ETHER_H
#cmakedefine HAVE_NETINET_IF_ETHER_H

/* Define to 1 if you have the <net/if_ether.h> header file. */
#cmakedefine HAVE_NET_IF_ETHER_H

/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H
#cmakedefine HAVE_NETINET_IN_H

/* Define to 1 if you have the <netinet/in_systm.h> header file. */
#undef HAVE_NETINET_IN_SYSTM_H
#cmakedefine HAVE_NETINET_IN_SYSTM_H

/* Define to 1 if you have the <net/ethernet.h> header file. */
#cmakedefine HAVE_NET_ETHERNET_H

/* Define to 1 if you have the <net/if_arp.h> header file. */
#undef HAVE_NET_IF_ARP_H

/* Define to 1 if you have the <net/if_ether.h> header file. */
#undef HAVE_NET_IF_ETHER_H

/* Define to 1 if you have the <net/if.h> header file. */
#undef HAVE_NET_IF_H

Expand All @@ -133,13 +136,13 @@
#undef HAVE_PUTUTLINE

/* Define to 1 if you have the <sched.h> header file. */
#undef HAVE_SCHED_H
#cmakedefine HAVE_SCHED_H

/* Define to 1 if you have the `select' function. */
#undef HAVE_SELECT

/* Define to 1 if you have the `setutent' function. */
#undef HAVE_SETUTENT
#cmakedefine HAVE_SETUTENT

/* Define to 1 if you have the `signal' function. */
#undef HAVE_SIGNAL
Expand Down Expand Up @@ -181,7 +184,7 @@
#undef HAVE_STRTOL

/* Define to 1 if `octet' is a member of `struct ether_addr'. */
#undef HAVE_STRUCT_ETHER_ADDR_OCTET
#cmakedefine HAVE_STRUCT_ETHER_ADDR_OCTET

/* Define to 1 if `ifr_hwaddr' is a member of `struct ifreq'. */
#undef HAVE_STRUCT_IFREQ_IFR_HWADDR
Expand Down
47 changes: 47 additions & 0 deletions scripts/utils.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# SPDX-License-Identifier: BSD-2-Clause

#
# Generates the configuration file at the `out` path, given the template in the `in` path
# Eg. generate_configuration(${PATH_TO}/config.h.in ${PATH_TO}/config.h)
#
function(generate_configuration in out)
include(CheckIncludeFiles)
check_include_files(net/ethernet.h HAVE_NET_ETHERNET_H)
check_include_files(net/if_ether.h HAVE_NET_IF_ETHER_H)
check_include_files(netinet/ether.h HAVE_NETINET_ETHER_H)
check_include_files(netinet/if_ether.h HAVE_NETINET_IF_ETHER_H)
check_include_files(netinet/in.h HAVE_NETINET_IN_H)
check_include_files(netinet/in_systm.h HAVE_NETINET_IN_SYSTM_H)
check_include_files(netdb.h HAVE_NETDB_H)
check_include_files(sys/socket.h HAVE_SYS_SOCKET_H)
check_include_files(sys/types.h HAVE_SYS_TYPES_H)
check_include_files(getopt.h HAVE_GETOPT_H)
check_include_files(sched.h HAVE_SCHED_H)
check_include_files(linux_rtc.h HAVE_LINUX_RTC_H)

include(CheckFunctionExists)
check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
check_function_exists(gethostbyname2 HAVE_GETHOSTBYNAME2)
check_function_exists(getopt_long HAVE_GETOPT_LONG)
check_function_exists(setutent HAVE_SETUTENT)
check_function_exists(endutent HAVE_ENDUTENT)

include(CheckSymbolExists)
check_symbol_exists(timer_create "time.h" HAVE_POSIX_TIMER)
check_symbol_exists(MSG_ERRQUEUE "socket.h" HAVE_DECL_MSG_ERRQUEUE)

include(CheckStructHasMember)
if (${HAVE_NET_ETHERNET_H})
check_struct_has_member("struct ether_addr" octet net/ethernet.h HAVE_STRUCT_ETHER_ADDR_OCTET)
endif ()
if (${HAVE_NET_IF_ETHER_H})
check_struct_has_member("struct ether_addr" octet net/if_ether.h HAVE_STRUCT_ETHER_ADDR_OCTET)
endif ()
if (${HAVE_NETINET_ETHER_H})
check_struct_has_member("struct ether_addr" octet netinet/ether.h HAVE_STRUCT_ETHER_ADDR_OCTET)
endif ()
if (${HAVE_NETINET_IF_ETHER_H})
check_struct_has_member("struct ether_addr" octet netinet/if_ether.h HAVE_STRUCT_ETHER_ADDR_OCTET)
endif ()
configure_file(${in} ${out})
endfunction()
7 changes: 4 additions & 3 deletions scripts/wait_for.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,20 @@ while true; do
# Execute the command
eval "$command"
if [ $? -eq 0 ]; then
echo "Success"
current_time=$(date +%s)
elapsed_time=$((current_time - start_time))
echo "Succeeded after $elapsed_time seconds"
exit 0
fi

# Check if the timeout has been reached
current_time=$(date +%s)
elapsed_time=$((current_time - start_time))
if [ $elapsed_time -ge "$timeout" ]; then
echo "Fail"
echo "Failed after $elapsed_time seconds"
exit 1
fi

# Sleep for a short interval before checking again
sleep 1
done

Loading

0 comments on commit 8b4df11

Please sign in to comment.