Update contrib.
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
25 #ifndef __G_LOG_MRT2_GLIB2_TEST
26 #define __G_LOG_MRT2_GLIB2_TEST
33 gboolean assert_failed = FALSE;
36 #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
39 void mrtLogHandler(const gchar* log_domain, GLogLevelFlags log_level,
40 const gchar* message, gpointer user_data)
43 fp = fopen("c:\\logtests.txt","a");
53 void mrtPrintHandler(const gchar *message)
56 fp = fopen("c:\\logtests.txt","a");
67 // This function is used to generate the xml file used bt ATS
68 void testResultXml(char *filename)
74 char xmlfilename[256];
76 time_t t = time(NULL);
78 struct tm *tm1 = localtime(&t);
80 char *atsinitmsg = "<test-report>\n\t<test-batch>";
82 char *atsbatchinit1 = \
84 \n\t\t\t<description></description>\
87 char *atsbatchinit2 = "</date>\
88 \n\t\t\t<factory>NA</factory>\
90 \n\t\t\t\t<name>NA</name>\
91 \n\t\t\t\t<version>NA</version>\
95 char *atsbatchresult= \
96 "\n\t\t<batch-result>\
97 \n\t\t\t<run-time>00:00:00</run-time>\
98 \n\t\t</batch-result>";
100 char *atsclosemsg = \
102 \n</test-report>\n ";
104 char *atstestinit = "\n\t\t<test-case time-stamp=\"00:00:00\">";
107 char *atscaseinit1 = \
108 "\n\t\t\t<case-init>\
109 \n\t\t\t\t<version></version>\
112 char *atscaseinit2 = "</id>\
113 \n\t\t\t\t<expected-result description=\"\">0</expected-result>\
114 \n\t\t\t</case-init>";
116 char *atscaseresult1= \
117 "\n\t\t\t<case-result status=\"";
119 char *atscaseresult2= "\">\
120 \n\t\t\t\t<actual-result>0</actual-result>\
121 \n\t\t\t\t<run-time>00:00:00</run-time>\
122 \n\t\t\t</case-result>";
124 char *atstestclose = "\n\t\t</test-case>";
126 /* Check and see if spd_logs/xml is existent or not. If not present create it */
130 dir = opendir("c:\\spd_logs");
132 mkdir("c:\\spd_logs",0777);
134 dir = opendir("c:\\spd_logs\\xml");
136 mkdir("c:\\spd_logs\\xml",0777);
138 // create the xml file name
139 strcpy(xmlfilename,"c:/spd_logs/xml/");
140 strcat(xmlfilename,filename);
141 strcat(xmlfilename,".xml");
143 strftime(time_buf,50,"%c",tm1);
146 strcpy(result,"FAILED");
148 strcpy(result,"PASSED");
150 fp = fopen(xmlfilename,"w");
154 fprintf(fp,"%s%s%s%s%s%s%s%s%s%s%s%s%s%s",atsinitmsg,atsbatchinit1,time_buf,atsbatchinit2,atstestinit,
155 atscaseinit1,filename,atscaseinit2,atscaseresult1,result,atscaseresult2,
156 atstestclose,atsbatchresult,atsclosemsg);
162 g_assert(FALSE && "Failed to create the xml file");