buildframework/helium/tools/common/test/test_logging.ant.xml
author wbernard
Wed, 23 Dec 2009 19:29:07 +0200
changeset 179 d8ac696cc51f
parent 1 be27ed110b50
permissions -rw-r--r--
helium_7.0-r14027

<?xml version="1.0" encoding="UTF-8"?>
<!-- 
============================================================================ 
Name        : test_logging.ant.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:

============================================================================
-->
<project name="test_logging" xmlns:au="org.apache.ant.antunit" xmlns:hlm="http://www.nokia.com/helium">
    <description>
        Logging testing targets
    </description>
    <property environment="env"/>
    
    <property name="helium.dir" location="../../.." />
    <property name="build.drive" location="${env.TEMP}/helium/temp_drive"/>
    <import file="../../../helium.ant.xml"/>
    
    
    <target name="test-logrecord">
        <hlm:logrecord name="logrecord_test.log" action="start" loglevel="verbose" emacsmode="true"/>
        <echo>Some logrecord test output.</echo>
        <hlm:logrecord name="logrecord_test.log" action="stop"/>
        <delete file="logrecord_test.log"/>
    </target>
    
    
    <target name="test-logrecord-filtering">
        <hlm:logrecord name="${env.TEMP}/logrecord_test.log" action="start" regexp="badtext"/>
        <echo>Some sensitive test output badtext</echo>
        <hlm:logrecord name="${env.TEMP}/logrecord_test.log" action="stop"/>
        <loadfile srcfile="${env.TEMP}/logrecord_test.log" property="logrecord.test.file"/>
        <au:assertTrue>
            <contains string="${logrecord.test.file}" substring="Some sensitive test output ******"/>
        </au:assertTrue>
        <delete file="${env.TEMP}/logrecord_test.log"/>
    </target>
    
    <target name="test-logrecord-filtering-regexp">
        <hlm:logrecord name="${env.TEMP}/logrecord_regexp_test.log" action="start" regexp="bad(text"/>
        <echo>Some sensitive test output. fubar and bad(text</echo>
        <hlm:logrecord name="${env.TEMP}/logrecord_regexp_test.log" action="stop"/>
        <loadfile srcfile="${env.TEMP}/logrecord_regexp_test.log" property="logrecord.test.regexp.file1"/>
        <au:assertTrue>
            <contains string="${logrecord.test.regexp.file1}" substring="Some sensitive test output. fubar and ********"/>
        </au:assertTrue>
        <delete file="${env.TEMP}/logrecord_regexp_test.log"/>
        
        <hlm:logrecord name="${env.TEMP}/logrecord_regexp_test.log" action="start" regexp="bad[text"/>
        <echo>Some sensitive test output. fubar and bad[text</echo>
        <hlm:logrecord name="${env.TEMP}/logrecord_regexp_test.log" action="stop"/>
        <loadfile srcfile="${env.TEMP}/logrecord_regexp_test.log" property="logrecord.test.regexp.file2"/>
        <au:assertTrue>
            <contains string="${logrecord.test.regexp.file2}" substring="Some sensitive test output. fubar and ********"/>
        </au:assertTrue>
        <delete file="${env.TEMP}/logrecord_regexp_test.log"/>
        
        <hlm:logrecord name="${env.TEMP}/logrecord_regexp_test.log" action="start" regexp="(ba[dt]ex)t"/>
        <echo>Some sensitive test output. fubar and (ba[dt]ex)t</echo>
        <hlm:logrecord name="${env.TEMP}/logrecord_regexp_test.log" action="stop"/>
        <loadfile srcfile="${env.TEMP}/logrecord_regexp_test.log" property="logrecord.test.regexp.file3"/>
        <au:assertTrue>
            <contains string="${logrecord.test.regexp.file3}" substring="Some sensitive test output. fubar and ********"/>
        </au:assertTrue>
        <delete file="${env.TEMP}/logrecord_regexp_test.log"/>
        
    </target>
    
    <!--<target name="test-logextract">
        <hlm:logextract file="${helium.dir}/tests/data/logs/test_log.log"/>
        <xmltask source="${helium.dir}/tests/data/logs/test_log.log2.xml">
            <copy path="count(/log/build/message)" property="message.total"/>
        </xmltask>
        <assertPropertyEquals name="message.total" value="2"/>
        <delete file="${helium.dir}/tests/data/logs/test_log.log2.xml"/>
    </target>-->

  
    <target name="test-specificlogmacro-create">
        <!--Record something-->
        <hlm:startSpecificLogMacro name="${env.TEMP}/record_test.log" phase="test"/>         
        <echo>astalavista</echo>
        <hlm:stopSpecificLogMacro name="${env.TEMP}/record_test.log" phase="test"/>         
        
        <!-- Assert if the file doesn't exists-->
        <au:assertFileExists file="${env.TEMP}/record_test.log"/>
        
        <!--Match the file content-->        
        <loadfile property="file.message" srcFile="${env.TEMP}/record_test.log"/>               
        <au:assertTrue message="Failed to match content!!">
            <equals arg1="${file.message}" arg2="[echo] astalavista" trim="true"/>          
        </au:assertTrue>        
        <delete file="${env.TEMP}/record_test.log"/>        
    </target>
    
   <!-- Commenting, as hlm:record is not yet has the feature of back up Raghu--> 
 <!--   <target name="test-specificlogmacro-backup">
        <touch file="${env.TEMP}/backup_test.log"/>        
        <echo file="${env.TEMP}/backup_test.log">childhood memory</echo>
        <hlm:startSpecificLogMacro name="${env.TEMP}/backup_test.log" backup="true" phase="test"/>         
        <echo>Now a days</echo>        
        <hlm:stopSpecificLogMacro name="${env.TEMP}/backup_test.log" phase="test"/>     -->                                       
        
        <!--Match the backup file content-->        
    <!--    <loadfile property="backup.message" srcFile="${backup.file.name}"/>        
        <au:assertTrue message="Failed to match content!!">
            <equals arg1="${backup.message}" arg2="childhood memory" trim="true"/>          
        </au:assertTrue>-->
        
        <!--Match the current file content-->        
     <!--   <loadfile property="current.message" srcFile="${env.TEMP}/backup_test.log"/>               
        <au:assertTrue message="Failed to match content!!">
            <equals arg1="${current.message}" arg2="[echo] Now a days" trim="true"/>          
        </au:assertTrue>
        
        <delete file="${env.TEMP}/backup_test.log"/>
        <delete file="${backup.file.name}"/>                
        
    </target>
    <target name="test-log4j-log-file">                
        <au:assertFileExists file="${log4j.cache.dir}/hlm_debug.log" />        
        <au:assertFileDoesntExist file="hlm_debug.log" />
    </target>-->
    
     <!-- Check the build-property-cache-file exists or not -->
    <target name="test-build-property-cache-file-exists">
        <antcall target="diamonds"/>
        <au:assertFileExists file="${build.property.cache.file}" />
    </target>
    
    <!-- Check the build-property-cache-file contents-->
    <target name="test-build-property-cache-file-content">
        <antcall target="diamonds"/>
        <loadfile property="test.data" srcFile="${build.property.cache.file}"/>
        <au:assertMatches string="${test.data}" pattern="diamonds.build.url" />
    </target>
    
    
</project>