From 0f5aaf299f85e9347fa65abc98fd03d0555cc254 Mon Sep 17 00:00:00 2001 From: Frederic Suter Date: Fri, 22 Jan 2016 15:31:05 +0100 Subject: [PATCH] improve coverage in teshsuite --- teshsuite/mc/mutex_handling.c | 15 +++++---------- teshsuite/msg/get_sender/get_sender.c | 5 +---- teshsuite/msg/host_on_off/host_on_off.c | 13 ++++--------- teshsuite/msg/host_on_off/host_on_off_recv.c | 13 ++++--------- teshsuite/msg/host_on_off/host_on_off_wait.c | 13 ++++--------- .../host_on_off_processes/host_on_off_processes.c | 5 +---- teshsuite/msg/pid/pid.c | 5 +---- teshsuite/msg/process/process.c | 13 ++++--------- teshsuite/msg/process_join/process_join.c | 13 ++++--------- teshsuite/msg/storage/concurrent_rw.c | 6 +----- teshsuite/msg/storage/storage_basic.c | 10 ++-------- .../msg/task_destroy_cancel/task_destroy_cancel.c | 13 ++++--------- teshsuite/msg/trace/test_trace_integration.c | 10 ++-------- teshsuite/simdag/platforms/basic_tracing.c | 5 +---- 14 files changed, 38 insertions(+), 101 deletions(-) diff --git a/teshsuite/mc/mutex_handling.c b/teshsuite/mc/mutex_handling.c index 4db2783552..d5aad96a7b 100644 --- a/teshsuite/mc/mutex_handling.c +++ b/teshsuite/mc/mutex_handling.c @@ -65,12 +65,10 @@ static int sender(int argc, char *argv[]) int main(int argc, char *argv[]) { MSG_init(&argc, argv); - if (argc != 3) { - printf("Usage: %s platform_file deployment_file\n", argv[0]); - printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]); - exit(1); - } - const char *platform_file = argv[1]; + xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); + + const char *platform_file = argv[1]; const char *application_file = argv[2]; MSG_create_environment(platform_file); MSG_function_register("receiver", receiver); @@ -86,8 +84,5 @@ int main(int argc, char *argv[]) #endif XBT_INFO("Simulation time %g", MSG_get_clock()); - if (res == MSG_OK) - return 0; - else - return 1; + return res != MSG_OK; } \ No newline at end of file diff --git a/teshsuite/msg/get_sender/get_sender.c b/teshsuite/msg/get_sender/get_sender.c index 68bd184788..592f13aa7c 100644 --- a/teshsuite/msg/get_sender/get_sender.c +++ b/teshsuite/msg/get_sender/get_sender.c @@ -47,8 +47,5 @@ int main(int argc, char *argv[]) MSG_launch_application(argv[2]); res = MSG_main(); - if (res == MSG_OK) - return 0; - else - return 1; + return res != MSG_OK; } diff --git a/teshsuite/msg/host_on_off/host_on_off.c b/teshsuite/msg/host_on_off/host_on_off.c index 9d6544da5b..eb4303025e 100644 --- a/teshsuite/msg/host_on_off/host_on_off.c +++ b/teshsuite/msg/host_on_off/host_on_off.c @@ -108,11 +108,9 @@ int main(int argc, char *argv[]) const char *application_file; MSG_init(&argc, argv); - if (argc != 3) { - printf("Usage: %s platform_file deployment_file\n", argv[0]); - printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]); - exit(1); - } + xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); + platform_file = argv[1]; application_file = argv[2]; @@ -129,8 +127,5 @@ int main(int argc, char *argv[]) XBT_INFO("Simulation time %g", MSG_get_clock()); - if (res == MSG_OK) - return 0; - else - return 1; + return res != MSG_OK; } /* end_of_main */ diff --git a/teshsuite/msg/host_on_off/host_on_off_recv.c b/teshsuite/msg/host_on_off/host_on_off_recv.c index 3763cac66e..73adf38c50 100644 --- a/teshsuite/msg/host_on_off/host_on_off_recv.c +++ b/teshsuite/msg/host_on_off/host_on_off_recv.c @@ -85,11 +85,9 @@ int main(int argc, char *argv[]) const char *application_file; MSG_init(&argc, argv); - if (argc != 3) { - printf("Usage: %s platform_file deployment_file\n", argv[0]); - printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]); - exit(1); - } + xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); + platform_file = argv[1]; application_file = argv[2]; @@ -105,8 +103,5 @@ int main(int argc, char *argv[]) XBT_INFO("Simulation time %g", MSG_get_clock()); - if (res == MSG_OK) - return 0; - else - return 1; + return res != MSG_OK; } /* end_of_main */ diff --git a/teshsuite/msg/host_on_off/host_on_off_wait.c b/teshsuite/msg/host_on_off/host_on_off_wait.c index 5c35cb9408..a3d829eb04 100644 --- a/teshsuite/msg/host_on_off/host_on_off_wait.c +++ b/teshsuite/msg/host_on_off/host_on_off_wait.c @@ -64,11 +64,9 @@ int main(int argc, char *argv[]) const char *application_file; MSG_init(&argc, argv); - if (argc != 3) { - printf("Usage: %s platform_file deployment_file\n", argv[0]); - printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]); - exit(1); - } + xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); + platform_file = argv[1]; application_file = argv[2]; @@ -85,8 +83,5 @@ int main(int argc, char *argv[]) XBT_INFO("Simulation time %g", MSG_get_clock()); - if (res == MSG_OK) - return 0; - else - return 1; + return res != MSG_OK; } /* end_of_main */ diff --git a/teshsuite/msg/host_on_off_processes/host_on_off_processes.c b/teshsuite/msg/host_on_off_processes/host_on_off_processes.c index 0b19a419b4..c6e82220cb 100644 --- a/teshsuite/msg/host_on_off_processes/host_on_off_processes.c +++ b/teshsuite/msg/host_on_off_processes/host_on_off_processes.c @@ -274,8 +274,5 @@ int main(int argc, char *argv[]) XBT_INFO("Simulation time %g", MSG_get_clock()); - if (res == MSG_OK) - return 0; - else - return 1; + return res != MSG_OK; } /* end_of_main */ diff --git a/teshsuite/msg/pid/pid.c b/teshsuite/msg/pid/pid.c index 8542e30053..66c27dc4b5 100644 --- a/teshsuite/msg/pid/pid.c +++ b/teshsuite/msg/pid/pid.c @@ -62,8 +62,5 @@ int main(int argc, char *argv[]) MSG_launch_application(argv[2]); res = MSG_main(); - if (res == MSG_OK) - return 0; - else - return 1; + return res != MSG_OK; } diff --git a/teshsuite/msg/process/process.c b/teshsuite/msg/process/process.c index 2339ebcc43..18cf2d1e2f 100644 --- a/teshsuite/msg/process/process.c +++ b/teshsuite/msg/process/process.c @@ -78,11 +78,9 @@ int main(int argc, char *argv[]) const char *application_file; MSG_init(&argc, argv); - if (argc != 3) { - printf("Usage: %s platform_file deployment_file\n", argv[0]); - printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]); - exit(1); - } + xbt_assert(argc == 3, "Usage: %s platform_file deployment_file\n" + "\n Example: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); + platform_file = argv[1]; application_file = argv[2]; @@ -99,8 +97,5 @@ int main(int argc, char *argv[]) XBT_INFO("Simulation time %g", MSG_get_clock()); - if (res == MSG_OK) - return 0; - else - return 1; + return res != MSG_OK; } /* end_of_main */ diff --git a/teshsuite/msg/process_join/process_join.c b/teshsuite/msg/process_join/process_join.c index 7fcb141bf6..e6d8f782d3 100644 --- a/teshsuite/msg/process_join/process_join.c +++ b/teshsuite/msg/process_join/process_join.c @@ -65,11 +65,9 @@ int main(int argc, char *argv[]) const char *application_file; MSG_init(&argc, argv); - if (argc != 3) { - printf("Usage: %s platform_file deployment_file\n", argv[0]); - printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]); - exit(1); - } + xbt_assert(argc == 3, "Usage: %s platform_file deployment_file\n" + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); + platform_file = argv[1]; application_file = argv[2]; @@ -86,8 +84,5 @@ int main(int argc, char *argv[]) XBT_INFO("Simulation time %g", MSG_get_clock()); - if (res == MSG_OK) - return 0; - else - return 1; + return res != MSG_OK; } /* end_of_main */ diff --git a/teshsuite/msg/storage/concurrent_rw.c b/teshsuite/msg/storage/concurrent_rw.c index c3c02d7c8a..201d8bc77d 100644 --- a/teshsuite/msg/storage/concurrent_rw.c +++ b/teshsuite/msg/storage/concurrent_rw.c @@ -130,9 +130,5 @@ int main(int argc, char **argv) storage_info(MSG_host_by_name(xbt_strdup("host"))); XBT_INFO("Simulation time %g", MSG_get_clock()); - if (res == MSG_OK) - return 0; - else - return 1; - + return res != MSG_OK; } diff --git a/teshsuite/msg/storage/storage_basic.c b/teshsuite/msg/storage/storage_basic.c index 63f322dd5c..c19be283ac 100644 --- a/teshsuite/msg/storage/storage_basic.c +++ b/teshsuite/msg/storage/storage_basic.c @@ -205,10 +205,7 @@ int main(int argc, char *argv[]) MSG_init(&argc, argv); /* Check the arguments */ - if (argc < 3) { - printf("Usage: %s platform_file deployment_file \n", argv[0]); - return -1; - } + xbt_assert(argc > 2,"Usage: %s platform_file deployment_file \n", argv[0]); const char *platform_file = argv[1]; const char *deployment_file = argv[2]; @@ -222,8 +219,5 @@ int main(int argc, char *argv[]) msg_error_t res = MSG_main(); XBT_INFO("Simulated time: %g", MSG_get_clock()); - if (res == MSG_OK) - return 0; - else - return 1; + return res != MSG_OK; } diff --git a/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.c b/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.c index cc9ea1cdfe..112c71935d 100644 --- a/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.c +++ b/teshsuite/msg/task_destroy_cancel/task_destroy_cancel.c @@ -144,11 +144,9 @@ int main(int argc, char *argv[]) const char *application_file; MSG_init(&argc, argv); - if (argc != 3) { - printf("Usage: %s platform_file deployment_file\n", argv[0]); - printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]); - exit(1); - } + xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" + "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); + platform_file = argv[1]; application_file = argv[2]; @@ -165,8 +163,5 @@ int main(int argc, char *argv[]) XBT_INFO("Simulation time %g", MSG_get_clock()); - if (res == MSG_OK) - return 0; - else - return 1; + return res != MSG_OK; } /* end_of_main */ diff --git a/teshsuite/msg/trace/test_trace_integration.c b/teshsuite/msg/trace/test_trace_integration.c index e06af1dd65..ff5292ce92 100644 --- a/teshsuite/msg/trace/test_trace_integration.c +++ b/teshsuite/msg/trace/test_trace_integration.c @@ -53,10 +53,7 @@ int main(int argc, char *argv[]) /* Verify if the platform xml file was passed by command line. */ MSG_init(&argc, argv); - if (argc < 2) { - printf("Usage: %s test_trace_integration_model.xml\n", argv[0]); - exit(1); - } + xbt_assert(argc > 2, "Usage: %s test_trace_integration_model.xml deployment.xml\n", argv[0]); /* Register SimGrid process function. */ MSG_function_register("test_trace", test_trace); @@ -66,8 +63,5 @@ int main(int argc, char *argv[]) /* Run the example. */ res = MSG_main(); - if (res == MSG_OK) - return 0; - else - return 1; + return res != MSG_OK; } diff --git a/teshsuite/simdag/platforms/basic_tracing.c b/teshsuite/simdag/platforms/basic_tracing.c index 006ab596a5..5b8db615ff 100644 --- a/teshsuite/simdag/platforms/basic_tracing.c +++ b/teshsuite/simdag/platforms/basic_tracing.c @@ -35,8 +35,5 @@ int main(int argc, char **argv) res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); - if (res == MSG_OK) - return 0; - else - return 1; + return res != MSG_OK; } -- 2.20.1