X-Git-Url: https://git.llucax.com/software/dgc/cdgc.git/blobdiff_plain/6a3232d8f1c52377e792b4f4e18fd75f2a3b0f60..53daba87c2208fcced6c7704dd31932a8a56467b:/rt/gc/cdgc/opts.d diff --git a/rt/gc/cdgc/opts.d b/rt/gc/cdgc/opts.d index bb6529a..042cc01 100644 --- a/rt/gc/cdgc/opts.d +++ b/rt/gc/cdgc/opts.d @@ -52,6 +52,7 @@ struct Options bool sentinel = false; bool mem_stomp = false; bool conservative = false; + bool fork = true; } package Options options; @@ -87,6 +88,8 @@ void process_option(char* opt_name, char* opt_value) options.mem_stomp = parse_bool(opt_value); else if (cstr_eq(opt_name, "conservative")) options.conservative = parse_bool(opt_value); + else if (cstr_eq(opt_name, "no_fork")) + options.fork = !parse_bool(opt_value); } @@ -145,6 +148,7 @@ unittest assert (sentinel == false); assert (mem_stomp == false); assert (conservative == false); + assert (fork == true); } parse("mem_stomp"); with (options) { @@ -153,14 +157,16 @@ unittest assert (sentinel == false); assert (mem_stomp == true); assert (conservative == false); + assert (fork == true); } - parse("mem_stomp=0:verbose=2:conservative"); + parse("mem_stomp=0:verbose=2:conservative:no_fork=10"); with (options) { assert (verbose == 2); assert (log_file[0] == '\0'); assert (sentinel == false); assert (mem_stomp == false); assert (conservative == true); + assert (fork == false); } parse("log_file=12345 67890:verbose=1:sentinel=4:mem_stomp=1"); with (options) { @@ -169,6 +175,7 @@ unittest assert (sentinel == true); assert (mem_stomp == true); assert (conservative == true); + assert (fork == false); } parse(null); with (options) { @@ -177,6 +184,34 @@ unittest assert (sentinel == true); assert (mem_stomp == true); assert (conservative == true); + assert (fork == false); + } + parse(""); + with (options) { + assert (verbose == 1); + assert (cstring.strcmp(log_file.ptr, "12345 67890".ptr) == 0); + assert (sentinel == true); + assert (mem_stomp == true); + assert (conservative == true); + assert (fork == false); + } + parse(":"); + with (options) { + assert (verbose == 1); + assert (cstring.strcmp(log_file.ptr, "12345 67890".ptr) == 0); + assert (sentinel == true); + assert (mem_stomp == true); + assert (conservative == true); + assert (fork == false); + } + parse("::::"); + with (options) { + assert (verbose == 1); + assert (cstring.strcmp(log_file.ptr, "12345 67890".ptr) == 0); + assert (sentinel == true); + assert (mem_stomp == true); + assert (conservative == true); + assert (fork == false); } }