Skip to content

Commit 1b15de7

Browse files
jbachorikclaude
andcommitted
Fix test infrastructure for cross-platform stability
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f2a3a22 commit 1b15de7

2 files changed

Lines changed: 15 additions & 4 deletions

File tree

ddprof-test/src/test/java/com/datadoghq/profiler/context/TagContextTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ private void checkTagValues(ContextSetter contextSetter, String contextAttribute
161161

162162
@Override
163163
protected String getProfilerCommand() {
164-
return "wall=1ms,filter=0,attributes=tag1;tag2;tag3";
164+
// Use cstack=default explicitly: this test covers context-tagging correctness,
165+
// not stack-walking mode. CSTACK_VM is the global default but is unreliable
166+
// on certain CI runners (musl x64), so we pin to a stable mode here.
167+
return "wall=1ms,filter=0,cstack=default,attributes=tag1;tag2;tag3";
165168
}
166169
}

ddprof-test/src/test/java/com/datadoghq/profiler/junit/CStackInjector.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,17 @@ public Stream<TestTemplateInvocationContext> provideTestTemplateInvocationContex
5050
// zing is a bit iffy when using anything but 'no' for cstack
5151
return Stream.of(new ParameterizedTestContext("no", retryCount));
5252
} else {
53-
return Stream.of(valueSource.strings()).
54-
filter(CStackInjector::isModeSafe).
55-
map(param -> new ParameterizedTestContext(param, retryCount));
53+
List<String> safeValues = Stream.of(valueSource.strings())
54+
.filter(CStackInjector::isModeSafe)
55+
.collect(Collectors.toList());
56+
if (safeValues.isEmpty()) {
57+
// No mode passed the filter (e.g. J9 with a {"vm","vmx"} @ValueSource).
58+
// Fall back to the first declared value so the test can reach
59+
// isPlatformSupported() and skip cleanly rather than failing with
60+
// PreconditionViolationException (JUnit 5 requires ≥1 invocation context).
61+
safeValues = Collections.singletonList(valueSource.strings()[0]);
62+
}
63+
return safeValues.stream().map(param -> new ParameterizedTestContext(param, retryCount));
5664
}
5765
}
5866

0 commit comments

Comments
 (0)