summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-07-24 21:20:47 -0400
committerDavid Robillard <d@drobilla.net>2016-07-24 21:21:27 -0400
commit5ac170a5c8af27bd5e76beb587a001d7648548d6 (patch)
tree3d2c7eb50241d9d5bc1fd3870585ef30ecbffd16
parent305a1b226ac27737c3626126b8c61f722e383911 (diff)
downloadingen-5ac170a5c8af27bd5e76beb587a001d7648548d6.tar.gz
ingen-5ac170a5c8af27bd5e76beb587a001d7648548d6.tar.bz2
ingen-5ac170a5c8af27bd5e76beb587a001d7648548d6.zip
Fix crash when initial test graph does not exist
-rw-r--r--tests/ingen_test.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/ingen_test.cpp b/tests/ingen_test.cpp
index 71529454..1ebb897f 100644
--- a/tests/ingen_test.cpp
+++ b/tests/ingen_test.cpp
@@ -149,9 +149,15 @@ main(int argc, char** argv)
}
// Get start graph and commands file options
- char* real_start_graph = realpath((const char*)load.get_body(), NULL);
- const std::string start_graph = real_start_graph;
- const std::string cmds_file_path = (const char*)execute.get_body();
+ const char* load_path = (const char*)load.get_body();
+ char* real_start_graph = realpath(load_path, NULL);
+ if (!real_start_graph) {
+ cerr << "error: initial graph '" << load_path << "' does not exist" << endl;
+ return EXIT_FAILURE;
+ }
+
+ const std::string start_graph = real_start_graph;
+ const std::string cmds_file_path = (const char*)execute.get_body();
free(real_start_graph);
// Load modules
@@ -167,7 +173,7 @@ main(int argc, char** argv)
// Load patch
if (!world->parser()->parse_file(world, world->interface().get(), start_graph)) {
cerr << "error: failed to load initial graph " << start_graph << endl;
- return 1;
+ return EXIT_FAILURE;
}
while (world->engine()->pending_events()) {
world->engine()->run(4096);
@@ -252,5 +258,5 @@ main(int argc, char** argv)
world->engine()->deactivate();
delete world;
- return 0;
+ return EXIT_SUCCESS;
}