<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<!-- 
============================================================================ 
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:
Contains the template for the test.xml file output. The test.xml file contains
information on the files used to create the drop file.
============================================================================
-->

{% import 'ats4_macros.xml' as macros with context %}

<testrun>
    <metadata>
        {% if test_plan['diamonds_build_url'] -%}
        <meta name="diamonds-buildid">{{ test_plan['diamonds_build_url'] }}</meta> 
        <meta name="diamonds-testtype">Smoke</meta>
        {% endif %}
        <meta name="name">{{ test_plan['testrun_name'] }}</meta> 
    </metadata>
    
    <agents>
        <agent alias="DEFAULT_{{ test_plan['harness'] }}">
            <property name="hardware" value="{{ test_plan["device_type"] }}"/>
        </agent>
    </agents>
    
    {% include 'preset_custom.xml' ignore missing %}
    
    {% for setd in test_plan.sets -%}
    <execution defaultAgent="DEFAULT_{{ test_plan['harness'] }}">        
        <initialization>
            {% include 'prestep_custom.xml' ignore missing %}
        
            {% if setd.image_files -%}
            <task>
                <type>FlashTask</type>
                <parameters>
                {% set i = 1 %}
                {% for img in atsself.get_sorted_images(setd) -%}
                    <parameter name="image-{{ i }}" value="ATS3Drop\images\{{ os.path.basename(img) }}" />
                    {% set i = i + 1 %}
                {% endfor -%}
                </parameters>
            </task>
            {% endif %}
            
            {% if setd["ctc_enabled"] == "True" -%}
            {{ macros.ctc_initialization() }}
            {% endif %}
            
            <task>
                <type>CreateDirTask</type>
                <parameters>                
                    <parameter value="{{ atsself.getlogdir(setd) }}" name="dir"/>
                </parameters>
            </task>
                      
          {% if setd.has_key("sis_files") and setd["sis_files"] -%}
              {% for sis_file in setd["sis_files"] -%}
            <task>
                <type>FileUploadTask</type>
                <parameters>
                    <parameter name="src" value="ATS3Drop\{{ setd.name }}\sis\{{ os.path.basename(sis_file) }}"/>
                    <parameter name="dst" value="c:\testframework\{{ os.path.basename(sis_file) }}"/>
                </parameters>
            </task>
              {% endfor -%}
          {% else %}
              {% if setd['src_dst'] != [] -%}
                {% for file in setd['src_dst'] -%}            
            <task>
                <type>FileUploadTask</type>
                <parameters>
                    <parameter value="ATS3Drop\{{ setd.name }}\{{ file[1].replace(":", "") }}" name="src"/>
                    <parameter value="{{ file[1] }}" name="dst"/>
                </parameters>
            </task>
                {% endfor -%}
              {% else %}
                  {% for data_file in setd["data_files"] -%}
            <task>
                <type>FileUploadTask</type>
                <parameters>
                    <parameter name="src" value="ATS3Drop\{{ setd.name }}\data\{{ os.path.basename(data_file) }}"/>
                    <parameter name="dst" value="e:\testing\data\{{ os.path.basename(data_file) }}"/>
                </parameters>
            </task>
                  {% endfor -%}
                  {% for data_file in setd["config_files"] -%}
            <task>
                <type>FileUploadTask</type>
                <parameters>
                    <parameter name="src" value="ATS3Drop\{{ setd.name }}\conf\{{ os.path.basename(data_file) }}"/>
                    <parameter name="dst" value="e:\testing\conf\{{ os.path.basename(data_file) }}"/>
                </parameters>
            </task>
                  {% endfor -%}
                  {% for data_file in setd["testmodule_files"] -%}
            <task>
                <type>FileUploadTask</type>
                <parameters>
                    <parameter name="src" value="ATS3Drop\{{ setd.name }}\testmodules\{{ os.path.basename(data_file) }}"/>
                    <parameter name="dst" value="c:\sys\bin\{{ os.path.basename(data_file) }}"/>
                </parameters>
            </task>
                  {% endfor -%}
              {% endif %}
          {% endif %}
          
          {% if setd.engine_ini_file -%}
              {% if (setd.has_key("sis_files") and setd["sis_files"]) or setd["src_dst"] == [] -%}
            <task>
                <type>FileUploadTask</type>
                <parameters>
                    <parameter name="src" value="ATS3Drop\{{ setd.name }}\init\{{ os.path.basename(setd["engine_ini_file"]) }}"/>
                    <parameter name="dst" value="c:\testframework\{{ os.path.basename(setd["engine_ini_file"]) }}"/>
                </parameters>
            </task>
              {% endif %}
          {% endif %}
          
          {% for sis_file in setd["sis_files"] -%}
            <task>
               <type>InstallSisTask</type>
               <parameters>
                    <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
                    <parameter name="upgrade-data " value="true"/>
                    <parameter name="ignore-ocsp-warnings" value="true"/>
                    <parameter name="ocsp-done" value="true"/>
                    <parameter name="software-package" value="c:\testframework\{{ os.path.basename(sis_file) }}"/>
               </parameters>
            </task>
          {% endfor -%}
        </initialization>    
        
        {% include 'prerun_custom.xml' ignore missing %}

        {% if setd['src_dst'] -%}
            {{ macros.generate_runsteps_stif(setd) }}
            
            {% for file in setd['src_dst'] -%}
                {% if setd["test_harness"] == "GENERIC" -%}
                    {% if 'testscript' in file[2] -%}
        <task>
            <type>TEFTask</type>
            <parameters>
                <parameter name="file" value="testexecute.exe"/>
                <parameter name="parameters" value="{{ file[1] }}"/>
                <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
                <parameter name="result-file" value="{{ atsself.TEF_LOG_DIR }}\{{ os.path.basename(file[1]).replace('.script', '.htm') }}"/>
            </parameters>
        </task>
                    {% endif %}
                    
                    {% if 'testmodule' in file[2] -%}
        <task>
            <type>ExecutableTestCaseTask</type>
            <parameters>
                <parameter name="file" value="{{ file[1] }}"/>
                <parameter name="parser" value="RTestResultParser" />
                <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
                <parameter name="result-file" value="{{ atsself.TEF_LOG_DIR }}\{{ os.path.basename(file[1]).replace('.exe', '.htm') }}"/>
            </parameters>
        </task>
                    {% endif %}
                {% endif %}
                {% if setd["test_harness"] == "EUNIT" -%}
                    {% if file[2] == "testmodule" -%}
        <task>
            <type>EUnitTask</type>
            <parameters>
                <parameter value="z:\sys\bin\EUNITEXERUNNER.EXE" name="file"/>
                <parameter name="result-file" value="{{ atsself.EUNIT_LOG_DIR }}\{{ atspath.basename(file[1]).replace('.' + file[1].rsplit(".")[1], '_log.xml') }}"/>
                <parameter name="parameters" value="{{ test_plan["eunitexerunner_flags"] }} /F {{ atspath.basename(file[1]).replace('.dll', '').replace('.exe', '') }} /l xml {{ atspath.basename(file[1]) }}"/>
                <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
            </parameters>
        </task>
                    {% endif %}
                    {% if file[2] == "testmodule:qt" -%}
        <task>
            <type>QTestTask</type>
            <parameters>
                <parameter name="file" value="{{ file[1] }}"/>                      
                <parameter name="parameters" value="-lightxml -o {{ atsself.QT_LOG_DIR }}\{{ os.path.basename(file[1]).replace('.' + file[1].rsplit(".")[1], '_log.xml') }}"/>
                <parameter name="result-file" value="{{ atsself.QT_LOG_DIR }}\{{ os.path.basename(file[1]).replace('.' + file[1].rsplit(".")[1], '_log.xml') }}"/>
                <parameter name="timeout" value="{{ test_plan["test_timeout"] }}"/>
            </parameters>
        </task>
                    {% endif %}
                {% endif %}
            {% endfor -%}
        {% else %}
            {{ macros.generate_runsteps_stif_single_set(setd) }}
        {% endif %}
        
        {% include 'postrun_custom.xml' ignore missing %}
        
        <finalization>
        {% if setd["ctc_enabled"] == "True" -%}
        {{ macros.ctc_finalization(setd) }}
        {% endif %}

            <task>
                <type>FileDownloadTask</type>
                <parameters>
                    <parameter value="{{ atsself.getlogdir(setd) }}\*" name="src"/>
                </parameters>
            </task>
        {% include 'poststep_custom.xml' ignore missing %}
        </finalization>
        
    </execution>    
    {% endfor -%}
    
    {% include 'postset_custom.xml' ignore missing %}
    
    <postActions>
        {% include 'prepostaction.xml' ignore missing %}
        {% for action_type, parameters in test_plan.post_actions -%}
            {% if action_type == 'RunProcessAction' %}
        <action>
            <type>{{ action_type }}</type>
            <parameters>
                {% for name, value in parameters -%}
                <parameter name="{{ name }}" value="{{ value }}"/>
                {% endfor -%}
            </parameters>
        </action>
            {% endif %}
        {% endfor -%}
        {% if test_plan['report_email'] -%}
        <action>
            <type>EmailAction</type>
            <parameters>
                <parameter value="Release testing" name="subject"/>
                <parameter value="{{ test_plan['report_email'] }}" name="to"/>
                <parameter value="simplelogger" name="format"/>
            </parameters>
        </action>
        {% endif %}
        {% if test_plan['diamonds_build_url'] -%}
        <action>
            <type>DiamondsAction</type>
        </action>
        {% endif %}
        {% include 'postpostaction.xml' ignore missing %}
    </postActions>
    
</testrun>
