Skip to content

Commit

Permalink
Add support for adjusting TimeoutFactor through options. Set to 6 for…
Browse files Browse the repository at this point in the history
… OpenJDK. Should adjust accept timeout as well.
  • Loading branch information
wasabii committed Sep 25, 2023
1 parent ef8dd8f commit 51cb28c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
11 changes: 7 additions & 4 deletions src/IKVM.JTReg.TestAdapter.Core/JTRegTestManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ internal void RunTestsImpl(string source, string[] testDirs, List<JTRegTestCase>
bool Filter(dynamic td) => FilterByList(td) && FilterByContext(td);

context.SendMessage(JTRegTestMessageLevel.Informational, $"JTReg: Running test suite: {(string)testSuite.getName()}");
RunTestsImpl(source, testManager, testSuite, context, tests, output, CreateParameters(testManager, testSuite, (Func<dynamic, bool>)Filter, debugUri), cancellationToken);
RunTestsImpl(source, testManager, testSuite, context, tests, output, CreateParameters(testManager, testSuite, (Func<dynamic, bool>)Filter, context.Options, debugUri), cancellationToken);
}
}
catch (Exception e)
Expand All @@ -360,9 +360,10 @@ internal void RunTestsImpl(string source, string[] testDirs, List<JTRegTestCase>
/// <param name="testManager"></param>
/// <param name="testSuite"></param>
/// <param name="filter"></param>
/// <param name="options"></param>
/// <param name="debugUri"></param>
/// <returns></returns>
dynamic CreateParameters(dynamic testManager, dynamic testSuite, Func<dynamic, bool> filter, Uri debugUri)
dynamic CreateParameters(dynamic testManager, dynamic testSuite, Func<dynamic, bool> filter, JTRegTestOptions options, Uri debugUri)
{
if (testManager is null)
throw new ArgumentNullException(nameof(testManager));
Expand Down Expand Up @@ -397,7 +398,7 @@ dynamic CreateParameters(dynamic testManager, dynamic testSuite, Func<dynamic, b
rp.setFile((java.io.File)wd.getFile("config.jti"));
rp.setEnvVars(GetEnvVars(debugUri));
rp.setConcurrency(Environment.ProcessorCount);
rp.setTimeoutFactor(6);
rp.setTimeoutFactor(options.TimeoutFactor);
rp.setRetainArgs(java.util.Collections.singletonList("all"));
rp.setExcludeLists(excludeFileList.ToArray());
rp.setMatchLists(includeFileList.ToArray());
Expand Down Expand Up @@ -501,10 +502,12 @@ internal void RunTestsImpl(string source, dynamic testManager, dynamic testSuite
policyFileStream.WriteLine($@"grant codebase ""{java.nio.file.Paths.get(Path.Combine(JTREG_LIB, jarName)).toUri().toURL()}"" {{ permission java.security.AllPermission; }};");

// set parameters on pool
var opts = context.Options;
var pool = JTRegTypes.Agent.Pool.Instance();
pool.setTimeoutFactor(opts.TimeoutFactor);
pool.setSecurityPolicy(policyFile);

// before we install our own security manager (which will restrict access to the system properties) take a copy of the system properties
// before we install our own security manager (which will restrict access to the system properties) take a copy of the system propearties
JTRegTypes.TestEnvironment.AddDefaultPropTable("(system properties)", java.lang.System.getProperties());

// collect events from the harness
Expand Down
5 changes: 5 additions & 0 deletions src/IKVM.JTReg.TestAdapter.Core/JTRegTestOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ public class JTRegTestOptions
/// </summary>
public int PartitionCount { get; set; } = 8;

/// <summary>
/// Gets or sets the factor by which to multiply various timeouts.
/// </summary>
public float TimeoutFactor { get; set; } = 1.0f;

}

}
5 changes: 2 additions & 3 deletions src/IKVM.JTReg.TestAdapter/JTRegTestOptionsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ namespace IKVM.JTReg.TestAdapter
public static class JTRegTestOptionsExtensions
{

const int DEFAULT_PARTITION_COUNT = 8;

public static JTRegTestOptions ToJTRegOptions(this IRunSettings self)
{
var x = self?.SettingsXml != null ? XDocument.Parse(self.SettingsXml)?.Root?.Element("JTRegConfiguration") : null;
var o = new JTRegTestOptions();
o.PartitionCount = (int?)x?.Element("PartitionCount") ?? DEFAULT_PARTITION_COUNT;
o.PartitionCount = (int?)x?.Element("PartitionCount") ?? o.PartitionCount;
o.TimeoutFactor = (float?)x?.Element("TimeoutFactor") ?? o.TimeoutFactor;
return o;
}

Expand Down
1 change: 1 addition & 0 deletions src/IKVM.OpenJDK.Tests/IKVM.OpenJDK.Tests.runsettings
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<RunSettings>
<JTRegConfiguration>
<PartitionCount>16</PartitionCount>
<TimeoutFactor>6</TimeoutFactor>
</JTRegConfiguration>
</RunSettings>

0 comments on commit 51cb28c

Please sign in to comment.