diff -r 000000000000 -r bde4ae8d615e os/ossrv/glib/tsrc/BC/inc/mrt2_glib2_test.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os/ossrv/glib/tsrc/BC/inc/mrt2_glib2_test.h Fri Jun 15 03:10:57 2012 +0200 @@ -0,0 +1,166 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved. +* +* This library is free software; you can redistribute it and/or +* modify it under the terms of the GNU Lesser General Public +* License as published by the Free Software Foundation; either +* version 2 of the License, or (at your option) any later version. +* +* This library is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public +* License along with this library; if not, write to the +* Free Software Foundation, Inc., 59 Temple Place - Suite 330, +* Boston, MA 02111-1307, USA. +* +* Description: +* +*/ + + + +#ifndef __G_LOG_MRT2_GLIB2_TEST +#define __G_LOG_MRT2_GLIB2_TEST +#include +#include +#include +#include +#include + +gboolean assert_failed = FALSE; + +#undef g_assert +#define g_assert(expr) G_STMT_START{ if (expr) { } else {g_log (G_LOG_DOMAIN,G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, "file %s: line %d: assertion failed: (%s)", __FILE__, __LINE__, #expr);assert_failed = TRUE; }}G_STMT_END + + +void mrtLogHandler(const gchar* log_domain, GLogLevelFlags log_level, + const gchar* message, gpointer user_data) +{ + FILE *fp; + fp = fopen("c:\\logtests.txt","a"); + + if(fp) + { + fprintf(fp,message); + fprintf(fp,"\n"); + fclose(fp); + } +} + +void mrtPrintHandler(const gchar *message) +{ + FILE *fp; + fp = fopen("c:\\logtests.txt","a"); + + if(fp) + { + fprintf(fp,message); + fprintf(fp,"\n"); + 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"; + + /* Check and see if spd_logs/xml is existent or not. If not present create it */ + DIR *dir; + FILE *fp; + + dir = opendir("c:\\spd_logs"); + if(!dir) + mkdir("c:\\spd_logs",0777); + + dir = opendir("c:\\spd_logs\\xml"); + if(!dir) + mkdir("c:\\spd_logs\\xml",0777); + + // create the xml file name + strcpy(xmlfilename,"c:/spd_logs/xml/"); + strcat(xmlfilename,filename); + strcat(xmlfilename,".xml"); + + strftime(time_buf,50,"%c",tm1); + + if(assert_failed ) + strcpy(result,"FAILED"); + else + strcpy(result,"PASSED"); + + fp = fopen(xmlfilename,"w"); + + if(fp) + { + fprintf(fp,"%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); + } + else + { + g_assert(FALSE && "Failed to create the xml file"); + } +} + +#endif