From 126d9f095b3050d7d457ae4bb061897798495dd7 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Thu, 3 Oct 2013 23:02:39 +0200 Subject: [PATCH] Exit cleanly on error. --- examples/simdag/dot/dot_test.c | 22 +++++++++++--------- examples/simdag/dot/simulate_dot.c | 22 +++++++++++--------- examples/simdag/dot/test_simdag_dotload.tesh | 8 +++---- 3 files changed, 28 insertions(+), 24 deletions(-) diff --git a/examples/simdag/dot/dot_test.c b/examples/simdag/dot/dot_test.c index 45e96bcaf9..4456c2f1f1 100644 --- a/examples/simdag/dot/dot_test.c +++ b/examples/simdag/dot/dot_test.c @@ -32,6 +32,18 @@ int main(int argc, char **argv) XBT_INFO("example: %s ../2clusters.xml dag.dot dag.mytrace", argv[0]); exit(1); } + + /* creation of the environment */ + SD_create_environment(argv[1]); + + /* load the DOT file */ + dot = SD_dotload(argv[2]); + if(dot == NULL){ + XBT_CRITICAL("No dot load may be you have a cycle in your graph"); + SD_exit(); + exit(2); + } + char *tracefilename; if (argc == 3) { char *last = strrchr(argv[2], '.'); @@ -44,16 +56,6 @@ int main(int argc, char **argv) tracefilename = xbt_strdup(argv[3]); } - /* creation of the environment */ - SD_create_environment(argv[1]); - - /* load the DOT file */ - dot = SD_dotload(argv[2]); - if(dot == NULL){ - SD_exit(); - xbt_die("No dot load may be you have a cycle in your graph"); - } - /* Display all the tasks */ XBT_INFO ("------------------- Display all tasks of the loaded DAG ---------------------------"); diff --git a/examples/simdag/dot/simulate_dot.c b/examples/simdag/dot/simulate_dot.c index 1af8fb643f..ceb400f5aa 100644 --- a/examples/simdag/dot/simulate_dot.c +++ b/examples/simdag/dot/simulate_dot.c @@ -32,6 +32,18 @@ int main(int argc, char **argv) XBT_INFO("example: %s ../2clusters.xml dag.dot dag.mytrace", argv[0]); exit(1); } + + /* creation of the environment */ + SD_create_environment(argv[1]); + + /* load the DOT file and schedule tasks */ + dot = SD_dotload_with_sched(argv[2]); + if(!dot){ + XBT_CRITICAL("The dot file with the provided scheduling is wrong, more information with the option : --log=sd_dotparse.thres:verbose"); + SD_exit(); + exit(2); + } + char *tracefilename; if (argc == 3) { char *last = strrchr(argv[2], '.'); @@ -44,16 +56,6 @@ int main(int argc, char **argv) tracefilename = xbt_strdup(argv[3]); } - /* creation of the environment */ - SD_create_environment(argv[1]); - - /* load the DOT file and schedule tasks */ - dot = SD_dotload_with_sched(argv[2]); - if(!dot){ - SD_exit(); - xbt_die("The dot file with the provided scheduling is wrong, more information with the option : --log=sd_dotparse.thres:verbose"); - } - /* Display all the tasks */ XBT_INFO ("------------------- Display all tasks of the loaded DAG ---------------------------"); diff --git a/examples/simdag/dot/test_simdag_dotload.tesh b/examples/simdag/dot/test_simdag_dotload.tesh index 7bbed3d9cf..5b49c3193b 100644 --- a/examples/simdag/dot/test_simdag_dotload.tesh +++ b/examples/simdag/dot/test_simdag_dotload.tesh @@ -233,7 +233,7 @@ $ cat ${srcdir:=.}/dag.trace $ rm -f dag.trace -! expect signal SIGABRT +! expect return 2 $ $SG_TEST_EXENV ./simulate_dot --log=no_loc "--log=sd_dotparse.thres:verbose" ${srcdir:=.}/../2clusters.xml ${srcdir:=.}/dag_with_bad_schedule.dot > [0.000000] [surf_workstation/INFO] surf_workstation_model_init_ptask_L07 > [0.000000] [sd_dotparse/VERBOSE] The schedule is ignored, the task end is not correctly scheduled @@ -242,7 +242,7 @@ $ $SG_TEST_EXENV ./simulate_dot --log=no_loc "--log=sd_dotparse.thres:verbose" > [0.000000] [sd_dotparse/VERBOSE] The schedule is ignored, the task 3 is not correctly scheduled > [0.000000] [sd_dotparse/VERBOSE] The schedule is ignored, the task root is not correctly scheduled > [0.000000] [sd_dotparse/WARNING] The scheduling is ignored -> [0.000000] [xbt/CRITICAL] The dot file with the provided scheduling is wrong, more information with the option : --log=sd_dotparse.thres:verbose +> [0.000000] [test/CRITICAL] The dot file with the provided scheduling is wrong, more information with the option : --log=sd_dotparse.thres:verbose $ $SG_TEST_EXENV ./simulate_dot --log=no_loc ${srcdir:=.}/../2clusters.xml ${srcdir:=.}/dag_with_good_schedule.dot > [0.000000] [surf_workstation/INFO] surf_workstation_model_init_ptask_L07 @@ -491,7 +491,7 @@ $ cat ${srcdir:=.}/dag_with_good_schedule.trace $ rm -f ${srcdir:=.}/dag_with_good_schedule.trace -! expect signal SIGABRT +! expect return 2 $ $SG_TEST_EXENV ./dot_test --log=no_loc ${srcdir:=.}/../2clusters.xml ${srcdir:=.}/dag_with_cycle.dot > [0.000000] [surf_workstation/INFO] surf_workstation_model_init_ptask_L07 > [0.000000] [sd_daxparse/WARNING] the task root is not marked @@ -503,4 +503,4 @@ $ $SG_TEST_EXENV ./dot_test --log=no_loc ${srcdir:=.}/../2clusters.xml ${srcdir: > [0.000000] [sd_daxparse/WARNING] the task 5 is in a cycle > [0.000000] [sd_daxparse/WARNING] the task 6 is in a cycle > [0.000000] [sd_dotparse/ERROR] The DOT described in dag_with_cycle.dot is not a DAG. It contains a cycle. -> [0.000000] [xbt/CRITICAL] No dot load may be you have a cycle in your graph +> [0.000000] [test/CRITICAL] No dot load may be you have a cycle in your graph -- 2.20.1