From 0072787363806a175ef408e24455f31f9d480571 Mon Sep 17 00:00:00 2001 From: Andrew McCaffrey Date: Thu, 25 Aug 2022 11:30:11 -0400 Subject: [PATCH 1/3] Output commandline options in JSON output --- cpp/conditioning_main.cpp | 2 ++ cpp/iid_main.cpp | 2 ++ cpp/non_iid_main.cpp | 3 +++ cpp/restart_main.cpp | 5 ++++- cpp/shared/test_run_base.h | 2 ++ cpp/shared/utils.h | 12 +++++++++++- 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/cpp/conditioning_main.cpp b/cpp/conditioning_main.cpp index 3758d72..0995c63 100644 --- a/cpp/conditioning_main.cpp +++ b/cpp/conditioning_main.cpp @@ -446,6 +446,7 @@ int main(int argc, char* argv[]) { string timestamp = getCurrentTimestamp(); string outputfilename; string inputfilename; + string commandline = recreateCommandLine(argc, argv); for(int i = 0; i < argc; i++) { std::string Str = std::string(argv[i]); @@ -489,6 +490,7 @@ int main(int argc, char* argv[]) { NonIidTestRun testRunNonIid; testRunNonIid.type = "Conditioning"; testRunNonIid.timestamp = timestamp; + testRunNonIid.commandline = commandline; // Parse args if (vetted && argc != 4) { diff --git a/cpp/iid_main.cpp b/cpp/iid_main.cpp index 66b809f..444264b 100644 --- a/cpp/iid_main.cpp +++ b/cpp/iid_main.cpp @@ -75,6 +75,7 @@ int main(int argc, char* argv[]) { bool jsonOutput = false; string timestamp = getCurrentTimestamp(); string outputfilename; + string commandline = recreateCommandLine(argc, argv); for(int i = 0; i < argc; i++) { std::string Str = std::string(argv[i]); @@ -149,6 +150,7 @@ int main(int argc, char* argv[]) { IidTestRun testRun; testRun.timestamp = timestamp; testRun.filename = file_path; + testRun.commandline = commandline; if (argc == 2) { // get bits per word diff --git a/cpp/non_iid_main.cpp b/cpp/non_iid_main.cpp index 7aa08bc..7cc5c72 100644 --- a/cpp/non_iid_main.cpp +++ b/cpp/non_iid_main.cpp @@ -76,6 +76,8 @@ int main(int argc, char* argv[]) { bool jsonOutput = false; string timestamp = getCurrentTimestamp(); string outputfilename; + string commandline = recreateCommandLine(argc, argv); + data.word_size = 0; initial_entropy = true; @@ -157,6 +159,7 @@ int main(int argc, char* argv[]) { testRun.timestamp = timestamp; testRun.sha256 = hash; testRun.filename = file_path; + testRun.commandline = commandline; if (argc == 2) { // get bits per word diff --git a/cpp/restart_main.cpp b/cpp/restart_main.cpp index 1199993..83da393 100644 --- a/cpp/restart_main.cpp +++ b/cpp/restart_main.cpp @@ -154,7 +154,8 @@ int main(int argc, char* argv[]) { bool jsonOutput = false; string timestamp = getCurrentTimestamp(); string outputfilename = timestamp + ".json"; - + string commandline = recreateCommandLine(argc, argv); + for (int i = 0; i < argc; i++) { std::string Str = std::string(argv[i]); if ("--version" == Str) { @@ -209,6 +210,7 @@ int main(int argc, char* argv[]) { testRunIid.type = "Restart"; testRunIid.timestamp = timestamp; testRunIid.filename = file_path; + testRunIid.commandline = commandline; testRunIid.sha256 = hash; NonIidTestRun testRunNonIid; @@ -216,6 +218,7 @@ int main(int argc, char* argv[]) { testRunNonIid.timestamp = timestamp; testRunNonIid.sha256 = hash; testRunNonIid.filename = file_path; + testRunNonIid.commandline = commandline; if (argc == 2) { // get bits per word diff --git a/cpp/shared/test_run_base.h b/cpp/shared/test_run_base.h index c7c0ebe..58db325 100644 --- a/cpp/shared/test_run_base.h +++ b/cpp/shared/test_run_base.h @@ -15,12 +15,14 @@ class TestRunBase { int errorLevel = 0; string errorMsg; string type; + string commandline; protected: Json::Value GetBaseJson() { Json::Value baseJson; baseJson["dateTimeStamp"] = timestamp; baseJson["filename"] = filename; + baseJson["commandline"] = commandline; baseJson["sha256"] = sha256; baseJson["errorLevel"] = errorLevel; baseJson["type"] = type; diff --git a/cpp/shared/utils.h b/cpp/shared/utils.h index 3d3c617..4bf1d43 100644 --- a/cpp/shared/utils.h +++ b/cpp/shared/utils.h @@ -36,7 +36,7 @@ #define ZALPHA 2.5758293035489008 //Version of the tool -#define VERSION "1.1.4" +#define VERSION "1.1.5" typedef unsigned char byte; @@ -971,6 +971,16 @@ static void printVersion(string name) { cout << "\n\n"; } +static string recreateCommandLine(int argc, char* argv[]) { + string commandLine = ""; + for(int i = 0; i < argc; ++i) { + commandLine.append(argv[i]); + if((i + 1) != argc) { + commandLine.append(" "); + } + } + return commandLine; +} class PostfixDictionary { map postfixes; From 0e595b9f2e1973b4a83a8deb38e4ae3dd17862f4 Mon Sep 17 00:00:00 2001 From: Andrew McCaffrey Date: Thu, 1 Sep 2022 18:47:22 -0400 Subject: [PATCH 2/3] More JSON error outputs after 'bad' run --- cpp/conditioning_main.cpp | 30 +++++++++++++++--- cpp/iid_main.cpp | 66 +++++++++++++++++++++++++-------------- cpp/non_iid_main.cpp | 66 ++++++++++++++++++++++++++++----------- 3 files changed, 116 insertions(+), 46 deletions(-) diff --git a/cpp/conditioning_main.cpp b/cpp/conditioning_main.cpp index 0995c63..3b5e915 100644 --- a/cpp/conditioning_main.cpp +++ b/cpp/conditioning_main.cpp @@ -448,12 +448,12 @@ int main(int argc, char* argv[]) { string inputfilename; string commandline = recreateCommandLine(argc, argv); - for(int i = 0; i < argc; i++) { + for (int i = 0; i < argc; i++) { std::string Str = std::string(argv[i]); - if("--version" == Str) { + if ("--version" == Str) { printVersion("conditioning"); exit(0); - } + } } while ((opt = getopt(argc, argv, "vnqo:i:c:")) != -1) { @@ -513,7 +513,17 @@ int main(int argc, char* argv[]) { // get h_in; note that h_in <= n_in h_in = inputLongDoubleOption(argv[3], 0.0L, (long double) n_in, "h_in"); - if (h_in <= 0.0L) print_usage(); + if (h_in <= 0.0L) { + if (jsonOutput) { + testRunNonIid.errorLevel = -1; + testRunNonIid.errorMsg = "Error with input: generating h_in."; + ofstream output; + output.open(outputfilename); + output << testRunNonIid.GetAsJson(); + output.close(); + } + print_usage(); + } if (!vetted) { if (argc == 4) { @@ -522,7 +532,17 @@ int main(int argc, char* argv[]) { } else { // If h_p is provided via command line, use that value h_p = inputLongDoubleOption(argv[4], 0.0L, 1.0L, "h_p"); - if (h_p <= 0) print_usage(); + if (h_p <= 0) { + if (jsonOutput) { + testRunNonIid.errorLevel = -1; + testRunNonIid.errorMsg = "Error with input: generating h_p."; + ofstream output; + output.open(outputfilename); + output << testRunNonIid.GetAsJson(); + output.close(); + } + print_usage(); + } } } } diff --git a/cpp/iid_main.cpp b/cpp/iid_main.cpp index 444264b..66f745d 100644 --- a/cpp/iid_main.cpp +++ b/cpp/iid_main.cpp @@ -77,14 +77,18 @@ int main(int argc, char* argv[]) { string outputfilename; string commandline = recreateCommandLine(argc, argv); - for(int i = 0; i < argc; i++) { + IidTestRun testRun; + testRun.timestamp = timestamp; + testRun.commandline = commandline; + + for (int i = 0; i < argc; i++) { std::string Str = std::string(argv[i]); - if("--version" == Str) { + if ("--version" == Str) { printVersion("iid"); exit(0); - } + } } - + while ((opt = getopt(argc, argv, "icatvl:qo:")) != -1) { switch (opt) { case 'i': @@ -105,6 +109,16 @@ int main(int argc, char* argv[]) { case 'l': inint = strtoull(optarg, &nextOption, 0); if ((inint > ULONG_MAX) || (errno == EINVAL) || (nextOption == NULL) || (*nextOption != ',')) { + + testRun.errorLevel = -1; + testRun.errorMsg = "Error on index/samples."; + + if (jsonOutput) { + ofstream output; + output.open(outputfilename); + output << testRun.GetAsJson(); + output.close(); + } print_usage(); } subsetIndex = inint; @@ -113,6 +127,15 @@ int main(int argc, char* argv[]) { inint = strtoull(nextOption, NULL, 0); if ((inint > ULONG_MAX) || (errno == EINVAL)) { + testRun.errorLevel = -1; + testRun.errorMsg = "Error on index/samples."; + + if (jsonOutput) { + ofstream output; + output.open(outputfilename); + output << testRun.GetAsJson(); + output.close(); + } print_usage(); } @@ -147,10 +170,7 @@ int main(int argc, char* argv[]) { // get filename file_path = argv[0]; - IidTestRun testRun; - testRun.timestamp = timestamp; testRun.filename = file_path; - testRun.commandline = commandline; if (argc == 2) { // get bits per word @@ -233,19 +253,19 @@ int main(int argc, char* argv[]) { int sample_size = data.len; if ((verbose == 1) || (verbose == 2)) - printf("Calculating baseline statistics...\n"); - + printf("Calculating baseline statistics...\n"); + calc_stats(&data, rawmean, median); - if(verbose == 2) { - printf("\tRaw Mean: %f\n", rawmean); - printf("\tMedian: %f\n", median); - printf("\tBinary: %s\n\n", (alphabet_size == 2 ? "true" : "false")); - } else if(verbose > 2) { - printf("Raw Mean = %.17g\n", rawmean); - printf("Median = %.17g\n", median); - printf("Binary = %s\n", (alphabet_size == 2 ? "true" : "false")); - } + if (verbose == 2) { + printf("\tRaw Mean: %f\n", rawmean); + printf("\tMedian: %f\n", median); + printf("\tBinary: %s\n\n", (alphabet_size == 2 ? "true" : "false")); + } else if (verbose > 2) { + printf("Raw Mean = %.17g\n", rawmean); + printf("Median = %.17g\n", median); + printf("Binary = %s\n", (alphabet_size == 2 ? "true" : "false")); + } IidTestCase tc; tc.mean = rawmean; @@ -305,7 +325,7 @@ int main(int argc, char* argv[]) { } else { printf("** Failed chi square tests\n\n"); } - } else if(verbose > 2) { + } else if (verbose > 2) { if (chi_square_test_pass) { printf("Chi square tests: Passed\n"); } else { @@ -323,7 +343,7 @@ int main(int argc, char* argv[]) { } else { printf("** Failed length of longest repeated substring test\n\n"); } - } else if(verbose > 2) { + } else if (verbose > 2) { if (len_LRS_test_pass) { printf("Length of longest repeated substring test: Passed\n"); } else { @@ -340,13 +360,13 @@ int main(int argc, char* argv[]) { printf("** Passed IID permutation tests\n\n"); } else { printf("** Failed IID permutation tests\n\n"); - } - } else if(verbose > 2) { + } + } else if (verbose > 2) { if (perm_test_pass) { printf("IID permutation tests: Passed\n"); } else { printf("IID permutation tests: Failed\n"); - } + } } testRun.testCases.push_back(tc); diff --git a/cpp/non_iid_main.cpp b/cpp/non_iid_main.cpp index 7cc5c72..4abd63b 100644 --- a/cpp/non_iid_main.cpp +++ b/cpp/non_iid_main.cpp @@ -77,20 +77,24 @@ int main(int argc, char* argv[]) { string timestamp = getCurrentTimestamp(); string outputfilename; string commandline = recreateCommandLine(argc, argv); - + + NonIidTestRun testRun; + testRun.timestamp = timestamp; + testRun.commandline = commandline; + data.word_size = 0; initial_entropy = true; all_bits = true; - for(int i = 0; i < argc; i++) { + for (int i = 0; i < argc; i++) { std::string Str = std::string(argv[i]); - if("--version" == Str) { + if ("--version" == Str) { printVersion("noniid"); exit(0); - } + } } - + while ((opt = getopt(argc, argv, "icatvql:o:")) != -1) { switch (opt) { case 'i': @@ -114,6 +118,15 @@ int main(int argc, char* argv[]) { case 'l': inint = strtoull(optarg, &nextOption, 0); if ((inint > ULONG_MAX) || (errno == EINVAL) || (nextOption == NULL) || (*nextOption != ',')) { + testRun.errorLevel = -1; + testRun.errorMsg = "Error on index/samples."; + + if (jsonOutput) { + ofstream output; + output.open(outputfilename); + output << testRun.GetAsJson(); + output.close(); + } print_usage(); } subsetIndex = inint; @@ -122,6 +135,15 @@ int main(int argc, char* argv[]) { inint = strtoull(nextOption, NULL, 0); if ((inint > ULONG_MAX) || (errno == EINVAL)) { + testRun.errorLevel = -1; + testRun.errorMsg = "Error on index/samples."; + + if (jsonOutput) { + ofstream output; + output.open(outputfilename); + output << testRun.GetAsJson(); + output.close(); + } print_usage(); } subsetSize = inint; @@ -155,16 +177,24 @@ int main(int argc, char* argv[]) { char hash[65]; sha256_file(file_path, hash); - NonIidTestRun testRun; - testRun.timestamp = timestamp; testRun.sha256 = hash; testRun.filename = file_path; - testRun.commandline = commandline; if (argc == 2) { // get bits per word inint = atoi(argv[1]); if (inint < 1 || inint > 8) { + + testRun.errorLevel = -1; + testRun.errorMsg = "Invalid bits per symbol."; + + if (jsonOutput) { + ofstream output; + output.open(outputfilename); + output << testRun.GetAsJson(); + output.close(); + } + printf("Invalid bits per symbol.\n"); print_usage(); } else { @@ -172,8 +202,8 @@ int main(int argc, char* argv[]) { } } - if(verbose>1) { - if(subsetSize == 0) printf("Opening file: '%s'\n", file_path); + if (verbose > 1) { + if (subsetSize == 0) printf("Opening file: '%s'\n", file_path); else printf("Opening file: '%s', reading block %ld of size %ld\n", file_path, subsetIndex, subsetSize); } @@ -321,7 +351,7 @@ int main(int argc, char* argv[]) { NonIidTestCase tc635; if ((verbose == 1) || (verbose == 2)) printf("\nRunning Tuple Estimates...\n"); - + if (((data.alph_size > 2) || !initial_entropy)) { SAalgs(data.bsymbols, data.blen, 2, bin_t_tuple_res, bin_lrs_res, verbose, "Bitstring"); if (bin_t_tuple_res >= 0.0) { @@ -343,7 +373,7 @@ int main(int argc, char* argv[]) { tc635.testCaseNumber = "T-Tuple Test"; testRun.testCases.push_back(tc635); - // Section 6.3.6 - Estimate entropy with LRS Test + // Section 6.3.6 - Estimate entropy with LRS Test NonIidTestCase tc636; if ((((data.alph_size > 2) || !initial_entropy)) && (bin_lrs_res >= 0.0)) { @@ -470,18 +500,18 @@ int main(int argc, char* argv[]) { h_assessed = min(h_assessed, H_original); } - if((verbose == 1) || (verbose == 2)) { - if(initial_entropy) { + if ((verbose == 1) || (verbose == 2)) { + if (initial_entropy) { printf("\nH_original: %f\n", H_original); - if(data.alph_size > 2) { + if (data.alph_size > 2) { printf("H_bitstring: %f\n", H_bitstring); - printf("min(H_original, %d X H_bitstring): %f\n", data.word_size, min(H_original, data.word_size*H_bitstring)); + printf("min(H_original, %d X H_bitstring): %f\n", data.word_size, min(H_original, data.word_size * H_bitstring)); } } else { printf("\nh': %f\n", H_bitstring); } - } else if(verbose > 2) { - if((data.alph_size > 2) || !initial_entropy) { + } else if (verbose > 2) { + if ((data.alph_size > 2) || !initial_entropy) { printf("H_bitstring = %.17g\n", H_bitstring); printf("H_bitstring Per Symbol = %.17g\n", H_bitstring * data.word_size); } From b3ee04d82e75b819a6db43418f573cf3354b6574 Mon Sep 17 00:00:00 2001 From: Andrew McCaffrey Date: Tue, 6 Sep 2022 16:50:14 -0400 Subject: [PATCH 3/3] BUG FIX: Correct type (iid/non-iid) in JSON output when tool exits early (on error) --- cpp/restart_main.cpp | 189 ++++++++++++++++++++++++++++++------------- 1 file changed, 135 insertions(+), 54 deletions(-) diff --git a/cpp/restart_main.cpp b/cpp/restart_main.cpp index 83da393..8eea2a2 100644 --- a/cpp/restart_main.cpp +++ b/cpp/restart_main.cpp @@ -226,12 +226,21 @@ int main(int argc, char* argv[]) { if (data.word_size < 1 || data.word_size > 8) { printf("Invalid bits per symbol.\n"); if (jsonOutput) { - testRunIid.errorLevel = -1; - testRunIid.errorMsg = "Invalid bits per symbol."; - ofstream output; - output.open(outputfilename); - output << testRunIid.GetAsJson(); - output.close(); + if (iid) { + testRunIid.errorLevel = -1; + testRunIid.errorMsg = "Invalid bits per symbol."; + ofstream output; + output.open(outputfilename); + output << testRunIid.GetAsJson(); + output.close(); + } else { + testRunNonIid.errorLevel = -1; + testRunNonIid.errorMsg = "Invalid bits per symbol."; + ofstream output; + output.open(outputfilename); + output << testRunNonIid.GetAsJson(); + output.close(); + } } print_usage(); @@ -245,12 +254,21 @@ int main(int argc, char* argv[]) { if (H_I < 0) { printf("H_I must be nonnegative.\n"); if (jsonOutput) { - testRunIid.errorLevel = -1; - testRunIid.errorMsg = "H_I must be nonnegative."; - ofstream output; - output.open(outputfilename); - output << testRunIid.GetAsJson(); - output.close(); + if (iid) { + testRunIid.errorLevel = -1; + testRunIid.errorMsg = "H_I must be nonnegative."; + ofstream output; + output.open(outputfilename); + output << testRunIid.GetAsJson(); + output.close(); + } else { + testRunNonIid.errorLevel = -1; + testRunNonIid.errorMsg = "H_I must be nonnegative."; + ofstream output; + output.open(outputfilename); + output << testRunNonIid.GetAsJson(); + output.close(); + } } print_usage(); @@ -262,12 +280,21 @@ int main(int argc, char* argv[]) { printf("Error reading file.\n"); if (jsonOutput) { - testRunIid.errorLevel = -1; - testRunIid.errorMsg = "Error reading file."; - ofstream output; - output.open(outputfilename); - output << testRunIid.GetAsJson(); - output.close(); + if (iid) { + testRunIid.errorLevel = -1; + testRunIid.errorMsg = "Error reading file."; + ofstream output; + output.open(outputfilename); + output << testRunIid.GetAsJson(); + output.close(); + } else { + testRunNonIid.errorLevel = -1; + testRunNonIid.errorMsg = "Error reading file."; + ofstream output; + output.open(outputfilename); + output << testRunNonIid.GetAsJson(); + output.close(); + } } print_usage(); @@ -278,12 +305,21 @@ int main(int argc, char* argv[]) { if (H_I > data.word_size) { printf("H_I must be at most 'bits_per_symbol'.\n"); if (jsonOutput) { - testRunIid.errorLevel = -1; - testRunIid.errorMsg = "H_I must be at most 'bits_per_symbol'."; - ofstream output; - output.open(outputfilename); - output << testRunIid.GetAsJson(); - output.close(); + if(iid) { + testRunIid.errorLevel = -1; + testRunIid.errorMsg = "H_I must be at most 'bits_per_symbol'."; + ofstream output; + output.open(outputfilename); + output << testRunIid.GetAsJson(); + output.close(); + } else { + testRunNonIid.errorLevel = -1; + testRunNonIid.errorMsg = "H_I must be at most 'bits_per_symbol'."; + ofstream output; + output.open(outputfilename); + output << testRunNonIid.GetAsJson(); + output.close(); + } } free_data(&data); exit(-1); @@ -292,12 +328,21 @@ int main(int argc, char* argv[]) { if (data.alph_size <= 1) { printf("Symbol alphabet consists of 1 symbol. No entropy awarded...\n"); if (jsonOutput) { - testRunIid.errorLevel = -1; - testRunIid.errorMsg = "Symbol alphabet consists of 1 symbol. No entropy awarded..."; - ofstream output; - output.open(outputfilename); - output << testRunIid.GetAsJson(); - output.close(); + if(iid) { + testRunIid.errorLevel = -1; + testRunIid.errorMsg = "Symbol alphabet consists of 1 symbol. No entropy awarded..."; + ofstream output; + output.open(outputfilename); + output << testRunIid.GetAsJson(); + output.close(); + } else { + testRunNonIid.errorLevel = -1; + testRunNonIid.errorMsg = "Symbol alphabet consists of 1 symbol. No entropy awarded..."; + ofstream output; + output.open(outputfilename); + output << testRunNonIid.GetAsJson(); + output.close(); + } } free_data(&data); exit(-1); @@ -306,12 +351,21 @@ int main(int argc, char* argv[]) { if (data.len != MIN_SIZE) { printf("\n*** Error: data does not contain %d samples ***\n\n", MIN_SIZE); if (jsonOutput) { - testRunIid.errorLevel = -1; - testRunIid.errorMsg = "*** Error: data does not contain " + std::to_string(MIN_SIZE) + " samples ***"; - ofstream output; - output.open(outputfilename); - output << testRunIid.GetAsJson(); - output.close(); + if (iid) { + testRunIid.errorLevel = -1; + testRunIid.errorMsg = "*** Error: data does not contain " + std::to_string(MIN_SIZE) + " samples ***"; + ofstream output; + output.open(outputfilename); + output << testRunIid.GetAsJson(); + output.close(); + } else { + testRunNonIid.errorLevel = -1; + testRunNonIid.errorMsg = "*** Error: data does not contain " + std::to_string(MIN_SIZE) + " samples ***"; + ofstream output; + output.open(outputfilename); + output << testRunNonIid.GetAsJson(); + output.close(); + } } exit(-1); } @@ -325,12 +379,21 @@ int main(int argc, char* argv[]) { if (cdata == NULL) { printf("Error: failure to initialize memory for columns\n"); if (jsonOutput) { - testRunIid.errorLevel = -1; - testRunIid.errorMsg = "Error: failure to initialize memory for columns"; - ofstream output; - output.open(outputfilename); - output << testRunIid.GetAsJson(); - output.close(); + if(iid) { + testRunIid.errorLevel = -1; + testRunIid.errorMsg = "Error: failure to initialize memory for columns"; + ofstream output; + output.open(outputfilename); + output << testRunIid.GetAsJson(); + output.close(); + } else { + testRunNonIid.errorLevel = -1; + testRunNonIid.errorMsg = "Error: failure to initialize memory for columns"; + ofstream output; + output.open(outputfilename); + output << testRunNonIid.GetAsJson(); + output.close(); + } } exit(-1); } @@ -374,12 +437,21 @@ int main(int argc, char* argv[]) { if (X_max > X_cutoff) { if (verbose > 0) printf("\n*** Restart Sanity Check Failed ***\n"); if (jsonOutput) { - testRunIid.errorLevel = -1; - testRunIid.errorMsg = "Restart Sanity Check Failed."; - ofstream output; - output.open(outputfilename); - output << testRunIid.GetAsJson(); - output.close(); + if(iid) { + testRunIid.errorLevel = -1; + testRunIid.errorMsg = "Restart Sanity Check Failed."; + ofstream output; + output.open(outputfilename); + output << testRunIid.GetAsJson(); + output.close(); + } else { + testRunNonIid.errorLevel = -1; + testRunNonIid.errorMsg = "Restart Sanity Check Failed."; + ofstream output; + output.open(outputfilename); + output << testRunNonIid.GetAsJson(); + output.close(); + } } exit(-1); } else if (verbose > 1) printf("\nRestart Sanity Check Passed...\n"); @@ -621,12 +693,21 @@ int main(int argc, char* argv[]) { if (min(H_r, H_c) < H_I / 2.0) { if (verbose > 0) printf("*** min(H_r, H_c) < H_I/2, Validation Testing Failed ***\n"); if (jsonOutput) { - testRunIid.errorLevel = -1; - testRunIid.errorMsg = "min(H_r, H_c) < H_I/2, Validation Testing Failed."; - ofstream output; - output.open(outputfilename); - output << testRunIid.GetAsJson(); - output.close(); + if(iid) { + testRunIid.errorLevel = -1; + testRunIid.errorMsg = "min(H_r, H_c) < H_I/2, Validation Testing Failed."; + ofstream output; + output.open(outputfilename); + output << testRunIid.GetAsJson(); + output.close(); + } else { + testRunNonIid.errorLevel = -1; + testRunNonIid.errorMsg = "min(H_r, H_c) < H_I/2, Validation Testing Failed."; + ofstream output; + output.open(outputfilename); + output << testRunNonIid.GetAsJson(); + output.close(); + } } exit(-1); }