diff -r 6c1a2771f4b7 -r ae3f1779f6da searchengine/cpix/tsrc/cpixunittest/src/std_log_result.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/searchengine/cpix/tsrc/cpixunittest/src/std_log_result.cpp Thu May 27 13:59:44 2010 +0300 @@ -0,0 +1,144 @@ +/* +* 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 "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: +* +*/ +#include "std_log_result.h" +#ifdef __SYMBIAN32__ +#define LOG_FILE "c:\\logs\\std_test_log.txt" +#define LOG_DIR "c:\\logs\\" +#define LOG_FILE_EXT "xml" +int assert_failed = 0; +#else +#define LOG_DIR "" +#define LOG_FILE_EXT "xml" +#define LOG_FILE "std_test_log.txt" +int assert_failed = 0; +#endif +FILE *fp; + +int gnutest = 1; + +# define VERIFY(fn) gnutest &= (fn) + +void std_log(const char *filename,const int lineno,const char* aformat,...) +{ + va_list va; + if(fp==NULL) + { + fp = fopen(LOG_FILE,"a"); + } + + va_start(va,aformat); + { + fprintf(fp,"%s - [%d] : ",filename,lineno); + vfprintf(fp,aformat,va); + fprintf(fp,"\n"); + } + va_end(va); +} + + +void init_log_file() +{ + if(fp == NULL) + { + fp = fopen(LOG_FILE, "a"); + } +} + +void close_log_file() +{ + fclose(fp); +} + +// This function is used to generate the xml file used bt ATS +void testResultXml(char *filename) +{ + char time_buf[50]; + + char result[10]; + + char xmlfilename[256]; + + time_t t = time(NULL); + + struct tm *tm1 = localtime(&t); + + char *atsinitmsg = "\n\t"; + + char *atsbatchinit1 = \ + "\n\t\t\ + \n\t\t\t\ + \n\t\t\t"; + char *atsbatchinit2 = "\ + \n\t\t\tNA\ + \n\t\t\t\ + \n\t\t\t\tNA\ + \n\t\t\t\tNA\ + \n\t\t\t\ + \n\t\t"; + + char *atsbatchresult= \ + "\n\t\t\ + \n\t\t\t00:00:00\ + \n\t\t"; + + char *atsclosemsg = \ + "\n\t\ + \n\n "; + + char *atstestinit = "\n\t\t"; + + + char *atscaseinit1 = \ + "\n\t\t\t\ + \n\t\t\t\t\ + \n\t\t\t\t"; + + char *atscaseinit2 = "\ + \n\t\t\t\t0\ + \n\t\t\t"; + + char *atscaseresult1= \ + "\n\t\t\t\ + \n\t\t\t\t0\ + \n\t\t\t\t00:00:00\ + \n\t\t\t"; + + char *atstestclose = "\n\t\t"; + + // create the xml file name + FILE *fp_result; + sprintf(xmlfilename, "%s%s.%s", LOG_DIR, filename, LOG_FILE_EXT); + strftime(time_buf,50,"%c",tm1); + + if(assert_failed ) + strcpy(result,"FAILED"); + else + strcpy(result,"PASSED"); + + fp_result = fopen(xmlfilename,"w"); + + if(fp_result) + { + fprintf(fp_result,"%s%s%s%s%s%s%s%s%s%s%s%s%s%s",atsinitmsg,atsbatchinit1,time_buf,atsbatchinit2,atstestinit, + atscaseinit1,filename,atscaseinit2,atscaseresult1,result,atscaseresult2, + atstestclose,atsbatchresult,atsclosemsg); + + fclose(fp_result); + } +}