1 parent
8583a479dd
commit
3851aeb703
42 files changed
+6948
-759
No files matched your search
@@ -0,0 +1,24 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(VoidAuditedConsumer LANGUAGES CXX)
|
||||
|
||||
find_package(Void CONFIG REQUIRED COMPONENTS
|
||||
Archive
|
||||
Binary
|
||||
Crypto
|
||||
Plugin
|
||||
System
|
||||
Update
|
||||
)
|
||||
|
||||
add_executable(void_audited_consumer main.cpp)
|
||||
target_link_libraries(void_audited_consumer PRIVATE
|
||||
Void::Archive
|
||||
Void::Binary
|
||||
Void::Crypto
|
||||
Void::Plugin
|
||||
Void::System
|
||||
Void::Update
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME VoidAuditedConsumer COMMAND void_audited_consumer)
|
||||
@@ -0,0 +1,28 @@
|
||||
#include <Void/Archive/Archive.hpp>
|
||||
#include <Void/Binary/Reader.hpp>
|
||||
#include <Void/Crypto/Crypto.hpp>
|
||||
#include <Void/Plugin/Loader.hpp>
|
||||
#include <Void/Plugin/Manager.hpp>
|
||||
#include <Void/System/SignalWatcher.hpp>
|
||||
#include <Void/Update/Update.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <bit>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
int main()
|
||||
{
|
||||
const std::array bytes{std::byte{0x01}, std::byte{0x02}};
|
||||
Void::Binary::Reader reader{bytes};
|
||||
const auto value = reader.read<std::uint16_t>(std::endian::big);
|
||||
const auto digest = Void::Crypto::sha256(bytes);
|
||||
const Void::Archive::ExtractionOptions limits{};
|
||||
const Void::Update::VerificationPolicy policy{};
|
||||
const Void::Plugin::PluginManager::Options plugins{};
|
||||
return value && *value == 0x0102 && digest && !digest->empty() &&
|
||||
limits.maxEntries > 0 && policy.maxReleases > 0 &&
|
||||
plugins.debounce_polls > 0
|
||||
? 0
|
||||
: 1;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
project(VoidBinaryConsumer LANGUAGES CXX)
|
||||
|
||||
find_package(Void CONFIG REQUIRED COMPONENTS Binary)
|
||||
|
||||
add_executable(void_binary_consumer main.cpp)
|
||||
target_link_libraries(void_binary_consumer PRIVATE Void::Binary)
|
||||
|
||||
enable_testing()
|
||||
add_test(NAME VoidBinaryConsumer COMMAND void_binary_consumer)
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <Void/Binary/Reader.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <bit>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
||||
int main()
|
||||
{
|
||||
const std::array bytes{std::byte{0x01}, std::byte{0x02}};
|
||||
Void::Binary::Reader reader{bytes};
|
||||
const auto value = reader.read<std::uint16_t>(std::endian::big);
|
||||
return value && *value == 0x0102 ? 0 : 1;
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
cmake_minimum_required(VERSION 4.0)
|
||||
|
||||
foreach(required IN ITEMS VOID_BUILD_DIR VOID_TEST_SOURCE_DIR VOID_TEST_ROOT
|
||||
VOID_CXX_COMPILER VOID_CTEST_COMMAND)
|
||||
if(NOT DEFINED ${required} OR "${${required}}" STREQUAL "")
|
||||
message(FATAL_ERROR "${required} is required")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
file(REMOVE_RECURSE "${VOID_TEST_ROOT}")
|
||||
set(install_prefix "${VOID_TEST_ROOT}/install")
|
||||
|
||||
set(install_command "${CMAKE_COMMAND}" --install "${VOID_BUILD_DIR}"
|
||||
--prefix "${install_prefix}")
|
||||
if(DEFINED VOID_BUILD_CONFIG AND NOT VOID_BUILD_CONFIG STREQUAL "")
|
||||
list(APPEND install_command --config "${VOID_BUILD_CONFIG}")
|
||||
endif()
|
||||
execute_process(COMMAND ${install_command} COMMAND_ERROR_IS_FATAL ANY)
|
||||
|
||||
function(run_consumer name)
|
||||
set(source_dir "${VOID_TEST_SOURCE_DIR}/${name}")
|
||||
set(build_dir "${VOID_TEST_ROOT}/${name}")
|
||||
execute_process(
|
||||
COMMAND "${CMAKE_COMMAND}" -S "${source_dir}" -B "${build_dir}"
|
||||
"-DCMAKE_PREFIX_PATH=${install_prefix}"
|
||||
"-DCMAKE_CXX_COMPILER=${VOID_CXX_COMPILER}"
|
||||
${ARGN}
|
||||
COMMAND_ERROR_IS_FATAL ANY)
|
||||
|
||||
set(build_command "${CMAKE_COMMAND}" --build "${build_dir}")
|
||||
set(test_command "${VOID_CTEST_COMMAND}" --test-dir "${build_dir}"
|
||||
--output-on-failure)
|
||||
if(DEFINED VOID_BUILD_CONFIG AND NOT VOID_BUILD_CONFIG STREQUAL "")
|
||||
list(APPEND build_command --config "${VOID_BUILD_CONFIG}")
|
||||
list(APPEND test_command -C "${VOID_BUILD_CONFIG}")
|
||||
endif()
|
||||
execute_process(COMMAND ${build_command} COMMAND_ERROR_IS_FATAL ANY)
|
||||
execute_process(COMMAND ${test_command} COMMAND_ERROR_IS_FATAL ANY)
|
||||
endfunction()
|
||||
|
||||
# A header-only component must remain independently consumable even when every
|
||||
# optional external package is explicitly unavailable.
|
||||
run_consumer(Binary
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_LibArchive=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_OpenSSL=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Threads=TRUE)
|
||||
|
||||
# Exercise the transitive dependency closure for every newly extracted runtime
|
||||
# module while proving unrelated Sodium and SQLite dependencies are not loaded.
|
||||
run_consumer(Audited
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_Boost=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=TRUE
|
||||
-DCMAKE_DISABLE_FIND_PACKAGE_SQLite3=TRUE)
|
||||
Reference in new issue
Block a user