Commit 69231de5 authored by cesomark's avatar cesomark
Browse files

Added Generation Test when Tagging datapath

parent ffd39b99
Pipeline #156000 failed with stages
in 21 seconds
...@@ -37,6 +37,7 @@ import java.util.Arrays; ...@@ -37,6 +37,7 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import static junit.framework.TestCase.assertTrue; import static junit.framework.TestCase.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
public class GenerationTest extends AbstractSymtabTest { public class GenerationTest extends AbstractSymtabTest {
...@@ -51,29 +52,24 @@ public class GenerationTest extends AbstractSymtabTest { ...@@ -51,29 +52,24 @@ public class GenerationTest extends AbstractSymtabTest {
@Test @Test
public void testCifar10Generation() throws IOException, TemplateException { public void testCifar10Generation() throws IOException, TemplateException {
Log.getFindings().clear(); Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/models/", "-r", "cifar10.Cifar10Classifier", "-b", "MXNET", "-f", "n", "-c", "n"}; String[] args = { "-m", "src/test/resources/models/", "-r", "cifar10.Cifar10Classifier", "-b", "MXNET", "-f",
"n", "-c", "n" };
EMADLGeneratorCli.main(args); EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().isEmpty()); assertTrue(Log.getFindings().isEmpty());
checkFilesAreEqual( checkFilesAreEqual(Paths.get("./target/generated-sources-emadl"), Paths.get("./src/test/resources/target_code"),
Paths.get("./target/generated-sources-emadl"), Arrays.asList("cifar10_cifar10Classifier.cpp", "cifar10_cifar10Classifier.h",
Paths.get("./src/test/resources/target_code"), "CNNCreator_cifar10_cifar10Classifier_net.py", "CNNBufferFile.h",
Arrays.asList( "CNNPredictor_cifar10_cifar10Classifier_net.h", "cifar10_cifar10Classifier_net.h",
"cifar10_cifar10Classifier.cpp", "CNNTranslator.h", "cifar10_cifar10Classifier_calculateClass.h",
"cifar10_cifar10Classifier.h",
"CNNCreator_cifar10_cifar10Classifier_net.py",
"CNNBufferFile.h",
"CNNPredictor_cifar10_cifar10Classifier_net.h",
"cifar10_cifar10Classifier_net.h",
"CNNTranslator.h",
"cifar10_cifar10Classifier_calculateClass.h",
"CNNTrainer_cifar10_cifar10Classifier_net.py")); "CNNTrainer_cifar10_cifar10Classifier_net.py"));
} }
@Test @Test
public void testSimulatorGeneration() throws IOException, TemplateException { public void testSimulatorGeneration() throws IOException, TemplateException {
Log.getFindings().clear(); Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/models/", "-r", "simulator.MainController", "-b", "MXNET", "-f", "n", "-c", "n"}; String[] args = { "-m", "src/test/resources/models/", "-r", "simulator.MainController", "-b", "MXNET", "-f",
"n", "-c", "n" };
EMADLGeneratorCli.main(args); EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().isEmpty()); assertTrue(Log.getFindings().isEmpty());
} }
...@@ -81,7 +77,7 @@ public class GenerationTest extends AbstractSymtabTest { ...@@ -81,7 +77,7 @@ public class GenerationTest extends AbstractSymtabTest {
@Test @Test
public void testAddGeneration() throws IOException, TemplateException { public void testAddGeneration() throws IOException, TemplateException {
Log.getFindings().clear(); Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/models/", "-r", "Add", "-b", "MXNET", "-f", "n", "-c", "n"}; String[] args = { "-m", "src/test/resources/models/", "-r", "Add", "-b", "MXNET", "-f", "n", "-c", "n" };
EMADLGeneratorCli.main(args); EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().isEmpty()); assertTrue(Log.getFindings().isEmpty());
} }
...@@ -89,7 +85,7 @@ public class GenerationTest extends AbstractSymtabTest { ...@@ -89,7 +85,7 @@ public class GenerationTest extends AbstractSymtabTest {
@Test @Test
public void testAlexnetGeneration() throws IOException, TemplateException { public void testAlexnetGeneration() throws IOException, TemplateException {
Log.getFindings().clear(); Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/models/", "-r", "Alexnet", "-b", "MXNET", "-f", "n", "-c", "n"}; String[] args = { "-m", "src/test/resources/models/", "-r", "Alexnet", "-b", "MXNET", "-f", "n", "-c", "n" };
EMADLGeneratorCli.main(args); EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().isEmpty()); assertTrue(Log.getFindings().isEmpty());
} }
...@@ -97,7 +93,7 @@ public class GenerationTest extends AbstractSymtabTest { ...@@ -97,7 +93,7 @@ public class GenerationTest extends AbstractSymtabTest {
@Test @Test
public void testResNeXtGeneration() throws IOException, TemplateException { public void testResNeXtGeneration() throws IOException, TemplateException {
Log.getFindings().clear(); Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/models/", "-r", "ResNeXt50", "-b", "MXNET", "-f", "n", "-c", "n"}; String[] args = { "-m", "src/test/resources/models/", "-r", "ResNeXt50", "-b", "MXNET", "-f", "n", "-c", "n" };
EMADLGeneratorCli.main(args); EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().isEmpty()); assertTrue(Log.getFindings().isEmpty());
} }
...@@ -105,7 +101,8 @@ public class GenerationTest extends AbstractSymtabTest { ...@@ -105,7 +101,8 @@ public class GenerationTest extends AbstractSymtabTest {
@Test @Test
public void testThreeInputGeneration() throws IOException, TemplateException { public void testThreeInputGeneration() throws IOException, TemplateException {
Log.getFindings().clear(); Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/models/", "-r", "ThreeInputCNN_M14", "-b", "MXNET", "-f", "n", "-c", "n"}; String[] args = { "-m", "src/test/resources/models/", "-r", "ThreeInputCNN_M14", "-b", "MXNET", "-f", "n", "-c",
"n" };
EMADLGeneratorCli.main(args); EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().size() == 1); assertTrue(Log.getFindings().size() == 1);
} }
...@@ -113,7 +110,8 @@ public class GenerationTest extends AbstractSymtabTest { ...@@ -113,7 +110,8 @@ public class GenerationTest extends AbstractSymtabTest {
@Test @Test
public void testMultipleOutputsGeneration() throws IOException, TemplateException { public void testMultipleOutputsGeneration() throws IOException, TemplateException {
Log.getFindings().clear(); Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/models/", "-r", "MultipleOutputs", "-b", "MXNET", "-f", "n", "-c", "n"}; String[] args = { "-m", "src/test/resources/models/", "-r", "MultipleOutputs", "-b", "MXNET", "-f", "n", "-c",
"n" };
EMADLGeneratorCli.main(args); EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().size() == 1); assertTrue(Log.getFindings().size() == 1);
} }
...@@ -121,7 +119,7 @@ public class GenerationTest extends AbstractSymtabTest { ...@@ -121,7 +119,7 @@ public class GenerationTest extends AbstractSymtabTest {
@Test @Test
public void testVGGGeneration() throws IOException, TemplateException { public void testVGGGeneration() throws IOException, TemplateException {
Log.getFindings().clear(); Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/models/", "-r", "VGG16", "-b", "MXNET", "-f", "n", "-c", "n"}; String[] args = { "-m", "src/test/resources/models/", "-r", "VGG16", "-b", "MXNET", "-f", "n", "-c", "n" };
EMADLGeneratorCli.main(args); EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().isEmpty()); assertTrue(Log.getFindings().isEmpty());
} }
...@@ -130,11 +128,11 @@ public class GenerationTest extends AbstractSymtabTest { ...@@ -130,11 +128,11 @@ public class GenerationTest extends AbstractSymtabTest {
public void testMultipleInstances() throws IOException, TemplateException { public void testMultipleInstances() throws IOException, TemplateException {
try { try {
Log.getFindings().clear(); Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/models/", "-r", "InstanceTest.MainB", "-b", "MXNET", "-f", "n", "-c", "n"}; String[] args = { "-m", "src/test/resources/models/", "-r", "InstanceTest.MainB", "-b", "MXNET", "-f", "n",
"-c", "n" };
EMADLGeneratorCli.main(args); EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().isEmpty()); assertTrue(Log.getFindings().isEmpty());
} } catch (Exception e) {
catch(Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
...@@ -142,59 +140,56 @@ public class GenerationTest extends AbstractSymtabTest { ...@@ -142,59 +140,56 @@ public class GenerationTest extends AbstractSymtabTest {
@Test @Test
public void testMnistClassifier() throws IOException, TemplateException { public void testMnistClassifier() throws IOException, TemplateException {
Log.getFindings().clear(); Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/models/", "-r", "mnist.MnistClassifier", "-b", "CAFFE2", "-f", "n", "-c", "n"}; String[] args = { "-m", "src/test/resources/models/", "-r", "mnist.MnistClassifier", "-b", "CAFFE2", "-f", "n",
"-c", "n" };
EMADLGeneratorCli.main(args); EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().isEmpty()); assertTrue(Log.getFindings().isEmpty());
checkFilesAreEqual( checkFilesAreEqual(Paths.get("./target/generated-sources-emadl"), Paths.get("./src/test/resources/target_code"),
Paths.get("./target/generated-sources-emadl"), Arrays.asList("mnist_mnistClassifier.cpp", "mnist_mnistClassifier.h",
Paths.get("./src/test/resources/target_code"), "CNNCreator_mnist_mnistClassifier_net.py", "CNNPredictor_mnist_mnistClassifier_net.h",
Arrays.asList( "mnist_mnistClassifier_net.h", "CNNTranslator.h", "mnist_mnistClassifier_calculateClass.h",
"mnist_mnistClassifier.cpp",
"mnist_mnistClassifier.h",
"CNNCreator_mnist_mnistClassifier_net.py",
"CNNPredictor_mnist_mnistClassifier_net.h",
"mnist_mnistClassifier_net.h",
"CNNTranslator.h",
"mnist_mnistClassifier_calculateClass.h",
"CNNTrainer_mnist_mnistClassifier_net.py")); "CNNTrainer_mnist_mnistClassifier_net.py"));
} }
@Test @Test
public void testMnistClassifierForGluon() throws IOException, TemplateException { public void testMnistClassifierForGluon() throws IOException, TemplateException {
Log.getFindings().clear(); Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/models/", "-r", "mnist.MnistClassifier", "-b", "GLUON", "-f", "n", "-c", "n"}; String[] args = { "-m", "src/test/resources/models/", "-r", "mnist.MnistClassifier", "-b", "GLUON", "-f", "n",
"-c", "n" };
EMADLGeneratorCli.main(args); EMADLGeneratorCli.main(args);
assertTrue(Log.getFindings().isEmpty()); assertTrue(Log.getFindings().isEmpty());
checkFilesAreEqual( checkFilesAreEqual(Paths.get("./target/generated-sources-emadl"),
Paths.get("./target/generated-sources-emadl"),
Paths.get("./src/test/resources/target_code/gluon"), Paths.get("./src/test/resources/target_code/gluon"),
Arrays.asList( Arrays.asList("CNNBufferFile.h", "CNNNet_mnist_mnistClassifier_net.py", "mnist_mnistClassifier.cpp",
"CNNBufferFile.h", "mnist_mnistClassifier.h", "CNNCreator_mnist_mnistClassifier_net.py",
"CNNNet_mnist_mnistClassifier_net.py", "CNNPredictor_mnist_mnistClassifier_net.h", "CNNDataLoader_mnist_mnistClassifier_net.py",
"mnist_mnistClassifier.cpp", "supervised_trainer.py", "mnist_mnistClassifier_net.h", "HelperA.h", "CNNTranslator.h",
"mnist_mnistClassifier.h", "mnist_mnistClassifier_calculateClass.h", "CNNTrainer_mnist_mnistClassifier_net.py",
"CNNCreator_mnist_mnistClassifier_net.py",
"CNNPredictor_mnist_mnistClassifier_net.h",
"CNNDataLoader_mnist_mnistClassifier_net.py",
"supervised_trainer.py",
"mnist_mnistClassifier_net.h",
"HelperA.h",
"CNNTranslator.h",
"mnist_mnistClassifier_calculateClass.h",
"CNNTrainer_mnist_mnistClassifier_net.py",
"mnist_mnistClassifier_net.h")); "mnist_mnistClassifier_net.h"));
} }
@Test @Test
public void testHashFunction() { public void testHashFunction() {
EMADLGenerator tester = new EMADLGenerator(Backend.MXNET); EMADLGenerator tester = new EMADLGenerator(Backend.MXNET);
try{ try {
tester.getChecksumForFile("invalid Path!"); tester.getChecksumForFile("invalid Path!");
assertTrue("Hash method should throw IOException on invalid path", false); assertTrue("Hash method should throw IOException on invalid path", false);
} catch(IOException e){ } catch (IOException e) {
} }
} }
@Test
public void testAlexNetTagging() {
Log.getFindings().clear();
String[] args = { "-m", "src/test/resources/models/", "-r", "tagging.Alexnet", "-b", "MXNET", "-f", "n", "-c",
"n" };
EMADLGeneratorCli.main(args);
assertEquals(Log.getFindings().size(), 1);
assertEquals(Log.getFindings().get(0).toString(),
"Tagfile was found, ignoring data_paths.txt: test/resources/models");
assertTrue(Log.getErrorCount() == 0);
}
} }
package tagging; package tagging;
conforms to dltag.DataPathTagSchema; conforms to dltag.DataPathTagSchema;
tags AlexNet { tags Alexnet {
tag Alexnet with DataPath = {path = component, type = random}; tag Alexnet with DataPath = {path = test/resources/models, type = random};
tag Parent.a1 with DataPath = {path = instanceA1, type = random}; tag Parent.a1 with DataPath = {path = instanceA1, type = random};
} }
package tagging; package tagging;
component Parent{ component Parent{
instance tagging.Alexnet a1; instance Alexnet a1;
instance tagging.Alexnet a2; instance Alexnet a2;
} }
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment