tracesrv/tracecompiler/test/src/FixedIdDefinitionsTest.java
changeset 56 aa2539c91954
parent 41 838cdffd57ce
equal deleted inserted replaced
54:a151135b0cf9 56:aa2539c91954
       
     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 "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  * JUnit tests for fixed_id.definitions file
       
    17  *
       
    18  */
       
    19 
       
    20 import java.io.BufferedReader;
       
    21 import java.io.BufferedWriter;
       
    22 import java.io.DataInputStream;
       
    23 import java.io.File;
       
    24 import java.io.FileInputStream;
       
    25 import java.io.FileNotFoundException;
       
    26 import java.io.FileReader;
       
    27 import java.io.FileWriter;
       
    28 import java.io.InputStream;
       
    29 import java.io.InputStreamReader;
       
    30 import java.io.Writer;
       
    31 
       
    32 import junit.framework.TestCase;
       
    33 
       
    34 import org.junit.Test;
       
    35 
       
    36 import com.nokia.tracecompiler.file.FileUtils;
       
    37 import com.nokia.tracecompiler.source.SourceDocumentFactory;
       
    38 
       
    39 public class FixedIdDefinitionsTest extends TestCase {
       
    40 
       
    41 	/**
       
    42 	 * EMMA output prefix
       
    43 	 */
       
    44 	private static final String EMMA_OUTPUT_PREFIX = "EMMA: "; //$NON-NLS-1$
       
    45 	
       
    46 	/**
       
    47 	 * Fixed id definitions test app took note prefix
       
    48 	 */
       
    49 	private static final String FIXED_ID_DEFINITIONS_TEST_APP_TOOK_NOTE_PREFIX = "FixedIdDefinitionsTestApp took"; //$NON-NLS-1$
       
    50 
       
    51 	/**
       
    52 	 * UID3 of FixedIdDefinitionsTestApp
       
    53 	 */
       
    54 	private static final String FIXED_ID_DEFINITIONS_TEST_APP_UID3 = "E8576D92"; //$NON-NLS-1$
       
    55 
       
    56 	/**
       
    57 	 * txt extension
       
    58 	 */
       
    59 	private static final String TXT_EXTENSION = ".txt"; //$NON-NLS-1$
       
    60 
       
    61 	/**
       
    62 	 * Reference fid file name prefix
       
    63 	 */
       
    64 	private static final String REFERENCE_FID_FILE_NAME_PREFIX = "reference_fid_file_"; //$NON-NLS-1$
       
    65 
       
    66 	/**
       
    67 	 * Reference fid file name prefix
       
    68 	 */
       
    69 	private static final String REFERENCE_TC_OUTPUT_NAME_PREFIX = "reference_tc_output_"; //$NON-NLS-1$	
       
    70 
       
    71 	/**
       
    72 	 * data directory name
       
    73 	 */
       
    74 	private static final String DATA_DIRECTORY = "data"; //$NON-NLS-1$
       
    75 
       
    76 	/**
       
    77 	 * traces directory name
       
    78 	 */
       
    79 	private static final String TRACES_DIRECTORY = "traces"; //$NON-NLS-1$
       
    80 
       
    81 	/**
       
    82 	 * fixed_id.definitions file name
       
    83 	 */
       
    84 	private static final String FIXED_ID_DEFINITIONS_FILE_NAME = "fixed_id.definitions"; //$NON-NLS-1$
       
    85 
       
    86 	/**
       
    87 	 * Line comment tag
       
    88 	 */
       
    89 	private static final String LINE_COMMENT_TAG = "//"; //$NON-NLS-1$
       
    90 
       
    91 	/**
       
    92 	 * TRACE_USED_IN_TEST_CASE tag
       
    93 	 */
       
    94 	private static final String TRACE_USED_IN_TEST_CASE_TAG = "TRACE_USED_IN_TEST_CASE"; //$NON-NLS-1$
       
    95 
       
    96 	/**
       
    97 	 * Error text prefix
       
    98 	 */
       
    99 	private static final String ERROR_TEXT_PREFIX = "Error: "; //$NON-NLS-1$
       
   100 
       
   101 	/**
       
   102 	 * src directory name
       
   103 	 */
       
   104 	private static final String SRC_DIRECTORY = "src"; //$NON-NLS-1$
       
   105 
       
   106 	/**
       
   107 	 * .cpp extension
       
   108 	 */
       
   109 	private static final String CPP_EXTENSION = ".cpp"; //$NON-NLS-1$
       
   110 
       
   111 	/**
       
   112 	 * FixedIdDefinitionsTestApp
       
   113 	 */
       
   114 	private static final String FIXED_ID_DEFINITIONS_TEST_APP = "FixedIdDefinitionsTestApp"; //$NON-NLS-1$
       
   115 
       
   116 	/**
       
   117 	 * Variable for epocroot
       
   118 	 */
       
   119 	String e32;
       
   120 
       
   121 	/**
       
   122 	 * Path to FixedIdDefinitionsTestApp application
       
   123 	 */
       
   124 	String fixedIdDefinitionsTestAppPath;
       
   125 
       
   126 	/**
       
   127 	 * Process builder
       
   128 	 */
       
   129 	ProcessBuilder pb = null;
       
   130 
       
   131 	/**
       
   132 	 * Compiler path
       
   133 	 */
       
   134 	File compilerPath = null;
       
   135 
       
   136 	/**
       
   137 	 * Line separator
       
   138 	 */
       
   139 	String lineSeparator;
       
   140 
       
   141 	/**
       
   142 	 * Source file name with full path
       
   143 	 */
       
   144 	String sourceFileNameWithFullPath;
       
   145 
       
   146 	/**
       
   147 	 * fixed_id.definitions file name with full path
       
   148 	 */
       
   149 	String fixedIdDefinitionsFileNameWithFullPath;
       
   150 
       
   151 	/**
       
   152 	 * SourceDocumentFactory
       
   153 	 */
       
   154 	SourceDocumentFactory factory = null;
       
   155 
       
   156 	public static void main(String[] args) {
       
   157 		org.junit.runner.JUnitCore.main(FixedIdDefinitionsTest.class.getName());
       
   158 	}
       
   159 
       
   160 	/**
       
   161 	 * setup
       
   162 	 */
       
   163 	@Test
       
   164 	public void setUp() {
       
   165 		System.out.println("Setup class variables"); //$NON-NLS-1$
       
   166 
       
   167 		e32 = System.getenv("EPOCROOT"); //$NON-NLS-1$
       
   168 
       
   169 		if (!e32.endsWith(File.separator)) {
       
   170 			e32 += File.separator;
       
   171 		}
       
   172 
       
   173 		fixedIdDefinitionsTestAppPath = e32 + "testdata" + File.separator //$NON-NLS-1$
       
   174 				+ FIXED_ID_DEFINITIONS_TEST_APP + File.separator;
       
   175 				
       
   176 		// These EMMA flags are added, because of EMMA reporting in Hudson
       
   177 		String emmaOutputFileFlag = "-Demma.coverage.out.file=" + e32 + "testdata" + File.separator + "reports" + File.separator + "emma" + File.separator + "coverage.emma";
       
   178 		String emmaOutputMergeFlag = "-Demma.coverage.out.merge=true";
       
   179 
       
   180 		pb = new ProcessBuilder("java", emmaOutputFileFlag, emmaOutputMergeFlag, "-classpath", ".", //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
       
   181 				"com.nokia.tracecompiler.TraceCompiler", FIXED_ID_DEFINITIONS_TEST_APP_UID3, //$NON-NLS-1$
       
   182 				FIXED_ID_DEFINITIONS_TEST_APP, fixedIdDefinitionsTestAppPath
       
   183 						+ "group" + File.separator //$NON-NLS-1$
       
   184 						+ FIXED_ID_DEFINITIONS_TEST_APP + ".mmp", //$NON-NLS-1$
       
   185 				fixedIdDefinitionsTestAppPath + SRC_DIRECTORY + File.separator
       
   186 						+ FIXED_ID_DEFINITIONS_TEST_APP + CPP_EXTENSION);
       
   187 
       
   188 		compilerPath = new File(e32 + "epoc32" + File.separator + "tools" //$NON-NLS-1$//$NON-NLS-2$
       
   189 				+ File.separator + "tracecompiler" + File.separator); //$NON-NLS-1$
       
   190 
       
   191 		lineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$
       
   192 
       
   193 		sourceFileNameWithFullPath = fixedIdDefinitionsTestAppPath
       
   194 				+ SRC_DIRECTORY + File.separator
       
   195 				+ FIXED_ID_DEFINITIONS_TEST_APP + CPP_EXTENSION;
       
   196 
       
   197 		fixedIdDefinitionsFileNameWithFullPath = fixedIdDefinitionsTestAppPath
       
   198 				+ TRACES_DIRECTORY + File.separator
       
   199 				+ FIXED_ID_DEFINITIONS_FILE_NAME;
       
   200 	}
       
   201 
       
   202 	/**
       
   203 	 * Check if fixed id file is created correctly when it doesn't already exist
       
   204 	 */
       
   205 	@Test
       
   206 	public void testFixedIdDefinitionsFunctionalityTestCase_1() {
       
   207 		int testCaseNumber = 1;
       
   208 		System.out
       
   209 				.println("*** Check if fixed id file is created correctly when it doesn't already exist ***"); //$NON-NLS-1$
       
   210 		executeTestCase(testCaseNumber, 0);
       
   211 	}
       
   212 
       
   213 	/**
       
   214 	 * Check new trace points are assigned values correctly (i.e. existing ones
       
   215 	 * don't change)
       
   216 	 */
       
   217 	@Test
       
   218 	public void testFixedIdDefinitionsFunctionalityTestCase_2() {
       
   219 		int testCaseNumber = 2;
       
   220 		System.out
       
   221 				.println("*** Check new trace points are assigned values correctly (i.e. existing ones don't change) ***"); //$NON-NLS-1$
       
   222 		executeTestCase(testCaseNumber, 0);
       
   223 	}
       
   224 
       
   225 	/**
       
   226 	 * Check removed trace points / user-defined groups are obsoleted correctly
       
   227 	 */
       
   228 	@Test
       
   229 	public void testFixedIdDefinitionsFunctionalityTestCase_3() {
       
   230 		int testCaseNumber = 3;
       
   231 		System.out
       
   232 				.println("*** Check removed trace points / user-defined groups are obsoleted correctly ***"); //$NON-NLS-1$
       
   233 		executeTestCase(testCaseNumber, 0);
       
   234 	}
       
   235 
       
   236 	/**
       
   237 	 * Check that adding a trace point with an obsoleted name is given a new
       
   238 	 * value.
       
   239 	 */
       
   240 	@Test
       
   241 	public void testFixedIdDefinitionsFunctionalityTestCase_4() {
       
   242 		int testCaseNumber = 4;
       
   243 		System.out
       
   244 				.println("*** Check that adding a trace point with an obsoleted name is given a new value. ***"); //$NON-NLS-1$
       
   245 		executeTestCase(testCaseNumber, 0);
       
   246 	}
       
   247 
       
   248 	/**
       
   249 	 * Check that obsoleting all trace points in a component that refer to a
       
   250 	 * common group id (e.g. TRACE_FLOW) does NOT mark group as obsolete
       
   251 	 */
       
   252 	@Test
       
   253 	public void testFixedIdDefinitionsFunctionalityTestCase_5() {
       
   254 		int testCaseNumber = 5;
       
   255 		System.out
       
   256 				.println("*** Check that obsoleting all trace points in a component that refer to a common group id (e.g. TRACE_FLOW) does NOT mark group as obsolete ***"); //$NON-NLS-1$
       
   257 		executeTestCase(testCaseNumber, 0);
       
   258 	}
       
   259 
       
   260 	/**
       
   261 	 * Check that repeatedly obsoleting a trace point does not mess
       
   262 	 * TraceCompiler.
       
   263 	 */
       
   264 	@Test
       
   265 	public void testFixedIdDefinitionsFunctionalityTestCase_6() {
       
   266 		int testCaseNumber = 6;
       
   267 		int subTestNumber = 1;
       
   268 		System.out
       
   269 				.println("*** Check that repeatedly obsoleting a trace point does not mess TraceCompiler. ***"); //$NON-NLS-1$
       
   270 		int numberOfSubTests = 4;
       
   271 		while (subTestNumber < numberOfSubTests) {
       
   272 			executeTestCase(testCaseNumber, subTestNumber);
       
   273 			subTestNumber++;
       
   274 		}
       
   275 	}
       
   276 
       
   277 	/**
       
   278 	 * Check that repeatedly changing group of the trace point does not mess
       
   279 	 * TraceCompiler.
       
   280 	 */
       
   281 	@Test
       
   282 	public void testFixedIdDefinitionsFunctionalityTestCase_7() {
       
   283 		int testCaseNumber = 7;
       
   284 		int subTestNumber = 1;
       
   285 		System.out
       
   286 				.println("*** Check that repeatedly changing group of the trace point does not mess TraceCompiler. ***"); //$NON-NLS-1$
       
   287 		int numberOfSubTests = 3;
       
   288 		while (subTestNumber < numberOfSubTests) {
       
   289 			executeTestCase(testCaseNumber, subTestNumber);
       
   290 			subTestNumber++;
       
   291 		}
       
   292 	}
       
   293 
       
   294 	/**
       
   295 	 * Check that a OSTv1 common group id values results in new fixed id file.
       
   296 	 */
       
   297 	@Test
       
   298 	public void testFixedIdDefinitionsFunctionalityTestCase_8() {
       
   299 		int testCaseNumber = 8;
       
   300 		System.out
       
   301 				.println("*** Check that a OSTv1 common group id values results in new fixed id file. ***"); //$NON-NLS-1$
       
   302 		executeTestCaseWithTraceCompilerOutputCheck(testCaseNumber, 0);
       
   303 	}
       
   304 
       
   305 	/**
       
   306 	 * Check that a OSTv1 user group id values results in new fixed id file.
       
   307 	 */
       
   308 	@Test
       
   309 	public void testFixedIdDefinitionsFunctionalityTestCase_9() {
       
   310 		int testCaseNumber = 9;
       
   311 		System.out
       
   312 				.println("*** Check that a OSTv1 user group id values results in new fixed id file. ***"); //$NON-NLS-1$
       
   313 		executeTestCaseWithTraceCompilerOutputCheck(testCaseNumber, 0);
       
   314 	}
       
   315 
       
   316 	/**
       
   317 	 * Sub function to execute test case with TraceCompiler output check
       
   318 	 * 
       
   319 	 * @param testCaseNumber
       
   320 	 *            Test case number
       
   321 	 */
       
   322 	private void executeTestCaseWithTraceCompilerOutputCheck(
       
   323 			int testCaseNumber, int subTestNumber) {
       
   324 		System.out
       
   325 				.println("Start to execute test case with TraceCompiler output check."); //$NON-NLS-1$
       
   326 		modifyFixedIdDefinitionsTestApp(testCaseNumber, subTestNumber);
       
   327 		InputStream traceCompilerOutput = runTraceCompiler();
       
   328 		verifyTraceCompilerOutput(testCaseNumber, subTestNumber,
       
   329 				traceCompilerOutput);
       
   330 		verifyTestResults(testCaseNumber, subTestNumber);
       
   331 	}
       
   332 
       
   333 	/**
       
   334 	 * Sub function to execute test case
       
   335 	 * 
       
   336 	 * @param testCaseNumber
       
   337 	 *            Test case number
       
   338 	 */
       
   339 	private void executeTestCase(int testCaseNumber, int subTestNumber) {
       
   340 		System.out.println("Start to execute test case."); //$NON-NLS-1$
       
   341 		modifyFixedIdDefinitionsTestApp(testCaseNumber, subTestNumber);
       
   342 		if (testCaseNumber > 1) {
       
   343 			initializeFixedIDDefinitionsFile(testCaseNumber, subTestNumber);
       
   344 		}
       
   345 		runTraceCompiler();
       
   346 		verifyTestResults(testCaseNumber, subTestNumber);
       
   347 	}
       
   348 
       
   349 	/**
       
   350 	 * Initialize fixed_id.defitions file
       
   351 	 * 
       
   352 	 * @param testCaseNumber
       
   353 	 *            Test case number
       
   354 	 */
       
   355 	private void initializeFixedIDDefinitionsFile(int testCaseNumber,
       
   356 			int subTestNumber) {
       
   357 		System.out.println("Initialize fixed_id.defitions file"); //$NON-NLS-1$
       
   358 		String refesenceFileName;
       
   359 		if (subTestNumber == 0) {
       
   360 			refesenceFileName = REFERENCE_FID_FILE_NAME_PREFIX
       
   361 					+ (testCaseNumber - 1);
       
   362 		} else {
       
   363 			refesenceFileName = REFERENCE_FID_FILE_NAME_PREFIX + testCaseNumber
       
   364 					+ "_" + (subTestNumber - 1); //$NON-NLS-1$
       
   365 		}
       
   366 		refesenceFileName = refesenceFileName + TXT_EXTENSION;
       
   367 		String sourceFile = fixedIdDefinitionsTestAppPath + DATA_DIRECTORY
       
   368 				+ File.separator + refesenceFileName;
       
   369 		File source = new File(sourceFile);
       
   370 		File target = new File(fixedIdDefinitionsFileNameWithFullPath);
       
   371 		FileUtils.copyFile(source, target);
       
   372 	}
       
   373 
       
   374 	/**
       
   375 	 * Modify FixedIdDefinitionsTestApp application source code
       
   376 	 * 
       
   377 	 * @param testCaseNumber
       
   378 	 *            test case number
       
   379 	 */
       
   380 	private void modifyFixedIdDefinitionsTestApp(int testCaseNumber,
       
   381 			int subTestNumber) {
       
   382 		System.out
       
   383 				.println("Modify FixedIdDefinitionsTestApp application source code"); //$NON-NLS-1$
       
   384 		try {
       
   385 			StringBuilder modifiedContents = new StringBuilder();
       
   386 			File sourceFile = new File(sourceFileNameWithFullPath);
       
   387 			BufferedReader input = new BufferedReader(
       
   388 					new FileReader(sourceFile));
       
   389 			String line;
       
   390 			String currentTestCaseTag = TRACE_USED_IN_TEST_CASE_TAG
       
   391 					+ "_" + testCaseNumber; //$NON-NLS-1$
       
   392 			if (subTestNumber != 0) {
       
   393 				currentTestCaseTag = currentTestCaseTag + "_" + subTestNumber; //$NON-NLS-1$
       
   394 			}
       
   395 			while ((line = input.readLine()) != null) {
       
   396 				if (line.indexOf(TRACE_USED_IN_TEST_CASE_TAG) != -1) {
       
   397 					if (line.indexOf(currentTestCaseTag) != -1) {
       
   398 						if (line.startsWith(LINE_COMMENT_TAG)) {
       
   399 							line = line.substring(LINE_COMMENT_TAG.length());
       
   400 						}
       
   401 					} else {
       
   402 						if (!line.startsWith(LINE_COMMENT_TAG)) {
       
   403 							line = LINE_COMMENT_TAG + line;
       
   404 						}
       
   405 					}
       
   406 				}
       
   407 				modifiedContents.append(line);
       
   408 				modifiedContents.append(lineSeparator);
       
   409 			}
       
   410 			input.close();
       
   411 			Writer sourceFileWriter = new BufferedWriter(new FileWriter(
       
   412 					sourceFileNameWithFullPath));
       
   413 			sourceFileWriter.write(modifiedContents.toString());
       
   414 			sourceFileWriter.close();
       
   415 
       
   416 			if (testCaseNumber == 8 || testCaseNumber == 9) {
       
   417 				String fileContent = "#Fixed group and trace id definitions. If this file is removed, the identifiers are rebuilt." + lineSeparator; //$NON-NLS-1$
       
   418 
       
   419 				if (testCaseNumber == 8) {
       
   420 					fileContent += "[GROUP]TRACE_FLOW=0x7" + lineSeparator //$NON-NLS-1$
       
   421 							+ "[TRACE]TRACE_FLOW[0x7]_TRACE1=0x1"; //$NON-NLS-1$
       
   422 				} else if (testCaseNumber == 9) {
       
   423 					fileContent += "[GROUP]MY_GROUP=0x70" + lineSeparator //$NON-NLS-1$
       
   424 							+ "[TRACE]MY_GROUP [0x70]_TRACE1=0x1"; //$NON-NLS-1$
       
   425 				}
       
   426 				Writer fixedIDDefinitionsFileWriter = new BufferedWriter(
       
   427 						new FileWriter(fixedIdDefinitionsFileNameWithFullPath));
       
   428 				fixedIDDefinitionsFileWriter.write(fileContent);
       
   429 				fixedIDDefinitionsFileWriter.close();
       
   430 			}
       
   431 
       
   432 		} catch (Exception e) {
       
   433 			System.err.println(ERROR_TEXT_PREFIX + e.getMessage());
       
   434 			fail();
       
   435 		}
       
   436 	}
       
   437 
       
   438 	/**
       
   439 	 * Run TraceCompiler
       
   440 	 */
       
   441 	private InputStream runTraceCompiler() {
       
   442 		System.out.println("Run TraceCompiler"); //$NON-NLS-1$
       
   443 		InputStream inp = null;
       
   444 		pb.directory(compilerPath);
       
   445 		pb.redirectErrorStream(true);
       
   446 		// start the compiler
       
   447 		try {
       
   448 			Process p = pb.start();
       
   449 			p.waitFor();
       
   450 			inp = p.getInputStream();
       
   451 		} catch (Exception e) {// Catch exception if any
       
   452 			System.err.println(ERROR_TEXT_PREFIX + e.getMessage());
       
   453 			fail();
       
   454 		}
       
   455 
       
   456 		return inp;
       
   457 	}
       
   458 
       
   459 	/**
       
   460 	 * Verify TraceCompiler output
       
   461 	 * 
       
   462 	 * @param traceCompilerOutput
       
   463 	 *            TraceCompiler output
       
   464 	 */
       
   465 	private void verifyTraceCompilerOutput(int testCaseNumber,
       
   466 			int subTestNumber, InputStream traceCompilerOutput) {
       
   467 		System.out.println("Verify TraceCompiler output"); //$NON-NLS-1$
       
   468 
       
   469 		String refesenceFileName = REFERENCE_TC_OUTPUT_NAME_PREFIX
       
   470 				+ testCaseNumber;
       
   471 		if (subTestNumber != 0) {
       
   472 			refesenceFileName = refesenceFileName + "_" + subTestNumber; //$NON-NLS-1$
       
   473 		}
       
   474 		refesenceFileName = refesenceFileName + TXT_EXTENSION;
       
   475 
       
   476 		try {
       
   477 			FileInputStream fstreamExpected = new FileInputStream(
       
   478 					fixedIdDefinitionsTestAppPath + DATA_DIRECTORY
       
   479 							+ File.separator + refesenceFileName);
       
   480 			compareExpectedAndActual(fstreamExpected, traceCompilerOutput);
       
   481 		} catch (FileNotFoundException e) {
       
   482 			System.err.println(ERROR_TEXT_PREFIX + e.getMessage());
       
   483 			fail();
       
   484 		}
       
   485 	}
       
   486 
       
   487 	/**
       
   488 	 * Verify test result
       
   489 	 * 
       
   490 	 * @param testCaseNumber
       
   491 	 *            test case number
       
   492 	 */
       
   493 	private void verifyTestResults(int testCaseNumber, int subTestNumber) {
       
   494 		System.out.println("Verify test result"); //$NON-NLS-1$
       
   495 		String refesenceFileName = REFERENCE_FID_FILE_NAME_PREFIX
       
   496 				+ testCaseNumber;
       
   497 
       
   498 		if (subTestNumber != 0) {
       
   499 			refesenceFileName = refesenceFileName + "_" + subTestNumber; //$NON-NLS-1$
       
   500 		}
       
   501 
       
   502 		refesenceFileName = refesenceFileName + TXT_EXTENSION;
       
   503 		try {
       
   504 			FileInputStream fstreamExpected = new FileInputStream(
       
   505 					fixedIdDefinitionsTestAppPath + DATA_DIRECTORY
       
   506 							+ File.separator + refesenceFileName);
       
   507 			FileInputStream fstreamActual = new FileInputStream(
       
   508 					fixedIdDefinitionsFileNameWithFullPath);
       
   509 			compareExpectedAndActual(fstreamExpected, fstreamActual);
       
   510 		} catch (FileNotFoundException e) {
       
   511 			System.err.println(ERROR_TEXT_PREFIX + e.getMessage());
       
   512 			fail();
       
   513 		}
       
   514 	}
       
   515 
       
   516 	/**
       
   517 	 * Compare expected and actual input streams
       
   518 	 * 
       
   519 	 * @param streamExpected
       
   520 	 *            Expected input stream
       
   521 	 * @param streamActual
       
   522 	 *            Actual input stream
       
   523 	 */
       
   524 	private void compareExpectedAndActual(InputStream streamExpected,
       
   525 			InputStream streamActual) {
       
   526 		System.out.println("Compare expected and actual input streams"); //$NON-NLS-1$
       
   527 		try {
       
   528 			// Get the objects of DataInputStream
       
   529 			DataInputStream inExpected = new DataInputStream(streamExpected);
       
   530 			DataInputStream inActual = new DataInputStream(streamActual);
       
   531 			BufferedReader brExpected = new BufferedReader(
       
   532 					new InputStreamReader(inExpected));
       
   533 			BufferedReader brActual = new BufferedReader(new InputStreamReader(
       
   534 					inActual));
       
   535 
       
   536 			String strLineExpected;
       
   537 			String strLineActual;
       
   538 			int i = 1;
       
   539 			// compare the expected and actual input streams
       
   540 			while (((strLineExpected = brExpected.readLine()) != null)
       
   541 					&& (((strLineActual = brActual.readLine()) != null))) {
       
   542 
       
   543 				// Skip EMMA outputs if those exists
       
   544 				if (strLineActual.trim().startsWith(EMMA_OUTPUT_PREFIX)) {
       
   545 						strLineActual = brActual.readLine();
       
   546 						if (strLineActual == null) {
       
   547 							break;
       
   548 						}
       
   549 				}
       
   550 
       
   551 				// Following check skips different TraceCompiler execution time
       
   552 				// values
       
   553 				if (strLineExpected
       
   554 						.indexOf(FIXED_ID_DEFINITIONS_TEST_APP_TOOK_NOTE_PREFIX) != -1
       
   555 						&& strLineActual
       
   556 								.indexOf(FIXED_ID_DEFINITIONS_TEST_APP_TOOK_NOTE_PREFIX) != -1) {
       
   557 					strLineActual = strLineActual.trim().substring(
       
   558 							0,
       
   559 							FIXED_ID_DEFINITIONS_TEST_APP_TOOK_NOTE_PREFIX
       
   560 									.length());
       
   561 
       
   562 				}
       
   563 				assertTrue(ERROR_TEXT_PREFIX + "Line \"" + strLineActual //$NON-NLS-1$
       
   564 						+ "\" does not match to \"" + strLineExpected + "\"", //$NON-NLS-1$ //$NON-NLS-2$
       
   565 						strLineExpected.compareTo(strLineActual) == 0);
       
   566 				i++;
       
   567 			}
       
   568 			
       
   569 			// Check that actual file does not contain any extra lines, it could be that there are some EMMA outputs and those are ok
       
   570 			while ((strLineActual = brActual.readLine()) != null) {
       
   571 				assertTrue(
       
   572 						ERROR_TEXT_PREFIX
       
   573 								+ "Actual file does contain extra lines", strLineActual.trim().startsWith(EMMA_OUTPUT_PREFIX)); //$NON-NLS-1$				
       
   574 			}
       
   575 			
       
   576 			// never entered loop therefore there actual file was empty or
       
   577 			// missing
       
   578 			assertTrue(ERROR_TEXT_PREFIX + "Actual file was empty or missing", //$NON-NLS-1$
       
   579 					i > 0);
       
   580 
       
   581 			inExpected.close();
       
   582 			inActual.close();
       
   583 		} catch (Exception e) {
       
   584 			System.err.println(ERROR_TEXT_PREFIX + e.getMessage());
       
   585 			fail();
       
   586 		}
       
   587 	}
       
   588 
       
   589 	/**
       
   590 	 * tearDown
       
   591 	 */
       
   592 	@Test
       
   593 	public void tearDown() {
       
   594 		System.out.println("Comment out all trace points in FixedIdDefinitionsTestApp"); //$NON-NLS-1$
       
   595 		modifyFixedIdDefinitionsTestApp(0, 0);
       
   596 	}
       
   597 }