Skip to content

Commit

Permalink
Add test for configuration propagation with recursive calls
Browse files Browse the repository at this point in the history
  • Loading branch information
DSouzaM committed Jan 14, 2025
1 parent ef177c1 commit 9e17866
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 0 deletions.
1 change: 1 addition & 0 deletions substratevm/mx.substratevm/mx_substratevm.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,6 +584,7 @@ def run_nic_conditional_config_test(agent_path, conditional_config_filter_path):
"createConfigPartOne",
"createConfigPartTwo",
"createConfigPartThree",
"createConfigPartFour",
]
config_directories = []
nic_test_dir = join(svmbuild_dir(), 'nic-cond-config-test')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void createTestConfig() {
NoPropagationNecessary.runTest();
PropagateToParent.runTest();
PropagateButLeaveCommonConfiguration.runTest();
PropagateThroughRecursiveCall.runTest();
}

}
Expand Down Expand Up @@ -190,3 +191,54 @@ static void doWork(String clazz, String resource, Class<?>... interfaceList) {
}

}

/**
* This is a regression test. It ensures that configuration propagated from a recursive call does
* not get lost (which can happen unless the configuration is propagated past any recursive
* callers).
*/
@SuppressWarnings("unused")
class PropagateThroughRecursiveCall {

public static void runTest() {
ParentA.doWork();
ParentB.doWork();
}

private static final class ParentA {
static void doWork() {
Recursive.recur(true, "PropagateThroughRecursiveCall$A");
}
}

private static final class ParentB {
static void doWork() {
Recursive.recur(true, "PropagateThroughRecursiveCall$B");
}
}

private static final class A1 {
}

private static final class A2 {
}

private static final class B1 {
}

private static final class B2 {
}

private static final class Recursive {
static void recur(boolean recurse, String clazz) {
ClassUtil.forName("PropagateThroughRecursiveCall$Recursive");
if (recurse) {
ClassUtil.forName(clazz + "1");
recur(false, clazz);
} else {
ClassUtil.forName(clazz + "2");
}

}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,9 @@ public void createConfigPartTwo() {
public void createConfigPartThree() {
runIfEnabled(PropagateButLeaveCommonConfiguration::runTest);
}

@Test
public void createConfigPartFour() {
runIfEnabled(PropagateThroughRecursiveCall::runTest);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,36 @@
"com.oracle.svm.configure.test.conditionalconfig.PropagateButLeaveCommonConfiguration$IC"
]
}
},
{
"condition": {
"typeReached": "com.oracle.svm.configure.test.conditionalconfig.PropagateThroughRecursiveCall$ParentA"
},
"type": "com.oracle.svm.configure.test.conditionalconfig.PropagateThroughRecursiveCall$A1"
},
{
"condition": {
"typeReached": "com.oracle.svm.configure.test.conditionalconfig.PropagateThroughRecursiveCall$ParentA"
},
"type": "com.oracle.svm.configure.test.conditionalconfig.PropagateThroughRecursiveCall$A2"
},
{
"condition": {
"typeReached": "com.oracle.svm.configure.test.conditionalconfig.PropagateThroughRecursiveCall$ParentB"
},
"type": "com.oracle.svm.configure.test.conditionalconfig.PropagateThroughRecursiveCall$B1"
},
{
"condition": {
"typeReached": "com.oracle.svm.configure.test.conditionalconfig.PropagateThroughRecursiveCall$ParentB"
},
"type": "com.oracle.svm.configure.test.conditionalconfig.PropagateThroughRecursiveCall$B2"
},
{
"condition": {
"typeReached": "com.oracle.svm.configure.test.conditionalconfig.PropagateThroughRecursiveCall$Recursive"
},
"type": "com.oracle.svm.configure.test.conditionalconfig.PropagateThroughRecursiveCall$Recursive"
}
],
"resources": [
Expand Down

0 comments on commit 9e17866

Please sign in to comment.