--- /dev/null
+/*
+ * This is simple tests to check that generator is running properly and creates compilable artifact
+ * This test is not intended to check correctness of generated artifact
+ */
+
+#include <iostream>
+#include <fstream>
+#include <string>
+
+#include <stdlib.h>
+
+#include "support/CommandLine.h"
+#include "option/Options.h"
+
+#include "core/modelIR/graph.h"
+#include "core/modelIR/Shape.h"
+#include "core/modelIR/operations/relu_op.h"
+#include "core/modelIR/operations/variable_op.h"
+
+#include "core/modelIR/ShapeInference.h"
+#include "cpp_generator.h"
+
+// This header generated and contains array with test_main.def contents
+#include "test_main.h"
+
+using namespace std;
+
+using namespace nncc::contrib;
+using namespace nncc::contrib::core::data;
+using namespace nncc::contrib::core::IR::model;
+
+// Creates simple graph with input and output
+void fillGraph(Graph &g)
+{
+ INode *opNode = g.create<ops::ReluOp>("out");
+ Shape inputShape{1, 2, 3};
+
+ INode *inputNode = g.create<ops::VariableOp>("in");
+
+ opNode->connectInputTo(0, inputNode->getOutput(0));
+
+ inputNode->getOperation()->setOutputShape(0, inputShape);
+
+ g.markOutput(opNode);
+
+ ShapeInference shapeInferencer;
+ g.accept(&shapeInferencer);
+}
+
+static void checkFileExists(const string &path)
+{
+ ifstream f(path);
+ if (!f.good())
+ {
+ cerr << "file " << path << " not created\n";
+ exit(1);
+ }
+}
+
+static void createMain(const string &path, const string &headerPath)
+{
+ ofstream out(path);
+ if (!out.good())
+ {
+ cerr << "Main file " << path << " not created\n";
+ exit(1);
+ }
+ out << "#include \"" << headerPath << "\"\n";
+ out.write(test_main, sizeof(test_main));
+}
+
+int main(int argc, const char *argv[])
+{
+ clopt::CommandLine::getParser()->parseCommandLine(argc, argv, false);
+ std::string outputDir = clopt::artifactDir;
+ std::string artifactName = clopt::artifactName;
+
+ Graph g;
+ fillGraph(g);
+
+ nncc::contrib::backend::soft::CPPCodeGenerator().generate(&g);
+
+ string basePath = outputDir + "/" + artifactName;
+
+ string codePath = basePath + ".cpp";
+ string headerPath = basePath + ".h";
+ string mainPath = basePath + "_main.cpp";
+
+ checkFileExists(codePath);
+ checkFileExists(headerPath);
+ checkFileExists(basePath + ".params");
+
+ createMain(mainPath, artifactName + ".h");
+
+ string targetCompiler = "g++ -Wall --std=c++11";
+
+ string compilerCommand = targetCompiler + " -I" + outputDir + " " + mainPath + " " + codePath;
+
+ // call compiler
+ int res = system(compilerCommand.c_str());
+
+ if (res == -1)
+ {
+ cerr << "failed to call compiler\n";
+ return 2;
+ }
+ if (res != 0)
+ {
+ cerr << "compiler did not succeed with error code " << res << ": " << compilerCommand << "\n";
+ return 3;
+ }
+ return 0;
+}