9
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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 the License "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 |
*/
|
2
|
17 |
package com.nokia.cdt.debug.cw.symbian.tests;
|
|
18 |
|
|
19 |
import junit.framework.TestCase;
|
|
20 |
|
|
21 |
import com.nokia.cdt.debug.cw.symbian.symbolreader.IFunction;
|
|
22 |
import com.nokia.cdt.debug.cw.symbian.symbolreader.ISourceLocation;
|
|
23 |
import com.nokia.cdt.debug.cw.symbian.symbolreader.ISymbolFile;
|
|
24 |
import com.nokia.cdt.debug.cw.symbian.symbolreader.SymbolReaderManager;
|
|
25 |
|
|
26 |
public class SymbolReaderTest extends TestCase {
|
|
27 |
|
|
28 |
protected void setUp() throws Exception {
|
|
29 |
super.setUp();
|
|
30 |
}
|
|
31 |
|
|
32 |
protected void tearDown() throws Exception {
|
|
33 |
super.tearDown();
|
|
34 |
}
|
|
35 |
|
|
36 |
public void testSymUnload() throws Exception {
|
|
37 |
|
|
38 |
java.io.File src = new java.io.File(TestsPlugin.getPluginPath()+"\\data\\_h2_dma.sym");
|
|
39 |
java.io.File test = java.io.File.createTempFile("testSymUnload_", ".sym");
|
|
40 |
|
|
41 |
java.io.InputStream srcStream = new java.io.FileInputStream(src);
|
|
42 |
java.io.OutputStream testStream = new java.io.FileOutputStream(test);
|
|
43 |
|
|
44 |
// copy to test file
|
|
45 |
byte[] buf = new byte[1024];
|
|
46 |
int len;
|
|
47 |
while ((len = srcStream.read(buf)) > 0) {
|
|
48 |
testStream.write(buf, 0, len);
|
|
49 |
}
|
|
50 |
srcStream.close();
|
|
51 |
testStream.close();
|
|
52 |
|
|
53 |
//open symbol file
|
|
54 |
ISymbolFile symbolFile = SymbolReaderManager.getSymbolReaderManager().openSymbolFile(test.getAbsolutePath());
|
|
55 |
|
|
56 |
//create address from hex string
|
|
57 |
java.math.BigInteger big = new java.math.BigInteger("841d", 16);
|
|
58 |
|
|
59 |
//get function and source location
|
|
60 |
IFunction function = symbolFile.findFunctionByAddress( big );
|
|
61 |
ISourceLocation loca = symbolFile.findSourceLocation( big );
|
|
62 |
|
|
63 |
// close and make sure we released the file(can delete)
|
|
64 |
symbolFile.close();
|
|
65 |
|
|
66 |
boolean succeed = test.delete();
|
|
67 |
|
|
68 |
assertTrue(succeed);
|
|
69 |
}
|
|
70 |
}
|