use of helper.Utils.TestContext in project claw-compiler by C2SM-RCM.
the class AnalyzedPragmaTest method ctorTest.
@Test
public void ctorTest() {
Context context = new TestContext();
XcodeProgram xcodeml = XmlHelper.getDummyXcodeProgram(context);
Xnode p1 = xcodeml.createNode(Xcode.F_PRAGMA_STATEMENT);
p1.setValue("acc parallel");
Xnode p2 = xcodeml.createNode(Xcode.F_PRAGMA_STATEMENT);
p2.setValue("acc end parallel");
AnalyzedPragma ap1 = new AnalyzedPragma(p1);
assertFalse(ap1.isEndPragma());
assertNotNull(ap1.getPragma());
assertEquals("acc parallel", ap1.getPragma().value());
ap1.setEndPragma();
assertTrue(ap1.isEndPragma());
AnalyzedPragma ap2 = new AnalyzedPragma();
assertFalse(ap2.isEndPragma());
assertNull(ap2.getPragma());
ap2.setPragma(p2);
ap2.setEndPragma();
assertTrue(ap2.isEndPragma());
assertNotNull(ap2.getPragma());
}
use of helper.Utils.TestContext in project claw-compiler by C2SM-RCM.
the class ConfigurationTest method readConfig.
void readConfig(Path cfgDirPath) {
try {
Configuration conf = new TestConfiguration();
assertNotNull(conf);
Context context = new TestContext();
assertNotNull(context);
conf = Configuration.load(cfgDirPath, null, null, null, null, Integer.valueOf(MAX_COLUMN), context, Collections.emptyList());
assertNotNull(context.getGenerator());
assertNotNull(conf.accelerator());
assertEquals(MAX_COLUMN, context.getMaxColumns());
assertFalse(conf.isForcePure());
conf.setForcePure();
assertTrue(conf.isForcePure());
int[] majorMinor = conf.getMajorMinor("0.3");
assertEquals(0, majorMinor[0]);
assertEquals(3, majorMinor[1]);
try {
conf.checkVersion("0.2");
fail();
} catch (Exception ignored) {
}
try {
conf.getMajorMinor("sdjhsajkd");
fail();
} catch (Exception ignored) {
}
try {
conf.checkVersion(ClawVersion.VERSION);
} catch (Exception ignored) {
fail();
}
assertTrue(conf.accelerator() instanceof OpenAccConfiguration);
assertTrue(context.getGenerator() instanceof OpenAcc);
assertSame(Target.GPU, conf.getCurrentTarget());
assertSame(CompilerDirective.OPENACC, conf.getCurrentDirective());
assertEquals(Configuration.CPU_STRATEGY_FUSION, conf.getParameter(Configuration.CPU_STRATEGY));
conf.overrideConfigurationParameter(Configuration.CPU_STRATEGY, Configuration.CPU_STRATEGY_SINGLE);
assertEquals(Configuration.CPU_STRATEGY_SINGLE, conf.getParameter(Configuration.CPU_STRATEGY));
assertNull(conf.getParameter(DUMMY_KEY));
conf.overrideConfigurationParameter(DUMMY_KEY, DUMMY_VALUE);
assertEquals(DUMMY_VALUE, conf.getParameter(DUMMY_KEY));
} catch (Exception e) {
fail();
}
}
use of helper.Utils.TestContext in project claw-compiler by C2SM-RCM.
the class FmoduleDefinitionTest method simpleModuleDefinitionTest.
@Test
public void simpleModuleDefinitionTest() {
Context context = new TestContext();
Xnode node = XmlHelper.createXnode(module1);
FmoduleDefinition mod = new FmoduleDefinition(node);
assertNotNull(mod);
assertEquals("module", mod.getName());
assertEquals(4, mod.lineNo());
assertEquals("./src/module.f90", mod.filename());
assertNull(mod.getSymbolTable());
assertNull(mod.getDeclarationTable());
XcodeProgram xcodeml = XcodeProgram.createFromFile(TestConstant.TEST_DECLARATIONS, context);
assertNotNull(xcodeml);
List<Xnode> nodes = xcodeml.matchAll(Xcode.F_MODULE_DEFINITION);
assertFalse(nodes.isEmpty());
FmoduleDefinition modDef = new FmoduleDefinition(nodes.get(0));
assertEquals("mod1", modDef.getName());
assertFalse(modDef.getFunctionDefinition(null).isPresent());
assertFalse(modDef.getFunctionDefinition("").isPresent());
assertTrue(modDef.getFunctionDefinition("sub1").isPresent());
assertNotNull(modDef.cloneNode());
}
use of helper.Utils.TestContext in project claw-compiler by C2SM-RCM.
the class ClawPragmaTest method setUp.
@Before
public void setUp() {
cfg = new TestConfiguration();
context = new TestContext();
}
use of helper.Utils.TestContext in project claw-compiler by C2SM-RCM.
the class XnodeUtilTest method gatherArgumentsTest.
@Test
public void gatherArgumentsTest() {
Context context = new TestContext();
String arg1 = "nz";
String arg2 = "q(:,1:60)";
String arg3 = "ty%y(:,:)";
String arg4 = "z(:)";
String arg5 = "nproma";
assertTrue(Files.exists(TestConstant.TEST_ARGUMENTS));
XcodeProgram xcodeml = XcodeProgram.createFromFile(TestConstant.TEST_ARGUMENTS, context);
assertNotNull(xcodeml);
List<Xnode> functionCalls = xcodeml.matchAll(Xcode.FUNCTION_CALL);
assertEquals(1, functionCalls.size());
FunctionCall fctCall = new FunctionCall(functionCalls.get(0));
assertSame(fctCall.opcode(), Xcode.FUNCTION_CALL);
FfunctionType fctType = xcodeml.getTypeTable().getFunctionType(fctCall);
List<String> allArguments = fctCall.gatherArguments(xcodeml, fctType, xcodeml, Intent.ANY, false, false);
assertEquals(5, allArguments.size());
assertEquals(arg1, allArguments.get(0));
assertEquals(arg2, allArguments.get(1));
assertEquals(arg3, allArguments.get(2));
assertEquals(arg4, allArguments.get(3));
assertEquals(arg5, allArguments.get(4));
List<String> inArguments = fctCall.gatherArguments(xcodeml, fctType, xcodeml, Intent.IN, false, false);
assertEquals(5, inArguments.size());
assertEquals(arg1, inArguments.get(0));
assertEquals(arg2, inArguments.get(1));
assertEquals(arg3, inArguments.get(2));
assertEquals(arg4, inArguments.get(3));
assertEquals(arg5, inArguments.get(4));
List<String> outArguments = fctCall.gatherArguments(xcodeml, fctType, xcodeml, Intent.OUT, false, false);
assertEquals(3, outArguments.size());
assertEquals(arg2, outArguments.get(0));
assertEquals(arg3, outArguments.get(1));
assertEquals(arg4, outArguments.get(2));
List<String> inArrayArguments = fctCall.gatherArguments(xcodeml, fctType, xcodeml, Intent.IN, true, false);
assertEquals(3, inArrayArguments.size());
assertEquals(arg2, inArrayArguments.get(0));
assertEquals(arg3, inArrayArguments.get(1));
assertEquals(arg4, inArrayArguments.get(2));
List<String> outArrayArguments = fctCall.gatherArguments(xcodeml, fctType, xcodeml, Intent.OUT, true, false);
assertEquals(3, outArrayArguments.size());
assertEquals(arg2, outArrayArguments.get(0));
assertEquals(arg3, outArrayArguments.get(1));
assertEquals(arg4, outArrayArguments.get(2));
List<String> inOutArrayArguments = fctCall.gatherArguments(xcodeml, fctType, xcodeml, Intent.INOUT, true, false);
assertEquals(3, inOutArrayArguments.size());
assertEquals(arg2, inOutArrayArguments.get(0));
assertEquals(arg3, inOutArrayArguments.get(1));
assertEquals(arg4, inOutArrayArguments.get(2));
// TODO add test with optional arguments
}
Aggregations