Commit 03328183 authored by advasila's avatar advasila
Browse files

merging the main in

parents 35303c95 4fc98050
Loading
Loading
Loading
Loading
Loading
+65 −5
Original line number Diff line number Diff line
variables:
  TESTV_DIR: "/usr/local/testv"
  BUILD_OUTPUT: "build_output.txt"
  EVS_BE_TEST_DIR: "/usr/local/be_2_evs_test"


# This sets when pipelines are created. Jobs have more specific rules to restrict them.
@@ -51,6 +52,8 @@ stages:
  rules:
    - if: $MIRROR_ACCESS_TOKEN # Don't run in the mirror update pipeline (only then MIRROR_ACCESS_TOKEN is defined)
      when: never
    - if: $CI_PIPELINE_SOURCE == 'schedule' # Don't run in any scheduled pipelines by default (use schedule templates below to enable again for certain conditions)
      when: never
    - when: on_success

.rules-merge-request:
@@ -216,6 +219,12 @@ msan-on-merge-request-linux:
    - python3 scripts/self_test.py --create | tee test_output.txt
    - run_errors=$(cat test_output.txt | grep -ic "run errors") || true
    - if [ $run_errors != 0 ] ; then echo "Run errors in self_test.py with Clang memory-sanitizer"; exit 1; fi
  artifacts:
    name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results"
    paths:
      - scripts/ref/logs/
      - test_output.txt
    expose_as: 'Msan selftest results'


# code selftest testvectors with address-sanitizer binaries
@@ -232,6 +241,12 @@ asan-on-merge-request-linux:
    - python3 scripts/self_test.py --create | tee test_output.txt
    - run_errors=$(cat test_output.txt | grep -ic "run errors") || true
    - if [ $run_errors != 0 ] ; then echo "Run errors in self_test.py with Clang address-sanitizer"; exit 1; fi
  artifacts:
    name: "mr-$CI_MERGE_REQUEST_IID--sha-$CI_COMMIT_SHORT_SHA--stage-$CI_JOB_STAGE--results"
    paths:
      - scripts/ref/logs/
      - test_output.txt
    expose_as: 'Asan selftest results'


# compare bit exactness between target and source branch
@@ -331,6 +346,34 @@ self-test-on-merge-request:
# Test jobs for main branch
# ---------------------------------------------------------------

# check bitexactness to EVS
be-2-evs-linux:
  extends:
    - .test-job-linux
    - .rules-main-push
  tags:
    - be-2-evs-temp
  stage: test
  needs: [ "build-codec-linux-cmake" ]
  timeout: "20 minutes" # To be revisited
  script:
    - *print-common-info

    - mkdir build
    - cd build
    - cmake ..
    - make -j
    - cd ..

    # copy over to never change the testvector dir
    - cp -r $EVS_BE_TEST_DIR ./evs_be_test
    - cp build/IVAS_cod ./evs_be_test/bin/EVS_cod
    - cp build/IVAS_dec ./evs_be_test/bin/EVS_dec

    - cd evs_be_test
    - python3 ../ci/run_evs_be_test.py


codec-comparison-on-main-push:
  extends:
    - .test-job-linux
@@ -420,16 +463,33 @@ codec-comparison-on-main-push:
      junit: report-junit.xml


# parameterizable job for sanitizer tests per format
# how to set up: create a schedule (CI/CD -> schedules) and enter the respective values for the environment variables:
#   - SANITIZER_TEST_IN_FMT: input format
#   - SANITIZER_TEST_OUT_FMTS: list of output formats, blank-separated, e.g.: stereo mono 5_1
#   - SANITIZER_TEST_TESTS: list of checks to do, can be one of CLANG1, CLANG2, CLANG3, VALGRIND
sanitizer-test-on-main-scheduled:
  extends: .test-job-linux-needs-testv-dir
  extends: 
    - .test-job-linux-needs-testv-dir
    # this next one is maybe not really needed, since there is the rule checking for the existence of the env vars below, but use for clarity
    - .rules-main-scheduled
  tags:
    - sanitizer_test_main
  stage: test
  rules:
    # only run in scheduled pipeline that passes this env var
    - if: $SANITIZER_TEST_IN_FMT
    # only run in scheduled pipeline that passes this env vars
    - if: $SANITIZER_TEST_IN_FMT && $SANITIZER_TEST_OUT_FMTS && $SANITIZER_TEST_TESTS
  script:
    - *print-common-info
    - echo "Running scheduled sanitizer"
    # - python3 ci/run_scheduled_sanitizer_test.py $SANITIZER_TEST_IN_FMT $SANITIZER_TEST_OUT_FMTS
    - echo "Running scheduled sanitizer tests $SANITIZER_TEST_TESTS for input format $SANITIZER_TEST_IN_FMT and output format(s) $SANITIZER_TEST_OUT_FMTS"

    - python3 ci/run_scheduled_sanitizer_test.py $SANITIZER_TEST_IN_FMT $SANITIZER_TEST_OUT_FMTS --tests $SANITIZER_TEST_TESTS
  artifacts:
    name: "sanitizer-test-results-and-error_pattern-$SANITIZER_TEST_IN_FMT-in-$SANITIZER_TEST_OUT_FMTS-out"
    when: always
    paths:
      - ep_015.g192
      - "./*/logs"


# ---------------------------------------------------------------
+1 −1
Original line number Diff line number Diff line
@@ -1618,7 +1618,7 @@ static void usage_enc( void )
    fprintf( stdout, "                      where 0 = adaptive, 3-100 = fixed in number of frames,\n" );
    fprintf( stdout, "                      default is deactivated\n" );
    fprintf( stdout, "-dtx                : Activate DTX mode with a SID update rate of 8 frames\n" );
    fprintf( stdout, "                      Note: DTX is currently supported in EVS, DFT/TD stereo, 1 ISm, \n" );
    fprintf( stdout, "                      Note: DTX is currently supported in EVS, stereo, 1 ISm, \n" );
    fprintf( stdout, "                      SBA (up to 128kbps) and MASA (up to 128kbps)\n" );
    fprintf( stdout, "-rf p o             : Activate channel-aware mode for WB and SWB signal at 13.2kbps, \n" );
    fprintf( stdout, "                      where FEC indicator, p: LO or HI, and FEC offset, o: 2, 3, 5, or 7 in number of frames.\n" );
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ import argparse
import sys


SEARCH_FOR = "warning:"
SEARCH_FOR = "warning"
RETURN_FOUND = 123


ci/run_evs_be_test.py

0 → 100755
+76 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3
import subprocess
import pathlib
import sys
import concurrent.futures
from threading import Lock


README_FILES_PARALLEL = [
    "Readme_AMRWB_IO_enc.txt",
    "Readme_AMRWB_IO_dec.txt",
    "Readme_EVS_enc.txt",
    "Readme_EVS_dec.txt",
]
README_FILES_JBM = ["Readme_JBM_dec.txt"]
README_FILES = README_FILES_PARALLEL + README_FILES_JBM
BINARY_PATHS = ["./bin/EVS_cod", "./bin/EVS_dec"]
FOLDER_PATHS = ["testv"]
BIN_PATHS = BINARY_PATHS * 2

def main():

    if not environment_is_correct():
        return 1

    result_dict = dict()
    # run first part in parallel
    with concurrent.futures.ThreadPoolExecutor(max_workers=4) as executor:
        executor.map(
            run_file, README_FILES_PARALLEL, BIN_PATHS, [result_dict] * len(README_FILES_PARALLEL)
        )

    # JBM test can not run concurrently with the others
    run_file(README_FILES_JBM[0], BINARY_PATHS[1], result_dict)

    return analyze_results(result_dict)


def analyze_results(result_dict):
    ret = 0

    for filename, ret_code in result_dict.items():
        if ret_code != 0:
            print(f"========= Test for {filename} failed! See log below: ==========")
            with open(filename.replace("Readme", "Log")) as f:
                print(f.read())
            ret = 1

    return ret


def run_file(filename: str, bin_path: str, result_dict: dict):
    ret_code = subprocess.call(["bash", filename, bin_path])
    with Lock():
        result_dict[filename] = ret_code


def environment_is_correct():
    """
    Check that the folder with the test resources is set up correctly:
    - all Readme files there
    - EVS binaries available in bin/
    - testv and switchPaths folder exist - Content is not checked, though
    """
    ret = True

    for path in README_FILES + BINARY_PATHS + FOLDER_PATHS:
        if not pathlib.Path(path).exists():
            print(f"Environment setup is incorrect - {path} not found.")
            ret = False

    return ret


if __name__ == "__main__":
    sys.exit(main())
+119 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3

import argparse
import sys
import subprocess
import pathlib


DURATION = "120"
CFG = "ci_linux.json"
SUPPORTED_TESTS = ["CLANG1", "CLANG2", "CLANG3", "VALGRIND"]
EP_FILE = "ep_015.g192"
GENPATT_CMD = f"gen-patt -tailstat -fer -g192 -gamma 0 -rate 0.15 -tol 0.001 -reset -n {int(DURATION) * 50} {EP_FILE}"
EIDXOR_CMD = "eid-xor -vbr -fer {bitstream} {ep_file} {out_file}"
MC_MODES = ["5_1", "5_1_2", "5_1_4", "7_1", "7_1_4"]

SCRIPT_DIR = pathlib.Path("./scripts").resolve()


def main(args):
    in_format = args.in_format
    out_formats = args.out_formats
    tests = args.tests
    run_fec = not args.skip_fec

    assert all([t in SUPPORTED_TESTS for t in tests])

    modes = get_modes(in_format)
    returncode = run_check(modes, out_formats, tests, run_fec=run_fec)

    sys.exit(returncode)


def get_modes(in_format: str) -> list:
    cmd = [SCRIPT_DIR.joinpath("runIvasCodec.py"), "-l"]
    list_process = subprocess.run(cmd, capture_output=True)

    output = list_process.stdout.decode("utf8")

    # correction for multichannel modes to avoid selecting some mono modes...
    if in_format in MC_MODES:
        in_format = "MC_" + in_format

    return [m for m in output.splitlines() if in_format in m]


def run_check(modes: list, out_formats: list, tests: list, run_fec: bool = True):

    ### always run encoder and decoder with no frameloss
    cmd_no_fec = [
        str(SCRIPT_DIR.joinpath("IvasBuildAndRunChecks.py")),
        "-U",
        DURATION,
        "-p",
        CFG,
        "--checks",
        *tests,
        "-m",
        *modes,
        "--oc",
        *out_formats,
    ]

    print("======== Script command line WITHOUT plc: ========\n{}".format(" ".join(cmd_no_fec)))

    proc = subprocess.Popen(cmd_no_fec, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    for c in iter(lambda: proc.stdout.read(1), b""):
        sys.stdout.buffer.write(c)
    proc.wait()

    if proc.returncode not in [0, 101]:
        raise IvasBuildAndRunFailed("Failed at first run (no PLC)")

    returncode_no_fec = proc.returncode

    if not run_fec:
        return returncode_no_fec

    ### second run: decoder only with disturbed bitstream

    # generate error pattern
    subprocess.call(GENPATT_CMD.split())

    # cleanup to avoid script errors
    # we want "logs" and "dec" subfolders to be empty -> delete and recreate them
    cleanup_folders = ["logs", "dec"]
    for t in tests:
        for fol in cleanup_folders:
            for fi in pathlib.Path(t).joinpath(fol).iterdir():
                fi.unlink()

    cmd_fec = cmd_no_fec + ["--decoder_only", "-f", EP_FILE]
    print("======== Script command line WITH plc: ========\n{}".format(" ".join(cmd_no_fec)))

    proc = subprocess.Popen(cmd_fec, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    for c in iter(lambda: proc.stdout.read(1), b""):
        sys.stdout.buffer.write(c)
    proc.wait()

    returncode_fec = proc.returncode

    if returncode_fec not in [0, 101]:
        raise IvasBuildAndRunFailed("failed at second run (PLC)")

    return 101 if 101 in [returncode_no_fec, returncode_fec] else 0


class IvasBuildAndRunFailed(Exception):
    pass


if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("in_format", type=str)
    parser.add_argument("out_formats", type=str, nargs="+")
    parser.add_argument("--tests", type=str, nargs="+", default=["CLANG1", "CLANG2"])
    parser.add_argument("--skip_fec", action="store_true")

    sys.exit(main(parser.parse_args()))
Loading