diff --git a/python/scripts/generate_enums.py b/python/scripts/generate_enums.py index 1dbcdc2b5..d20dbe3eb 100644 --- a/python/scripts/generate_enums.py +++ b/python/scripts/generate_enums.py @@ -10,18 +10,18 @@ import re import subprocess -def remove_comments(text): - def replacer(match): - s = match.group(0) - if s.startswith('/'): - return " " # note: a space and not an empty string - else: - return s - pattern = re.compile( - r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', - re.DOTALL | re.MULTILINE - ) - return re.sub(pattern, replacer, text) +# def remove_comments(text): +# def replacer(match): +# s = match.group(0) +# if s.startswith('/'): +# return " " # note: a space and not an empty string +# else: +# return s +# pattern = re.compile( +# r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', +# re.DOTALL | re.MULTILINE +# ) +# return re.sub(pattern, replacer, text) def extract_enums(lines): line_iter = iter(lines) diff --git a/python/scripts/list_tested_cmd.py b/python/scripts/list_tested_cmd.py new file mode 100644 index 000000000..5f2835451 --- /dev/null +++ b/python/scripts/list_tested_cmd.py @@ -0,0 +1,62 @@ +import parse +from pathlib import Path +import os +import locale +import argparse +path = Path('../../slsDetectorSoftware/tests/') +import subprocess + +parser = argparse.ArgumentParser() +parser.add_argument("-s", "--startswith", help="for filter", type = str, default=None) +args = parser.parse_args() + +files = [f for f in os.listdir(path) if 'CmdProxy' in f] +tested = [] +for fname in files: + with open(path/fname) as f: + data = f.read() + + data = parse.remove_comments(data) + data = data.splitlines() + + + for line in data: + if 'TEST_CASE' in line: + cmd = line.split("\"")[1] + print(cmd) + tested.append(cmd) + +out = subprocess.run(['g', 'list'], capture_output = True, encoding=locale.getpreferredencoding()) +all_cmd = out.stdout.splitlines() + +if 'vrf' in all_cmd: + print('HEY\n') + +if args.startswith is not None: + all_cmd = [cmd for cmd in all_cmd if cmd.startswith(args.startswith)] + tested = [cmd for cmd in tested if cmd.startswith(args.startswith)] + + + +not_tested = [] +misnamed = [] +for cmd in all_cmd: + if cmd not in tested: + not_tested.append(cmd) + +for cmd in tested: + if cmd not in all_cmd: + misnamed.append(cmd) + +print("\nThe following commands are tested:") +for cmd in tested: + print(cmd) + +print("\nThe following commands are NOT tested:") +for cmd in not_tested: + print(cmd) + +print(f"\nThe following {len(misnamed)} tests are misnamed and should be renamed:") +for cmd in misnamed: + print(cmd) +print(f'\nTests cover {len(tested)} of {len(all_cmd)} commands') \ No newline at end of file diff --git a/python/scripts/parse.py b/python/scripts/parse.py new file mode 100644 index 000000000..a186d52c8 --- /dev/null +++ b/python/scripts/parse.py @@ -0,0 +1,13 @@ +import re +def remove_comments(text): + def replacer(match): + s = match.group(0) + if s.startswith('/'): + return " " # note: a space and not an empty string + else: + return s + pattern = re.compile( + r'//.*?$|/\*.*?\*/|\'(?:\\.|[^\\\'])*\'|"(?:\\.|[^\\"])*"', + re.DOTALL | re.MULTILINE + ) + return re.sub(pattern, replacer, text) \ No newline at end of file diff --git a/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp b/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp index cb98f205a..85a777b5f 100644 --- a/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp +++ b/slsDetectorSoftware/tests/test-CmdProxy-rx.cpp @@ -296,6 +296,53 @@ TEST_CASE("rx_lock", "[.cmd]") { } } +// TEST_CASE("rx_zmqport", "[.cmd]") { +// multiSlsDetector d; +// int socketsperdetector = 1; +// if (test::type == slsDetectorDefs::EIGER) { +// socketsperdetector *= 2; +// } else if (test::type == slsDetectorDefs::JUNGFRAU) { +// REQUIRE_NOTHROW(multiSlsDetectorClient("numinterfaces 2", PUT)); +// socketsperdetector *= 2; +// } +// int port = 3500; +// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_zmqport " + +// std::to_string(port), PUT)); for (int i = 0; i != d.size(); ++i) { +// std::ostringstream oss; +// REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + +// ":rx_zmqport", GET, nullptr, oss)); REQUIRE(oss.str() == "rx_zmqport +// " + std::to_string(port + i * socketsperdetector) + '\n'); +// } +// port = 30001; +// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_zmqport " + +// std::to_string(port), PUT)); for (int i = 0; i != d.size(); ++i) { +// std::ostringstream oss; +// REQUIRE_NOTHROW(multiSlsDetectorClient(std::to_string(i) + +// ":rx_zmqport", GET, nullptr, oss)); REQUIRE(oss.str() == "rx_zmqport +// " + std::to_string(port + i * socketsperdetector) + '\n'); +// } +// if (test::type == slsDetectorDefs::JUNGFRAU) { +// REQUIRE_NOTHROW(multiSlsDetectorClient("numinterfaces 1", PUT)); +// } +// } + +// TEST_CASE("rx_datastream", "[.cmd]") { +// { +// std::ostringstream oss; +// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_datastream 1", PUT, +// nullptr, oss)); REQUIRE(oss.str() == "rx_datastream 1\n"); +// } +// { +// std::ostringstream oss; +// REQUIRE_NOTHROW(multiSlsDetectorClient("0:rx_datastream", GET, +// nullptr, oss)); REQUIRE(oss.str() == "rx_datastream 1\n"); +// } +// { +// std::ostringstream oss; +// REQUIRE_NOTHROW(multiSlsDetectorClient("rx_datastream 0", PUT, +// nullptr, oss)); REQUIRE(oss.str() == "rx_datastream 0\n"); +// } +// } // TEST_CASE("rx_tcpport", "[.cmd]") { // multiSlsDetector d;