sl@0: /* sl@0: * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: * All rights reserved. sl@0: * This component and the accompanying materials are made available sl@0: * under the terms of "Eclipse Public License v1.0" sl@0: * which accompanies this distribution, and is available sl@0: * at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: * sl@0: * Initial Contributors: sl@0: * Nokia Corporation - initial contribution. sl@0: * sl@0: * Contributors: sl@0: * sl@0: * Description: sl@0: * sl@0: */ sl@0: /*This material, including documentation and any related sl@0: :* computer programs, is protected by copyright controlled by sl@0: * Nokia Corporation. All rights are reserved. Copying, sl@0: * including reproducing, storing, adapting or translating, any sl@0: * or all of this material requires the prior written consent of sl@0: * Nokia Corporation. This material also contains confidential sl@0: * information which may not be disclosed to others without the sl@0: * prior written consent of Nokia Corporation. sl@0: * ============================================================================ sl@0: */ sl@0: sl@0: sl@0: #ifndef _STD_LOG_FILE_H__ sl@0: #define _STD_LOG_FILE_H__ sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #ifdef __SYMBIAN32__ sl@0: #define LOG_FILE "c:\\logs\\std_test_log.txt" sl@0: #define LOG_DIR "c:\\logs\\" sl@0: #define LOG_FILE_EXT "xml" sl@0: bool assert_failed = false; sl@0: #else sl@0: #define LOG_DIR "" sl@0: #define LOG_FILE_EXT "xml" sl@0: #define LOG_FILE "std_test_log.txt" sl@0: bool assert_failed = false; sl@0: #endif sl@0: FILE *fp; sl@0: sl@0: bool gnutest = true; sl@0: sl@0: # define VERIFY(fn) gnutest &= (fn) sl@0: sl@0: sl@0: void std_log(const char *filename,const int lineno,const char* aformat,...) sl@0: { sl@0: if(fp==NULL) sl@0: { sl@0: fp = fopen(LOG_FILE,"a"); sl@0: } sl@0: va_list va; sl@0: va_start(va,aformat); sl@0: { sl@0: fprintf(fp,"%s - [%d] : ",filename,lineno); sl@0: vfprintf(fp,aformat,va); sl@0: fprintf(fp,"\n"); sl@0: } sl@0: va_end(va); sl@0: } sl@0: sl@0: sl@0: void init_log_file() sl@0: { sl@0: if(fp == NULL) sl@0: { sl@0: fp = fopen(LOG_FILE, "a"); sl@0: } sl@0: } sl@0: sl@0: void close_log_file() sl@0: { sl@0: fclose(fp); sl@0: } sl@0: sl@0: // This function is used to generate the xml file used bt ATS sl@0: void testResultXml(char *filename) sl@0: { sl@0: char time_buf[50]; sl@0: sl@0: char result[10]; sl@0: sl@0: char xmlfilename[256]; sl@0: sl@0: time_t t = time(NULL); sl@0: sl@0: struct tm *tm1 = localtime(&t); sl@0: sl@0: char *atsinitmsg = "\n\t"; sl@0: sl@0: char *atsbatchinit1 = \ sl@0: "\n\t\t\ sl@0: \n\t\t\t\ sl@0: \n\t\t\t"; sl@0: char *atsbatchinit2 = "\ sl@0: \n\t\t\tNA\ sl@0: \n\t\t\t\ sl@0: \n\t\t\t\tNA\ sl@0: \n\t\t\t\tNA\ sl@0: \n\t\t\t\ sl@0: \n\t\t"; sl@0: sl@0: char *atsbatchresult= \ sl@0: "\n\t\t\ sl@0: \n\t\t\t00:00:00\ sl@0: \n\t\t"; sl@0: sl@0: char *atsclosemsg = \ sl@0: "\n\t\ sl@0: \n\n "; sl@0: sl@0: char *atstestinit = "\n\t\t"; sl@0: sl@0: sl@0: char *atscaseinit1 = \ sl@0: "\n\t\t\t\ sl@0: \n\t\t\t\t\ sl@0: \n\t\t\t\t"; sl@0: sl@0: char *atscaseinit2 = "\ sl@0: \n\t\t\t\t0\ sl@0: \n\t\t\t"; sl@0: sl@0: char *atscaseresult1= \ sl@0: "\n\t\t\t\ sl@0: \n\t\t\t\t0\ sl@0: \n\t\t\t\t00:00:00\ sl@0: \n\t\t\t"; sl@0: sl@0: char *atstestclose = "\n\t\t"; sl@0: sl@0: // create the xml file name sl@0: FILE *fp_result; sl@0: sprintf(xmlfilename, "%s%s.%s", LOG_DIR, filename, LOG_FILE_EXT); sl@0: strftime(time_buf,50,"%c",tm1); sl@0: sl@0: if(assert_failed ) sl@0: strcpy(result,"FAILED"); sl@0: else sl@0: strcpy(result,"PASSED"); sl@0: sl@0: fp_result = fopen(xmlfilename,"w"); sl@0: sl@0: if(fp_result) sl@0: { sl@0: fprintf(fp_result,"%s%s%s%s%s%s%s%s%s%s%s%s%s%s",atsinitmsg,atsbatchinit1,time_buf,atsbatchinit2,atstestinit, sl@0: atscaseinit1,filename,atscaseinit2,atscaseresult1,result,atscaseresult2, sl@0: atstestclose,atsbatchresult,atsclosemsg); sl@0: sl@0: fclose(fp_result); sl@0: } sl@0: } sl@0: sl@0: #endif sl@0: