From cccdc0e46695387eef3753dc5ff7f4ff9bcb9daa Mon Sep 17 00:00:00 2001 From: David Hummel <6109326+hummeltech@users.noreply.github.com> Date: Wed, 31 Jul 2024 14:37:29 -0700 Subject: [PATCH] Add OpenBSD builds --- .../actions/dependencies/install/action.yml | 27 ++++- .../install/pkg_add-openbsd/action.yml | 15 +++ .github/workflows/build-and-test.yml | 102 ++++++++++++++---- src/mod_tile.c | 6 +- src/render_expired.c | 32 +++--- src/render_submit_queue.c | 11 +- src/renderd.c | 2 +- tests/CMakeLists.txt | 2 +- tests/gen_tile_test.cpp | 9 +- tests/render_expired_test.cpp | 2 +- tests/render_list_test.cpp | 2 +- tests/render_old_test.cpp | 2 +- tests/render_speedtest_test.cpp | 2 +- tests/renderd_config_test.cpp | 2 +- tests/renderd_test.cpp | 2 +- 15 files changed, 158 insertions(+), 60 deletions(-) create mode 100644 .github/actions/dependencies/install/pkg_add-openbsd/action.yml diff --git a/.github/actions/dependencies/install/action.yml b/.github/actions/dependencies/install/action.yml index 06b4805f..c11a75fa 100644 --- a/.github/actions/dependencies/install/action.yml +++ b/.github/actions/dependencies/install/action.yml @@ -85,6 +85,21 @@ inputs: jq lcov memcached + openbsd-build-dependencies: + default: >- + apache-httpd + cairo + coreutils + curl + glib2 + iniparser + libmemcached + mapnik + pkgconf + openbsd-test-dependencies: + default: >- + jq + memcached-- opensuse-build-dependencies: default: >- apache2-devel @@ -251,6 +266,16 @@ runs: ${{ matrix.compiler == 'GNU' && 'gcc' || '' }} if: github.job == 'macOS' + - name: Install Dependencies (OpenBSD) + uses: ./.github/actions/dependencies/install/pkg_add-openbsd + with: + packages: >- + ${{ inputs.openbsd-build-dependencies }} + ${{ inputs.openbsd-test-dependencies }} + ${{ matrix.build_system == 'CMake' && 'cmake' || 'autoconf automake' }} + ${{ matrix.compiler == 'GNU' && 'gcc' || '' }} + if: github.job == 'OpenBSD' + - name: Install Dependencies (openSUSE) uses: ./.github/actions/dependencies/install/zypper with: @@ -274,7 +299,7 @@ runs: ${{ matrix.compiler == 'LLVM' && 'clang' || 'g++ gcc' }} if: | startsWith(matrix.image, 'ubuntu:') || - (!matrix.image && github.job != 'FreeBSD' && runner.os == 'Linux') + (!matrix.image && github.job != 'FreeBSD' && github.job != 'OpenBSD' && runner.os == 'Linux') - name: Link `gcc`/`g++` (openSUSE) run: | diff --git a/.github/actions/dependencies/install/pkg_add-openbsd/action.yml b/.github/actions/dependencies/install/pkg_add-openbsd/action.yml new file mode 100644 index 00000000..8b5433b0 --- /dev/null +++ b/.github/actions/dependencies/install/pkg_add-openbsd/action.yml @@ -0,0 +1,15 @@ +--- +inputs: + packages: + description: List of package(s) to install + required: true + options: + default: -Iv + description: Option(s) to pass + +runs: + using: composite + steps: + - name: Install package(s) + run: ${{ !matrix.image && 'sudo' || '' }} pkg_add ${{ inputs.options }} ${{ inputs.packages }} + shell: bash --noprofile --norc -euxo pipefail {0} diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml index 3d76580f..feea91a1 100644 --- a/.github/workflows/build-and-test.yml +++ b/.github/workflows/build-and-test.yml @@ -145,6 +145,78 @@ jobs: - name: Install `mod_tile` uses: ./.github/actions/install + FreeBSD: + env: + CFLAGS: --coverage + CTEST_CLIENT_HOST: ::1 + CTEST_SERVER_HOST: localhost + CXXFLAGS: --coverage + INSTALL_PREFIX: /usr/local + LIBRARY_PATH: /usr/local/lib + TMPDIR: /tmp + name: >- + ${{ matrix.box_generic }} + (${{ matrix.build_system }}) + (${{ matrix.compiler }}) + runs-on: ubuntu-latest + strategy: + matrix: + box_generic: + - freebsd13 + build_system: + - CMake + compiler: + - LLVM + on_default_branch: + - ${{ contains(github.ref, 'master') || contains(github.ref, 'develop') || contains(github.ref, 'CI') }} + include: + - box_generic: freebsd14 + build_system: CMake + compiler: LLVM + exclude: + - on_default_branch: false + fail-fast: false + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Set `BUILD_PARALLEL_LEVEL` & `TEST_PARALLEL_LEVEL` + run: | + echo "BUILD_PARALLEL_LEVEL=$(nproc)" >> ${GITHUB_ENV} + echo "TEST_PARALLEL_LEVEL=$(nproc)" >> ${GITHUB_ENV} + + - name: Provision VM + uses: hummeltech/freebsd-vagrant-action@v1.4 + with: + box: generic/${{ matrix.box_generic }} + cpus: ${{ env.BUILD_PARALLEL_LEVEL }} + memory: 4096 + + # Mapnik is not in the `quarterly` repository (2023.10.12) + - name: Use "latest" repository + run: | + sudo mkdir -p /usr/local/etc/pkg/repos + sed 's#/quarterly#/latest#g' /etc/pkg/FreeBSD.conf | sudo tee /usr/local/etc/pkg/repos/FreeBSD.conf + sudo pkg upgrade + + - name: Install dependencies + uses: ./.github/actions/dependencies/install + + - name: Build `mod_tile` + uses: ./.github/actions/build + + - name: Test `mod_tile` + uses: ./.github/actions/test + + - name: Process & Report `mod_tile` coverage results + uses: ./.github/actions/coverage + + - name: Package `mod_tile` + uses: ./.github/actions/cmake/package + + - name: Install `mod_tile` + uses: ./.github/actions/install + macOS: env: CFLAGS: --coverage @@ -208,12 +280,10 @@ jobs: - name: Install `mod_tile` uses: ./.github/actions/install - FreeBSD: + OpenBSD: env: - CFLAGS: --coverage CTEST_CLIENT_HOST: ::1 CTEST_SERVER_HOST: localhost - CXXFLAGS: --coverage INSTALL_PREFIX: /usr/local LIBRARY_PATH: /usr/local/lib TMPDIR: /tmp @@ -225,19 +295,11 @@ jobs: strategy: matrix: box_generic: - - freebsd13 + - openbsd7 build_system: - CMake compiler: - LLVM - on_default_branch: - - ${{ contains(github.ref, 'master') || contains(github.ref, 'develop') || contains(github.ref, 'CI') }} - include: - - box_generic: freebsd14 - build_system: CMake - compiler: LLVM - exclude: - - on_default_branch: false fail-fast: false steps: - name: Checkout code @@ -249,18 +311,17 @@ jobs: echo "TEST_PARALLEL_LEVEL=$(nproc)" >> ${GITHUB_ENV} - name: Provision VM - uses: hummeltech/freebsd-vagrant-action@v1.4 + uses: hummeltech/openbsd-vagrant-action@v2 with: box: generic/${{ matrix.box_generic }} cpus: ${{ env.BUILD_PARALLEL_LEVEL }} - memory: 4096 + memory: 8192 - # Mapnik is not in the `quarterly` repository (2023.10.12) - - name: Use "latest" repository + - name: Install X Windows run: | - sudo mkdir -p /usr/local/etc/pkg/repos - sed 's#/quarterly#/latest#g' /etc/pkg/FreeBSD.conf | sudo tee /usr/local/etc/pkg/repos/FreeBSD.conf - sudo pkg upgrade + curl -L https://cdn.openbsd.org/pub/OpenBSD/$(uname -r)/amd64/xbase$(uname -r | sed 's/\.//').tgz | sudo tar -C / -xzvf - + curl -L https://cdn.openbsd.org/pub/OpenBSD/$(uname -r)/amd64/xfont$(uname -r | sed 's/\.//').tgz | sudo tar -C / -xzvf - + sudo ldconfig /usr/*/lib - name: Install dependencies uses: ./.github/actions/dependencies/install @@ -271,9 +332,6 @@ jobs: - name: Test `mod_tile` uses: ./.github/actions/test - - name: Process & Report `mod_tile` coverage results - uses: ./.github/actions/coverage - - name: Package `mod_tile` uses: ./.github/actions/cmake/package diff --git a/src/mod_tile.c b/src/mod_tile.c index 9234f191..6c472812 100644 --- a/src/mod_tile.c +++ b/src/mod_tile.c @@ -75,8 +75,10 @@ module AP_MODULE_DECLARE_DATA tile_module; APLOG_USE_MODULE(tile); -#if (defined(__FreeBSD__) || defined(__MACH__)) && !defined(s6_addr32) -#define s6_addr32 __u6_addr.__u6_addr32 +#if defined(AF_INET6) && !defined(s6_addr32) +# if defined(__APPLE__)|| defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) +# define s6_addr32 __u6_addr.__u6_addr32 +# endif #endif apr_shm_t *stats_shm; diff --git a/src/render_expired.c b/src/render_expired.c index 9bd13cab..ed3387d6 100644 --- a/src/render_expired.c +++ b/src/render_expired.c @@ -305,22 +305,6 @@ int main(int argc, char **argv) } } - // initialise arrays for tile markings - - tile_requested = (unsigned int **)malloc((max_zoom - excess_zoomlevels + 1) * sizeof(unsigned int *)); - - for (int i = 0; i <= max_zoom - excess_zoomlevels; i++) { - // initialize twopow array - twopow[i] = (i == 0) ? 1 : twopow[i - 1] * 2; - unsigned long long fourpow = twopow[i] * twopow[i]; - tile_requested[i] = (unsigned int *)calloc((fourpow / METATILE) + 1, 1); - - if (NULL == tile_requested[i]) { - g_logger(G_LOG_LEVEL_CRITICAL, "not enough memory available"); - return 1; - } - } - store = init_storage_backend(tile_dir); if (store == NULL) { @@ -364,6 +348,22 @@ int main(int argc, char **argv) doRender = 1; } + // initialise arrays for tile markings + + tile_requested = (unsigned int **)malloc((max_zoom - excess_zoomlevels + 1) * sizeof(unsigned int *)); + + for (int i = 0; i <= max_zoom - excess_zoomlevels; i++) { + // initialize twopow array + twopow[i] = (i == 0) ? 1 : twopow[i - 1] * 2; + unsigned long long fourpow = twopow[i] * twopow[i]; + tile_requested[i] = (unsigned int *)calloc((fourpow / METATILE) + 1, 1); + + if (NULL == tile_requested[i]) { + g_logger(G_LOG_LEVEL_CRITICAL, "not enough memory available"); + return 1; + } + } + gettimeofday(&start, NULL); while (!feof(stdin)) { diff --git a/src/render_submit_queue.c b/src/render_submit_queue.c index 28315dc8..f22d3bd9 100644 --- a/src/render_submit_queue.c +++ b/src/render_submit_queue.c @@ -265,9 +265,12 @@ int make_connection(const char *spath) if (!hostname_len) { hostname = strdup(RENDERD_HOST); } else { - hostname = malloc(hostname_len + sizeof('\0')); - assert(hostname != NULL); - strncpy(hostname, spath, hostname_len); + hostname = strndup(spath, hostname_len); + } + + if (!hostname) { + g_logger(G_LOG_LEVEL_CRITICAL, "Error duplicating hostname: %s", strerror(errno)); + exit(2); } if (d) { @@ -348,6 +351,8 @@ int make_connection(const char *spath) g_logger(G_LOG_LEVEL_CRITICAL, "cannot connect to any address for %s", hostname); exit(2); } + + free(hostname); } return fd; diff --git a/src/renderd.c b/src/renderd.c index 8fa98f4b..20e92fdf 100644 --- a/src/renderd.c +++ b/src/renderd.c @@ -910,7 +910,7 @@ int main(int argc, char **argv) unlink(config.socketname); free_map_sections(maps); - free_renderd_sections(config_slaves); + free_renderd_section(config_slaves[active_renderd_section_num]); close(fd); return 0; } diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index cac96ef3..783d1192 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -29,7 +29,7 @@ find_program(ID_EXECUTABLE NAMES id REQUIRED) find_program(JQ_EXECUTABLE NAMES jq) find_program(KILL_EXECUTABLE NAMES kill REQUIRED) find_program(MEMCACHED_EXECUTABLE NAMES memcached) -find_program(MKDIR_EXECUTABLE NAMES mkdir REQUIRED) +find_program(MKDIR_EXECUTABLE NAMES gmkdir mkdir REQUIRED) find_program(PS_EXECUTABLE NAMES ps REQUIRED) find_program(SHA256SUM_EXECUTABLE NAMES gsha256sum sha256sum REQUIRED) find_program(SLEEP_EXECUTABLE NAMES sleep REQUIRED) diff --git a/tests/gen_tile_test.cpp b/tests/gen_tile_test.cpp index e9529cec..b8f37457 100644 --- a/tests/gen_tile_test.cpp +++ b/tests/gen_tile_test.cpp @@ -82,14 +82,7 @@ void *addition_thread(void *arg) { struct request_queue *queue = (struct request_queue *)arg; struct item *item; - uint64_t threadid; -#ifdef __MACH__ // Mac OS X does not support SYS_gettid - pthread_threadid_np(NULL, &threadid); -#elif __FreeBSD__ // FreeBSD does not support SYS_getid either - threadid = (uint64_t)pthread_self(); -#else - threadid = syscall(SYS_gettid); -#endif + uint64_t threadid = (uint64_t)pthread_self(); // Requests need to be unique across threads to avoid being discarded as duplicates, // thereby ensuring the queue counts can be compared correctly. diff --git a/tests/render_expired_test.cpp b/tests/render_expired_test.cpp index 288dd974..948b0ab5 100644 --- a/tests/render_expired_test.cpp +++ b/tests/render_expired_test.cpp @@ -23,7 +23,7 @@ #include "config.h" #include "render_config.h" -#ifdef __FreeBSD__ +#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #include #endif diff --git a/tests/render_list_test.cpp b/tests/render_list_test.cpp index 581e6f7b..e413b2bf 100644 --- a/tests/render_list_test.cpp +++ b/tests/render_list_test.cpp @@ -23,7 +23,7 @@ #include "config.h" #include "render_config.h" -#ifdef __FreeBSD__ +#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #include #endif diff --git a/tests/render_old_test.cpp b/tests/render_old_test.cpp index f9074014..5c281821 100644 --- a/tests/render_old_test.cpp +++ b/tests/render_old_test.cpp @@ -22,7 +22,7 @@ #include "config.h" #include "render_config.h" -#ifdef __FreeBSD__ +#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #include #endif diff --git a/tests/render_speedtest_test.cpp b/tests/render_speedtest_test.cpp index 2414dbe3..d90b677d 100644 --- a/tests/render_speedtest_test.cpp +++ b/tests/render_speedtest_test.cpp @@ -22,7 +22,7 @@ #include "config.h" #include "render_config.h" -#ifdef __FreeBSD__ +#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #include #endif diff --git a/tests/renderd_config_test.cpp b/tests/renderd_config_test.cpp index bcb6ceee..a6df34c2 100644 --- a/tests/renderd_config_test.cpp +++ b/tests/renderd_config_test.cpp @@ -24,7 +24,7 @@ #include "render_config.h" #include "renderd.h" -#ifdef __FreeBSD__ +#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #include #endif diff --git a/tests/renderd_test.cpp b/tests/renderd_test.cpp index 54850a40..89c94d8b 100644 --- a/tests/renderd_test.cpp +++ b/tests/renderd_test.cpp @@ -21,7 +21,7 @@ #include "catch_test_common.hpp" #include "config.h" -#ifdef __FreeBSD__ +#if defined(__DragonFly__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) #include #endif