package adder;

import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.FileNotFoundException;

import org.junit.BeforeClass;
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.verify.Comparison;

public class AdderTest {

	private static ModelIF specModel, implModel;
	private static CompareConfiguration compareConfiguration;
	private static int nprocs = 10;

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
		ModelPair pair;
		File rootDirectory = new File(Example.exampleDirectory, "adder");

		compareConfiguration = new CompareConfiguration(new File(rootDirectory,
				"TASSREP"));

		// turn on debugging....
		// compareConfiguration.setDebugOut(compareConfiguration.out());
		// compareConfiguration.setVerbose(true);

		compareConfiguration.setReductionStrategy(ReductionStrategy.URGENT);
		compareConfiguration.setDeadlockStrategy(DeadlockStrategy.POTENTIAL);
		compareConfiguration.setSpecSourceFile(new File(rootDirectory,
				"adder_seq.c"));
		compareConfiguration.setImplSourceFile(new File(rootDirectory,
				"adder_par.c"));
		compareConfiguration.setInput("B", 10);
		compareConfiguration.setSpecNumProcs(1);
		compareConfiguration.setImplNumProcs(nprocs);
		compareConfiguration.setSpecModelName("adder_seq");
		compareConfiguration.setImplModelName("adder_par");
		pair = ModelExtractor.extractModelPair(compareConfiguration);
		specModel = pair.spec();
		implModel = pair.impl();
	}

	@Test
	public void testCompare() throws FileNotFoundException {
		assertTrue(Comparison.compare(specModel, implModel,
				compareConfiguration, true));
	}
}
