Loading tests/create_short_testvectors.py +16 −8 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ __doc__ = \ Create short (5sec) testvectors. """ import sys from pathlib import Path from cut_pcm import cut_samples Loading @@ -45,6 +46,9 @@ TEST_VECTOR_DIR = str(HERE.joinpath("../scripts/testv").resolve()) NUM_CHANNELS = "4" # currently only FOA CUT_FROM = "0.0" CUT_LEN = "5.0" def create_short_testvectors(): for fs in ['48', '32', '16']: in_file = f"{TEST_VECTOR_DIR}/stvFOA{fs}c.pcm" cut_gain = "1.0" Loading @@ -53,3 +57,7 @@ for fs in ['48', '32', '16']: cut_gain = "16.0" cut_file = f"{TEST_VECTOR_DIR}/stvFOA{fs}c_cut_{cut_gain}.pcm" cut_samples(in_file, cut_file, NUM_CHANNELS, fs + "000", CUT_FROM, CUT_LEN, cut_gain) if __name__ == "__main__": sys.exit(create_short_testvectors()) tests/self_test_b.py→tests/run_pytests.py +128 −0 Original line number Diff line number Diff line Loading @@ -33,9 +33,8 @@ """ Script to run the pytest tests. Step 1: Set the stage for the pytest run. Step 2: Run pytest. Test prerequisites are checked for and check failures are reported. When prerequisites are met, the pytest test is executed. """ import os Loading @@ -46,7 +45,7 @@ import platform from pathlib import Path sys.path.append('tests/') from cut_pcm import cut_samples from create_short_testvectors import create_short_testvectors BIN_EXT = ".exe" if platform.system() == "Windows" else "" HERE = Path(__file__).parent.resolve() Loading @@ -54,78 +53,7 @@ DEFAULT_ENCODER_DUT = str(HERE.joinpath(f"../IVAS_cod{BIN_EXT}").resolve()) DEFAULT_DECODER_DUT = str(HERE.joinpath(f"../IVAS_dec{BIN_EXT}").resolve()) DEFAULT_ENCODER_REF = str(HERE.joinpath(f"../IVAS_cod_ref{BIN_EXT}").resolve()) DEFAULT_DECODER_REF = str(HERE.joinpath(f"../IVAS_dec_ref{BIN_EXT}").resolve()) CREND_UNITTEST_REF = str(HERE.joinpath(f"../scripts/ivas_pytests/tests/unit_tests/crend/IVAS_crend_unit_test_ref{BIN_EXT}").resolve()) TEST_VECTOR_DIR = str(HERE.joinpath("../scripts/testv").resolve()) REFERENCE_DIR = str(HERE.joinpath("ref").resolve()) DUT_BASE_DIR = str(HERE.joinpath("dut").resolve()) def build_enc_and_dec(src_dir): """ Build the encoder and decoder binaries. """ if platform.system() == "Windows": olddir = os.getcwd() os.chdir(src_dir) os.chdir("Workspace_msvc") command = ["MSBuild.exe", "Workspace_msvc.sln", "/t:Clean", "/p:configuration=Release", "/p:Platform=Win32"] subprocess.run(command, check=True) command = ["MSBuild.exe", "Workspace_msvc.sln", "/property:configuration=Release", "/p:Platform=Win32"] subprocess.run(command, check=True) os.chdir(olddir) else: command = ["make", "-C", src_dir, "clean"] subprocess.run(command, check=True) command = ["make", "-C", src_dir] subprocess.run(command, check=True) def build_crend_unittest(src_dir): """ Build the crend unit test binary. """ crend_dir = f"{src_dir}/scripts/ivas_pytests/tests/unit_tests/crend" if platform.system() == "Windows": olddir = os.getcwd() os.chdir(crend_dir) # command = ["MSBuild.exe", "ivas_crend_unit_test.sln", "/t:Clean", "/p:configuration=Release", "/p:Platform=Win32"] # subprocess.run(command, check=True) command = ["MSBuild.exe", "ivas_crend_unit_test.sln", "/property:configuration=Release", "/p:Platform=Win32"] subprocess.run(command, check=True) os.chdir(olddir) else: # command = ["make", "-C", src_dir, "clean"] # subprocess.run(command, check=True) command = ["make", "-C", src_dir, "IVAS_crend_unit_test"] subprocess.run(command, check=True) def build_dut_binaries(): """ Build the DUT binaries. """ print("Building the DUT binaries") dut_src_dir = str(HERE.joinpath("..").resolve()) build_enc_and_dec(dut_src_dir) build_crend_unittest(dut_src_dir) def create_short_testvectors(): """ Create short (5sec) testvectors. """ print("Creating short (5sec) testvectors") num_channels = "4" # currently only FOA cut_from = "0.0" cut_len = "5.0" for fs in ['48', '32', '16']: in_file = f"{TEST_VECTOR_DIR}/stvFOA{fs}c.pcm" cut_gain = "1.0" cut_file = f"{TEST_VECTOR_DIR}/stvFOA{fs}c_cut.pcm" cut_samples(in_file, cut_file, num_channels, fs + "000", cut_from, cut_len, cut_gain) cut_gain = "16.0" cut_file = f"{TEST_VECTOR_DIR}/stvFOA{fs}c_cut_{cut_gain}.pcm" cut_samples(in_file, cut_file, num_channels, fs + "000", cut_from, cut_len, cut_gain) def main(argv): Loading @@ -146,54 +74,22 @@ def main(argv): default="auto", help="Number of processes to use in pytest (default: auto)", ) parser.add_argument("--encref", help=f"REF encoder binary (default:{DEFAULT_ENCODER_REF})") parser.add_argument("--decref", help=f"REF decoder binary (default:{DEFAULT_DECODER_REF})") parser.add_argument("--encdut", help=f"DUT encoder binary (default:{DEFAULT_ENCODER_DUT})") parser.add_argument("--decdut", help=f"DUT decoder binary (default:{DEFAULT_DECODER_DUT})") args = parser.parse_args(argv[1:]) # check for DUT binaries if args.encdut: encdut_path = os.path.realpath(args.encdut) if not os.path.exists(encdut_path): sys.exit(f"DUT encoder binary {encdut_path} does not exist.") else: encdut_path = DEFAULT_ENCODER_DUT if args.decdut: decdut_path = os.path.realpath(args.decdut) if not os.path.exists(decdut_path): sys.exit(f"DUT encoder binary {decdut_path} does not exist.") else: decdut_path = DEFAULT_DECODER_DUT if not os.path.exists(encdut_path) or not os.path.exists(decdut_path): build_dut_binaries() if not os.path.exists(REFERENCE_DIR): # check for REF binaries if args.encref: encref_path = os.path.realpath(args.encref) if not os.path.exists(encref_path): sys.exit(f"REF encoder binary {encref_path} does not exist.") else: encref_path = DEFAULT_ENCODER_REF if args.decref: decref_path = os.path.realpath(args.decref) if not os.path.exists(decref_path): sys.exit(f"REF encoder binary {decref_path} does not exist.") else: decref_path = DEFAULT_DECODER_REF if not os.path.exists(encref_path) or not os.path.exists(decref_path): sys.exit("Reference binaries do not exist.") # check for test vectors if not os.path.exists(TEST_VECTOR_DIR): sys.exit(f"Test vector directory {TEST_VECTOR_DIR} does not exist.") if not os.path.exists(DEFAULT_ENCODER_DUT) or not os.path.exists(DEFAULT_DECODER_DUT): sys.exit(f"Need DUT binaries {DEFAULT_ENCODER_DUT} and {DEFAULT_DECODER_DUT}. Please create the binaries.") # check for references if os.path.exists(REFERENCE_DIR): print(f"Using existing references directory {REFERENCE_DIR}") else: # check for REF binaries print(f"References directory {REFERENCE_DIR} does not exist.") if not os.path.exists(DEFAULT_ENCODER_REF) or not os.path.exists(DEFAULT_DECODER_REF): sys.exit(f"Need REF binaries {DEFAULT_ENCODER_REF} and {DEFAULT_DECODER_REF}. Please create the binaries.") # create references print(f"Creating references within the references directory {REFERENCE_DIR}") create_short_testvectors() Loading @@ -207,35 +103,9 @@ def main(argv): args.numprocesses, "--update_ref", "1", "-v", "--test_vector_path", TEST_VECTOR_DIR, "--reference_path", REFERENCE_DIR, "--dut_base_path", DUT_BASE_DIR, "--ref_encoder_path", encref_path, "--ref_decoder_path", decref_path, "--dut_encoder_path", encdut_path, "--dut_decoder_path", decdut_path, ] # work-around in unit tests via environment variable # TESTVECTOR_PATH_REL_GROUPB: to specify the test vector directory relative to ivas_pytests folder # TESTVECTOR_PATH_REL_TRUNK: to specify the test vector directory relative to trunk my_env = os.environ.copy() my_env["TESTVECTOR_PATH_REL_GROUPB"] = "testv/" my_env["TESTVECTOR_PATH_REL_TRUNK"] = "/scripts/ivas_pytests/testv/" # leading "/" is important my_env["CREND_UNIT_TEST_BIN"] = CREND_UNITTEST_REF print("pytest command line to be executed from project root folder:") print(" ".join(base_cmd + ["-m", "create_ref"])) subprocess.run(base_cmd + ["-m", "create_ref"], check=False, env=my_env) print("pytest command line to be executed from project root folder:") print(" ".join(base_cmd + ["-m", "create_ref_part2"])) subprocess.run(base_cmd + ["-m", "create_ref_part2"], check=False, env=my_env) subprocess.run(base_cmd + ["-m", "create_ref"], check=False) subprocess.run(base_cmd + ["-m", "create_ref_part2"], check=False) if args.create_only: return Loading @@ -249,22 +119,7 @@ def main(argv): "tests", "-n", args.numprocesses, "-v", "--test_vector_path", TEST_VECTOR_DIR, "--reference_path", REFERENCE_DIR, "--dut_base_path", DUT_BASE_DIR, "--dut_encoder_path", encdut_path, "--dut_decoder_path", decdut_path, "--junit-xml=report-junit.xml", ] # print pytest commandline print("pytest command line to be executed from project root folder:") print(" ".join(cmd)) result = subprocess.run(cmd, check=False) return result.returncode Loading Loading
tests/create_short_testvectors.py +16 −8 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ __doc__ = \ Create short (5sec) testvectors. """ import sys from pathlib import Path from cut_pcm import cut_samples Loading @@ -45,6 +46,9 @@ TEST_VECTOR_DIR = str(HERE.joinpath("../scripts/testv").resolve()) NUM_CHANNELS = "4" # currently only FOA CUT_FROM = "0.0" CUT_LEN = "5.0" def create_short_testvectors(): for fs in ['48', '32', '16']: in_file = f"{TEST_VECTOR_DIR}/stvFOA{fs}c.pcm" cut_gain = "1.0" Loading @@ -53,3 +57,7 @@ for fs in ['48', '32', '16']: cut_gain = "16.0" cut_file = f"{TEST_VECTOR_DIR}/stvFOA{fs}c_cut_{cut_gain}.pcm" cut_samples(in_file, cut_file, NUM_CHANNELS, fs + "000", CUT_FROM, CUT_LEN, cut_gain) if __name__ == "__main__": sys.exit(create_short_testvectors())
tests/self_test_b.py→tests/run_pytests.py +128 −0 Original line number Diff line number Diff line Loading @@ -33,9 +33,8 @@ """ Script to run the pytest tests. Step 1: Set the stage for the pytest run. Step 2: Run pytest. Test prerequisites are checked for and check failures are reported. When prerequisites are met, the pytest test is executed. """ import os Loading @@ -46,7 +45,7 @@ import platform from pathlib import Path sys.path.append('tests/') from cut_pcm import cut_samples from create_short_testvectors import create_short_testvectors BIN_EXT = ".exe" if platform.system() == "Windows" else "" HERE = Path(__file__).parent.resolve() Loading @@ -54,78 +53,7 @@ DEFAULT_ENCODER_DUT = str(HERE.joinpath(f"../IVAS_cod{BIN_EXT}").resolve()) DEFAULT_DECODER_DUT = str(HERE.joinpath(f"../IVAS_dec{BIN_EXT}").resolve()) DEFAULT_ENCODER_REF = str(HERE.joinpath(f"../IVAS_cod_ref{BIN_EXT}").resolve()) DEFAULT_DECODER_REF = str(HERE.joinpath(f"../IVAS_dec_ref{BIN_EXT}").resolve()) CREND_UNITTEST_REF = str(HERE.joinpath(f"../scripts/ivas_pytests/tests/unit_tests/crend/IVAS_crend_unit_test_ref{BIN_EXT}").resolve()) TEST_VECTOR_DIR = str(HERE.joinpath("../scripts/testv").resolve()) REFERENCE_DIR = str(HERE.joinpath("ref").resolve()) DUT_BASE_DIR = str(HERE.joinpath("dut").resolve()) def build_enc_and_dec(src_dir): """ Build the encoder and decoder binaries. """ if platform.system() == "Windows": olddir = os.getcwd() os.chdir(src_dir) os.chdir("Workspace_msvc") command = ["MSBuild.exe", "Workspace_msvc.sln", "/t:Clean", "/p:configuration=Release", "/p:Platform=Win32"] subprocess.run(command, check=True) command = ["MSBuild.exe", "Workspace_msvc.sln", "/property:configuration=Release", "/p:Platform=Win32"] subprocess.run(command, check=True) os.chdir(olddir) else: command = ["make", "-C", src_dir, "clean"] subprocess.run(command, check=True) command = ["make", "-C", src_dir] subprocess.run(command, check=True) def build_crend_unittest(src_dir): """ Build the crend unit test binary. """ crend_dir = f"{src_dir}/scripts/ivas_pytests/tests/unit_tests/crend" if platform.system() == "Windows": olddir = os.getcwd() os.chdir(crend_dir) # command = ["MSBuild.exe", "ivas_crend_unit_test.sln", "/t:Clean", "/p:configuration=Release", "/p:Platform=Win32"] # subprocess.run(command, check=True) command = ["MSBuild.exe", "ivas_crend_unit_test.sln", "/property:configuration=Release", "/p:Platform=Win32"] subprocess.run(command, check=True) os.chdir(olddir) else: # command = ["make", "-C", src_dir, "clean"] # subprocess.run(command, check=True) command = ["make", "-C", src_dir, "IVAS_crend_unit_test"] subprocess.run(command, check=True) def build_dut_binaries(): """ Build the DUT binaries. """ print("Building the DUT binaries") dut_src_dir = str(HERE.joinpath("..").resolve()) build_enc_and_dec(dut_src_dir) build_crend_unittest(dut_src_dir) def create_short_testvectors(): """ Create short (5sec) testvectors. """ print("Creating short (5sec) testvectors") num_channels = "4" # currently only FOA cut_from = "0.0" cut_len = "5.0" for fs in ['48', '32', '16']: in_file = f"{TEST_VECTOR_DIR}/stvFOA{fs}c.pcm" cut_gain = "1.0" cut_file = f"{TEST_VECTOR_DIR}/stvFOA{fs}c_cut.pcm" cut_samples(in_file, cut_file, num_channels, fs + "000", cut_from, cut_len, cut_gain) cut_gain = "16.0" cut_file = f"{TEST_VECTOR_DIR}/stvFOA{fs}c_cut_{cut_gain}.pcm" cut_samples(in_file, cut_file, num_channels, fs + "000", cut_from, cut_len, cut_gain) def main(argv): Loading @@ -146,54 +74,22 @@ def main(argv): default="auto", help="Number of processes to use in pytest (default: auto)", ) parser.add_argument("--encref", help=f"REF encoder binary (default:{DEFAULT_ENCODER_REF})") parser.add_argument("--decref", help=f"REF decoder binary (default:{DEFAULT_DECODER_REF})") parser.add_argument("--encdut", help=f"DUT encoder binary (default:{DEFAULT_ENCODER_DUT})") parser.add_argument("--decdut", help=f"DUT decoder binary (default:{DEFAULT_DECODER_DUT})") args = parser.parse_args(argv[1:]) # check for DUT binaries if args.encdut: encdut_path = os.path.realpath(args.encdut) if not os.path.exists(encdut_path): sys.exit(f"DUT encoder binary {encdut_path} does not exist.") else: encdut_path = DEFAULT_ENCODER_DUT if args.decdut: decdut_path = os.path.realpath(args.decdut) if not os.path.exists(decdut_path): sys.exit(f"DUT encoder binary {decdut_path} does not exist.") else: decdut_path = DEFAULT_DECODER_DUT if not os.path.exists(encdut_path) or not os.path.exists(decdut_path): build_dut_binaries() if not os.path.exists(REFERENCE_DIR): # check for REF binaries if args.encref: encref_path = os.path.realpath(args.encref) if not os.path.exists(encref_path): sys.exit(f"REF encoder binary {encref_path} does not exist.") else: encref_path = DEFAULT_ENCODER_REF if args.decref: decref_path = os.path.realpath(args.decref) if not os.path.exists(decref_path): sys.exit(f"REF encoder binary {decref_path} does not exist.") else: decref_path = DEFAULT_DECODER_REF if not os.path.exists(encref_path) or not os.path.exists(decref_path): sys.exit("Reference binaries do not exist.") # check for test vectors if not os.path.exists(TEST_VECTOR_DIR): sys.exit(f"Test vector directory {TEST_VECTOR_DIR} does not exist.") if not os.path.exists(DEFAULT_ENCODER_DUT) or not os.path.exists(DEFAULT_DECODER_DUT): sys.exit(f"Need DUT binaries {DEFAULT_ENCODER_DUT} and {DEFAULT_DECODER_DUT}. Please create the binaries.") # check for references if os.path.exists(REFERENCE_DIR): print(f"Using existing references directory {REFERENCE_DIR}") else: # check for REF binaries print(f"References directory {REFERENCE_DIR} does not exist.") if not os.path.exists(DEFAULT_ENCODER_REF) or not os.path.exists(DEFAULT_DECODER_REF): sys.exit(f"Need REF binaries {DEFAULT_ENCODER_REF} and {DEFAULT_DECODER_REF}. Please create the binaries.") # create references print(f"Creating references within the references directory {REFERENCE_DIR}") create_short_testvectors() Loading @@ -207,35 +103,9 @@ def main(argv): args.numprocesses, "--update_ref", "1", "-v", "--test_vector_path", TEST_VECTOR_DIR, "--reference_path", REFERENCE_DIR, "--dut_base_path", DUT_BASE_DIR, "--ref_encoder_path", encref_path, "--ref_decoder_path", decref_path, "--dut_encoder_path", encdut_path, "--dut_decoder_path", decdut_path, ] # work-around in unit tests via environment variable # TESTVECTOR_PATH_REL_GROUPB: to specify the test vector directory relative to ivas_pytests folder # TESTVECTOR_PATH_REL_TRUNK: to specify the test vector directory relative to trunk my_env = os.environ.copy() my_env["TESTVECTOR_PATH_REL_GROUPB"] = "testv/" my_env["TESTVECTOR_PATH_REL_TRUNK"] = "/scripts/ivas_pytests/testv/" # leading "/" is important my_env["CREND_UNIT_TEST_BIN"] = CREND_UNITTEST_REF print("pytest command line to be executed from project root folder:") print(" ".join(base_cmd + ["-m", "create_ref"])) subprocess.run(base_cmd + ["-m", "create_ref"], check=False, env=my_env) print("pytest command line to be executed from project root folder:") print(" ".join(base_cmd + ["-m", "create_ref_part2"])) subprocess.run(base_cmd + ["-m", "create_ref_part2"], check=False, env=my_env) subprocess.run(base_cmd + ["-m", "create_ref"], check=False) subprocess.run(base_cmd + ["-m", "create_ref_part2"], check=False) if args.create_only: return Loading @@ -249,22 +119,7 @@ def main(argv): "tests", "-n", args.numprocesses, "-v", "--test_vector_path", TEST_VECTOR_DIR, "--reference_path", REFERENCE_DIR, "--dut_base_path", DUT_BASE_DIR, "--dut_encoder_path", encdut_path, "--dut_decoder_path", decdut_path, "--junit-xml=report-junit.xml", ] # print pytest commandline print("pytest command line to be executed from project root folder:") print(" ".join(cmd)) result = subprocess.run(cmd, check=False) return result.returncode Loading