Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion build/devops_gated.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ resources:
jobs:
- template: /pipeline_templates/build_all_flavors.yml@c_build_tools
parameters:
cmake_options: -Drun_repo_validation:BOOL=ON -Drun_unittests:BOOL=ON -Drun_e2e_tests:BOOL=ON -Drun_int_tests:BOOL=ON -Drun_perf_tests:BOOL=ON -Drun_traceability:BOOL=ON -Duse_cppunittest:BOOL=ON -Drun_reals_check:BOOL=ON
cmake_options: -Drun_repo_validation:BOOL=ON -Drun_unittests:BOOL=ON -Drun_e2e_tests:BOOL=ON -Drun_int_tests:BOOL=ON -Drun_perf_tests:BOOL=ON -Drun_traceability:BOOL=ON -Duse_cppunittest:BOOL=ON -Drun_reals_check:BOOL=ON -Dlog_sink_etw:BOOL=ON
GBALLOC_LL_TYPE_VALUES: ["PASSTHROUGH", "JEMALLOC"]
pool_name_x64: ${{ parameters.pool_name_windows_x64 }}
pool_name_arm64: ${{ parameters.pool_name_windows_arm64 }}
arm64_max_stage: ALL

- template: /pipeline_templates/run_master_check.yml@c_build_tools
parameters:
Expand Down
2 changes: 1 addition & 1 deletion deps/c-logging
2 changes: 1 addition & 1 deletion deps/c-testrunnerswitcher
2 changes: 1 addition & 1 deletion deps/ctest
2 changes: 1 addition & 1 deletion deps/macro-utils-c
2 changes: 1 addition & 1 deletion deps/umock-c
2 changes: 1 addition & 1 deletion interfaces/tests/socket_transport_int/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set(${theseTestsName}_c_files
set(${theseTestsName}_h_files
)

build_test_artifacts(${theseTestsName} "tests/c_pal/int" ADDITIONAL_LIBS pal_interfaces c_pal)
build_test_artifacts_with_custom_main(${theseTestsName} "tests/c_pal/int" ADDITIONAL_LIBS pal_interfaces c_pal)

if(WIN32)
if("${building}" STREQUAL "exe")
Expand Down
73 changes: 73 additions & 0 deletions interfaces/tests/socket_transport_int/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include <stddef.h>

#ifdef WIN32
#include "winsock2.h"
#include "ws2tcpip.h"
#endif

#include "c_logging/logger.h"

#include "testrunnerswitcher.h"

#ifdef WIN32
// On the first name resolution call (getaddrinfo) Winsock lazily loads a namespace provider
// DLL. That one time load performs a heap allocation inside WS2_32/ntdll that lives for the
// lifetime of the process and is only released when the DLL is unloaded during process exit.
// ctest samples the VLD leak baseline at the very start of the run (before any test, including
// the suite initialize, executes), so when that allocation happens during the first test it is
// counted as a leak even though it is not one (VLD's own end of process report confirms no real
// leak). Whether VLD attributes the block at the sampling point is timing dependent, which made
// this test flaky (observed failing on ARM64 and reproducible on x64). Warming up name
// resolution here, before the baseline is captured, folds that one time allocation into the
// baseline so the leak delta nets to zero. The namespace provider DLL loaded by the first
// getaddrinfo is observed to stay resident after WSACleanup in the configurations tested, so its
// one time loader allocation persists for the rest of the run; WSACleanup is still called here so
// that Winsock's per startup caches are released and not reported as leaks themselves.
static void warm_up_winsock_name_resolution(void)
{
WSADATA wsa_data;
if (WSAStartup(MAKEWORD(2, 2), &wsa_data) == 0)
{
ADDRINFO hints = { 0 };
hints.ai_family = AF_INET;
hints.ai_socktype = SOCK_STREAM;
hints.ai_protocol = 0;
hints.ai_flags = AI_CANONNAME;

ADDRINFO* addr_info = NULL;
// Use the same host, family, socktype and flags as the production path in
// connect_to_client so the same namespace provider is loaded; the numeric service value
// mirrors the ports the tests use.
if (getaddrinfo("localhost", "4466", &hints, &addr_info) == 0)
{
freeaddrinfo(addr_info);
}

(void)WSACleanup();
}
}
#endif

int main(int argc, char* argv[])
{
size_t failed_test_count = 0;

// If a command line argument is provided, use it as a test name filter
// to run only the test case matching that name
const char* test_name_filter = (argc > 1) ? argv[1] : NULL;

#ifdef WIN32
warm_up_winsock_name_resolution();
#endif

(void)logger_init();

RUN_TEST_SUITE(TEST_SUITE_NAME_FROM_CMAKE, failed_test_count, test_name_filter);

logger_deinit();

return failed_test_count;
}
7 changes: 7 additions & 0 deletions interfaces/tests/socket_transport_int/main_cpp_unittest.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#include "run_cppunittest_suite.h"

// test_suite_name is a define passed from the CMakeLists and identifies the test suite name
RUN_TESTS_WITH_CPP_UNITTEST(TEST_SUITE_NAME_FROM_CMAKE)