buildframework/helium/tools/common/python/lib/cpythontest/test_atsconfigparser.py
changeset 179 d8ac696cc51f
equal deleted inserted replaced
1:be27ed110b50 179:d8ac696cc51f
       
     1 #============================================================================ 
       
     2 #Name    : test_atsconfigparser.py
       
     3 #Part of     : Helium 
       
     4 
       
     5 #Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     6 #All rights reserved.
       
     7 #This component and the accompanying materials are made available
       
     8 #under the terms of the License "Eclipse Public License v1.0"
       
     9 #which accompanies this distribution, and is available
       
    10 #at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
    11 #
       
    12 #Initial Contributors:
       
    13 #Nokia Corporation - initial contribution.
       
    14 #
       
    15 #Contributors:
       
    16 #
       
    17 #Description:
       
    18 #===============================================================================
       
    19 
       
    20 """ Testing the ATS configuration file """
       
    21 
       
    22 import os
       
    23 import logging
       
    24 import tempfile
       
    25 import unittest
       
    26 
       
    27 import ats3.atsconfigparser
       
    28 
       
    29 _logger = logging.getLogger('test.atsconfigparser')
       
    30 logging.basicConfig(level=logging.INFO)
       
    31 
       
    32 class AtsConfigParserTest(unittest.TestCase):
       
    33       
       
    34     def test_x(self):
       
    35         spectext = """<ATSConfigData>
       
    36     <config name="common" abstract="true">
       
    37 
       
    38         <!-- Properties to add/modify -->
       
    39         <config type="properties">
       
    40            <set name="HARNESS" value="STIFx" />
       
    41            <set name="HARNESS2" value="STIF2"/>
       
    42            <set name="HARNESS3" value="STIF2"/>
       
    43            <set name="2" value="3" />
       
    44         </config>
       
    45 
       
    46         <!-- Attributes to modify -->
       
    47         <config type="attributes">
       
    48            <set name="xyz" value="2" />
       
    49            <set name="significant" value="true" />
       
    50         </config>
       
    51 
       
    52         <!-- Settings to add/modify -->
       
    53         <config type="settings">
       
    54            <set name="HARNESS" value="STIF" />
       
    55            <set name="2" value="3" />
       
    56         </config>
       
    57 
       
    58     </config>
       
    59 </ATSConfigData>
       
    60         """
       
    61 
       
    62         testxmldata = """<test>
       
    63   <name>helium_clock</name>
       
    64   <target>
       
    65     <device alias="DEFAULT_STIF" rank="none">
       
    66       <property name="HARNESS" value="STIF"/>
       
    67       <property name="HARNESS2" value="STIF"/>
       
    68       <property name="HARNESS3" value="STIF"/>
       
    69     </device>
       
    70     <device alias="DEFAULT_EUIT" rank="none">
       
    71       <property name="HARNESS" value="STIF"/>
       
    72       <property name="HARNESS2" value="STIF3"/>
       
    73     </device>
       
    74   </target>
       
    75   <plan passrate="100" harness="STIF" enabled="true" name="helium_clock Plan" significant="false">
       
    76     <session passrate="100" harness="STIF" enabled="true" name="session" significant="false">
       
    77       <set passrate="100" harness="STIF" enabled="true" name="set0" significant="false">
       
    78         <target>
       
    79           <device alias="DEFAULT_STIF" rank="master"/>
       
    80         </target>
       
    81       </set>
       
    82     </session>
       
    83   </plan>
       
    84 </test>
       
    85         """
       
    86         
       
    87         (fd, filename) = tempfile.mkstemp()
       
    88         f = os.fdopen(fd, 'w')
       
    89         f.write(spectext)
       
    90         f.close()
       
    91         
       
    92         output = ats3.atsconfigparser.converttestxml(filename, testxmldata)
       
    93         os.remove(filename)
       
    94         _logger.info(output)
       
    95         assert '<property name="2" value="3"/>' in output
       
    96         assert '<property name="HARNESS" value="STIFx"/>' in output
       
    97         assert '<property name="HARNESS" value="STIF"/>' not in output
       
    98         assert '<property name="HARNESS2" value="STIF2"/>' in output
       
    99         assert '<property name="HARNESS2" value="STIF3"/>' not in output
       
   100         assert '<property name="HARNESS3" value="STIF2"/>' in output
       
   101