diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index ad1ef666..37a3746f 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -14,36 +14,36 @@ concurrency: jobs: build-check: - name: "Check whether NTF builds and passes unit tests" + name: "Linux" runs-on: ubuntu-latest timeout-minutes: 60 steps: - uses: actions/checkout@v3 - - name: Get cache name + - name: Cache-Identify id: get-hash run: echo "ntf_deps_hash=`cat .github/workflows/docker/build_deps.sh .github/workflows/docker/build_test_ntf.sh .github/workflows/docker/Dockerfile | shasum`" >> $GITHUB_OUTPUT - - name: Get cached dependencies docker image + - name: Cache-Lookup id: cache-restore uses: actions/cache/restore@v3 with: path: ntf_deps_image.tar.gz key: ${{ steps.get-hash.outputs.ntf_deps_hash }} - - name: Build dependencies docker image + - name: Cache-Build if: steps.cache-restore.outputs.cache-hit != 'true' run: docker build --tag ntf-deps --platform linux/amd64 .github/workflows/docker - - name: Load dependencies docker image from cache + - name: Cache-Restore if: steps.cache-restore.outputs.cache-hit == 'true' run: docker load < ntf_deps_image.tar.gz - - name: Save built dependencies docker image + - name: Cache-Save if: steps.cache-restore.outputs.cache-hit != 'true' run: docker save ntf-deps:latest | gzip > ntf_deps_image.tar.gz - - name: Cache built dependencies docker image + - name: Cache-Commit id: cache-save if: steps.cache-restore.outputs.cache-hit != 'true' uses: actions/cache/save@v3 @@ -51,6 +51,6 @@ jobs: path: ntf_deps_image.tar.gz key: ${{ steps.get-hash.outputs.ntf_deps_hash }} - - name: Run dependencies docker container + - name: Build id: ntf-deps-run run: docker run -v $(pwd):/workspace/ntf-core --name ntf-deps ntf-deps /bin/bash -c "/workspace/ntf-core/.github/workflows/docker/build_test_ntf.sh" diff --git a/.github/workflows/docker/build_test_ntf.sh b/.github/workflows/docker/build_test_ntf.sh index e6c61a17..4aba1eba 100755 --- a/.github/workflows/docker/build_test_ntf.sh +++ b/.github/workflows/docker/build_test_ntf.sh @@ -1,28 +1,84 @@ -#!/bin/bash +#!/usr/bin/env bash -set -e +# configure() { +# cd /workspace +# PATH="$PATH:$(realpath srcs/bde-tools/bin)" +# export PATH +# eval "$(bbs_build_env -u opt_64_cpp17)" +# } -configure() { - cd /workspace - PATH="$PATH:$(realpath srcs/bde-tools/bin)" - export PATH - eval "$(bbs_build_env -u opt_64_cpp17)" -} +build_ntf() { + local rc=0 -build_ntf() { cd /workspace/ntf-core - sed -i s/CMakeLists.txt//g ./configure - ./configure --prefix /opt/bb - make -j8 - make test | tee test.log - - if cat test.log | grep -q "Errors while running CTest"; then - echo "There are errors while running UTs, exiting..." - exit 1 + rc=${?} + if [ ${rc} -ne 0 ]; then + echo "Failed to change directory: rc = ${rc}" + exit ${rc} + fi + + local jobs=$(getconf _NPROCESSORS_ONLN) + + echo "Cores: ${concurrency}" + free -h + + echo "Environment" + env + + echo "File: /etc/hosts" + cat /etc/hosts + + echo "File: /etc/services" + cat /etc/services + + echo "File: /etc/resolv.conf" + cat /etc/resolv.conf + + unset DISTRIBUTION_REFROOT + unset PREFIX + + ./configure --prefix /opt/bb \ + --output /workspace/ntf-core/build \ + --jobs ${jobs} \ + --standalone \ + --without-warnings \ + --without-warnings-as-errors \ + --from-continuous-integration + rc=${?} + if [ ${rc} -ne 0 ]; then + echo "Failed to configure: rc = ${rc}" + exit ${rc} + fi + + make build + rc=${?} + if [ ${rc} -ne 0 ]; then + echo "Failed to build: rc = ${rc}" + exit ${rc} + fi + + make build_test + rc=${?} + if [ ${rc} -ne 0 ]; then + echo "Failed to build tests: rc = ${rc}" + exit ${rc} + fi + + make test + rc=${?} + if [ ${rc} -ne 0 ]; then + cat /workspace/ntf-core/build/Testing/Temporary/LastTest.log + echo "Failed to run tests successfully: rc = ${rc}" + exit ${rc} fi make install + rc=${?} + if [ ${rc} -ne 0 ]; then + echo "Failed to install: rc = ${rc}" + exit ${rc} + fi } -configure +# configure build_ntf diff --git a/configure b/configure index 1d597e92..528c7fe8 100755 --- a/configure +++ b/configure @@ -732,7 +732,6 @@ while true ; do --from-continuous-integration) NTF_CONFIGURE_FROM_CONTINUOUS_INTEGRATION=1 - NTF_CONFIGURE_VERBOSE=1 shift ;; --from-packaging) NTF_CONFIGURE_FROM_PACKAGING=1 ; shift ;; @@ -948,7 +947,7 @@ cd ${NTF_CONFIGURE_OUTPUT} echo "${NTF_CONFIGURE_CMAKE}${NTF_CONFIGURE_CMAKE_OPTION_DISTRIBUTION_REFROOT}${NTF_CONFIGURE_CMAKE_OPTION_UFID}${NTF_CONFIGURE_CMAKE_OPTION_BUILD_TYPE}${NTF_CONFIGURE_CMAKE_OPTION_INSTALL_PREFIX}${NTF_CONFIGURE_CMAKE_OPTION_PREFIX_PATH}${NTF_CONFIGURE_CMAKE_OPTION_VERBOSE_MAKEFILE} -DCMAKE_TOOLCHAIN_FILE:PATH=${NTF_CONFIGURE_REPOSITORY}/toolchain.cmake -G \"${NTF_CONFIGURE_GENERATOR}\" -S ${NTF_CONFIGURE_REPOSITORY}" -${NTF_CONFIGURE_CMAKE}${NTF_CONFIGURE_CMAKE_OPTION_DISTRIBUTION_REFROOT}${NTF_CONFIGURE_CMAKE_OPTION_UFID}${NTF_CONFIGURE_CMAKE_OPTION_BUILD_TYPE}${NTF_CONFIGURE_CMAKE_OPTION_INSTALL_PREFIX}${NTF_CONFIGURE_CMAKE_OPTION_PREFIX_PATH}${NTF_CONFIGURE_CMAKE_OPTION_VERBOSE_MAKEFILE} -DCMAKE_TOOLCHAIN_FILE:PATH=${NTF_CONFIGURE_REPOSITORY}/toolchain.cmake -G "${NTF_CONFIGURE_GENERATOR}" -S ${NTF_CONFIGURE_REPOSITORY} 2>&1 | tee -a ${NTF_CONFIGURE_LOG_PREFIX}configure.log +${NTF_CONFIGURE_CMAKE}${NTF_CONFIGURE_CMAKE_OPTION_DISTRIBUTION_REFROOT}${NTF_CONFIGURE_CMAKE_OPTION_UFID}${NTF_CONFIGURE_CMAKE_OPTION_BUILD_TYPE}${NTF_CONFIGURE_CMAKE_OPTION_INSTALL_PREFIX}${NTF_CONFIGURE_CMAKE_OPTION_PREFIX_PATH}${NTF_CONFIGURE_CMAKE_OPTION_VERBOSE_MAKEFILE} -DCMAKE_TOOLCHAIN_FILE:PATH=${NTF_CONFIGURE_REPOSITORY}/toolchain.cmake -G "${NTF_CONFIGURE_GENERATOR}" -S ${NTF_CONFIGURE_REPOSITORY} if [ ${?} -ne 0 ]; then echo "Failed to configure" exit 1 @@ -966,21 +965,21 @@ MAKEFLAGS+=${NTF_CONFIGURE_MAKEFLAGS} all: build build: - @${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel ${NTF_CONFIGURE_JOBS} 2>&1 | tee -a ${NTF_CONFIGURE_LOG_PREFIX}build.log + @${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel ${NTF_CONFIGURE_JOBS} build_test: - @${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel ${NTF_CONFIGURE_JOBS} --target build_test 2>&1 | tee -a ${NTF_CONFIGURE_LOG_PREFIX}build.log + @${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel ${NTF_CONFIGURE_JOBS} --target build_test test: @export CTEST_PARALLEL_LEVEL=1 - @${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel ${NTF_CONFIGURE_JOBS} --target build_test 2>&1 | tee -a ${NTF_CONFIGURE_LOG_PREFIX}build.log - @${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel 1 --target test 2>&1 | tee -a ${NTF_CONFIGURE_LOG_PREFIX}test.log + @${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel ${NTF_CONFIGURE_JOBS} --target build_test + @${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel 1 --target test test_usage: - @${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel 1 --target test_usage 2>&1 | tee -a ${NTF_CONFIGURE_LOG_PREFIX}test_usage.log + @${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel 1 --target test_usage coverage: - @${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel 1 --target coverage 2>&1 | tee -a ${NTF_CONFIGURE_LOG_PREFIX}test.log + @${NTF_CONFIGURE_CMAKE} --build ${NTF_CONFIGURE_OUTPUT} --parallel 1 --target coverage install: @${NTF_CONFIGURE_CMAKE} --install ${NTF_CONFIGURE_OUTPUT} --prefix ${NTF_CONFIGURE_INSTALL_PREFIX_OVERRIDE} diff --git a/groups/ntc/ntcdns/ntcdns_database.t.cpp b/groups/ntc/ntcdns/ntcdns_database.t.cpp index cf4a2f1e..934cb578 100644 --- a/groups/ntc/ntcdns/ntcdns_database.t.cpp +++ b/groups/ntc/ntcdns/ntcdns_database.t.cpp @@ -2125,6 +2125,10 @@ NTCCFG_TEST_CASE(3) // Concern: Host database configurations from "/etc/hosts". // Plan: + if (!ntscfg::Platform::hasHostDatabase()) { + return; + } + NTCI_LOG_CONTEXT(); ntsa::Error error; @@ -2158,6 +2162,10 @@ NTCCFG_TEST_CASE(4) // Concern: Port database configurations from "/etc/services". // Plan: + if (!ntscfg::Platform::hasPortDatabase()) { + return; + } + NTCI_LOG_CONTEXT(); ntsa::Error error; diff --git a/groups/ntc/ntcdns/ntcdns_resolver.t.cpp b/groups/ntc/ntcdns/ntcdns_resolver.t.cpp index e2ff1ee7..edea0093 100644 --- a/groups/ntc/ntcdns/ntcdns_resolver.t.cpp +++ b/groups/ntc/ntcdns/ntcdns_resolver.t.cpp @@ -633,6 +633,14 @@ NTCCFG_TEST_CASE(6) // Concern: Test 'getIpAddress' from database. // Plan: + if (!ntscfg::Platform::hasHostDatabase()) { + return; + } + + if (!ntscfg::Platform::hasPortDatabase()) { + return; + } + NTCI_LOG_CONTEXT(); ntsa::Error error; @@ -731,6 +739,14 @@ NTCCFG_TEST_CASE(7) // Concern: Test 'getDomainName' from database. // Plan: + if (!ntscfg::Platform::hasHostDatabase()) { + return; + } + + if (!ntscfg::Platform::hasPortDatabase()) { + return; + } + NTCI_LOG_CONTEXT(); ntsa::Error error; @@ -832,6 +848,14 @@ NTCCFG_TEST_CASE(8) // Concern: Test 'getPort' from database. // Plan: + if (!ntscfg::Platform::hasHostDatabase()) { + return; + } + + if (!ntscfg::Platform::hasPortDatabase()) { + return; + } + NTCI_LOG_CONTEXT(); ntsa::Error error; @@ -929,6 +953,14 @@ NTCCFG_TEST_CASE(9) // Concern: Test 'getServiceName' from database. // Plan: + if (!ntscfg::Platform::hasHostDatabase()) { + return; + } + + if (!ntscfg::Platform::hasPortDatabase()) { + return; + } + NTCI_LOG_CONTEXT(); ntsa::Error error; @@ -1027,6 +1059,14 @@ NTCCFG_TEST_CASE(10) // Concern: Test 'getEndpoint' from database. // Plan: + if (!ntscfg::Platform::hasHostDatabase()) { + return; + } + + if (!ntscfg::Platform::hasPortDatabase()) { + return; + } + NTCI_LOG_CONTEXT(); ntsa::Error error; @@ -1734,6 +1774,10 @@ NTCCFG_TEST_CASE(18) // Concern: Test 'getPort' from system. // Plan: + if (!ntscfg::Platform::hasPortDatabase()) { + return; + } + NTCI_LOG_CONTEXT(); ntsa::Error error; @@ -1810,6 +1854,10 @@ NTCCFG_TEST_CASE(19) // Concern: Test 'getServiceName' from system. // Plan: + if (!ntscfg::Platform::hasPortDatabase()) { + return; + } + NTCI_LOG_CONTEXT(); ntsa::Error error; @@ -1887,6 +1935,14 @@ NTCCFG_TEST_CASE(20) // Concern: Test 'getEndpoint' from system. // Plan: + if (!ntscfg::Platform::hasHostDatabase()) { + return; + } + + if (!ntscfg::Platform::hasPortDatabase()) { + return; + } + NTCI_LOG_CONTEXT(); ntsa::Error error; diff --git a/groups/ntc/ntcdns/ntcdns_utility.cpp b/groups/ntc/ntcdns/ntcdns_utility.cpp index d6972f6c..efa0f2ad 100644 --- a/groups/ntc/ntcdns/ntcdns_utility.cpp +++ b/groups/ntc/ntcdns/ntcdns_utility.cpp @@ -1317,7 +1317,16 @@ ntsa::Error Utility::loadClientConfig(ntcdns::ClientConfig* result) { #if defined(BSLS_PLATFORM_OS_UNIX) - return loadClientConfigFromPath(result, "/etc/resolv.conf"); + const bsl::string path = "/etc/resolv.conf"; + + if (bdls::FilesystemUtil::exists(path)) { + return loadClientConfigFromPath(result, path); + } + else { + result->reset(); + sanitizeClientConfig(result); + return ntsa::Error(); + } #elif defined(BSLS_PLATFORM_OS_WINDOWS) @@ -1404,13 +1413,27 @@ ntsa::Error Utility::loadHostDatabaseConfig(ntcdns::HostDatabaseConfig* result) { #if defined(BSLS_PLATFORM_OS_UNIX) - return loadHostDatabaseConfigFromPath(result, "/etc/hosts"); + const bsl::string path = "/etc/hosts"; + + if (bdls::FilesystemUtil::exists(path)) { + return loadHostDatabaseConfigFromPath(result, path); + } + else { + result->reset(); + return ntsa::Error(); + } #elif defined(BSLS_PLATFORM_OS_WINDOWS) - return loadHostDatabaseConfigFromPath( - result, - "C:\\Windows\\System32\\drivers\\etc\\hosts"); + const bsl::string path = "C:\\Windows\\System32\\drivers\\etc\\hosts"; + + if (bdls::FilesystemUtil::exists(path)) { + return loadHostDatabaseConfigFromPath(result, path); + } + else { + result->reset(); + return ntsa::Error(); + } #else #error Not implemented @@ -1487,13 +1510,27 @@ ntsa::Error Utility::loadPortDatabaseConfig(ntcdns::PortDatabaseConfig* result) { #if defined(BSLS_PLATFORM_OS_UNIX) - return loadPortDatabaseConfigFromPath(result, "/etc/services"); + const bsl::string path = "/etc/services"; + + if (bdls::FilesystemUtil::exists(path)) { + return loadPortDatabaseConfigFromPath(result, path); + } + else { + result->reset(); + return ntsa::Error(); + } #elif defined(BSLS_PLATFORM_OS_WINDOWS) - return loadPortDatabaseConfigFromPath( - result, - "C:\\Windows\\System32\\drivers\\etc\\services"); + const bsl::string path = "C:\\Windows\\System32\\drivers\\etc\\services"; + + if (bdls::FilesystemUtil::exists(path)) { + return loadPortDatabaseConfigFromPath(result, path); + } + else { + result->reset(); + return ntsa::Error(); + } #else #error Not implemented diff --git a/groups/ntc/ntcdns/ntcdns_utility.t.cpp b/groups/ntc/ntcdns/ntcdns_utility.t.cpp index e37df5e2..62f67b29 100644 --- a/groups/ntc/ntcdns/ntcdns_utility.t.cpp +++ b/groups/ntc/ntcdns/ntcdns_utility.t.cpp @@ -55,7 +55,7 @@ NTCCFG_TEST_CASE(1) { ntcdns::ClientConfig clientConfig(&ta); error = ntcdns::Utility::loadClientConfig(&clientConfig); - NTCCFG_TEST_ASSERT(!error); + NTCCFG_TEST_OK(error); NTCI_LOG_STREAM_TRACE << "Client configuration = " << clientConfig << NTCI_LOG_STREAM_END; @@ -67,6 +67,10 @@ NTCCFG_TEST_CASE(2) { // Concern: Host database configurations. + if (!ntscfg::Platform::hasHostDatabase()) { + return; + } + NTCI_LOG_CONTEXT(); ntsa::Error error; @@ -76,7 +80,7 @@ NTCCFG_TEST_CASE(2) { ntcdns::HostDatabaseConfig hostDatabaseConfig(&ta); error = ntcdns::Utility::loadHostDatabaseConfig(&hostDatabaseConfig); - NTCCFG_TEST_ASSERT(!error); + NTCCFG_TEST_OK(error); NTCI_LOG_STREAM_TRACE << "Host database = " << hostDatabaseConfig << NTCI_LOG_STREAM_END; @@ -88,6 +92,10 @@ NTCCFG_TEST_CASE(3) { // Concern: Port database configurations. + if (!ntscfg::Platform::hasPortDatabase()) { + return; + } + NTCI_LOG_CONTEXT(); ntsa::Error error; @@ -97,7 +105,7 @@ NTCCFG_TEST_CASE(3) { ntcdns::PortDatabaseConfig portDatabaseConfig(&ta); error = ntcdns::Utility::loadPortDatabaseConfig(&portDatabaseConfig); - NTCCFG_TEST_ASSERT(!error); + NTCCFG_TEST_OK(error); NTCI_LOG_STREAM_TRACE << "Port database = " << portDatabaseConfig << NTCI_LOG_STREAM_END; @@ -118,7 +126,7 @@ NTCCFG_TEST_CASE(4) { ntcdns::ResolverConfig resolverConfig(&ta); error = ntcdns::Utility::loadResolverConfig(&resolverConfig); - NTCCFG_TEST_ASSERT(!error); + NTCCFG_TEST_OK(error); NTCI_LOG_STREAM_TRACE << "Resolver configuration = " << resolverConfig << NTCI_LOG_STREAM_END; diff --git a/groups/ntc/ntcf/ntcf_system.t.cpp b/groups/ntc/ntcf/ntcf_system.t.cpp index bfdff27e..8492c44c 100644 --- a/groups/ntc/ntcf/ntcf_system.t.cpp +++ b/groups/ntc/ntcf/ntcf_system.t.cpp @@ -6454,6 +6454,10 @@ void concernResolverGetPort(bslma::Allocator* allocator) // Concern: Test 'Resolver::getPort' // Plan: + if (!ntscfg::Platform::hasPortDatabase()) { + return; + } + NTCI_LOG_CONTEXT(); const bsl::size_t k_NUM_ITERATIONS = 2; @@ -6512,6 +6516,10 @@ void concernResolverGetServiceName(bslma::Allocator* allocator) // Concern: Test 'Resolver::getServiceName' // Plan: + if (!ntscfg::Platform::hasPortDatabase()) { + return; + } + NTCI_LOG_CONTEXT(); const bsl::size_t k_NUM_ITERATIONS = 2; @@ -11575,7 +11583,7 @@ void concernDatagramSocketReceiveRateLimitTimerClose( ntsa::SocketOption socketOption; socketOption.makeSendBufferSize(k_MESSAGE_SIZE); - error = ntsf::System::setOption(basicClientSocket->handle(), + error = ntsf::System::setOption(basicClientSocket->handle(), socketOption); NTCCFG_TEST_FALSE(error); } @@ -11583,8 +11591,8 @@ void concernDatagramSocketReceiveRateLimitTimerClose( { ntsa::SocketOption socketOption; error = ntsf::System::getOption( - &socketOption, - basicClientSocket->handle(), + &socketOption, + basicClientSocket->handle(), ntsa::SocketOptionType::e_SEND_BUFFER_SIZE); NTCCFG_TEST_FALSE(error); @@ -11843,7 +11851,7 @@ void concernDatagramSocketSendRateLimitTimerClose( ntsa::SocketOption socketOption; socketOption.makeSendBufferSize(k_MESSAGE_SIZE); - error = ntsf::System::setOption(basicClientSocket->handle(), + error = ntsf::System::setOption(basicClientSocket->handle(), socketOption); NTCCFG_TEST_FALSE(error); } @@ -11851,8 +11859,8 @@ void concernDatagramSocketSendRateLimitTimerClose( { ntsa::SocketOption socketOption; error = ntsf::System::getOption( - &socketOption, - basicClientSocket->handle(), + &socketOption, + basicClientSocket->handle(), ntsa::SocketOptionType::e_SEND_BUFFER_SIZE); NTCCFG_TEST_FALSE(error); @@ -12343,7 +12351,7 @@ void concernDatagramSocketReceiveRateLimitTimerEventNotifications( ntsa::SocketOption socketOption; socketOption.makeSendBufferSize(k_MESSAGE_SIZE); - error = ntsf::System::setOption(basicClientSocket->handle(), + error = ntsf::System::setOption(basicClientSocket->handle(), socketOption); NTCCFG_TEST_FALSE(error); } @@ -12351,8 +12359,8 @@ void concernDatagramSocketReceiveRateLimitTimerEventNotifications( { ntsa::SocketOption socketOption; error = ntsf::System::getOption( - &socketOption, - basicClientSocket->handle(), + &socketOption, + basicClientSocket->handle(), ntsa::SocketOptionType::e_SEND_BUFFER_SIZE); NTCCFG_TEST_FALSE(error); @@ -12496,7 +12504,7 @@ void concernDatagramSocketSendRateLimitTimerEventNotifications( ntsa::SocketOption socketOption; socketOption.makeSendBufferSize(k_MESSAGE_SIZE); - error = ntsf::System::setOption(basicClientSocket->handle(), + error = ntsf::System::setOption(basicClientSocket->handle(), socketOption); NTCCFG_TEST_FALSE(error); } @@ -12504,8 +12512,8 @@ void concernDatagramSocketSendRateLimitTimerEventNotifications( { ntsa::SocketOption socketOption; error = ntsf::System::getOption( - &socketOption, - basicClientSocket->handle(), + &socketOption, + basicClientSocket->handle(), ntsa::SocketOptionType::e_SEND_BUFFER_SIZE); NTCCFG_TEST_FALSE(error); @@ -12594,7 +12602,7 @@ void concernStreamSocketReceiveRateLimitTimerEventNotifications( NTCI_LOG_CONTEXT(); NTCI_LOG_DEBUG("Test started"); - + const ntsa::Transport::Value transport = ntsa::Transport::e_TCP_IPV4_STREAM; @@ -12948,6 +12956,8 @@ void concernListenerSocketAcceptRateLimitTimerEventNotifications( NTCCFG_TEST_CASE(1) { + bsls::Log::setSeverityThreshold(bsls::LogSeverity::e_INFO); + ntccfg::TestAllocator ta; { test::concernExample1(&ta); diff --git a/groups/nts/ntscfg/ntscfg_platform.cpp b/groups/nts/ntscfg/ntscfg_platform.cpp index b0f2fbe7..28531d3f 100644 --- a/groups/nts/ntscfg/ntscfg_platform.cpp +++ b/groups/nts/ntscfg/ntscfg_platform.cpp @@ -18,6 +18,7 @@ #include BSLS_IDENT_RCSID(ntscfg_platform_cpp, "$Id$ $CSID$") +#include #include #include #include @@ -187,5 +188,35 @@ bool Platform::supportsTimestamps() return s_supportsTimestamps; } +#if defined(BSLS_PLATFORM_OS_UNIX) + +bool Platform::hasHostDatabase() +{ + return bdls::FilesystemUtil::exists("/etc/hosts"); +} + +bool Platform::hasPortDatabase() +{ + return bdls::FilesystemUtil::exists("/etc/services"); +} + +#elif defined(BSLS_PLATFORM_OS_WINDOWS) + +bool Platform::hasHostDatabase() +{ + return bdls::FilesystemUtil::exists( + "C:\\Windows\\System32\\drivers\\etc\\hosts"); +} + +bool Platform::hasPortDatabase() +{ + return bdls::FilesystemUtil::exists( + "C:\\Windows\\System32\\drivers\\etc\\services"); +} + +#else +#error Not implemented +#endif + } // close package namespace } // close enterprise namespace diff --git a/groups/nts/ntscfg/ntscfg_platform.h b/groups/nts/ntscfg/ntscfg_platform.h index 36fc582b..9cb5c409 100644 --- a/groups/nts/ntscfg/ntscfg_platform.h +++ b/groups/nts/ntscfg/ntscfg_platform.h @@ -220,6 +220,14 @@ struct Platform { /// process supports timestamping incoming and outgoing data, otherwise /// return false. static bool supportsTimestamps(); + + /// Return true if the local host database (i.e. "/etc/hosts" or the + /// platform equivalent) exists, otherwise return false. + static bool hasHostDatabase(); + + /// Return true if the local host database (i.e. "/etc/hosts" or the + /// platform equivalent) exists, otherwise return false. + static bool hasPortDatabase(); }; /// @internal @brief diff --git a/groups/nts/ntsu/ntsu_resolverutil.t.cpp b/groups/nts/ntsu/ntsu_resolverutil.t.cpp index 70c890ee..35bad8c3 100644 --- a/groups/nts/ntsu/ntsu_resolverutil.t.cpp +++ b/groups/nts/ntsu/ntsu_resolverutil.t.cpp @@ -16,6 +16,8 @@ #include #include +#include + #include #include #include @@ -422,6 +424,10 @@ NTSCFG_TEST_CASE(11) // Concern: Test resolution of service names to port numbers for use by // an unspecified transport. + if (!ntscfg::Platform::hasPortDatabase()) { + return; + } + ntscfg::TestAllocator ta; { ntsa::Error error; @@ -470,6 +476,10 @@ NTSCFG_TEST_CASE(12) // Concern: Test resolution of service names to port numbers for use by // a specific TCP-based transport. + if (!ntscfg::Platform::hasPortDatabase()) { + return; + } + ntscfg::TestAllocator ta; { ntsa::Error error; @@ -511,6 +521,10 @@ NTSCFG_TEST_CASE(13) // Concern: Test resolution of service names to port numbers for use by // a specific UDP-based transport. + if (!ntscfg::Platform::hasPortDatabase()) { + return; + } + ntscfg::TestAllocator ta; { ntsa::Error error; @@ -551,6 +565,10 @@ NTSCFG_TEST_CASE(14) // Concern: Test resolution of port numbers to service names. // Plan: + if (!ntscfg::Platform::hasPortDatabase()) { + return; + } + ntscfg::TestAllocator ta; { ntsa::Error error; @@ -656,7 +674,7 @@ NTSCFG_TEST_CASE(17) ipAddressOptions); if (error) { - NTSCFG_TEST_LOG_ERROR << "Error: " << error << NTSCFG_TEST_LOG_END; + NTSCFG_TEST_LOG_DEBUG << "Error: " << error << NTSCFG_TEST_LOG_END; } else { for (bsl::vector::const_iterator it = @@ -758,7 +776,7 @@ NTSCFG_TEST_CASE(20) ipAddressOptions); if (error) { - NTSCFG_TEST_LOG_ERROR << "Error: " << error << NTSCFG_TEST_LOG_END; + NTSCFG_TEST_LOG_DEBUG << "Error: " << error << NTSCFG_TEST_LOG_END; } else { for (bsl::vector::const_iterator it = @@ -792,7 +810,7 @@ NTSCFG_TEST_CASE(21) ipAddressOptions); if (error) { - NTSCFG_TEST_LOG_ERROR << "Error: " << error << NTSCFG_TEST_LOG_END; + NTSCFG_TEST_LOG_DEBUG << "Error: " << error << NTSCFG_TEST_LOG_END; } else { for (bsl::vector::const_iterator it = diff --git a/repository.cmake b/repository.cmake index 8ddf616d..d0e7822d 100644 --- a/repository.cmake +++ b/repository.cmake @@ -4696,7 +4696,7 @@ function (ntf_repository) ntf_repository_doxygen_output_path_set(VALUE ${doxygenOutputDirectory}) set(cmake_ctest_arguments ${CMAKE_CTEST_ARGUMENTS}) - list(APPEND cmake_ctest_arguments --output-junit Testing/Temporary/Test.xml) + list(APPEND cmake_ctest_arguments --stop-on-failure --output-on-failure --output-junit Testing/Temporary/Test.xml) set(CMAKE_CTEST_ARGUMENTS ${cmake_ctest_arguments} PARENT_SCOPE) set(CPACK_OUTPUT_FILE_PREFIX ${packageOutputDirectory} PARENT_SCOPE)