- #282: TIT convertor erase traces when using absolute path in the trace list file
- #285: segfault when a s4u actor kills itself with msg process tracing activated
- #286: Pajé traces are not exposing the number of cores
+ - #287: Command-line parsing should stop when encountering '--'
----------------------------------------------------------------------------
int shall_exit = 0;
int i;
int j;
+ bool parse_args = true; // Stop parsing the parameters once we found '--'
for (j = i = 1; i < *argc; i++) {
- if (not strncmp(argv[i], "--cfg=", strlen("--cfg="))) {
+ if (not strcmp("--", argv[i])) {
+ parse_args = false;
+ // Remove that '--' from the arguments
+ } else if (parse_args && not strncmp(argv[i], "--cfg=", strlen("--cfg="))) {
char *opt = strchr(argv[i], '=');
opt++;
simgrid::config::set_parse(opt);
XBT_DEBUG("Did apply '%s' as config setting", opt);
- } else if (not strcmp(argv[i], "--version")) {
+ } else if (parse_args && not strcmp(argv[i], "--version")) {
printf("%s\n", SIMGRID_VERSION_STRING);
shall_exit = 1;
- } else if (not strcmp(argv[i], "--cfg-help") || not strcmp(argv[i], "--help")) {
+ } else if (parse_args && (not strcmp(argv[i], "--cfg-help") || not strcmp(argv[i], "--help"))) {
printf("Description of the configuration accepted by this simulator:\n");
simgrid::config::help();
printf(
"\n"
);
shall_exit = 1;
- } else if (not strcmp(argv[i], "--help-aliases")) {
+ } else if (parse_args && not strcmp(argv[i], "--help-aliases")) {
printf("Here is a list of all deprecated option names, with their replacement.\n");
simgrid::config::show_aliases();
printf("Please consider using the recent names\n");
shall_exit = 1;
- } else if (not strcmp(argv[i], "--help-models")) {
+ } else if (parse_args && not strcmp(argv[i], "--help-models")) {
model_help("host", surf_host_model_description);
printf("\n");
model_help("CPU", surf_cpu_model_description);
surf_optimization_mode_description[k].description);
printf("Both network and CPU models have 'Lazy' as default optimization level\n\n");
shall_exit = 1;
- } else if (not strcmp(argv[i], "--help-tracing")) {
+ } else if (parse_args && not strcmp(argv[i], "--help-tracing")) {
TRACE_help();
shall_exit = 1;
} else {
{
unsigned help_requested = 0; /* 1: logs; 2: categories */
int j = 1;
+ int parse_args = 1; // Stop parsing the parameters once we found '--'
/* Set logs and init log submodule */
for (int i = 1; i < *argc; i++) {
- if (!strncmp(argv[i], "--log=", strlen("--log="))) {
+ if (!strcmp("--", argv[i])) {
+ parse_args = 0;
+ argv[j++] = argv[i]; // Keep the '--' for sg_config
+ } else if (parse_args && !strncmp(argv[i], "--log=", strlen("--log="))) {
char* opt = strchr(argv[i], '=');
opt++;
xbt_log_control_set(opt);
XBT_DEBUG("Did apply '%s' as log setting", opt);
- } else if (!strcmp(argv[i], "--help-logs")) {
+ } else if (parse_args && !strcmp(argv[i], "--help-logs")) {
help_requested |= 1U;
- } else if (!strcmp(argv[i], "--help-log-categories")) {
+ } else if (parse_args && !strcmp(argv[i], "--help-log-categories")) {
help_requested |= 2U;
} else {
argv[j++] = argv[i];
-foreach(x log_large log_usage mallocator parallel_log_crashtest)
+foreach(x cmdline log_large log_usage mallocator parallel_log_crashtest)
add_executable (${x} ${x}/${x}.c)
target_link_libraries(${x} simgrid)
set_target_properties(${x} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
${CMAKE_CURRENT_SOURCE_DIR}/mmalloc/mmalloc_32.tesh PARENT_SCOPE)
set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/mmalloc/mmalloc_test.cpp PARENT_SCOPE)
-foreach(x log_large parallel_log_crashtest parmap_test) #mallocator parmap_bench
+foreach(x cmdline log_large parallel_log_crashtest parmap_test) #mallocator parmap_bench
ADD_TESH(tesh-xbt-${x} --setenv bindir=${CMAKE_BINARY_DIR}/teshsuite/xbt/${x} --cd ${CMAKE_HOME_DIRECTORY}/teshsuite/xbt/${x} ${x}.tesh)
endforeach()
--- /dev/null
+/* Copyright (c) 2018. The SimGrid Team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "simgrid/engine.h"
+#include <xbt.h>
+
+XBT_LOG_NEW_DEFAULT_CATEGORY(test, "Logging specific to this test");
+
+int main(int argc, char** argv)
+{
+ simgrid_init(&argc, argv);
+
+ for (int i = 1; i < argc; i++)
+ XBT_INFO("argv[%d]=%s", i, argv[i]);
+
+ return 0;
+}
--- /dev/null
+
+p Test that -- correctly stops the command line parsing
+
+$ ${bindir:=.}/cmdline -- --help
+> [0.000000] [test/INFO] argv[1]=--help