From ffa795703f606bbece9283128ba6237543b1ef79 Mon Sep 17 00:00:00 2001 From: Hector Espert Date: Wed, 20 May 2026 18:12:42 +0200 Subject: [PATCH 1/4] Test Ubuntu OS Release --- tests/executeUnitTests.sh | 4 +- tests/unit-tests/CMakeLists.txt | 1 + tests/unit-tests/client/CMakeLists.txt | 9 ++++ .../unit-tests/client/test_hostinfo_linux.cpp | 41 +++++++++++++++++++ tests/unit-tests/testdata/os-release.ubuntu | 13 ++++++ 5 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 tests/unit-tests/client/CMakeLists.txt create mode 100644 tests/unit-tests/client/test_hostinfo_linux.cpp create mode 100644 tests/unit-tests/testdata/os-release.ubuntu diff --git a/tests/executeUnitTests.sh b/tests/executeUnitTests.sh index ba98556ed69..f8f8ccac303 100755 --- a/tests/executeUnitTests.sh +++ b/tests/executeUnitTests.sh @@ -76,9 +76,9 @@ make if [ $? -ne 0 ]; then cd ../..; exit 1; fi if [[ "$OSTYPE" == "darwin"* ]]; then - MODULES="lib vboxwrapper" + MODULES="lib client vboxwrapper" else - MODULES="lib sched vboxwrapper" + MODULES="lib client sched vboxwrapper" fi for T in ${MODULES}; do XML_FLAGS="" diff --git a/tests/unit-tests/CMakeLists.txt b/tests/unit-tests/CMakeLists.txt index f286c272c74..8ffb9bb5ecd 100644 --- a/tests/unit-tests/CMakeLists.txt +++ b/tests/unit-tests/CMakeLists.txt @@ -71,6 +71,7 @@ else() endif() add_subdirectory(lib) +add_subdirectory(client) if (NOT APPLE) add_subdirectory(sched) endif() diff --git a/tests/unit-tests/client/CMakeLists.txt b/tests/unit-tests/client/CMakeLists.txt new file mode 100644 index 00000000000..177e01585d7 --- /dev/null +++ b/tests/unit-tests/client/CMakeLists.txt @@ -0,0 +1,9 @@ +file(GLOB SRCS *.cpp) + +LIST(APPEND SRCS "${PROJECT_SOURCE_DIR}/../../client/hostinfo_linux.cpp") + +add_executable(test_client ${SRCS}) + +TARGET_LINK_LIBRARIES(test_client "${SCHED_LIB}" "${BOINC_CRYPT_LIB}" "${BOINC_LIB}" pthread GTest::gtest GTest::gtest_main) + +add_test(NAME test_client COMMAND test_client) diff --git a/tests/unit-tests/client/test_hostinfo_linux.cpp b/tests/unit-tests/client/test_hostinfo_linux.cpp new file mode 100644 index 00000000000..0c27cb58abe --- /dev/null +++ b/tests/unit-tests/client/test_hostinfo_linux.cpp @@ -0,0 +1,41 @@ +// This file is part of BOINC. +// https://boinc.berkeley.edu +// Copyright (C) 2026 University of California +// +// BOINC is free software; you can redistribute it and/or modify it +// under the terms of the GNU Lesser General Public License +// as published by the Free Software Foundation, +// either version 3 of the License, or (at your option) any later version. +// +// BOINC is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// See the GNU Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public License +// along with BOINC. If not, see . + +#include "gtest/gtest.h" +#include "hostinfo.h" + +#include +#include + +namespace test_hostinfo_linux { + class test_hostinfo_linux : public ::testing::Test {}; + + TEST_F(test_hostinfo_linux, parse_linux_os_info_os_release_ubuntu) { + std::string fixture_path(__FILE__); + fixture_path = fixture_path.substr(0, fixture_path.find_last_of('/')) + "/../testdata/os-release.ubuntu"; + + FILE* os_release = fopen(fixture_path.c_str(), "r"); + ASSERT_NE(nullptr, os_release); + + char os_name[256] = "", os_version[256] = ""; + EXPECT_TRUE(HOST_INFO::parse_linux_os_info(os_release, osrelease, os_name, sizeof(os_name), os_version, sizeof(os_version))); + fclose(os_release); + + EXPECT_STREQ("Ubuntu", os_name); + EXPECT_STREQ("Ubuntu 26.04 LTS", os_version); + } +} diff --git a/tests/unit-tests/testdata/os-release.ubuntu b/tests/unit-tests/testdata/os-release.ubuntu new file mode 100644 index 00000000000..e89ba5478cc --- /dev/null +++ b/tests/unit-tests/testdata/os-release.ubuntu @@ -0,0 +1,13 @@ +PRETTY_NAME="Ubuntu 26.04 LTS" +NAME="Ubuntu" +VERSION_ID="26.04" +VERSION="26.04 LTS (Resolute Raccoon)" +VERSION_CODENAME=resolute +ID=ubuntu +ID_LIKE=debian +HOME_URL="https://www.ubuntu.com/" +SUPPORT_URL="https://help.ubuntu.com/" +BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" +PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" +UBUNTU_CODENAME=resolute +LOGO=ubuntu-logo From 7fe5df68793358fd6442f3264b4b4256f86b83b9 Mon Sep 17 00:00:00 2001 From: Hector Espert Date: Wed, 20 May 2026 18:17:03 +0200 Subject: [PATCH 2/4] Test openwrt os release --- .../unit-tests/client/test_hostinfo_linux.cpp | 15 ++++++++++++++ tests/unit-tests/testdata/os-release.openwrt | 20 +++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 tests/unit-tests/testdata/os-release.openwrt diff --git a/tests/unit-tests/client/test_hostinfo_linux.cpp b/tests/unit-tests/client/test_hostinfo_linux.cpp index 0c27cb58abe..80cee79b72d 100644 --- a/tests/unit-tests/client/test_hostinfo_linux.cpp +++ b/tests/unit-tests/client/test_hostinfo_linux.cpp @@ -38,4 +38,19 @@ namespace test_hostinfo_linux { EXPECT_STREQ("Ubuntu", os_name); EXPECT_STREQ("Ubuntu 26.04 LTS", os_version); } + + TEST_F(test_hostinfo_linux, parse_linux_os_info_os_release_openwrt) { + std::string fixture_path(__FILE__); + fixture_path = fixture_path.substr(0, fixture_path.find_last_of('/')) + "/../testdata/os-release.openwrt"; + + FILE* os_release = fopen(fixture_path.c_str(), "r"); + ASSERT_NE(nullptr, os_release); + + char os_name[256] = "", os_version[256] = ""; + EXPECT_TRUE(HOST_INFO::parse_linux_os_info(os_release, osrelease, os_name, sizeof(os_name), os_version, sizeof(os_version))); + fclose(os_release); + + EXPECT_STREQ("OpenWrt", os_name); + EXPECT_STREQ("OpenWrt 25.12.4", os_version); + } } diff --git a/tests/unit-tests/testdata/os-release.openwrt b/tests/unit-tests/testdata/os-release.openwrt new file mode 100644 index 00000000000..081d8bf1e52 --- /dev/null +++ b/tests/unit-tests/testdata/os-release.openwrt @@ -0,0 +1,20 @@ +NAME="OpenWrt" +VERSION="25.12.4" +ID="openwrt" +ID_LIKE="lede openwrt" +PRETTY_NAME="OpenWrt 25.12.4" +VERSION_ID="25.12.4" +HOME_URL="https://openwrt.org/" +BUG_URL="https://bugs.openwrt.org/" +SUPPORT_URL="https://forum.openwrt.org/" +FIRMWARE_URL="https://downloads.openwrt.org/" +BUILD_ID="r32933-4ccb782af7" +OPENWRT_BOARD="mediatek/filogic" +OPENWRT_ARCH="aarch64_cortex-a53" +OPENWRT_TAINTS="" +OPENWRT_DEVICE_MANUFACTURER="OpenWrt" +OPENWRT_DEVICE_MANUFACTURER_URL="https://openwrt.org/" +OPENWRT_DEVICE_PRODUCT="Generic" +OPENWRT_DEVICE_REVISION="v0" +OPENWRT_RELEASE="OpenWrt 25.12.4 r32933-4ccb782af7" +OPENWRT_BUILD_DATE="1778712129" From 786c5a953a38c314955438128b7cd2db2437ee2c Mon Sep 17 00:00:00 2001 From: Hector Espert Date: Sat, 23 May 2026 19:24:35 +0200 Subject: [PATCH 3/4] Test lsb-release --- tests/unit-tests/client/test_hostinfo_linux.cpp | 15 +++++++++++++++ tests/unit-tests/testdata/lsb-release.ubuntu | 5 +++++ 2 files changed, 20 insertions(+) create mode 100644 tests/unit-tests/testdata/lsb-release.ubuntu diff --git a/tests/unit-tests/client/test_hostinfo_linux.cpp b/tests/unit-tests/client/test_hostinfo_linux.cpp index 80cee79b72d..236eaa2f0b0 100644 --- a/tests/unit-tests/client/test_hostinfo_linux.cpp +++ b/tests/unit-tests/client/test_hostinfo_linux.cpp @@ -24,6 +24,21 @@ namespace test_hostinfo_linux { class test_hostinfo_linux : public ::testing::Test {}; + TEST_F(test_hostinfo_linux, parse_linux_os_info_lsb_release_ubuntu) { + std::string fixture_path(__FILE__); + fixture_path = fixture_path.substr(0, fixture_path.find_last_of('/')) + "/../testdata/lsb-release.ubuntu"; + + FILE* lsb_release = fopen(fixture_path.c_str(), "r"); + ASSERT_NE(nullptr, lsb_release); + + char os_name[256] = "", os_version[256] = ""; + EXPECT_TRUE(HOST_INFO::parse_linux_os_info(lsb_release, lsbrelease, os_name, sizeof(os_name), os_version, sizeof(os_version))); + fclose(lsb_release); + + EXPECT_STREQ("Ubuntu", os_name); + EXPECT_STREQ("Ubuntu 26.04 LTS", os_version); + } + TEST_F(test_hostinfo_linux, parse_linux_os_info_os_release_ubuntu) { std::string fixture_path(__FILE__); fixture_path = fixture_path.substr(0, fixture_path.find_last_of('/')) + "/../testdata/os-release.ubuntu"; diff --git a/tests/unit-tests/testdata/lsb-release.ubuntu b/tests/unit-tests/testdata/lsb-release.ubuntu new file mode 100644 index 00000000000..62d9e7d6aeb --- /dev/null +++ b/tests/unit-tests/testdata/lsb-release.ubuntu @@ -0,0 +1,5 @@ +No LSB modules are available. +Distributor ID: Ubuntu +Description: Ubuntu 26.04 LTS +Release: 26.04 +Codename: resolute \ No newline at end of file From ef53cd0831c1c84d4e281c24201fa7cf775388d5 Mon Sep 17 00:00:00 2001 From: Hector Espert Date: Sun, 24 May 2026 10:57:00 +0200 Subject: [PATCH 4/4] Exclude client tests on apple --- tests/executeUnitTests.sh | 2 +- tests/unit-tests/CMakeLists.txt | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/executeUnitTests.sh b/tests/executeUnitTests.sh index f8f8ccac303..e173b7004f3 100755 --- a/tests/executeUnitTests.sh +++ b/tests/executeUnitTests.sh @@ -76,7 +76,7 @@ make if [ $? -ne 0 ]; then cd ../..; exit 1; fi if [[ "$OSTYPE" == "darwin"* ]]; then - MODULES="lib client vboxwrapper" + MODULES="lib vboxwrapper" else MODULES="lib client sched vboxwrapper" fi diff --git a/tests/unit-tests/CMakeLists.txt b/tests/unit-tests/CMakeLists.txt index 8ffb9bb5ecd..c3612677795 100644 --- a/tests/unit-tests/CMakeLists.txt +++ b/tests/unit-tests/CMakeLists.txt @@ -71,7 +71,11 @@ else() endif() add_subdirectory(lib) -add_subdirectory(client) + +if(UNIX AND NOT APPLE) + add_subdirectory(client) +endif() + if (NOT APPLE) add_subdirectory(sched) endif()