Skip to content

Commit 013f2d2

Browse files
bsheedy-workDawn LUCI CQ
authored andcommitted
Refactor test name truncation
Refactors the logic used for determining if test names need to be truncated in order to fit within the 256 character limit for ResultDB. Previously, we checked if the test class + some fixed value + the sanitized name was less than some arbitrary number of characters. This was problematic since it did not cleanly take into account any prefixes added to the test class or test names that were significantly longer than the fixed value we used, leading to cases where tests were not truncated when they should be. Now, we keep track of the longest test name we've seen in the wild and truncate if that + the sanitized parameters are over a threshold. Bug: 413427416 Change-Id: I097f7a9f58ab5f2d74f61d0750e1fb60c3fa167f Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/261440 Reviewed-by: Kai Ninomiya <[email protected]> Commit-Queue: Kai Ninomiya <[email protected]> Auto-Submit: Brian Sheedy <[email protected]>
1 parent a906160 commit 013f2d2

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/dawn/tests/DawnTest.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,16 +166,20 @@ std::string DawnTestBase::PrintToStringParamName::SanitizeParamName(
166166
sanitizedName.resize(sanitizedName.length() - 1);
167167
}
168168

169-
// We don't know the test name at this point, but the format usually looks like
170-
// this.
171-
std::string prefix = mTest + ".TheTestNameUsuallyGoesHere/";
172-
std::string testFormat = prefix + sanitizedName;
173-
if (testFormat.length() > 210) {
169+
// We don't know the test name, so assume that it is the longest one we
170+
// have found in the wild for the purposes of calculating length.
171+
std::string longestKnownTest =
172+
(std::string("OpenGLES_EGLSync/SharedTextureMemoryTests.") +
173+
std::string("GetPropertiesAHardwareBufferPropertiesRequiresAHBFeature/"));
174+
std::string testFormat = longestKnownTest + sanitizedName;
175+
if (testFormat.length() > 240) {
174176
// The bots don't support test names longer than 256. Shorten the name and append a unique
175177
// index if we're close. The failure log will still print the full param name.
178+
// We use a number < 256 to leave a bit of buffer in case a new test gets added that is
179+
// slightly longer than our longest known test.
176180
std::string suffix = std::string("__") + std::to_string(index);
177181
size_t targetLength = sanitizedName.length();
178-
targetLength -= testFormat.length() - 210;
182+
targetLength -= testFormat.length() - 240;
179183
targetLength -= suffix.length();
180184
sanitizedName.resize(targetLength);
181185
sanitizedName = sanitizedName + suffix;

0 commit comments

Comments
 (0)