{#

################################################################################
#
# Copyright 2020 OpenHW Group
#
# Licensed under the Solderpad Hardware Licence, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://solderpad.org/licenses/
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier:Apache-2.0 WITH SHL-2.0
#
################################################################################

#}
{% import 'regress_macros.j2' as regress_macros -%}

session {{session}} {
    top_dir: {{results_path}}/vmgr_sessions;
{% if lsf %}
    drm: lsf;
    max_runs_in_parallel: {{parallel}};
    queuing_policy: round_robin;
    default_dispatch_parameters: <text>{{lsf}}</text>;
{% endif %}
}

group {{project}} {
{% if sve %}
    // SVE Verification Environment definition
    sve_name: {{sve}};

{% endif %}

{% for r in regressions %}
{% for b in r.get_builds_with_no_tests() %}
    // Build:{{b.name}} {{b.description}}
    pre_group_script: 'cd {{b.abs_dir}} && {{b.cmd}} CV_CORE={{project}} CFG={{b.cfg}} CV_SIM_PREFIX= {{toolchain|upper}}=1 SIMULATOR={{b.simulator}} COV={{regress_macros.yesorno(b.cov)}} {{regress_macros.cv_results(results)}} {{makeargs}}';

{% endfor %}
{% for build in r.get_builds() %}
    // --------------------------------------------------------------------------
    // Build: {{build.name}}
    // --------------------------------------------------------------------------
    group {{build.name}} {

        // Build:{{build.name}} {{build.description}}
        pre_group_script: 'cd {{build.abs_dir}} && {{build.cmd}} CV_CORE={{project}} CFG={{build.cfg}} CV_SIM_PREFIX= {{toolchain|upper}}=1 SIMULATOR={{build.simulator}} COV={{regress_macros.yesorno(build.cov)}} {{regress_macros.cv_results(results)}} {{makeargs}}';

{% for t in r.get_tests_of_build(build.name) %}
{% set indent = '    '%}
{% if t.precmd %}
{% set indent = index + '    '%}
    group {{t.name}}_precmd {
        // Test (Precommand): {{t.name}} {{t.description}}
        test precmd {
            sv_seed: gen_random;
            count: 1;
            run_script: 'cd {{t.abs_dir}} && {{t.precmd}} CV_SIM_PREFIX= CV_CORE={{project}} CFG={{build.cfg}} {{toolchain|upper}}=1 SIMULATOR={{t.simulator}} RNDSEED=$RUN_ENV(BRUN_SV_SEED) NUM_TESTS={{t.num}} {{regress_macros.cv_results(results)}} {{makeargs}}';
        };
{% else %}
{% endif %}
{{indent}}    //  Cfg: {{cfg}} Test: {{t.name}} {{t.description}}
{{indent}}    group {{t.name}} {
{% if t.precmd %}
{{indent}}        depends_on: ../precmd;
{% endif %}
{{indent}}        timeout: 3600;
{{indent}}        test run {
{{indent}}            sv_seed: gen_random;
{{indent}}            count: {{t.num}};
{{indent}}            run_script: 'cd {{t.abs_dir}} && {{t.cmd}} COMP=0 CV_SIM_PREFIX= CV_CORE={{project}} {{toolchain|upper}}=1 CFG={{build.cfg}} SIMULATOR={{t.simulator}} USE_ISS={{regress_macros.yesorno(t.iss)}} COV={{regress_macros.yesorno(t.cov)}} RUN_INDEX=$RUN_ENV(BRUN_RUN_ID) GEN_START_INDEX=$RUN_ENV(BRUN_RUN_ID) RNDSEED=$RUN_ENV(BRUN_SV_SEED) {{regress_macros.cv_results(results)}} {{makeargs}} {{t.makearg}}';
{% if simulator == 'vsim' %}
{{indent}}            scan_script: 'vm_scan.pl {{filter_dir}}/corev_uvm.flt {{filter_dir}}/vsim_run.flt';
{% endif %}
{% if simulator == 'xrun' %}
{{indent}}            scan_script: 'vm_scan.pl cdns_sim.flt {{filter_dir}}/corev_uvm.flt vm.flt shell.flt';
{% endif  %}
{{indent}}        };
{{indent}}    };
{% if t.precmd %}
    };
{% endif %}
{% endfor %}
    };
{% endfor %}
{% endfor %}
};

