Commit 61e4dd14 authored by Jonathan Shahen's avatar Jonathan Shahen

Lots of iterative work to find the bug....currently it looks like it is the...

Lots of iterative work to find the bug....currently it looks like it is the NuSMV version 2.5.4 that is buggy, but these bug hunt changes do provide much needed cleanup to the code (see the singleton MohawkSettings)
parent d3d07284
......@@ -11,6 +11,7 @@ import mohawk.global.formatter.MohawkConsoleFormatter;
import mohawk.global.results.MohawkResults;
import mohawk.global.timing.MohawkTiming;
import mohawk.helper.SMVSpecHelper;
import mohawk.singleton.MohawkSettings;
import mohawk.testing.TestingSuite;
/**
......@@ -25,23 +26,10 @@ public class MohawkInstance {
// Logger Fields
public static final Logger logger = Logger.getLogger("mohawk");
private String Logger_filepath = "mohawk.csv";
private String Logger_folderpath = "logs";
private ConsoleHandler consoleHandler = new ConsoleHandler();
private Level LoggerLevel;
private FileHandler fileHandler;
private Boolean WriteCSVFileHeader = true;
private String resultsFile = "logs/MohawkResults.csv";
private String timingFile = "logs/MohawkTiming.csv";
// Reference
private String NuSMV_filepath = "NuSMV";
// Helpers
private MohawkResults results;
private MohawkTiming timing;
private TestingSuite tests;
private SMVSpecHelper SMV_helper = new SMVSpecHelper();
private MohawkSettings settings = MohawkSettings.getInstance();
public ConsoleHandler consoleHandler = new ConsoleHandler();
public FileHandler fileHandler;
public int run(String[] args) {
try {
......@@ -65,22 +53,21 @@ public class MohawkInstance {
// Execute the test cases
if (cmd.hasOption(OptionString.RUN.toString())) {
logger.info("[ACTION] Run paramter detected");
results = new MohawkResults();
timing = new MohawkTiming();
tests = new TestingSuite(SMV_helper, results, timing);
tests.testingResultsFile = resultsFile;
tests.skipRefine = SMV_helper.skipRefine;
settings.results = new MohawkResults();
settings.timing = new MohawkTiming();
settings.smvHelper = new SMVSpecHelper();
settings.tests = new TestingSuite();
if (cmd.hasOption(OptionString.NOSLICING.toString())) {
logger.fine("[OPTION] RBAC Slicing is OFF");
tests.sliceRBAC = false;
settings.sliceRBAC = false;
} else {
logger.fine("[OPTION] RBAC Slicing is ON");
}
if (cmd.hasOption(OptionString.SLICEQUERY.toString())) {
logger.fine("[OPTION] RBAC Query Slicing is ON");
tests.sliceRBACQuery = true;
settings.sliceRBACQuery = true;
} else {
logger.fine("[OPTION] RBAC Query Slicing is OFF");
}
......@@ -89,24 +76,24 @@ public class MohawkInstance {
switch (runVal) {
case "all":
logger.info("[ALL ACTION] Will convert and then execute the testcase provided");
tests.runTests();
settings.tests.runTests();
break;
case "smv":
logger.info("[SMV ACTION] Will only convert the testcase provided");
tests.onlyConvertSpecToSmvFormat();
settings.tests.onlyConvertSpecToSmvFormat();
break;
case "dia":
logger.info("[DIA ACTION] Will only calculate the estimated diameter of the testcase provided");
tests.calculateDiameter();
settings.tests.calculateDiameter();
break;
default:
logger.severe("The Run Option '" + runVal + "' has not been implemented. "
+ "Please see use 'mohawk -help' to see which Run Options have been implemented");
}
tests.done();
logger.info("[TIMING] " + tests.timing);
tests.timing.writeOut(new File(timingFile), false);
settings.tests.done();
logger.info("[TIMING] " + settings.timing.toString());
settings.timing.writeOut(new File(settings.timingResultsFile), false);
}
} catch (ParseException e) {
StringWriter errors = new StringWriter();
......@@ -133,15 +120,15 @@ public class MohawkInstance {
}
public Level getLoggerLevel() {
return LoggerLevel;
return settings.LoggerLevel;
}
public TestingSuite getTestingSuite() {
return tests;
return settings.tests;
}
public void setLoggerLevel(Level loggerLevel) {
LoggerLevel = loggerLevel;
settings.LoggerLevel = loggerLevel;
}
@SuppressWarnings("static-access")
......@@ -167,7 +154,7 @@ public class MohawkInstance {
"The filepath where the log file should be created; "
+ "No file will be created when equal to 'n'; "
+ "A unique filename will be created when equal to 'u'; "
+ "default it creates a log called '" + Logger_filepath + "'")
+ "default it creates a log called '" + settings.Logger_filepath + "'")
.hasArg()
.create(OptionString.LOGFILE.toString()));
......@@ -208,7 +195,7 @@ public class MohawkInstance {
.withDescription(
"The file/folder path where the SMV file(s) should be created; "
+ "Only temporary files will be used when equal to 'n'; "
+ "by default it creates a SMV called '" + SMV_helper.smvFilepath + "'")
+ "by default it creates a SMV called '" + settings.smvFilepath + "'")
.hasArg()
.create(OptionString.SMVFILE.toString()));
......@@ -216,7 +203,7 @@ public class MohawkInstance {
.withArgName("extension")
.withDescription(
"File extention used when searching for SPEC files when the 'bulk' option is used. Default:'"
+ SMV_helper.specFileExt + "'")
+ settings.specFileExt + "'")
.hasArg().create(OptionString.SPECEXT.toString()));
// Add Functional Options
......@@ -241,7 +228,7 @@ public class MohawkInstance {
.withArgName("seconds")
.withDescription(
"The timeout time in seconds for Mohawk's refinement loop. Default: "
+ SMV_helper.TIMEOUT_SECONDS)
+ settings.TIMEOUT_SECONDS)
.hasArg().create(OptionString.TIMEOUT.toString()));
// Add Actionable Options
......@@ -284,29 +271,29 @@ public class MohawkInstance {
if (cmd.hasOption(OptionString.SMVFILE.toString())) {
if (cmd.getOptionValue(OptionString.SMVFILE.toString()).equals("n")) {
logger.fine("[OPTION] Using temporary SMV Files - will be deleted after each use");
SMV_helper.smvDeleteFile = true;
settings.smvDeleteFile = true;
} else {
logger.fine("[OPTION] Using a specific SMV File: "
+ cmd.getOptionValue(OptionString.SMVFILE.toString()));
SMV_helper.smvFilepath = cmd.getOptionValue(OptionString.SMVFILE.toString());
settings.smvFilepath = cmd.getOptionValue(OptionString.SMVFILE.toString());
}
} else {
logger.fine("[OPTION] No SMV Filename included, saving file under: " + SMV_helper.smvFilepath);
logger.fine("[OPTION] No SMV Filename included, saving file under: " + settings.smvFilepath);
}
// Turn off refining of the RBAC File
if (cmd.hasOption(OptionString.SKIPREFINE.toString())) {
logger.fine("[OPTION] RBAC Role Refining is OFF");
SMV_helper.skipRefine = true;
settings.skipRefine = true;
} else {
logger.fine("[OPTION] RBAC Role Refining is ON");
SMV_helper.skipRefine = false;
settings.skipRefine = false;
}
// Grab the SPEC file
if (cmd.hasOption(OptionString.SPECFILE.toString())) {
logger.fine("[OPTION] Using a specific SPEC File: " + cmd.getOptionValue(OptionString.SPECFILE.toString()));
SMV_helper.specFile = cmd.getOptionValue(OptionString.SPECFILE.toString());
settings.specFile = cmd.getOptionValue(OptionString.SPECFILE.toString());
} else {
logger.fine("[OPTION] No Spec File included");
}
......@@ -314,15 +301,15 @@ public class MohawkInstance {
if (cmd.hasOption(OptionString.SPECEXT.toString())) {
logger.fine("[OPTION] Using a specific SPEC File Extension: "
+ cmd.getOptionValue(OptionString.SPECEXT.toString()));
SMV_helper.specFileExt = cmd.getOptionValue(OptionString.SPECEXT.toString());
settings.specFileExt = cmd.getOptionValue(OptionString.SPECEXT.toString());
} else {
logger.fine("[OPTION] Using the default SPEC File Extension: " + SMV_helper.specFileExt);
logger.fine("[OPTION] Using the default SPEC File Extension: " + settings.specFileExt);
}
// Load more than one file from the SPEC File?
if (cmd.hasOption(OptionString.BULK.toString())) {
logger.fine("[OPTION] Bulk SPEC File inclusion: Enabled");
SMV_helper.bulk = true;
settings.bulk = true;
} else {
logger.fine("[OPTION] Bulk SPEC File inclusion: Disabled");
}
......@@ -331,13 +318,13 @@ public class MohawkInstance {
if (cmd.hasOption(OptionString.MODE.toString())) {
switch (cmd.getOptionValue(OptionString.MODE.toString())) {
case "bmc":
SMV_helper.mode = 1;
settings.mode = 1;
break;
case "smc":
SMV_helper.mode = 2;
settings.mode = 2;
break;
case "both":
SMV_helper.mode = 3;
settings.mode = 3;
break;
default:
logger.severe("[ERROR] Unknown mode: '" + cmd.getOptionValue(OptionString.MODE.toString()) + "'");
......@@ -347,7 +334,7 @@ public class MohawkInstance {
// Load more than one file from the SPEC File?
if (cmd.hasOption(OptionString.TIMEOUT.toString())) {
logger.fine("[OPTION] Timeout: " + cmd.getOptionValue(OptionString.TIMEOUT.toString()) + " seconds");
SMV_helper.TIMEOUT_SECONDS = new Long(cmd.getOptionValue(OptionString.TIMEOUT.toString()));
settings.TIMEOUT_SECONDS = new Long(cmd.getOptionValue(OptionString.TIMEOUT.toString()));
} else {
logger.fine("[OPTION] Bulk SPEC File inclusion: Disabled");
}
......@@ -395,13 +382,13 @@ public class MohawkInstance {
}
}
logger.setLevel(LoggerLevel);
consoleHandler.setLevel(LoggerLevel);
logger.setLevel(settings.LoggerLevel);
consoleHandler.setLevel(settings.LoggerLevel);
logger.addHandler(consoleHandler);
// Add CSV File Headers
if (cmd.hasOption(OptionString.NOHEADER.toString())) {
WriteCSVFileHeader = false;
settings.WriteCSVFileHeader = false;
}
// Set Logger Folder
......@@ -413,7 +400,7 @@ public class MohawkInstance {
}
if (logfile.isDirectory()) {
Logger_folderpath = cmd.getOptionValue(OptionString.LOGFOLDER.toString());
settings.Logger_folderpath = cmd.getOptionValue(OptionString.LOGFOLDER.toString());
} else {
logger.severe("logfolder did not contain a folder that exists or that could be created!");
}
......@@ -424,22 +411,22 @@ public class MohawkInstance {
// Check if no log file was requested
if (cmd.getOptionValue(OptionString.LOGFILE.toString()).equals("n")) {
// Create no log file
Logger_filepath = "";
settings.Logger_filepath = "";
} else if (cmd.getOptionValue(OptionString.LOGFILE.toString()).equals("u")) {
// Create a unique log file
Logger_filepath = "mohawk-log.%u.%g.txt";
settings.Logger_filepath = "mohawk-log.%u.%g.txt";
} else {
try {
// Create a log file with a specific name
File logfile = new File(Logger_folderpath + File.separator
File logfile = new File(settings.Logger_folderpath + File.separator
+ cmd.getOptionValue(OptionString.LOGFILE.toString()));
if (!logfile.exists()) {
logfile.createNewFile();
}
Logger_filepath = logfile.getAbsolutePath();
settings.Logger_filepath = logfile.getAbsolutePath();
if (WriteCSVFileHeader) {
if (settings.WriteCSVFileHeader) {
FileOutputStream writer = new FileOutputStream(logfile, true);// Always append!
writer.write(MohawkCSVFileFormatter.csvHeaders().getBytes());
writer.flush();
......@@ -453,10 +440,11 @@ public class MohawkInstance {
}
}
// Add Logger File Handler
if (!Logger_filepath.isEmpty()) {
File f = new File(Logger_folderpath + File.separator);
if (!settings.Logger_filepath.isEmpty()) {
File f = new File(settings.Logger_folderpath + File.separator);
f.mkdirs();
fileHandler = new FileHandler(Logger_folderpath + File.separator + Logger_filepath, true);
fileHandler = new FileHandler(
settings.Logger_folderpath + File.separator + settings.Logger_filepath, true);
fileHandler.setLevel(getLoggerLevel());
fileHandler.setFormatter(new MohawkCSVFileFormatter());
logger.addHandler(fileHandler);
......@@ -475,15 +463,16 @@ public class MohawkInstance {
return true;
}
if (cmd.hasOption("numsmv")) {
logger.info("Running with the 'nusmv' Custom Configuration. " + "Changing the path from '" + NuSMV_filepath
if (cmd.hasOption(OptionString.NUSMVPATH.toString())) {
logger.info("Running with the 'nusmv' Custom Configuration. " + "Changing the path from '"
+ settings.getNuSMV_filepath()
+ "' to '" + cmd.getOptionValue(OptionString.NUSMVPATH.toString()) + "'");
NuSMV_filepath = cmd.getOptionValue(OptionString.NUSMVPATH.toString());
settings.setNuSMV_filepath(cmd.getOptionValue(OptionString.NUSMVPATH.toString()));
}
if (cmd.hasOption(OptionString.CHECKNUSMV.toString())) {
try {
logger.fine("[OPTION] Checking the NuSMV version number");
String[] commands = { NuSMV_filepath, "-help" };
String[] commands = { settings.getNuSMV_filepath(), "-help" };
ProcessBuilder pb = new ProcessBuilder(commands);
pb.redirectErrorStream(true);// REQUIRED: NuSVM uses STDERR
// will throw error if it cannot find NuSMV
......@@ -501,7 +490,7 @@ public class MohawkInstance {
}
} else {
logger.warning("No output was given by NuSMV, " + "maybe the commandline arguments have changed "
+ "or the file " + NuSMV_filepath + " points to the wrong file");
+ "or the file " + settings.getNuSMV_filepath() + " points to the wrong file");
}
} catch (IOException e) {
logger.severe("No Version of NuSMV was found, " + "please check that NuSMV is on the PATH.");
......@@ -515,8 +504,8 @@ public class MohawkInstance {
private void setupResultOptions(CommandLine cmd, Options options) {
if (cmd.hasOption(OptionString.RESULTSFILE.toString())) {
logger.fine("[OPTION] Changing the results file");
resultsFile = cmd.getOptionValue(OptionString.RESULTSFILE.toString());
settings.testingResultsFile = cmd.getOptionValue(OptionString.RESULTSFILE.toString());
}
logger.info("Results File: " + resultsFile);
logger.info("Results File: " + settings.testingResultsFile);
}
}
......@@ -8,28 +8,21 @@ import mohawk.output.WriteNuSMV;
import mohawk.rbac.RBACInstance;
import mohawk.rbac.RBACSpecReader;
import mohawk.refine.RolesAbsRefine;
import mohawk.singleton.MohawkSettings;
import mohawk.slicer.RoleSlicer;
import mohawk.slicer.SliceQueryRole;
public class SMVSpecHelper {
public final static Logger logger = Logger.getLogger("mohawk");
public String smvFilepath = "latestRBAC2SMV.smv";
public String specFile = "";
public String specFileExt = ".mohawk";
private MohawkSettings settings = MohawkSettings.getInstance();
public ArrayList<File> specFiles = new ArrayList<File>();
public int mode = 3;// 1 for bmc, 2 for smc, 3 for both
public Long TIMEOUT_SECONDS = (long) 0;// Default infinite
public boolean bulk = false;
public Boolean smvDeleteFile = false;
public boolean sliceRBAC = true;
public boolean sliceRBACQuery = false;
public boolean skipRefine = true;
public void loadSpecFiles() throws IOException {
if (this.bulk == true) {
this.loadSpecFilesFromFolder(this.specFile);
if (settings.bulk == true) {
this.loadSpecFilesFromFolder(settings.specFile);
} else {
this.addSpecFile(this.specFile);
this.addSpecFile(settings.specFile);
}
}
......@@ -50,7 +43,7 @@ public class SMVSpecHelper {
}
for (File f : folder.listFiles()) {
if (f.getName().endsWith(specFileExt)) {
if (f.getName().endsWith(settings.specFileExt)) {
logger.fine("Adding file to specFiles: " + f.getAbsolutePath());
specFiles.add(f);
}
......@@ -96,7 +89,7 @@ public class SMVSpecHelper {
RBACSpecReader reader = new RBACSpecReader(specFile.getAbsolutePath());
RBACInstance rbac = reader.getRBAC();
if (sliceRBAC) {
if (settings.sliceRBAC) {
logger.info("[Slicing] Slicing the Spec File");
RoleSlicer roleslicer = new RoleSlicer(rbac);
......@@ -106,14 +99,14 @@ public class SMVSpecHelper {
+ (rbac.getCA().size() + rbac.getCR().size()));
}
if (sliceRBACQuery) {
if (settings.sliceRBACQuery) {
logger.info("[Slicing] Slicing the Spec's Query");
SliceQueryRole scRole = new SliceQueryRole(rbac);
rbac = scRole.getSlicedPolicy();
}
if (skipRefine) {
if (settings.skipRefine) {
nusmv.fillAttributes(rbac);
} else {
RolesAbsRefine absrefine = new RolesAbsRefine(rbac);
......@@ -140,7 +133,7 @@ public class SMVSpecHelper {
public File getSmvFile(File specFile) {
File nusmvFile = null;
if (smvDeleteFile) {
if (settings.smvDeleteFile) {
try {
nusmvFile = File.createTempFile("smvTempFile", ".smv");
} catch (IOException e) {
......@@ -150,10 +143,10 @@ public class SMVSpecHelper {
return nusmvFile;
}
if (bulk) {
if (settings.bulk) {
nusmvFile = new File(specFile.getAbsolutePath() + ".smv");
} else {
nusmvFile = new File(smvFilepath);
nusmvFile = new File(settings.smvFilepath);
}
if (!nusmvFile.exists()) {
......
package mohawk.singleton;
import java.util.logging.Level;
import mohawk.global.nusmv.NuSMV;
import mohawk.global.results.MohawkResults;
import mohawk.global.results.TestingResult;
import mohawk.global.timing.MohawkTiming;
import mohawk.helper.SMVSpecHelper;
import mohawk.testing.TestingSuite;
public class MohawkSettings {
private static volatile MohawkSettings _instance = null;
public String Logger_filepath = "mohawk.csv";
public String Logger_folderpath = "logs";
public Level LoggerLevel;
public Boolean WriteCSVFileHeader = true;
public String timingResultsFile = "logs/mohawkTimingResults.csv";
public String testingResultsFile = "logs/mohawkTestingResults.csv";
public String smvFilepath = "latestRBAC2SMV.smv";
// Reference
protected String NuSMV_filepath = "NuSMV";
public String getNuSMV_filepath() {
return NuSMV_filepath;
}
public void setNuSMV_filepath(String nuSMV_filepath) {
NuSMV_filepath = nuSMV_filepath;
NuSMV.NuSMVProcessName = nuSMV_filepath;
}
// Helpers
public MohawkResults results;
public MohawkTiming timing;
public TestingSuite tests;
public SMVSpecHelper smvHelper;
public TestingResult lastResult;
// SMV
public Long TIMEOUT_SECONDS = (long) 0;// Default infinite
public boolean bulk = false;
public Boolean smvDeleteFile = false;
public String specFile = "";
public String specFileExt = ".mohawk";
public int mode = 3;// 1 for bmc, 2 for smc, 3 for both
/**
* Flag for Slicing the RBAC Specification file before entering the Refinement Loop
*/
public boolean sliceRBAC = true;
/**
* Flag for Slicing the RBAC Specification Query before entering the Refinement Loop
*/
public boolean sliceRBACQuery = false;
/**
* Flag for skipping the abstraction-refinement step
*/
public boolean skipRefine = false;
protected MohawkSettings() {
}
public static MohawkSettings getInstance() {
if (_instance == null) {
_instance = new MohawkSettings();
}
return _instance;
}
@Override
public String toString() {
StringBuilder s = new StringBuilder();
s.append("MohawkSettings{");
s.append("sliceRBAC: ").append(sliceRBAC).append("; ");
s.append("sliceRBACQuery: ").append(sliceRBACQuery).append("; ");
s.append("skipRefine: ").append(skipRefine).append("; ");
s.append("NuSMV_filepath: ").append(NuSMV_filepath);
s.append("}");
return s.toString();
}
}
......@@ -6,6 +6,7 @@ import org.junit.Test;
import mohawk.MohawkInstance;
import mohawk.global.results.ExecutionResult;
import mohawk.singleton.MohawkSettings;
/**
* Run these JUnit tests before adding any branch to master
......@@ -25,7 +26,7 @@ public class MohawkRegressionTests {
MohawkInstance mohawk = new MohawkInstance();
mohawk.run(params(param));
assertEquals("The result was not correct!", expectedResult, mohawk.getTestingSuite().lastResult);
assertEquals("The result was not correct!", expectedResult, MohawkSettings.getInstance().lastResult);
}
@Test
......@@ -36,7 +37,7 @@ public class MohawkRegressionTests {
MohawkInstance mohawk = new MohawkInstance();
mohawk.run(params(param));
assertEquals("The result was not correct!", expectedResult, mohawk.getTestingSuite().lastResult);
assertEquals("The result was not correct!", expectedResult, MohawkSettings.getInstance().lastResult);
}
@Test
......@@ -47,7 +48,7 @@ public class MohawkRegressionTests {
MohawkInstance mohawk = new MohawkInstance();
mohawk.run(params(param));
assertEquals("The result was not correct!", expectedResult, mohawk.getTestingSuite().lastResult);
assertEquals("The result was not correct!", expectedResult, MohawkSettings.getInstance().lastResult);
}
@Test
......@@ -58,7 +59,7 @@ public class MohawkRegressionTests {
MohawkInstance mohawk = new MohawkInstance();
mohawk.run(params(param));
assertEquals("The result was not correct!", expectedResult, mohawk.getTestingSuite().lastResult);
assertEquals("The result was not correct!", expectedResult, MohawkSettings.getInstance().lastResult);
}
private String[] params(String param) {
......
package mohawk.testing;
import java.io.IOException;
import java.util.concurrent.Callable;
import java.util.logging.Logger;
import mohawk.global.results.ExecutionResult;
import mohawk.global.results.TestingResult;
import mohawk.output.WriteRBACSpec;
import mohawk.refine.RolesAbsRefine;
import mohawk.singleton.MohawkSettings;
public class TestRunner implements Callable<ExecutionResult> {
public class TestRunner implements Callable<TestingResult> {
public final static Logger logger = Logger.getLogger("mohawk");
public RolesAbsRefine absrefine = null;
public Boolean skipRefine = false;
private MohawkSettings settings = MohawkSettings.getInstance();
public TestRunner(RolesAbsRefine absrefine, boolean skipRefine) {
public TestRunner(RolesAbsRefine absrefine) {
this.absrefine = absrefine;
this.skipRefine = skipRefine;
}
@Override
public ExecutionResult call() throws Exception {
public TestingResult call() throws Exception {
ExecutionResult result = null;
if (skipRefine) {
if (settings.skipRefine) {
try {
WriteRBACSpec writer = new WriteRBACSpec("rbac.st");
writer.Write2File(absrefine.getInputRBACInstance(), "logs/rbacinstancefile" + 1 + ".txt");
} catch (IOException e1) {
e1.printStackTrace();
}
logger.info("[TestRunner] Skipping the Abstraction-Refinement Step");
Boolean counterExampleFound = absrefine.getResult(absrefine.getInputRBACInstance(), 1);
......@@ -35,7 +45,7 @@ public class TestRunner implements Callable<ExecutionResult> {
logger.info("[TestRunner] Running the Abstraction-Refinement Step");
result = absrefine.absrefineloop();
}
return result;
return new TestingResult(result, (long) 0, "", "Return Result: " + absrefine.getReturnValue());
}
}
......@@ -8,57 +8,32 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import mohawk.global.pieces.mohawk.NuSMVMode;
import mohawk.global.results.*;
import mohawk.global.timing.MohawkTiming;
import mohawk.helper.SMVSpecHelper;
import mohawk.global.results.ExecutionResult;
import mohawk.global.results.TestingResult;
import mohawk.math.CalculateDiameter;
import mohawk.rbac.RBACInstance;
import mohawk.rbac.RBACSpecReader;
import mohawk.refine.RolesAbsRefine;
import mohawk.singleton.MohawkSettings;
import mohawk.slicer.RoleSlicer;
import mohawk.slicer.SliceQueryRole;
public class TestingSuite {
public final static Logger logger = Logger.getLogger("mohawk");
private MohawkSettings settings = MohawkSettings.getInstance();
public MohawkResults results;
public MohawkTiming timing;
public SMVSpecHelper smvHelper;
public ExecutionResult lastResult;
public String timingResultsFile = "logs/mohawkTimingResults.csv";
public String testingResultsFile = "logs/mohawkTestingResults.csv";
/**
* Flag for Slicing the RBAC Specification file before entering the Refinement Loop
*/
public boolean sliceRBAC = true;
/**
* Flag for Slicing the RBAC Specification Query before entering the Refinement Loop
*/
public boolean sliceRBACQuery = false;
/**
* Flag for skipping the abstraction-refinement step
*/
public boolean skipRefine = false;
public TestingSuite(SMVSpecHelper smvHelper, MohawkResults results, MohawkTiming timing) {
this.smvHelper = smvHelper;
this.results = results;
this.timing = timing;
this.timing.startTimer("totalTime");
public TestingSuite() {
settings.timing.startTimer("totalTime");
}
public Boolean done() {
this.timing.stopTimer("totalTime");
settings.timing.stopTimer("totalTime");
boolean error = false;
File timingResults = new File(timingResultsFile);
File timingResults = new File(settings.timingResultsFile);
try {
this.timing.writeOut(timingResults);
settings.timing.writeOut(timingResults);
} catch (IOException e) {
logger.warning(
"[TIMING] Unable to save the Timing Results to the file: " + timingResults.getAbsolutePath());
......@@ -78,16 +53,16 @@ public class TestingSuite {
public void runTests() throws IOException {
logger.entering(getClass().getName(), "runTests()");
logger.info("[runTests] Results File: " + testingResultsFile);
FileWriter resultsFW = results.getFileWriter(new File(testingResultsFile), false);
logger.info("[runTests] Results File: " + settings.testingResultsFile);
FileWriter resultsFW = settings.results.getFileWriter(new File(settings.testingResultsFile), false);
if (resultsFW == null) {
logger.severe("[runTests] Unable to Create, or Write in, the results file: " + testingResultsFile);
throw new IOException("Unable to Create, or Write in, the results file: " + testingResultsFile);
logger.severe("[runTests] Unable to Create, or Write in, the results file: " + settings.testingResultsFile);
throw new IOException("Unable to Create, or Write in, the results file: " + settings.testingResultsFile);
}
ArrayList<NuSMVMode> modes = new ArrayList<NuSMVMode>();
switch (smvHelper.mode) {
switch (settings.mode) {
case 3:// Both
modes.add(NuSMVMode.SMC);
modes.add(NuSMVMode.BMC);
......@@ -99,24 +74,26 @@ public class TestingSuite {
modes.add(NuSMVMode.SMC);
break;
default:
logger.severe("[ERROR] Unknown mode = " + new Integer(smvHelper.mode));
logger.severe("[ERROR] Unknown mode = " + new Integer(settings.mode));