Skip to content
Snippets Groups Projects
Commit 2a4bbd9d authored by hansen's avatar hansen
Browse files

Fixed bug: 'can not find config file'

parent b9012aff
No related branches found
No related tags found
No related merge requests found
...@@ -55,8 +55,7 @@ public class TLC4B { ...@@ -55,8 +55,7 @@ public class TLC4B {
if (TLC4BGlobals.isRunTLC()) { if (TLC4BGlobals.isRunTLC()) {
try { try {
TLCRunner.runTLC(tlc4b.machineFileNameWithoutFileExtension, TLCRunner.runTLC(tlc4b.machineFileNameWithoutFileExtension,
tlc4b.mainfile.getParentFile()); tlc4b.buildDir);
TLCResults results = new TLCResults(tlc4b.tlcOutputInfo); TLCResults results = new TLCResults(tlc4b.tlcOutputInfo);
results.evalResults(); results.evalResults();
tlc4b.printResults(results, TLC4BGlobals.isCreateTraceFile()); tlc4b.printResults(results, TLC4BGlobals.isCreateTraceFile());
...@@ -89,7 +88,8 @@ public class TLC4B { ...@@ -89,7 +88,8 @@ public class TLC4B {
String trace = results.getTrace(); String trace = results.getTrace();
String tracefileName = machineFileNameWithoutFileExtension String tracefileName = machineFileNameWithoutFileExtension
+ ".tla.trace"; + ".tla.trace";
File traceFile = createFile(mainfile.getParentFile(), tracefileName, trace, false); File traceFile = createFile(mainfile.getParentFile(),
tracefileName, trace, false);
if (traceFile != null) { if (traceFile != null) {
System.out.println("Trace file '" + traceFile.getAbsolutePath() System.out.println("Trace file '" + traceFile.getAbsolutePath()
+ "' created."); + "' created.");
...@@ -113,17 +113,14 @@ public class TLC4B { ...@@ -113,17 +113,14 @@ public class TLC4B {
System.err.println(e.getMessage()); System.err.println(e.getMessage());
throw e; throw e;
} }
// System.out.println(tlc4b.tlaModule);
if (TLC4BGlobals.isRunTLC()) { if (TLC4BGlobals.isRunTLC()) {
TLCRunner.runTLC(tlc4b.machineFileNameWithoutFileExtension, TLCRunner.runTLC(tlc4b.machineFileNameWithoutFileExtension,
tlc4b.buildDir); tlc4b.buildDir);
TLCResults results = new TLCResults(tlc4b.tlcOutputInfo); TLCResults results = new TLCResults(tlc4b.tlcOutputInfo);
results.evalResults(); results.evalResults();
// System.out.println("Result: " + results.getTLCResult());
tlc4b.printResults(results, false); tlc4b.printResults(results, false);
// System.out.println(results.getTrace());
System.exit(0); System.exit(0);
} }
...@@ -240,23 +237,18 @@ public class TLC4B { ...@@ -240,23 +237,18 @@ public class TLC4B {
+ "' can not be accessed."); + "' can not be accessed.");
} }
machineFileNameWithoutFileExtension = mainfile.getName().substring(0, machineFileNameWithoutFileExtension = mainfile.getName().substring(0,
mainfile.getName().length() - 4); // deleting .mch mainfile.getName().length() - 4); // deleting .mch
if (buildDir == null) { if (buildDir == null) {
buildDir = new File(mainfile.getParentFile(), buildDir = new File(mainfile.getParentFile(),
machineFileNameWithoutFileExtension); machineFileNameWithoutFileExtension);
} }
} }
private void createFiles() { private void createFiles() {
buildDir.mkdir(); boolean dirCreated = buildDir.mkdir();
if(TLC4BGlobals.isDeleteOnExit()){ if (dirCreated && TLC4BGlobals.isDeleteOnExit()) {
buildDir.deleteOnExit(); buildDir.deleteOnExit();
} }
...@@ -391,9 +383,9 @@ public class TLC4B { ...@@ -391,9 +383,9 @@ public class TLC4B {
boolean deleteOnExit) { boolean deleteOnExit) {
File file = new File(dir, fileName); File file = new File(dir, fileName);
boolean exists = false;
try { try {
file.createNewFile(); exists = file.createNewFile();
BufferedWriter out = new BufferedWriter(new OutputStreamWriter( BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(file), "UTF-8")); new FileOutputStream(file), "UTF-8"));
out.write(text); out.write(text);
...@@ -406,7 +398,7 @@ public class TLC4B { ...@@ -406,7 +398,7 @@ public class TLC4B {
} catch (IOException e) { } catch (IOException e) {
throw new TLC4BIOException(e.getMessage()); throw new TLC4BIOException(e.getMessage());
} finally { } finally {
if (deleteOnExit && file.exists()) { if (deleteOnExit && exists) {
file.deleteOnExit(); file.deleteOnExit();
} }
} }
......
...@@ -68,7 +68,6 @@ public class TLCRunner { ...@@ -68,7 +68,6 @@ public class TLCRunner {
// list.add("1"); // list.add("1");
String[] args = list.toArray(new String[list.size()]); String[] args = list.toArray(new String[list.size()]);
System.out.println("Starting JVM...");
final Process p = startJVM("", TLCRunner.class.getCanonicalName(), args); final Process p = startJVM("", TLCRunner.class.getCanonicalName(), args);
StreamGobbler stdOut = new StreamGobbler(p.getInputStream()); StreamGobbler stdOut = new StreamGobbler(p.getInputStream());
stdOut.start(); stdOut.start();
...@@ -97,12 +96,12 @@ public class TLCRunner { ...@@ -97,12 +96,12 @@ public class TLCRunner {
list.add("" + TLC4BGlobals.getWorkers()); list.add("" + TLC4BGlobals.getWorkers());
} }
list.add("-config"); //list.add("-config");
list.add(machineName + ".cfg"); //list.add(machineName + ".cfg");
list.add(machineName); list.add(machineName);
System.out.println(path.getPath());
ToolIO.setUserDir(path.getPath()); ToolIO.setUserDir(path.getPath());
String[] args = list.toArray(new String[list.size()]); String[] args = list.toArray(new String[list.size()]);
TLC tlc = new TLC(); TLC tlc = new TLC();
// handle parameters // handle parameters
......
...@@ -51,6 +51,9 @@ public class TLCResults { ...@@ -51,6 +51,9 @@ public class TLCResults {
} }
public int getModelCheckingTime() { public int getModelCheckingTime() {
if(endTime == null || startTime == null){
return -1;
}
return (int) (endTime.getTime() - startTime.getTime()) / 1000; return (int) (endTime.getTime() - startTime.getTime()) / 1000;
} }
......
...@@ -29,8 +29,8 @@ public class Testing2 extends AbstractParseMachineTest { ...@@ -29,8 +29,8 @@ public class Testing2 extends AbstractParseMachineTest {
@Test @Test
public void testRunTLC() throws Exception { public void testRunTLC() throws Exception {
String[] a = new String[] { machine.getPath() }; String[] a = new String[] { machine.getPath() };
// TLC4B.main(a); TLC4B.main(a);
TLC4B.test(a, false); //TLC4B.test(a, false);
// test(a); // test(a);
} }
......
INIT Init
NEXT Next
INVARIANT Invariant1
---- MODULE EnumerationError ----
EXTENDS Sequences
VARIABLES x
Invariant1 == x = <<1>>
Init == x \in Seq({1}) /\ x \o x = <<1, 1>>
Next == 1 = 2 /\ UNCHANGED <<x>>
====
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment