package matmat;

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.VerifyConfiguration;
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;
import edu.udel.cis.vsl.tass.verify.Verification;

public class Matmat_3_4_Test {
	private static ModelIF specModel, implModel;
	private static CompareConfiguration compareConfiguration;
	private static VerifyConfiguration specConfiguration, implConfiguration;

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

		compareConfiguration = new CompareConfiguration(new File(rootDirectory,
				"TASSREP"));
		compareConfiguration.setSpecSourceFile(new File(rootDirectory,
				"matmat-seq.c"));
		compareConfiguration.setImplSourceFile(new File(rootDirectory,
				"matmat-par.c"));
		compareConfiguration.setInput("L_BOUND", 3);
		compareConfiguration.setInput("M_BOUND", 3);
		compareConfiguration.setInput("N_BOUND", 3);
		compareConfiguration.setSpecNumProcs(1);
		compareConfiguration.setImplNumProcs(4);
		compareConfiguration.setSpecModelName("matmat-seq");
		compareConfiguration.setImplModelName("matmat-par");
		compareConfiguration.setReductionStrategy(ReductionStrategy.URGENT);
		compareConfiguration.setDeadlockStrategy(DeadlockStrategy.IGNORE);
		specConfiguration = compareConfiguration.specConfiguration();
		implConfiguration = compareConfiguration.implConfiguration();
		implConfiguration.setDeadlockStrategy(DeadlockStrategy.POTENTIAL);
		pair = ModelExtractor.extractModelPair(compareConfiguration);
		specModel = pair.spec();
		implModel = pair.impl();
	}

	@Test
	public void testVerifySpec() throws FileNotFoundException {
		assertTrue(Verification.verify(specModel, specConfiguration, true));
	}

	@Test
	public void testVerifyImpl() throws FileNotFoundException {
		assertTrue(Verification.verify(implModel, implConfiguration, true));
	}

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