From a9ccb0243b245bd5c1e704608a4ee31ec7647f0e Mon Sep 17 00:00:00 2001 From: Mikhail Krinkin Date: Wed, 11 Dec 2024 15:46:02 +0000 Subject: [PATCH] [stream info] Fix broken StreamInfoImpl test I'm not fully familiar with the background of the assertStreamInfoSize, but it appears that the purpose of this check is to make sure that changes to StreamInfoImpl aren't going to break setFromForRecreateStream or setFrom. Ideally we would not rely on such a test and instead test setFromForRecreateStream functionality directly, but I understand that it might be difficult to come up with a good test that covers all the cases. However, this test was apprently broken by https://github.com/envoyproxy/envoy/pull/35650. This PR addedd a new field to the StreamInfoImpl changing the layout of the structure and with that the test. Interestingly enough, the same PR actually updated StreamInfoImpl::setFrom function (which the test reminds us to do every time we change StreamInfoImpl), but at the same time it didn't change the test. Anyways, keeping the status quo around while I don't have a good alternative solution in mind yet I fix this test and add some comments in the check to give folks a clue as to why sizeof(StreamInfoImpl) may return different values. I also noticed that the list of possible values for the size of StreamInfoImpl is way too long (we don't have that many different ABIs) and even contains a duplicate, so I cleaned it up as well and reduced the list to just 3 values. I will see in free time if I can replace this test with something else that does not rely on a specific layout of the StreamInfoImpl structure. Signed-off-by: Mikhail Krinkin --- test/common/stream_info/stream_info_impl_test.cc | 11 ++++++----- tools/spelling/spelling_dictionary.txt | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/test/common/stream_info/stream_info_impl_test.cc b/test/common/stream_info/stream_info_impl_test.cc index 6e8358c531ee..090424a4ce70 100644 --- a/test/common/stream_info/stream_info_impl_test.cc +++ b/test/common/stream_info/stream_info_impl_test.cc @@ -41,11 +41,12 @@ class StreamInfoImplTest : public testing::Test { protected: void assertStreamInfoSize(StreamInfoImpl stream_info) { ASSERT_TRUE( - sizeof(stream_info) == 840 || sizeof(stream_info) == 856 || sizeof(stream_info) == 888 || - sizeof(stream_info) == 776 || sizeof(stream_info) == 728 || sizeof(stream_info) == 744 || - sizeof(stream_info) == 680 || sizeof(stream_info) == 696 || sizeof(stream_info) == 688 || - sizeof(stream_info) == 736 || sizeof(stream_info) == 728 || sizeof(stream_info) == 712 || - sizeof(stream_info) == 704) + // with --config=docker-msan + sizeof(stream_info) == 712 || + // with --config=docker-clang + sizeof(stream_info) == 720 || + // with --config=docker-clang-libc++ + sizeof(stream_info) == 688) << "If adding fields to StreamInfoImpl, please check to see if you " "need to add them to setFromForRecreateStream or setFrom! Current size " << sizeof(stream_info); diff --git a/tools/spelling/spelling_dictionary.txt b/tools/spelling/spelling_dictionary.txt index ec5bdab317bf..e2648218fdfe 100644 --- a/tools/spelling/spelling_dictionary.txt +++ b/tools/spelling/spelling_dictionary.txt @@ -333,6 +333,7 @@ ODCDS middlewildcard monostate mpd +msan mutators mybucket myobject