Commit 1ef29551 authored by Nicolas Carion's avatar Nicolas Carion

fuzzing reproducer now emits test-case

parent 41a13fcc
...@@ -21,13 +21,28 @@ ...@@ -21,13 +21,28 @@
#include "core.h" #include "core.h"
#include "fuzzing.hpp" #include "fuzzing.hpp"
#include "logger.hpp"
#include <QApplication> #include <QApplication>
#include <csignal>
#include <cstring> #include <cstring>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
void signalHandler(int signum)
{
std::cout << "Interrupt signal (" << signum << ") received.\n";
Logger::print_trace();
exit(signum);
}
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
signal(SIGINT, signalHandler);
signal(SIGTERM, signalHandler);
signal(SIGABRT, signalHandler);
signal(SIGSEGV, signalHandler);
QApplication app(argc, argv); QApplication app(argc, argv);
qputenv("MLT_TESTS", QByteArray("1")); qputenv("MLT_TESTS", QByteArray("1"));
Core::build(); Core::build();
...@@ -38,5 +53,6 @@ int main(int argc, char **argv) ...@@ -38,5 +53,6 @@ int main(int argc, char **argv)
} }
std::cout << "executing " << ss.str() << std::endl; std::cout << "executing " << ss.str() << std::endl;
fuzz(ss.str()); fuzz(ss.str());
Logger::print_trace();
return 0; return 0;
} }
...@@ -256,9 +256,9 @@ void Logger::print_trace() ...@@ -256,9 +256,9 @@ void Logger::print_trace()
return ss.str(); return ss.str();
}; };
std::ofstream fuzz_file; std::ofstream fuzz_file;
fuzz_file.open("fuzz_case.txt"); fuzz_file.open("fuzz_case_" + std::to_string(dump_count) + ".txt");
std::ofstream test_file; std::ofstream test_file;
test_file.open("test_case.cpp"); test_file.open("test_case_" + std::to_string(dump_count) + ".cpp");
test_file << "TEST_CASE(\"Regression\") {" << std::endl; test_file << "TEST_CASE(\"Regression\") {" << std::endl;
test_file << "auto binModel = pCore->projectItemModel();" << std::endl; test_file << "auto binModel = pCore->projectItemModel();" << std::endl;
test_file << "std::shared_ptr<DocUndoStack> undoStack = std::make_shared<DocUndoStack>(nullptr);" << std::endl; test_file << "std::shared_ptr<DocUndoStack> undoStack = std::make_shared<DocUndoStack>(nullptr);" << std::endl;
......
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