Exemple #1
0
  /**
   * ******************************************************************** UNION
   * ********************************************************************
   */
  @Test
  public void testUnion() throws Exception {
    ToolIO.reset();
    final String module =
        "-------------- MODULE Testing ----------------\n"
            + "ASSUME UNION {{1},{2}} = {1,2} \n"
            + "=================================";

    StringBuilder sb = TestUtil.translateString(module);
    final String expected = "MACHINE Testing\n" + "PROPERTIES union({{1},{2}}) = {1,2} \n" + "END";
    assertEquals(TestUtil.getTreeAsString(expected), TestUtil.getTreeAsString(sb.toString()));
  }
Exemple #2
0
  @Test
  public void testNotIn() throws Exception {
    ToolIO.reset();
    final String module =
        "-------------- MODULE Testing ----------------\n"
            + "ASSUME 1 \\notin {} \n"
            + "=================================";

    StringBuilder sb = TestUtil.translateString(module);
    final String expected = "MACHINE Testing\n" + "PROPERTIES 1 /: {} \n" + "END";
    assertEquals(TestUtil.getTreeAsString(expected), TestUtil.getTreeAsString(sb.toString()));
  }
Exemple #3
0
  /**
   * ******************************************************************** SUBSET: conforms POW in B
   * ********************************************************************
   */
  @Test
  public void testSubset() throws Exception {
    ToolIO.reset();
    final String module =
        "-------------- MODULE Testing ----------------\n"
            + "ASSUME {{},{1}} = SUBSET {1,2} \n"
            + "=================================";

    StringBuilder sb = TestUtil.translateString(module);
    final String expected = "MACHINE Testing\n" + "PROPERTIES {{},{1}} = POW({1,2}) \n" + "END";
    assertEquals(TestUtil.getTreeAsString(expected), TestUtil.getTreeAsString(sb.toString()));
  }
Exemple #4
0
  @Test
  public void testSetOfAll() throws Exception {
    ToolIO.reset();
    final String module =
        "-------------- MODULE Testing ----------------\n"
            + "EXTENDS Naturals \n"
            + "ASSUME {1} = {x + y+ 2:  x \\in {1,2}, y \\in {1} } \n"
            + "=================================";

    StringBuilder sb = TestUtil.translateString(module);
    final String expected =
        "MACHINE Testing\n"
            + "PROPERTIES {1} = {t_|#x, y.(x : {1, 2} & y : {1} & t_ = x + y + 2)} \n"
            + "END";
    assertEquals(TestUtil.getTreeAsString(expected), TestUtil.getTreeAsString(sb.toString()));
  }
Exemple #5
0
  @Test
  public void testSetEnumeration2() throws Exception {
    ToolIO.reset();
    final String module =
        "-------------- MODULE Testing ----------------\n"
            + "CONSTANTS k\n"
            + "ASSUME k = {TRUE, 1 = 1}\n"
            + "=================================";

    StringBuilder sb = TestUtil.translateString(module);
    final String expected =
        "MACHINE Testing\n"
            + "ABSTRACT_CONSTANTS k\n"
            + "PROPERTIES k : POW(BOOL) & k = {TRUE, bool(1=1)} \n"
            + "END";
    assertEquals(TestUtil.getTreeAsString(expected), TestUtil.getTreeAsString(sb.toString()));
  }
Exemple #6
0
  /**
   * ******************************************************************** Set Enumeration: {1,2,3}
   * ********************************************************************
   */
  @Test
  public void testSetEnumeration() throws Exception {
    ToolIO.reset();
    final String module =
        "-------------- MODULE Testing ----------------\n"
            + "CONSTANTS k\n"
            + "ASSUME k = {1,2,3}\n"
            + "=================================";

    StringBuilder sb = TestUtil.translateString(module);
    System.out.println(sb);
    final String expected =
        "MACHINE Testing\n"
            + "ABSTRACT_CONSTANTS k\n"
            + "PROPERTIES k : POW(INTEGER) & k = {1,2,3} \n"
            + "END";
    assertEquals(TestUtil.getTreeAsString(expected), TestUtil.getTreeAsString(sb.toString()));
  }
Exemple #7
0
 static {
   ToolIO.setMode(ToolIO.TOOL);
 }
Exemple #8
0
 /**
  * Sets resolver for the file names
  *
  * @param resolver a resolver for the names, if <code>null</code> is used, the standard resolver
  *     {@link SimpleFilenameToStream} is used
  */
 public void setResolver(FilenameToStream resolver) {
   this.resolver = resolver;
   ToolIO.setDefaultResolver(resolver);
 }
Exemple #9
0
  /** The processing method */
  public void process() {
    ToolIO.cleanToolObjects(TLCGlobals.ToolId);
    // UniqueString.initialize();

    // a JMX wrapper that exposes runtime statistics
    TLCStandardMBean modelCheckerMXWrapper = TLCStandardMBean.getNullTLCStandardMBean();

    // SZ Feb 20, 2009: extracted this method to separate the
    // parameter handling from the actual processing
    try {
      // Initialize:
      if (fromChkpt != null) {
        // We must recover the intern var table as early as possible
        UniqueString.internTbl.recover(fromChkpt);
      }
      if (cleanup && fromChkpt == null) {
        // clean up the states directory only when not recovering
        FileUtil.deleteDir(TLCGlobals.metaRoot, true);
      }
      FP64.Init(fpIndex);

      // Start checking:
      if (isSimulate) {
        // random simulation
        RandomGenerator rng = new RandomGenerator();
        if (noSeed) {
          seed = rng.nextLong();
          rng.setSeed(seed);
        } else {
          rng.setSeed(seed, aril);
        }
        MP.printMessage(EC.TLC_MODE_SIMU, String.valueOf(seed));
        Simulator simulator =
            new Simulator(
                mainFile,
                configFile,
                null,
                deadlock,
                traceDepth,
                Long.MAX_VALUE,
                rng,
                seed,
                true,
                resolver,
                specObj);
        // The following statement moved to Spec.processSpec by LL on 10 March 2011
        //                MP.printMessage(EC.TLC_STARTING);
        instance = simulator;
        simulator.simulate();
      } else {
        // model checking
        MP.printMessage(EC.TLC_MODE_MC);

        AbstractChecker mc = null;
        if (TLCGlobals.DFIDMax == -1) {
          mc =
              new ModelChecker(
                  mainFile,
                  configFile,
                  dumpFile,
                  deadlock,
                  fromChkpt,
                  resolver,
                  specObj,
                  (long) fpMemSize,
                  fpBits);
          TLCGlobals.mainChecker = (ModelChecker) mc;
          modelCheckerMXWrapper = new ModelCheckerMXWrapper((ModelChecker) mc);
        } else {
          mc =
              new DFIDModelChecker(
                  mainFile, configFile, dumpFile, deadlock, fromChkpt, true, resolver, specObj);
        }
        // The following statement moved to Spec.processSpec by LL on 10 March 2011
        //                MP.printMessage(EC.TLC_STARTING);
        instance = mc;
        mc.modelCheck();
      }
    } catch (Throwable e) {
      if (e instanceof StackOverflowError) {
        System.gc();
        MP.printError(EC.SYSTEM_STACK_OVERFLOW, e);
      } else if (e instanceof OutOfMemoryError) {
        System.gc();
        MP.printError(EC.SYSTEM_OUT_OF_MEMORY, e);
      } else if (e instanceof RuntimeException) {
        // SZ 29.07.2009
        // printing the stack trace of the runtime exceptions
        MP.printError(EC.GENERAL, e);
        // e.printStackTrace();
      } else {
        MP.printError(EC.GENERAL, e);
      }
    } finally {
      modelCheckerMXWrapper.unregister();
      MP.printMessage(EC.TLC_FINISHED);
      MP.flush();
    }
  }