Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 01b6b569aa5c53ae88717c8275f33847d7fdfcab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*******************************************************************************
 * Copyright (c) 2009 STMicroelectronics.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Xavier Raynaud <xavier.raynaud@st.com> - initial API and implementation
 *******************************************************************************/
package org.eclipse.linuxtools.gprof.test;

import java.io.File;

import org.eclipse.linuxtools.gprof.Activator;
import org.eclipse.linuxtools.gprof.utils.GprofProgramChecker;

import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;


public class GprofBinaryTest extends TestCase {

	private static final String GMON_DIRECTORY_SUFFIX = "_gprof_input";
	private static final String GMON_BINARY_FILE = "a.out"; 
	private static final String GMON_OUTPUT_FILE = "gmon.out"; 

	public GprofBinaryTest() {
	}

	public static Test suite() {
		TestSuite ats = new TestSuite("Test Binary Consistency");
		File[] testDirs = STJunitUtils.getTestDirs("org.eclipse.linuxtools.gprof.test", ".*" + GMON_DIRECTORY_SUFFIX);
		for (File testDir : testDirs) {
			final String dirName = testDir.getName();
			ats.addTest(
					new TestCase(dirName + ":BinaryChecker") {
						public void runTest() throws Throwable {
							testValidBinary(dirName+File.separator+GMON_BINARY_FILE);
						}
					}
			);

//			ats.addTest(
//					new TestCase(dirName + ":GmonChecker") {
//						public void runTest() throws Throwable {
//							testInvalidBinary(dirName+"\\"+GMON_OUTPUT_FILE);
//						}
//					}
//			);
		}	
		return ats;
	}

	public static void testValidBinary(String relativeBinaryPath) throws Exception {
		String binary = STJunitUtils.getAbsolutePath(Activator.PLUGIN_ID , relativeBinaryPath);
		//Assert.assertEquals(true, GprofProgramChecker.isGProfCompatible(binary));
		// enhance coverage: testing cache
//		new File(binary).setLastModified(System.currentTimeMillis());
//		Assert.assertEquals(true, GprofProgramChecker.isGProfCompatible(binary));

	}

	public static void testInvalidBinary(String relativeGmonPath) throws Exception {
		String binary = STJunitUtils.getAbsolutePath(Activator.PLUGIN_ID , relativeGmonPath);
		//Assert.assertEquals(false, GprofProgramChecker.isGProfCompatible(binary));
	}
}

Back to the top