<!-- 
============================================================================ 
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() -%}
            <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(setd) -%}
            <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 -%}
        {% 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 %}
            {% else -%}
                {% 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>
                <parameter name="module" value="TESTSCRIPTER"/>
                <parameter name="filter" value="*"/>
                <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
                <parameter name="testcase-file" value="{{ 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 TESTSCRIPTER" />
                <parameter name="result-file" value="{{ atsself.AtsInterface_LOG_DIR }}\TESTSCRIPTER.xml" />
                <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="{{ os.path.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 %}
            {%- endif %}
{%- endmacro %}

{% macro generate_runsteps_stif_single_set(setd) -%}
            {% if setd["engine_ini_file"] != None -%}
        {% 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 %}
            {% elif setd["config_files"] != [] -%}
                 {% for config_file in setd["config_files"] -%}
        {% if test_plan['hti'] == 'True' -%}
        <task>
            <type>StifRunCasesTask</type>
            <parameters>
                <parameter name="module" value="TESTSCRIPTER"/>
                <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) }}"/>
            </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 %}