debuggercdi/com.nokia.cdt.debug.cw.symbian.tests/src/com/nokia/cdt/debug/cw/symbian/tests/SymbolReaderTest.java
author wpaul
Wed, 25 Mar 2009 12:24:24 -0500
changeset 9 6ef327765a4e
parent 2 d760517a8095
child 127 c937102a5510
permissions -rw-r--r--
added copyright
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9
6ef327765a4e added copyright
wpaul
parents: 2
diff changeset
     1
/*
6ef327765a4e added copyright
wpaul
parents: 2
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
6ef327765a4e added copyright
wpaul
parents: 2
diff changeset
     3
* All rights reserved.
6ef327765a4e added copyright
wpaul
parents: 2
diff changeset
     4
* This component and the accompanying materials are made available
6ef327765a4e added copyright
wpaul
parents: 2
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
6ef327765a4e added copyright
wpaul
parents: 2
diff changeset
     6
* which accompanies this distribution, and is available
6ef327765a4e added copyright
wpaul
parents: 2
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
6ef327765a4e added copyright
wpaul
parents: 2
diff changeset
     8
*
6ef327765a4e added copyright
wpaul
parents: 2
diff changeset
     9
* Initial Contributors:
6ef327765a4e added copyright
wpaul
parents: 2
diff changeset
    10
* Nokia Corporation - initial contribution.
6ef327765a4e added copyright
wpaul
parents: 2
diff changeset
    11
*
6ef327765a4e added copyright
wpaul
parents: 2
diff changeset
    12
* Contributors:
6ef327765a4e added copyright
wpaul
parents: 2
diff changeset
    13
*
6ef327765a4e added copyright
wpaul
parents: 2
diff changeset
    14
* Description: 
6ef327765a4e added copyright
wpaul
parents: 2
diff changeset
    15
*
6ef327765a4e added copyright
wpaul
parents: 2
diff changeset
    16
*/
2
cawthron
parents:
diff changeset
    17
package com.nokia.cdt.debug.cw.symbian.tests;
cawthron
parents:
diff changeset
    18
cawthron
parents:
diff changeset
    19
import junit.framework.TestCase;
cawthron
parents:
diff changeset
    20
cawthron
parents:
diff changeset
    21
import com.nokia.cdt.debug.cw.symbian.symbolreader.IFunction;
cawthron
parents:
diff changeset
    22
import com.nokia.cdt.debug.cw.symbian.symbolreader.ISourceLocation;
cawthron
parents:
diff changeset
    23
import com.nokia.cdt.debug.cw.symbian.symbolreader.ISymbolFile;
cawthron
parents:
diff changeset
    24
import com.nokia.cdt.debug.cw.symbian.symbolreader.SymbolReaderManager;
cawthron
parents:
diff changeset
    25
cawthron
parents:
diff changeset
    26
public class SymbolReaderTest extends TestCase {
cawthron
parents:
diff changeset
    27
cawthron
parents:
diff changeset
    28
	protected void setUp() throws Exception {
cawthron
parents:
diff changeset
    29
		super.setUp();
cawthron
parents:
diff changeset
    30
	}
cawthron
parents:
diff changeset
    31
cawthron
parents:
diff changeset
    32
	protected void tearDown() throws Exception {
cawthron
parents:
diff changeset
    33
		super.tearDown();
cawthron
parents:
diff changeset
    34
	}
cawthron
parents:
diff changeset
    35
cawthron
parents:
diff changeset
    36
	public void testSymUnload() throws Exception {
cawthron
parents:
diff changeset
    37
cawthron
parents:
diff changeset
    38
		java.io.File src = new java.io.File(TestsPlugin.getPluginPath()+"\\data\\_h2_dma.sym");
cawthron
parents:
diff changeset
    39
		java.io.File test = java.io.File.createTempFile("testSymUnload_", ".sym");
cawthron
parents:
diff changeset
    40
		
cawthron
parents:
diff changeset
    41
		java.io.InputStream srcStream = new java.io.FileInputStream(src);
cawthron
parents:
diff changeset
    42
		java.io.OutputStream testStream = new java.io.FileOutputStream(test);
cawthron
parents:
diff changeset
    43
    
cawthron
parents:
diff changeset
    44
        // copy to test file
cawthron
parents:
diff changeset
    45
        byte[] buf = new byte[1024];
cawthron
parents:
diff changeset
    46
        int len;
cawthron
parents:
diff changeset
    47
        while ((len = srcStream.read(buf)) > 0) {
cawthron
parents:
diff changeset
    48
        	testStream.write(buf, 0, len);
cawthron
parents:
diff changeset
    49
        }
cawthron
parents:
diff changeset
    50
        srcStream.close();
cawthron
parents:
diff changeset
    51
        testStream.close();
cawthron
parents:
diff changeset
    52
		
cawthron
parents:
diff changeset
    53
		//open symbol file
cawthron
parents:
diff changeset
    54
		ISymbolFile symbolFile = SymbolReaderManager.getSymbolReaderManager().openSymbolFile(test.getAbsolutePath());
cawthron
parents:
diff changeset
    55
cawthron
parents:
diff changeset
    56
		//create address from hex string
cawthron
parents:
diff changeset
    57
		java.math.BigInteger big = new java.math.BigInteger("841d", 16);
cawthron
parents:
diff changeset
    58
cawthron
parents:
diff changeset
    59
		//get function and source location
cawthron
parents:
diff changeset
    60
		IFunction function = symbolFile.findFunctionByAddress( big );
cawthron
parents:
diff changeset
    61
		ISourceLocation loca = symbolFile.findSourceLocation( big );
cawthron
parents:
diff changeset
    62
		
cawthron
parents:
diff changeset
    63
		// close and make sure we released the file(can delete)
cawthron
parents:
diff changeset
    64
		symbolFile.close();
cawthron
parents:
diff changeset
    65
		
cawthron
parents:
diff changeset
    66
		boolean succeed = test.delete();
cawthron
parents:
diff changeset
    67
		
cawthron
parents:
diff changeset
    68
		assertTrue(succeed);
cawthron
parents:
diff changeset
    69
	}
cawthron
parents:
diff changeset
    70
}