41
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
import static org.junit.Assert.fail;
|
|
19 |
|
|
20 |
import java.io.File;
|
|
21 |
import java.io.IOException;
|
|
22 |
import java.io.InputStream;
|
|
23 |
|
|
24 |
import org.junit.BeforeClass;
|
|
25 |
import org.junit.Test;
|
|
26 |
|
|
27 |
|
|
28 |
public class TracesInHeadersTest {
|
|
29 |
|
|
30 |
public static void main(String args[]) {
|
|
31 |
org.junit.runner.JUnitCore.main(TracesInHeadersTest.class.getName());
|
|
32 |
}
|
|
33 |
/****************************************************UTILITY FUNCTIONS FOR TESTS************************************************************/
|
|
34 |
|
|
35 |
private static String epocroot = null;
|
|
36 |
private static String projectdir = "testdata\\TracesInHeadersApps\\"; //$NON-NLS-1$
|
|
37 |
private static File compilerpath;
|
|
38 |
private static ProcessBuilder sbs_build = new ProcessBuilder("sbs.bat","-k","-c","winscw_udeb.tracecompiler");
|
|
39 |
private static ProcessBuilder sbs_reallyclean = new ProcessBuilder("sbs.bat","-k","-c","winscw_udeb.tracecompiler", "reallyclean");
|
|
40 |
|
|
41 |
@BeforeClass
|
|
42 |
static public void setEnvVariables() {
|
|
43 |
epocroot = System.getenv("EPOCROOT"); //$NON-NLS-1$
|
|
44 |
if(epocroot == null || (epocroot.length()==0)){
|
|
45 |
fail();
|
|
46 |
}
|
|
47 |
|
|
48 |
// need to check that the path ends in a backslash
|
|
49 |
if(!epocroot.endsWith("\\")){
|
|
50 |
epocroot += "\\";
|
|
51 |
}
|
|
52 |
}
|
|
53 |
|
|
54 |
|
|
55 |
/**
|
|
56 |
* This function invokes raptor on the desired test c++ project
|
|
57 |
*
|
|
58 |
* @param path String specifying the path the compiler needs
|
|
59 |
* to run from
|
|
60 |
*/
|
|
61 |
public void InvokeCompiler(String path, String builder) {
|
|
62 |
System.out.println ("InvokeCompiler() for : " + builder);
|
|
63 |
|
|
64 |
try{
|
|
65 |
|
|
66 |
//set up the directory from which the process will be called
|
|
67 |
if (path.compareTo("_diffnames")==0){ //$NON-NLS-1$
|
|
68 |
|
|
69 |
compilerpath = new File (epocroot+projectdir+"singlemmp_diffnames\\group\\"); //$NON-NLS-1$
|
|
70 |
} else if (path.compareTo("_samenames")==0){ //$NON-NLS-1$
|
|
71 |
|
|
72 |
compilerpath = new File (epocroot+projectdir+"singlemmp_samenames\\group\\"); //$NON-NLS-1$
|
|
73 |
} else if (path.compareTo("_diffnames_tracesplus")==0){ //$NON-NLS-1$
|
|
74 |
|
|
75 |
compilerpath = new File (epocroot+projectdir+"singlemmp_diffnames_tracesplus\\group\\"); //$NON-NLS-1$
|
|
76 |
} else if (path.compareTo("_samenames_tracesplus")==0){ //$NON-NLS-1$
|
|
77 |
|
|
78 |
compilerpath = new File (epocroot+projectdir+"singlemmp_samenames_tracesplus\\group\\"); //$NON-NLS-1$
|
|
79 |
} else if (path.compareTo("_samenames")==0){ //$NON-NLS-1$
|
|
80 |
|
|
81 |
compilerpath = new File (epocroot+projectdir+"singlemmp_samenames\\group\\"); //$NON-NLS-1$
|
|
82 |
} else if (path.compareTo("_separate_source")==0){ //$NON-NLS-1$
|
|
83 |
|
|
84 |
compilerpath = new File (epocroot+projectdir+"multmmp_separate_source\\group\\"); //$NON-NLS-1$
|
|
85 |
} else if (path.compareTo("_comm_source")==0){ //$NON-NLS-1$
|
|
86 |
|
|
87 |
compilerpath = new File (epocroot+projectdir+"multmmp_comm_source\\group\\"); //$NON-NLS-1$
|
|
88 |
} else if (path.compareTo("_comm_source_tracesplus")==0){ //$NON-NLS-1$
|
|
89 |
|
|
90 |
compilerpath = new File (epocroot+projectdir+"multmmp_comm_source_tracesplus\\group\\"); //$NON-NLS-1$
|
|
91 |
} else if (path.compareTo("_import")==0){ //$NON-NLS-1$
|
|
92 |
|
|
93 |
compilerpath = new File (epocroot+projectdir+"singlemmp_import\\group\\"); //$NON-NLS-1$
|
|
94 |
}
|
|
95 |
else{
|
|
96 |
|
|
97 |
System.out.println("Error: Unrecognised test case.");
|
|
98 |
fail();
|
|
99 |
}
|
|
100 |
|
|
101 |
//set up the process builder object
|
|
102 |
sbs_build.directory(compilerpath);
|
|
103 |
sbs_reallyclean.directory(compilerpath);
|
|
104 |
sbs_build.redirectErrorStream(true);
|
|
105 |
|
|
106 |
Process p = null;
|
|
107 |
String str = "";
|
|
108 |
//start the compiler
|
|
109 |
System.out.println("Starting build process ....");
|
|
110 |
|
|
111 |
System.out.println("Running sbs reallyclean on : " + compilerpath + " command: " + sbs_reallyclean.command().toString());
|
|
112 |
p = sbs_reallyclean.start();
|
|
113 |
readProcessOutput(p);
|
|
114 |
System.out.println("Running sbs on : " + compilerpath + " command: " + sbs_build.command().toString());
|
|
115 |
p = sbs_build.start();
|
|
116 |
str = readProcessOutput(p);
|
|
117 |
|
|
118 |
int ret = p.exitValue();
|
|
119 |
System.out.println("build process ended....");
|
|
120 |
if (ret!=0){
|
|
121 |
if (path.compareTo("_import")==0){ //$NON-NLS-1$
|
|
122 |
System.out.println("build process expected to fail: "+str);
|
|
123 |
} else {
|
|
124 |
System.out.println("build process failed:"+str);
|
|
125 |
fail();
|
|
126 |
}
|
|
127 |
}
|
|
128 |
}
|
|
129 |
|
|
130 |
catch (Exception e){//Catch exception if any
|
|
131 |
System.err.println("Error: " + e.getMessage());
|
|
132 |
fail();
|
|
133 |
}
|
|
134 |
|
|
135 |
}
|
|
136 |
|
|
137 |
|
|
138 |
static private String readProcessOutput(Process p) throws IOException {
|
|
139 |
InputStream inp = p.getInputStream();
|
|
140 |
|
|
141 |
int c;
|
|
142 |
String str = "";
|
|
143 |
//read the output from the compiler into the input stream
|
|
144 |
while ((c = inp.read()) != -1) {
|
|
145 |
str= str +((char)c);
|
|
146 |
}
|
|
147 |
return str;
|
|
148 |
}
|
|
149 |
|
|
150 |
|
|
151 |
|
|
152 |
/****************************************************ACTUAL TESTS************************************************************/
|
|
153 |
@Test
|
|
154 |
public void TracesInHeradersTest1 (){
|
|
155 |
System.out.println ("*********************single mmp with diff names****************************");
|
|
156 |
//Call Raptor
|
|
157 |
InvokeCompiler("_diffnames", "sbs");
|
|
158 |
}
|
|
159 |
|
|
160 |
@Test
|
|
161 |
public void TracesInHeradersTest2 (){
|
|
162 |
System.out.println ("*********************single mmp with same names****************************");
|
|
163 |
//Call Raptor
|
|
164 |
InvokeCompiler("_samenames", "sbs");
|
|
165 |
}
|
|
166 |
|
|
167 |
@Test
|
|
168 |
public void TracesInHeradersTest3 (){
|
|
169 |
System.out.println ("*********************single mmp with diff names and using tarce/<taget>_<ext>****************************");
|
|
170 |
//Call Raptor
|
|
171 |
InvokeCompiler("_diffnames_tracesplus", "sbs");
|
|
172 |
}
|
|
173 |
|
|
174 |
@Test
|
|
175 |
public void TracesInHeradersTest4 (){
|
|
176 |
System.out.println ("*********************single mmp with same names and using tarce/<taget>_<ext>****************************");
|
|
177 |
//Call Raptor
|
|
178 |
InvokeCompiler("_samenames_tracesplus", "sbs");
|
|
179 |
}
|
|
180 |
|
|
181 |
@Test
|
|
182 |
public void TracesInHeradersTest5 (){
|
|
183 |
System.out.println ("*********************multiple mmp with separate source ****************************");
|
|
184 |
//Call Raptor
|
|
185 |
InvokeCompiler("_separate_source", "sbs");
|
|
186 |
}
|
|
187 |
|
|
188 |
@Test
|
|
189 |
public void TracesInHeradersTest6 (){
|
|
190 |
System.out.println ("*********************multiple mmp with common source ****************************");
|
|
191 |
//Call Raptor
|
|
192 |
InvokeCompiler("_comm_source", "sbs");
|
|
193 |
}
|
|
194 |
|
|
195 |
@Test
|
|
196 |
public void TracesInHeradersTest7 (){
|
|
197 |
System.out.println ("*********************multiple mmp with common source and traces/<target>_<ext> ****************************");
|
|
198 |
//Call Raptor
|
|
199 |
InvokeCompiler("_comm_source_tracesplus", "sbs");
|
|
200 |
}
|
|
201 |
|
|
202 |
@Test
|
|
203 |
public void TracesInHeradersTest8 (){
|
|
204 |
System.out.println ("*********************Traces in header exported to epoc32 by another mmp****************************");
|
|
205 |
//Call Raptor
|
|
206 |
InvokeCompiler("_import", "sbs");
|
|
207 |
}
|
|
208 |
|
|
209 |
}
|
|
210 |
|