Commit 2ed6ff4c authored by Archit Tamarapu's avatar Archit Tamarapu
Browse files

Merge branch 'refactor_renderer_tests' into 'main'

[CI] Rendering test updates

See merge request !1194
parents c5365c9a 96dfdd5b
Loading
Loading
Loading
Loading
Loading
+21 −23
Original line number Diff line number Diff line
@@ -110,7 +110,7 @@ stages:
  - make -j
  - mv IVAS_cod ../IVAS_cod_test
  - mv IVAS_dec ../IVAS_dec_test
  - mv IVAS_rend ..
  - mv IVAS_rend ../IVAS_rend_test
  - cd ..
  - rm -rf build/*

@@ -129,11 +129,13 @@ stages:
  - make -j
  - mv IVAS_cod ../IVAS_cod_ref
  - mv IVAS_dec ../IVAS_dec_ref
  - mv IVAS_rend ../IVAS_rend_ref
  - cd ..

  # rename test binaries back
  - mv IVAS_cod_test IVAS_cod
  - mv IVAS_dec_test IVAS_dec
  - mv IVAS_rend_test IVAS_rend

.merge-request-comparison-check: &merge-request-comparison-check
  - if [ $zero_errors != 1 ]; then echo "Run errors encountered!"; exit $EXIT_CODE_FAIL; fi
@@ -618,6 +620,7 @@ renderer-pytest-on-merge-request:
    - *print-common-info
    - *get-commits-behind-count
    - *check-commits-behind-count-in-compare-jobs
    - *merge-request-comparison-setup-codec

    # some helper variables - "|| true" to prevent failures from grep not finding anything
    # write to temporary file as workaround for failures observed with piping echo
@@ -625,28 +628,17 @@ renderer-pytest-on-merge-request:
    - non_be_flag=$(grep -c --ignore-case "\[rend\(erer\)*[ -]*non[ -]*be\]" tmp.txt) || true
    - ref_using_main=$(grep -c --ignore-case "\[ref[ -]*using[ -]*main\]" tmp.txt) || true

    # store the current commit hash
    - source_branch_commit_sha=$(git rev-parse HEAD)

    - *mr-fetch-target-branch
    - *mr-get-target-commit
    - git checkout $target_commit

    # build reference binaries
    - make -j IVAS_rend
    - mv IVAS_rend IVAS_rend_ref
    ### If ref_using_main is not set, checkout the source branch to use scripts and input from there
    - if [ $ref_using_main == 0 ]; then git checkout $source_branch_commit_sha; fi

    # back to source branch
    - git checkout $source_branch_commit_sha
    - make clean
    - make -j IVAS_rend
    - exit_code=0
    - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer.py --create_ref || exit_code=$?

    ### Run test using scripts and input from main
    - if [ $ref_using_main == 1 ]; then git checkout $target_commit; fi
    ### Run test using branch scripts and input
    - if [ $ref_using_main == 1 ]; then git checkout $source_branch_commit_sha; fi

    # run test
    - exit_code=0
    - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer_be_comparison.py || exit_code=$?
    - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/renderer/test_renderer_.py --create_cut || exit_code=$?
    - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true

    - *merge-request-comparison-check
@@ -722,6 +714,12 @@ split-rendering-pytest-on-merge-request:
    - mv IVAS_dec IVAS_dec_ref
    - mv IVAS_rend IVAS_rend_ref

    ### If ref_using_main is not set, checkout the source branch to use scripts and input from there
    - if [ $ref_using_main == 0 ]; then git restore lib_com/options.h; fi # Revert changes back before checking out another branch to avoid conflicts
    - if [ $ref_using_main == 0 ]; then git checkout $source_branch_commit_sha; fi
    - exit_code=0
    - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_ref || exit_code=$?

    # back to source branch
    - git restore lib_com/options.h # Revert changes back before checking out another branch to avoid conflicts
    - git checkout $source_branch_commit_sha
@@ -731,11 +729,10 @@ split-rendering-pytest-on-merge-request:

    ### Run test using scripts and input from main
    - if [ $ref_using_main == 1 ]; then git restore lib_com/options.h; fi # Revert changes back before checking out another branch to avoid conflicts
    - if [ $ref_using_main == 1 ]; then git checkout $target_commit; fi
    - if [ $ref_using_main == 1 ]; then git checkout $source_branch_commit_sha; fi

    # run test
    - exit_code=0
    - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering_be_comparison.py || exit_code=$?
    - python3 -m pytest -q --log-level ERROR -n auto -rA --html=report.html --self-contained-html --junit-xml=report-junit.xml tests/split_rendering/test_split_rendering.py --create_cut || exit_code=$?
    - zero_errors=$(cat report-junit.xml | grep -c 'errors="0"') || true

    - *merge-request-comparison-check
@@ -1531,7 +1528,8 @@ coverage-test-on-main-scheduled:
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR -v -n auto --update_ref 1 -m create_ref_part2 --ref_encoder_path ./IVAS_cod --ref_decoder_path ./IVAS_dec
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v -n auto --update_ref 1 -m create_ref --param_file scripts/config/self_test_evs.prm --ref_encoder_path ./IVAS_cod --ref_decoder_path ./IVAS_dec
    - bash ci/smoke_test.sh coverage
    - python3 -m pytest -q -n auto tests/renderer/test_renderer_be_comparison.py
    - python3 -m pytest -q -n auto tests/renderer/test_renderer.py --create_ref
    - python3 -m pytest -q -n auto tests/renderer/test_renderer.py --create_cut
    - python3 -m pytest $TESTS_DIR_CODEC_BE_ON_MR/test_param_file.py -v -n auto --update_ref 1 -m create_ref --param_file scripts/config/self_test_ltv.prm --ref_encoder_path ./IVAS_cod --ref_decoder_path ./IVAS_dec
    - bash ci/ivas_voip_be_test.sh coverage
    - lcov -c -d obj -o coverage.info
+18 −7
Original line number Diff line number Diff line
@@ -8,26 +8,37 @@ See also the [contribution page](https://forge.3gpp.org/rep/ivas-codec-pc/ivas-c

### Run tests with:

`python3 -m pytest -q -n auto tests/renderer/test_renderer.py`
## Smoke test:

```bash
python3 -m pytest -q -n auto tests/renderer/test_renderer.py
```

## Comparison test:

```bash
python3 -m pytest -q -n auto tests/renderer/test_renderer.py --create_ref # requires IVAS_rend_ref in root!
python3 -m pytest -q -n auto tests/renderer/test_renderer.py --create_cut
```

### Important flags (see [pytest docs](https://docs.pytest.org/en/7.2.x/) for more information):

* `-k` flag can filter test cases, e.g. `-k "test_ism_binaural_static"`
* `-rA` reports ALL (pass, xpass, xfail, fail) instead of the default behaviour of reporting only failed tests\
- `-k` flag can filter test cases, e.g. `-k "test_ism_binaural_static"`
- `-rA` reports ALL (pass, xpass, xfail, fail) instead of the default behaviour of reporting only failed tests\
  this option will also report captured logs, **required for obtaining the commandline of testcases that pass or xfail**
* `--last-failed` re-runs only the cases that failed in the last test run
* `--collect-only` is useful when adding new testcases to check if argument parametrization is working correctly
- `--last-failed` re-runs only the cases that failed in the last test run
- `--collect-only` is useful when adding new testcases to check if argument parametrization is working correctly

### Directory tree

```
.
├── compare_audio.py                    ->  Python implementation of CompAudio, used for comparisons in tests
├── conftest.py                         ->  Pytest configuration (enable commandline argument ingestion)
├── constants.py                        ->  Important paths, formats, metadata files and commandline templates
├── cut                                 ->  Default location for output files for test conditions
├── data                                ->  Input test vectors
├── ref                                 ->  Default location for output files for reference conditions
├── test_renderer_be_comparison.py      ->  Tests for CI Merge Request pipeline to compare renderer bit-exactness
├── test_renderer.py                    ->  Runs the renderer for all modes
└── utils.py                            ->  Wrapper functions for executables for use in testcases
```
+44 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3

"""
   (C) 2022-2023 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
   Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
   Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
   Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
   contributors to this repository. All Rights Reserved.

   This software is protected by copyright law and by international treaties.
   The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
   Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
   Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
   Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
   contributors to this repository retain full ownership rights in their respective contributions in
   the software. This notice grants no license of any kind, including but not limited to patent
   license, nor is any license granted by implication, estoppel or otherwise.

   Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
   contributions.

   This software is provided "AS IS", without any express or implied warranties. The software is in the
   development stage. It is intended exclusively for experts who have experience with such software and
   solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
   and fitness for a particular purpose are hereby disclaimed and excluded.

   Any dispute, controversy or claim arising under or in relation to providing this software shall be
   submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
   accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
   the United Nations Convention on Contracts on the International Sales of Goods.
"""


def pytest_addoption(parser):
    parser.addoption(
        "--create_ref",
        action="store_true",
        default=False,
    )
    parser.addoption(
        "--create_cut",
        action="store_true",
        default=False,
    )
+20 −8
Original line number Diff line number Diff line
@@ -74,13 +74,19 @@ NCHAN_TO_FILE = {
    4: TEST_VECTOR_DIR.joinpath("spectral_test_4ch_48kHz.wav"),
    5: TEST_VECTOR_DIR.joinpath("spectral_test_5ch_48kHz.wav"),
    6: TEST_VECTOR_DIR.joinpath("spectral_test_6ch_48kHz.wav"),
    7: TEST_VECTOR_DIR.joinpath("spectral_test_7ch_48kHz.wav"),
    8: TEST_VECTOR_DIR.joinpath("spectral_test_8ch_48kHz.wav"),
    9: TEST_VECTOR_DIR.joinpath("spectral_test_9ch_48kHz.wav"),
    10: TEST_VECTOR_DIR.joinpath("spectral_test_10ch_48kHz.wav"),
    11: TEST_VECTOR_DIR.joinpath("spectral_test_11ch_48kHz.wav"),
    12: TEST_VECTOR_DIR.joinpath("spectral_test_12ch_48kHz.wav"),
    13: TEST_VECTOR_DIR.joinpath("spectral_test_13ch_48kHz.wav"),
    15: TEST_VECTOR_DIR.joinpath("spectral_test_15ch_48kHz.wav"),
    16: TEST_VECTOR_DIR.joinpath("spectral_test_16ch_48kHz.wav"),
    17: TEST_VECTOR_DIR.joinpath("spectral_test_17ch_48kHz.wav"),
    18: TEST_VECTOR_DIR.joinpath("spectral_test_18ch_48kHz.wav"),
    19: TEST_VECTOR_DIR.joinpath("spectral_test_19ch_48kHz.wav"),
    20: TEST_VECTOR_DIR.joinpath("spectral_test_20ch_48kHz.wav"),
}

FORMAT_TO_FILE_SMOKETEST = {
@@ -99,14 +105,20 @@ FORMAT_TO_FILE_SMOKETEST = {
    "ISM3": NCHAN_TO_FILE[3],
    "ISM4": NCHAN_TO_FILE[4],
    "NDP_ISM4": NCHAN_TO_FILE[4],
    # "ISM1": TEST_VECTOR_DIR.joinpath("spectral_test_ism1.txt"),
    # "ISM2": TEST_VECTOR_DIR.joinpath("spectral_test_ism2.txt"),
    # "ISM3": TEST_VECTOR_DIR.joinpath("spectral_test_ism3.txt"),
    # "ISM4": TEST_VECTOR_DIR.joinpath("spectral_test_ism4.txt"),
    # "MASA1": NCHAN_TO_FILE[1],
    # "MASA2": NCHAN_TO_FILE[2],
    "MASA1": TESTV_DIR.joinpath("stv1MASA1TC48c.wav"),
    "MASA2": TESTV_DIR.joinpath("stv2MASA2TC48c.wav"),
    "MASA1": NCHAN_TO_FILE[1],
    "MASA2": NCHAN_TO_FILE[2],
    "OSBA_1_1": NCHAN_TO_FILE[5],
    "OSBA_2_1": NCHAN_TO_FILE[6],
    "OSBA_3_1": NCHAN_TO_FILE[7],
    "OSBA_4_1": NCHAN_TO_FILE[8],
    "OSBA_1_2": NCHAN_TO_FILE[10],
    "OSBA_2_2": NCHAN_TO_FILE[11],
    "OSBA_3_2": NCHAN_TO_FILE[12],
    "OSBA_4_2": NCHAN_TO_FILE[13],
    "OSBA_1_3": NCHAN_TO_FILE[17],
    "OSBA_2_3": NCHAN_TO_FILE[18],
    "OSBA_3_3": NCHAN_TO_FILE[19],
    "OSBA_4_3": NCHAN_TO_FILE[20],
    "META": TEST_VECTOR_DIR.joinpath("mixed_scene.txt"),
    "16ch_8+4+4": NCHAN_TO_FILE[16],
    "4d4": NCHAN_TO_FILE[8],
+132 B

File added.

No diff preview for this file type.

Loading