From c60dc1c00f04aacdebddbba2b0ef00294bbacca4 Mon Sep 17 00:00:00 2001 From: renfeiw Date: Thu, 25 Mar 2021 13:34:31 -0400 Subject: [PATCH] Enhance platform requirements mechanism - the new feature utilize regex to specify platform fixes https://github.com/adoptium/TKG/issues/166 Signed-off-by: renfeiw --- src/org/testKitGen/TestInfo.java | 10 ++++++++++ src/org/testKitGen/TestInfoParser.java | 14 +++++++++++--- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/org/testKitGen/TestInfo.java b/src/org/testKitGen/TestInfo.java index 896fcbb4..68a6a820 100644 --- a/src/org/testKitGen/TestInfo.java +++ b/src/org/testKitGen/TestInfo.java @@ -22,6 +22,7 @@ public class TestInfo { private String testCaseName; private String command; + private String platform; private String platformRequirements; private List vars; private Map capabilities; @@ -37,6 +38,7 @@ public class TestInfo { public TestInfo(Arguments arg) { this.testCaseName = null; this.command = null; + this.platform = null; this.platformRequirements = null; this.vars = new ArrayList(); this.aotOptions = ""; @@ -72,6 +74,14 @@ public void setCommand(String command) { this.command = command; } + public String getPlatform() { + return this.platform; + } + + public void setPlatform(String platform) { + this.platform = platform; + } + public String getPlatformRequirements() { return this.platformRequirements; } diff --git a/src/org/testKitGen/TestInfoParser.java b/src/org/testKitGen/TestInfoParser.java index 5a868792..bb54f11f 100644 --- a/src/org/testKitGen/TestInfoParser.java +++ b/src/org/testKitGen/TestInfoParser.java @@ -75,6 +75,11 @@ public TestInfo parse() { } if (!isValidAot) return null; + NodeList platNodes = testEle.getElementsByTagName("platform"); + if (platNodes.getLength() > 0) { + ti.setPlatform(platNodes.item(0).getTextContent().trim()); + } + NodeList preqNodes = testEle.getElementsByTagName("platformRequirements"); if (preqNodes.getLength() > 0) { ti.setPlatformRequirements(preqNodes.item(0).getTextContent().trim()); @@ -85,12 +90,12 @@ public TestInfo parse() { List listOfVars = new ArrayList(); for (int i = 0; i < variations.size(); i++) { String subTestName = ti.getTestCaseName() + "_" + i; - Variation var = parseVariation(subTestName, variations.get(i), ti.getPlatformRequirements()); + Variation var = parseVariation(subTestName, variations.get(i), ti.getPlatform(), ti.getPlatformRequirements()); listOfVars.add(var); } if (variations.size() == 0) { String subTestName = ti.getTestCaseName() + "_0"; - Variation var = parseVariation(subTestName, "NoOptions", ti.getPlatformRequirements()); + Variation var = parseVariation(subTestName, "NoOptions", ti.getPlatform(), ti.getPlatformRequirements()); listOfVars.add(var); } ti.setVars(listOfVars); @@ -206,6 +211,7 @@ private void parseDisableInfo(TestInfo ti) { } private boolean checkPlat(String plat) { + if (plat == null) return true; Pattern pattern = Pattern.compile(plat); Matcher matcher = pattern.matcher(arg.getPlat()); return matcher.matches(); @@ -254,7 +260,7 @@ private String joinStrList(List list) { return sb.toString(); } - private Variation parseVariation(String subTestName, String variation, String platformRequirements) { + private Variation parseVariation(String subTestName, String variation, String platform, String platformRequirements) { Variation var = new Variation(subTestName, variation); String jvmOptions = " " + variation + " "; @@ -276,6 +282,8 @@ private Variation parseVariation(String subTestName, String variation, String pl jvmOptions = jvmOptions.replace("Mode" + mode, clArgs); } jvmOptions = jvmOptions.trim(); + isValid &= checkPlat(platform); + //TODO: remove platformRequirements isValid &= checkPlatformReq(platformRequirements); var.setJvmOptions(jvmOptions);