Skip to content

Commit 964eed9

Browse files
committed
[TEST] Bound the curl cases, and check the layout claim instead of asserting it
Two things this branch said but did not enforce. The cases here cover waits that are meant to end. When one stops ending it hangs rather than fails, and nothing bounded them, so a regression took the whole job with it instead of reporting. That happened three times while this branch was being written, each time as exit 124 with no case after it running. Every curl case now carries a CTest timeout of 120 seconds, read back from ctest --show-only=json-v1 as 120.0 on all 35. The slowest case that legitimately waits takes thirty. The description also claimed that std::atomic<SessionState> is one byte, aligned to one, and lock free, so the installed layout does not move. That was a measurement on one toolchain stated as a property of the language. The standard promises none of it. The size and alignment halves are now static_asserts, so a toolchain where they do not hold says so while building rather than silently changing an installed type. 32 tests pass. Signed-off-by: thc1006 <84045975+thc1006@users.noreply.github.com>
1 parent e7c9427 commit 964eed9

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎ext/src/http/client/curl/http_operation_curl.cc‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,18 @@ int HttpOperation::OnProgressCallback(void *clientp,
401401
}
402402
#endif
403403

404+
// The atomic member is only free of layout cost while it stays the size and alignment of the
405+
// enum it replaced. The standard does not promise that, so it is checked here rather than
406+
// asserted in prose: a toolchain where it does not hold changes an installed type and should say
407+
// so at build time.
408+
static_assert(sizeof(std::atomic<opentelemetry::ext::http::client::SessionState>) ==
409+
sizeof(opentelemetry::ext::http::client::SessionState),
410+
"std::atomic<SessionState> grew, which changes the layout of HttpOperation");
411+
static_assert(
412+
alignof(std::atomic<opentelemetry::ext::http::client::SessionState>) ==
413+
alignof(opentelemetry::ext::http::client::SessionState),
414+
"std::atomic<SessionState> is more aligned, which changes the layout of HttpOperation");
415+
404416
void HttpOperation::DispatchEvent(opentelemetry::ext::http::client::SessionState type,
405417
const std::string &reason)
406418
{

‎ext/test/http/CMakeLists.txt‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ if(WITH_HTTP_CLIENT_CURL)
1515
TARGET ${FILENAME}
1616
TEST_PREFIX ext.http.curl.
1717
TEST_LIST ${FILENAME})
18+
# These cover waits that are meant to end. When one stops ending it hangs
19+
# rather than fails, and without a bound it takes the whole job with it
20+
# instead of reporting. The slowest case that legitimately waits takes thirty
21+
# seconds.
22+
set_tests_properties(${${FILENAME}} PROPERTIES TIMEOUT 120)
1823
endif()
1924

2025
set(SOCKET_TOOLS_FILENAME socket_tools_test)

0 commit comments

Comments
 (0)