<!-- 
============================================================================ 
Name        : ats_template.xml
Part of     : Helium 

Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
All rights reserved.
This component and the accompanying materials are made available
under the terms of the License "Eclipse Public License v1.0"
which accompanies this distribution, and is available
at the URL "http://www.eclipse.org/legal/epl-v10.html".

Initial Contributors:
Nokia Corporation - initial contribution.

Contributors:

Description:

============================================================================
-->
{% macro ctc_initialization(test_plan) -%}
            <task>
                <type>CreateDirTask</type>
                <parameters>
                    <parameter value="{{ atsself.CTC_LOG_DIR }}" name="dir"/>
                </parameters>
            </task>
            <task>
                <type>NonTestExecuteTask</type>
                <parameters>
                    <parameter value="z:\sys\bin\ctcman.exe" name="file" />
                    <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
                </parameters>
            </task>
{%- endmacro %}

{% macro ctc_finalization(test_plan) -%}
            <task>
                <type>NonTestExecuteTask</type>
                <parameters>
                    <parameter value="writelocal" name="parameters" />
                    <parameter value="z:\sys\bin\ctcman.exe" name="file" />
                    <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
                </parameters>
            </task>
            <task>
                <type>NonTestExecuteTask</type>
                <parameters>
                    <parameter value="writefile" name="parameters" />
                    <parameter value="z:\sys\bin\ctcman.exe" name="file" />
                    <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
                </parameters>
            </task>
            <task>
                <metadata>
                    <meta name="file-type">CTCDATA</meta> 
                </metadata>
                <type>FileDownloadTask</type>
                <parameters>
                    <parameter name="src" value="{{ atsself.CTC_LOG_DIR }}\ctcdata.txt"/>
                    <parameter name="reboot-retry-count" value="1"/>
                    <parameter name="retry-count" value="1"/>
                </parameters>
            </task>
{%- endmacro %}

{% macro generate_runsteps_stif(setd) -%}
            {% set ini_file = atsself.stif_init_file(setd['src_dst']) %}
            {% if ini_file -%}
            {% set ini_file_module_name = atsself.stifmodulename(ini_file[0])  %}
        {% if test_plan['hti'] == 'True' -%}
        <task>
            <type>StifRunCasesTask</type>
            <parameters>
                <parameter name="filter" value="*"/>
                <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
                <parameter name="engineini" value="{{ ini_file[1] }}"/>
            </parameters>
        </task>
        {% else -%}
        <task>
            <type>AtsInterfaceTask</type>
            <parameters>
                <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
                <parameter name="file" value="atsinterface.exe" />
                <parameter name="parameters" value="-testmodule {{ atsself.stifmodulename(ini_file[0]) }} -engineini {{ ini_file[1] }}" />
                <parameter name="result-file" value="{{ atsself.AtsInterface_LOG_DIR }}\{{ atsself.stifmodulename(ini_file[0]) + '.xml' }}" />
                <parameter name="result-download-retry-count" value="1" />
                <parameter name="result-download-reboot-retry-count" value="1" />
            </parameters>
        </task>
        {%- endif %}
        {%- endif %}
            
                {% for file in setd['src_dst'] -%}
                    {% if setd["test_harness"] == "STIF" or setd["test_harness"] == "STIFUNIT" -%}
                        {% if file[2] == "conf" and ".dll" not in file[1].lower() -%}
        {% if test_plan['hti'] == 'True' -%}
        <task>
            <type>StifRunCasesTask</type>
            <parameters>
                {% if ini_file_module_name.upper() == 'TEFTESTMODULE' -%}
                <parameter name="module" value="{{ ini_file_module_name }}"/>
                {% else -%}
                <parameter name="module" value="TESTSCRIPTER"/>
                {%- endif %}
                <parameter name="filter" value="*"/>
                <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
                <parameter name="testcase-file" value="{{ file[1] }}"/>
                {% if ini_file_module_name.upper() == 'TEFTESTMODULE' and test_plan['ats_stf_enabled'].lower() == "true" -%}                
                <parameter name="result-file" value="{{ atsself.AtsInterface_LOG_DIR }}\{{ ini_file_module_name }}.xml" />
                {%- endif %}
            </parameters>
        </task>
        {% else -%}
        <task>
            <type>AtsInterfaceTask</type>
            <parameters>
                <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
                <parameter name="file" value="atsinterface.exe" />
                {% if ini_file_module_name.upper() == 'TEFTESTMODULE' -%}
                <parameter name="parameters" value="-testmodule {{ ini_file_module_name }}" />
                <parameter name="result-file" value="{{ atsself.AtsInterface_LOG_DIR }}\{{ ini_file_module_name }}.xml" />
                {% else -%}
                <parameter name="parameters" value="-testmodule TESTSCRIPTER" />
                <parameter name="result-file" value="{{ atsself.AtsInterface_LOG_DIR }}\TESTSCRIPTER.xml" />
                {%- endif %}
                <parameter name="result-download-retry-count" value="1" />
                <parameter name="result-download-reboot-retry-count" value="1" />
            </parameters>
        </task>
        {%- endif %}
                        {%- endif %}
                        {% if file[2] == "testmodule" -%}
        {% if test_plan['hti'] == 'True' -%}
        <task>
            <type>StifRunCasesTask</type>
            <parameters>
                <parameter name="module" value="{{ atspath.basename(file[1]) }}"/>
                <parameter name="filter" value="*"/>
                <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
            </parameters>
        </task>
        {% else -%}
        <task>
            <type>AtsInterfaceTask</type>
            <parameters>
                <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
                <parameter name="file" value="atsinterface.exe" />
                <parameter name="parameters" value="-testmodule {{ os.path.basename(file[1]) }}" />
                <parameter name="result-file" value="{{ atsself.AtsInterface_LOG_DIR }}\{{ os.path.basename(file[1]).replace('.' + file[1].rsplit(".")[1], '.xml') }}" />
                <parameter name="result-download-retry-count" value="1" />
                <parameter name="result-download-reboot-retry-count" value="1" />
            </parameters>
        </task>
        {%- endif %}
                        {%- endif %}
                    {%- endif %}
                {%- endfor %}
{%- endmacro %}

{% macro generate_runsteps_stif_single_set(setd) -%}
            {% if setd["engine_ini_file"] != None -%}

            {% set ini_file_module_name = atsself.stifmodulename(setd["engine_ini_file"])  %}
            
        {% if test_plan['hti'] == 'True' -%}
        <task>
            <type>StifRunCasesTask</type>
            <parameters>
                <parameter name="filter" value="*"/>
                <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
                <parameter name="engineini" value="c:\testframework\{{ os.path.basename(setd["engine_ini_file"]) }}"/>
            </parameters>
        </task>
        {% else -%}
        <task>
            <type>AtsInterfaceTask</type>
            <parameters>
                <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
                <parameter name="file" value="atsinterface.exe" />
                <parameter name="parameters" value="-engineini c:\testframework\{{ os.path.basename(setd["engine_ini_file"]) }}" />
                <parameter name="result-file" value="{{ atsself.AtsInterface_LOG_DIR }}\{{ os.path.basename(setd["engine_ini_file"]).replace('.' + setd["engine_ini_file"].rsplit(".")[1], '.xml') }}" />
                <parameter name="result-download-retry-count" value="1" />
                <parameter name="result-download-reboot-retry-count" value="1" />
            </parameters>
        </task>
        {%- endif %}
        {%- endif %}
            {% if setd["config_files"] != [] -%}
                 {% for config_file in setd["config_files"] -%}
        {% if test_plan['hti'] == 'True' -%}
        <task>
            <type>StifRunCasesTask</type>
            <parameters>
                {% if ini_file_module_name.upper() == 'TEFTESTMODULE' -%}
                <parameter name="module" value="{{ ini_file_module_name }}"/>
                {% else -%}
                <parameter name="module" value="TESTSCRIPTER"/>
                {%- endif %}
                <parameter name="filter" value="*"/>
                <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
                <parameter name="testcase-file" value="e:\testing\conf\{{ os.path.basename(config_file) }}"/>
                {% if ini_file_module_name.upper() == 'TEFTESTMODULE' and test_plan['ats_stf_enabled'].lower() == "true" -%}
                <parameter name="result-file" value="e:\testing\conf\{{ os.path.basename(config_file) }}.xml" />
                {%- endif %}
            </parameters>
        </task>
        {% else -%}
        <task>
            <type>AtsInterfaceTask</type>
            <parameters>
                <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
                <parameter name="file" value="atsinterface.exe" />
                <parameter name="parameters" value="-config e:\testing\conf\{{ os.path.basename(config_file) }}" />
                <parameter name="result-file" value="{{ atsself.AtsInterface_LOG_DIR }}\{{ os.path.basename(config_file).replace('.' + config_file.rsplit(".")[1], '.xml') }}" />
                <parameter name="result-download-retry-count" value="1" />
                <parameter name="result-download-reboot-retry-count" value="1" />
            </parameters>
        </task>
        {%- endif %}
                {%- endfor %}
            {% else -%}
                {% for testmodule_file in setd["testmodule_files"] -%}
        {% if test_plan['hti'] == 'True' -%}
        <task>
            <type>StifRunCasesTask</type>
            <parameters>
                <parameter name="module" value="{{ os.path.basename(testmodule_file) }}"/>
                <parameter name="filter" value="*"/>
                <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
            </parameters>
        </task>
        {% else -%}
        <task>
            <type>AtsInterfaceTask</type>
            <parameters>
                <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
                <parameter name="file" value="atsinterface.exe" />
                <parameter name="parameters" value="-testmodule {{ os.path.basename(testmodule_file) }}" />
                <parameter name="result-file" value="{{ atsself.AtsInterface_LOG_DIR }}\{{ os.path.basename(testmodule_file).replace('.' + testmodule_file.rsplit(".")[1], '.xml') }}" />
                <parameter name="result-download-retry-count" value="1" />
                <parameter name="result-download-reboot-retry-count" value="1" />
            </parameters>
        </task>
        {%- endif %}
                {%- endfor %}
            {%- endif %}
{%- endmacro %}
