79
|
1 |
/*
|
|
2 |
Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
|
|
3 |
|
|
4 |
Redistribution and use in source and binary forms, with or without
|
|
5 |
modification, are permitted provided that the following conditions are met:
|
|
6 |
|
|
7 |
* Redistributions of source code must retain the above copyright notice, this
|
|
8 |
list of conditions and the following disclaimer.
|
|
9 |
* Redistributions in binary form must reproduce the above copyright notice,
|
|
10 |
this list of conditions and the following disclaimer in the documentation
|
|
11 |
and/or other materials provided with the distribution.
|
|
12 |
* Neither the name of Nokia Corporation nor the names of its contributors
|
|
13 |
may be used to endorse or promote products derived from this software
|
|
14 |
without specific prior written permission.
|
|
15 |
|
|
16 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
17 |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
18 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
19 |
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
20 |
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
21 |
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
22 |
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
23 |
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
24 |
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
25 |
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26 |
|
|
27 |
* Description:
|
|
28 |
*
|
|
29 |
*/
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
#ifndef __RESULT_LOG_H__
|
|
34 |
#define __RESULT_LOG_H__
|
|
35 |
#include <sys/stat.h>
|
|
36 |
#include <sys/types.h>
|
|
37 |
|
|
38 |
#include <stdio.h>
|
|
39 |
#include <time.h>
|
|
40 |
#include <string.h>
|
|
41 |
#include <dirent.h>
|
|
42 |
|
|
43 |
|
|
44 |
#undef g_assert
|
|
45 |
#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
|
|
46 |
|
|
47 |
|
|
48 |
// This function is used to generate the xml file used bt ATS
|
|
49 |
void testResultXml(char *filename,int passed)
|
|
50 |
{
|
|
51 |
char time_buf[50];
|
|
52 |
|
|
53 |
char result[10];
|
|
54 |
|
|
55 |
char xmlfilename[256];
|
|
56 |
|
|
57 |
time_t t = time(NULL);
|
|
58 |
|
|
59 |
struct tm *tm1 = localtime(&t);
|
|
60 |
|
|
61 |
char *atsinitmsg = "<test-report>\n\t<test-batch>";
|
|
62 |
|
|
63 |
char *atsbatchinit1 = \
|
|
64 |
"\n\t\t<batch-init>\
|
|
65 |
\n\t\t\t<description></description>\
|
|
66 |
\n\t\t\t<date>";
|
|
67 |
|
|
68 |
char *atsbatchinit2 = "</date>\
|
|
69 |
\n\t\t\t<factory>NA</factory>\
|
|
70 |
\n\t\t\t<component>\
|
|
71 |
\n\t\t\t\t<name>NA</name>\
|
|
72 |
\n\t\t\t\t<version>NA</version>\
|
|
73 |
\n\t\t\t</component>\
|
|
74 |
\n\t\t</batch-init>";
|
|
75 |
|
|
76 |
char *atsbatchresult= \
|
|
77 |
"\n\t\t<batch-result>\
|
|
78 |
\n\t\t\t<run-time>00:00:00</run-time>\
|
|
79 |
\n\t\t</batch-result>";
|
|
80 |
|
|
81 |
char *atsclosemsg = \
|
|
82 |
"\n\t</test-batch>\
|
|
83 |
\n</test-report>\n ";
|
|
84 |
|
|
85 |
char *atstestinit = "\n\t\t<test-case time-stamp=\"00:00:00\">";
|
|
86 |
|
|
87 |
|
|
88 |
char *atscaseinit1 = \
|
|
89 |
"\n\t\t\t<case-init>\
|
|
90 |
\n\t\t\t\t<version></version>\
|
|
91 |
\n\t\t\t\t<id>";
|
|
92 |
|
|
93 |
char *atscaseinit2 = "</id>\
|
|
94 |
\n\t\t\t\t<expected-result description=\"\">0</expected-result>\
|
|
95 |
\n\t\t\t</case-init>";
|
|
96 |
|
|
97 |
char *atscaseresult1= \
|
|
98 |
"\n\t\t\t<case-result status=\"";
|
|
99 |
|
|
100 |
char *atscaseresult2= "\">\
|
|
101 |
\n\t\t\t\t<actual-result>0</actual-result>\
|
|
102 |
\n\t\t\t\t<run-time>00:00:00</run-time>\
|
|
103 |
\n\t\t\t</case-result>";
|
|
104 |
|
|
105 |
char *atstestclose = "\n\t\t</test-case>";
|
|
106 |
|
|
107 |
/* Check and see if spd_logs/xml is existent or not. If not present create it */
|
|
108 |
DIR *dir;
|
|
109 |
FILE *fp;
|
|
110 |
|
|
111 |
dir = opendir("c:\\spd_logs");
|
|
112 |
if(!dir)
|
|
113 |
mkdir("c:\\spd_logs",0777);
|
|
114 |
|
|
115 |
dir = opendir("c:\\spd_logs\\xml");
|
|
116 |
if(!dir)
|
|
117 |
mkdir("c:\\spd_logs\\xml",0777);
|
|
118 |
|
|
119 |
// create the xml file name
|
|
120 |
strcpy(xmlfilename,"c:\\spd_logs\\xml\\");
|
|
121 |
strcat(xmlfilename,filename);
|
|
122 |
strcat(xmlfilename,".xml");
|
|
123 |
|
|
124 |
strftime(time_buf,50,"%c",tm1);
|
|
125 |
|
|
126 |
if(passed != 0)
|
|
127 |
strcpy(result,"FAILED");
|
|
128 |
else
|
|
129 |
strcpy(result,"PASSED");
|
|
130 |
|
|
131 |
fp = fopen(xmlfilename,"w");
|
|
132 |
|
|
133 |
if(fp)
|
|
134 |
{
|
|
135 |
fprintf(fp,"%s%s%s%s%s%s%s%s%s%s%s%s%s%s",atsinitmsg,atsbatchinit1,time_buf,atsbatchinit2,atstestinit,
|
|
136 |
atscaseinit1,filename,atscaseinit2,atscaseresult1,result,atscaseresult2,
|
|
137 |
atstestclose,atsbatchresult,atsclosemsg);
|
|
138 |
|
|
139 |
fclose(fp);
|
|
140 |
}
|
|
141 |
else
|
|
142 |
{
|
|
143 |
}
|
|
144 |
}
|
|
145 |
|
|
146 |
#endif //__RESULT_LOG_H__
|