os/ossrv/genericopenlibs/liboil/tsrc/inc/std_log_result.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/genericopenlibs/liboil/tsrc/inc/std_log_result.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,158 @@
     1.4 +/*
     1.5 +* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +* All rights reserved.
     1.7 +* This component and the accompanying materials are made available
     1.8 +* under the terms of "Eclipse Public License v1.0"
     1.9 +* which accompanies this distribution, and is available
    1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +*
    1.12 +* Initial Contributors:
    1.13 +* Nokia Corporation - initial contribution.
    1.14 +*
    1.15 +* Contributors:
    1.16 +*
    1.17 +* Description: 
    1.18 +*
    1.19 +*/
    1.20 +
    1.21 +
    1.22 +
    1.23 +#ifndef _STD_LOG_FILE_H__
    1.24 +#define _STD_LOG_FILE_H__
    1.25 +
    1.26 +#include <stdio.h>
    1.27 +#include <time.h>
    1.28 +#include <string.h>
    1.29 +#include <stdarg.h>
    1.30 +#ifdef __SYMBIAN32__
    1.31 +//#define LOG_FILE "c:\\logs\\std_test_log.txt"
    1.32 +#define LOG_DIR "c:\\logs\\"
    1.33 +#define LOG_FILE_EXT "xml"
    1.34 +int assert_failed = 0;
    1.35 +#else
    1.36 +#define LOG_DIR ""
    1.37 +#define LOG_FILE_EXT "xml"
    1.38 +#define LOG_FILE "std_test_log.txt"
    1.39 +int assert_failed = 0;
    1.40 +#endif
    1.41 +FILE *fp;
    1.42 +
    1.43 +int gnutest = 1;
    1.44 +
    1.45 +# define VERIFY(fn) gnutest &= (fn)
    1.46 +
    1.47 +
    1.48 +void std_log(const char *filename,const int lineno,const char* aformat,...)
    1.49 +{
    1.50 +	va_list va;
    1.51 +	if(fp==NULL)
    1.52 +	{
    1.53 +		fp = fopen(LOG_FILE,"a");
    1.54 +	}
    1.55 +	
    1.56 +	va_start(va,aformat);    
    1.57 +    {
    1.58 +		fprintf(fp,"%s - [%d] : ",filename,lineno);
    1.59 +		vfprintf(fp,aformat,va);
    1.60 +		fprintf(fp,"\n");
    1.61 +	}
    1.62 +	va_end(va);
    1.63 +	fflush(fp);
    1.64 +}
    1.65 +
    1.66 +
    1.67 +void init_log_file()
    1.68 +{
    1.69 +	if(fp == NULL)
    1.70 +	{
    1.71 +		fp = fopen(LOG_FILE, "a");
    1.72 +	}
    1.73 +}
    1.74 +
    1.75 +void close_log_file()
    1.76 +{
    1.77 +   fclose(fp);
    1.78 +}
    1.79 +
    1.80 +// This function is used to generate the xml file used bt ATS
    1.81 +void testResultXml(char *filename)
    1.82 +{
    1.83 +	char time_buf[50];
    1.84 +
    1.85 +	char result[10];
    1.86 +
    1.87 +	char xmlfilename[256];
    1.88 +
    1.89 +	time_t t = time(NULL);
    1.90 +
    1.91 +	struct tm *tm1 = localtime(&t);
    1.92 +
    1.93 +	char *atsinitmsg        =   "<test-report>\n\t<test-batch>";
    1.94 +
    1.95 +	char *atsbatchinit1     =   \
    1.96 +								"\n\t\t<batch-init>\
    1.97 +								\n\t\t\t<description></description>\
    1.98 +								\n\t\t\t<date>";
    1.99 +	char *atsbatchinit2 =   "</date>\
   1.100 +							 \n\t\t\t<factory>NA</factory>\
   1.101 +							 \n\t\t\t<component>\
   1.102 +							 \n\t\t\t\t<name>NA</name>\
   1.103 +							 \n\t\t\t\t<version>NA</version>\
   1.104 +							 \n\t\t\t</component>\
   1.105 +							 \n\t\t</batch-init>";
   1.106 +
   1.107 +	char *atsbatchresult=   \
   1.108 +							"\n\t\t<batch-result>\
   1.109 +							\n\t\t\t<run-time>00:00:00</run-time>\
   1.110 +							\n\t\t</batch-result>";
   1.111 +
   1.112 +	char *atsclosemsg       =   \
   1.113 +								"\n\t</test-batch>\
   1.114 +								\n</test-report>\n ";
   1.115 +
   1.116 +	char *atstestinit       =       "\n\t\t<test-case time-stamp=\"00:00:00\">";
   1.117 +
   1.118 +
   1.119 +	char *atscaseinit1      =       \
   1.120 +									"\n\t\t\t<case-init>\
   1.121 +									\n\t\t\t\t<version></version>\
   1.122 +									\n\t\t\t\t<id>";
   1.123 +
   1.124 +	char *atscaseinit2 =    "</id>\
   1.125 +							 \n\t\t\t\t<expected-result description=\"\">0</expected-result>\
   1.126 +							 \n\t\t\t</case-init>";
   1.127 +
   1.128 +	char *atscaseresult1=   \
   1.129 +							"\n\t\t\t<case-result status=\"";
   1.130 +
   1.131 +	char *atscaseresult2=   "\">\
   1.132 +							 \n\t\t\t\t<actual-result>0</actual-result>\
   1.133 +							 \n\t\t\t\t<run-time>00:00:00</run-time>\
   1.134 +							 \n\t\t\t</case-result>";
   1.135 +
   1.136 +	char *atstestclose      =       "\n\t\t</test-case>";
   1.137 +
   1.138 +	// create the xml file name
   1.139 +	FILE *fp_result;
   1.140 +	sprintf(xmlfilename, "%s%s.%s", LOG_DIR, filename, LOG_FILE_EXT);
   1.141 +	strftime(time_buf,50,"%c",tm1);
   1.142 +
   1.143 +	if(assert_failed )
   1.144 +		strcpy(result,"FAILED");
   1.145 +	else
   1.146 +		strcpy(result,"PASSED");
   1.147 +
   1.148 +	fp_result = fopen(xmlfilename,"w");
   1.149 +
   1.150 +	if(fp_result)
   1.151 +	{
   1.152 +		fprintf(fp_result,"%s%s%s%s%s%s%s%s%s%s%s%s%s%s",atsinitmsg,atsbatchinit1,time_buf,atsbatchinit2,atstestinit,
   1.153 +				atscaseinit1,filename,atscaseinit2,atscaseresult1,result,atscaseresult2,
   1.154 +				atstestclose,atsbatchresult,atsclosemsg);
   1.155 +
   1.156 +		fclose(fp_result);
   1.157 +	}
   1.158 +}
   1.159 +
   1.160 +#endif
   1.161 +