Commit c18c2cf5 authored by Evgeny Kusmenko's avatar Evgeny Kusmenko

Merge branch 'new_junit_tests' into 'master'

New JUnit tests

See merge request !27
parents 45b48793 821b76b8
Pipeline #106586 passed with stages
......@@ -37,6 +37,7 @@ public class CNNArchTemplateController {
private LayerNameCreator nameManager;
private ArchitectureSymbol architecture;
private String loss;
//temporary attributes. They are set after calling process()
private Writer writer;
......@@ -44,8 +45,6 @@ public class CNNArchTemplateController {
private Target targetLanguage;
private ArchitectureElementData dataElement;
public String loss;
public static final String CROSS_ENTROPY = "cross_entropy";
public static final String EUCLIDEAN = "euclidean";
......
......@@ -22,6 +22,7 @@ package de.monticore.lang.monticar.cnnarch.caffe2generator;
import de.se_rwth.commons.logging.Log;
import freemarker.template.TemplateException;
import org.apache.commons.cli.ParseException;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
......@@ -31,6 +32,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import org.junit.contrib.java.lang.system.Assertion;
import org.junit.contrib.java.lang.system.ExpectedSystemExit;
import static junit.framework.TestCase.assertTrue;
......@@ -62,26 +64,33 @@ public class GenerationTest extends AbstractSymtabTest{
}
@Test
public void testCifar10Classifier() throws IOException, TemplateException {
public void testUnsupportedLayersCifar10Classifier() throws IOException, TemplateException {
Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/valid_tests", "-r", "CifarClassifierNetwork", "-o", "./target/generated-sources-cnnarch/"};
exit.expectSystemExit();
CNNArch2Caffe2Cli.main(args);
exit.checkAssertionAfterwards(new Assertion() {
public void checkAssertion() {
assertTrue(Log.getFindings().size() == 2);
}
});
CNNArch2Caffe2Cli.main(args);
}
@Test
public void testAlexnetGeneration() throws IOException, TemplateException {
public void testUnsupportedLayersAlexnet() throws IOException, TemplateException {
Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/architectures", "-r", "Alexnet", "-o", "./target/generated-sources-cnnarch/"};
exit.expectSystemExit();
CNNArch2Caffe2Cli.main(args);
exit.checkAssertionAfterwards(new Assertion() {
public void checkAssertion() {
assertTrue(Log.getFindings().size() == 2);
}
});
CNNArch2Caffe2Cli.main(args);
}
@Test
public void testGeneratorVGG16() throws IOException, TemplateException {
public void testGeneratorVGG16Generation() throws IOException, TemplateException {
Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/architectures", "-r", "VGG16", "-o", "./target/generated-sources-cnnarch/"};
CNNArch2Caffe2Cli.main(args);
......@@ -102,18 +111,26 @@ public class GenerationTest extends AbstractSymtabTest{
Log.getFindings().clear();
String[] args = {"-m", "src/test/resources/architectures", "-r", "ThreeInputCNN_M14"};
exit.expectSystemExit();
CNNArch2Caffe2Cli.main(args);
exit.checkAssertionAfterwards(new Assertion() {
public void checkAssertion() {
assertTrue(Log.getFindings().size() == 2);
}
});
CNNArch2Caffe2Cli.main(args);
}
@Test
public void testResNeXtGeneration() throws IOException, TemplateException {
public void testUnsupportedLayersResNeXt() throws IOException, TemplateException {
Log.getFindings().clear();;
String[] args = {"-m", "src/test/resources/architectures", "-r", "ResNeXt50"};
exit.expectSystemExit();
CNNArch2Caffe2Cli.main(args);
exit.checkAssertionAfterwards(new Assertion() {
public void checkAssertion() {
assertTrue(Log.getFindings().size() == 2);
}
});
CNNArch2Caffe2Cli.main(args);
}
@Test
public void testMultipleOutputs() throws IOException, TemplateException {
......@@ -190,7 +207,9 @@ public class GenerationTest extends AbstractSymtabTest{
String rootModelName = "alexnet";
CNNArch2Caffe2 generator = new CNNArch2Caffe2();
generator.setGenerationTargetPath("./target/generated-sources-cnnarch");
if(generator.isCMakeRequired()){
generator.generateCMake(rootModelName);
}
assertTrue(Log.getFindings().isEmpty());
......@@ -207,4 +226,17 @@ public class GenerationTest extends AbstractSymtabTest{
"FindArmadillo.cmake"));
}
@Test
public void testWrongArgumentCNNArch2Caffe2Cli() throws ParseException {
Log.getFindings().clear();
String[] args = {"-x", "src/test/resources/architectures", "-y", "LeNet", "-z", "./target/generated-sources-cnnarch/"};
exit.expectSystemExit();
exit.checkAssertionAfterwards(new Assertion() {
public void checkAssertion() {
assertTrue(Log.getFindings().size() == 2);
}
});
CNNArch2Caffe2Cli.main(args);
}
}
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