package dgemv;

import static org.junit.Assert.assertFalse;

import java.io.File;
import java.io.IOException;

import org.junit.Ignore;
import org.junit.Test;

import config.Example;
import edu.udel.cis.vsl.tass.config.CompareConfiguration;
import edu.udel.cis.vsl.tass.config.RunConfiguration.DeadlockStrategy;
import edu.udel.cis.vsl.tass.config.RunConfiguration.ReductionStrategy;
import edu.udel.cis.vsl.tass.front.minimp.ModelExtractor;
import edu.udel.cis.vsl.tass.front.minimp.ModelPair;
import edu.udel.cis.vsl.tass.model.IF.ModelIF;
import edu.udel.cis.vsl.tass.util.SyntaxException;
import edu.udel.cis.vsl.tass.verify.Comparison;

public class TriangleSolveTest {

	/**
	 * The test works but requires a lot of memory and some time, and the file
	 * generated by the trace is too large.
	 */
	@Test
	@Ignore
	public void testCompare() throws IOException, SyntaxException {
		ModelIF specModel, implModel;
		ModelPair pair;
		File rootDirectory = new File(Example.exampleDirectory, "dgemv");
		CompareConfiguration compareConfiguration = new CompareConfiguration(
				new File(rootDirectory, "TASSREP"));

		compareConfiguration.setSpecSourceFile(new File(rootDirectory,
				"dgemvSpec.c"));
		compareConfiguration.setImplSourceFile(new File(rootDirectory,
				"dgemvImpl.c"));
		compareConfiguration.setSpecNumProcs(1);
		compareConfiguration.setImplNumProcs(1);
		compareConfiguration.setErrorBound(10);
		compareConfiguration.setReductionStrategy(ReductionStrategy.URGENT);
		compareConfiguration.setDeadlockStrategy(DeadlockStrategy.IGNORE);
		pair = ModelExtractor.extractModelPair(compareConfiguration);
		specModel = pair.spec();
		implModel = pair.impl();
		assertFalse(Comparison.compare(specModel, implModel,
				compareConfiguration, true));
	}

	@Test
	@Ignore
	// problem here is trace is too big.   need to simplify trace output.
	public void testCompareReverse() throws IOException, SyntaxException {
		ModelIF specModel, implModel;
		ModelPair pair;
		File rootDirectory = new File(Example.exampleDirectory, "dgemv");
		CompareConfiguration compareConfiguration = new CompareConfiguration(
				new File(rootDirectory, "TASSREP"));

		compareConfiguration.setSpecSourceFile(new File(rootDirectory,
				"dgemvSpec.c"));
		compareConfiguration.setImplSourceFile(new File(rootDirectory,
				"dgemvReverse.c"));
		compareConfiguration.setSpecModelName("dgemvSpec");
		compareConfiguration.setImplModelName("dgemvReverse");
		compareConfiguration.setSpecNumProcs(1);
		compareConfiguration.setImplNumProcs(1);
		compareConfiguration.setErrorBound(10);
		compareConfiguration.setReductionStrategy(ReductionStrategy.URGENT);
		compareConfiguration.setDeadlockStrategy(DeadlockStrategy.IGNORE);
		pair = ModelExtractor.extractModelPair(compareConfiguration);
		specModel = pair.spec();
		implModel = pair.impl();
		assertFalse(Comparison.compare(specModel, implModel,
				compareConfiguration, true));
	}
}
