Beispiel #1
0
  public void testTypedefNonStructUnion() {
    String testname = "testTypedefNonStructUnion";
    LogHandle log = LogFactory.getLogHandle(testname);
    SVCorePlugin.getDefault().enableDebug(false);
    String content =
        "module t;\n"
            + "typedef int unsigned uint32_t;\n"
            + "typedef short unsigned uint16_t;\n"
            + "uint32_t foo;\n"
            + "endmodule\n";
    String expected =
        "module t;\n"
            + "	typedef int unsigned uint32_t;\n"
            + "	typedef short unsigned uint16_t;\n"
            + "	uint32_t foo;\n"
            + "endmodule\n";
    log.debug("--> " + testname);

    SVIndentScanner scanner = new SVIndentScanner(new StringTextScanner(content));

    ISVIndenter indenter = SVCorePlugin.getDefault().createIndenter();
    indenter.init(scanner);
    indenter.setTestMode(true);

    String result = indenter.indent();

    log.debug("Result:");
    log.debug(result);
    IndentComparator.compare(testname, expected, result);
    log.debug("<-- " + testname);

    LogFactory.removeLogHandle(log);
  }
Beispiel #2
0
  public void testBasicCoverpoint() {
    SVCorePlugin.getDefault().enableDebug(false);
    String content =
        "class c1;\n"
            + "\n"
            + "covergroup cg1;\n"
            + "cp : coverpoint a {\n"
            + "bins ab[] = {1, 2, 3, 4};\n"
            + "}\n"
            + "endgroup\n"
            + "endclass\n";
    String expected =
        "class c1;\n"
            + "\n"
            + "	covergroup cg1;\n"
            + "		cp : coverpoint a {\n"
            + "			bins ab[] = {1, 2, 3, 4};\n"
            + "		}\n"
            + "	endgroup\n"
            + "endclass\n";

    SVIndentScanner scanner = new SVIndentScanner(new StringTextScanner(content));

    ISVIndenter indenter = SVCorePlugin.getDefault().createIndenter();
    indenter.init(scanner);
    indenter.setTestMode(true);

    String result = indenter.indent();

    fLog.debug("Result:");
    fLog.debug(result);
    IndentComparator.compare(getName(), expected, result);
  }
Beispiel #3
0
  public void testClass() {
    SVCorePlugin.getDefault().enableDebug(false);
    BundleUtils utils = new BundleUtils(SVCoreTestsPlugin.getDefault().getBundle());
    ByteArrayOutputStream bos;

    bos = utils.readBundleFile("/indent/class1.svh");

    String ref = bos.toString();
    StringBuilder sb = removeLeadingWS(ref);

    // Run the indenter over the reference source
    SVIndentScanner scanner = new SVIndentScanner(new StringTextScanner(sb));
    ISVIndenter indenter = SVCorePlugin.getDefault().createIndenter();
    indenter.init(scanner);
    indenter.setTestMode(true);

    StringBuilder result = new StringBuilder(indenter.indent(-1, -1));

    fLog.debug("Reference:\n" + ref);

    fLog.debug("===");
    fLog.debug("Result:\n" + result.toString());

    IndentComparator.compare("testClass", ref, result.toString());
  }
Beispiel #4
0
  public void testFunctionFirstItemComment() {
    String ref =
        "module foo;\n"
            + "	\n"
            + "	function automatic void foobar_f();\n"
            + "		// this is a comment\n"
            + "	endfunction\n"
            + "	a = 5;\n"
            + "endmodule\n";

    SVCorePlugin.getDefault().enableDebug(false);
    LogHandle log = LogFactory.getLogHandle("testFunctionFirstItemComment");

    // Run the indenter over the reference source
    SVIndentScanner scanner = new SVIndentScanner(new StringTextScanner(ref));
    ISVIndenter indenter = SVCorePlugin.getDefault().createIndenter();
    indenter.init(scanner);
    indenter.setTestMode(true);

    String result = indenter.indent(-1, -1);

    log.debug("Ref:\n" + ref);
    log.debug("====");
    log.debug("Result:\n" + result);
    log.debug("====");

    IndentComparator.compare(log, "testFunctionFirstItemComment", ref, result);
    LogFactory.removeLogHandle(log);
  }
Beispiel #5
0
  public void testForever() {
    String testname = "testForever";
    String ref =
        "module foo ();\n"
            + "	initial begin\n"
            + "		forever #1\n"
            + "		begin\n"
            + "			a=b;\n"
            + "		end\n"
            + "	end\n"
            + "endmodule\n";

    SVCorePlugin.getDefault().enableDebug(false);
    LogHandle log = LogFactory.getLogHandle(testname);

    // Run the indenter over the reference source
    SVIndentScanner scanner = new SVIndentScanner(new StringTextScanner(ref));
    ISVIndenter indenter = SVCorePlugin.getDefault().createIndenter();
    indenter.init(scanner);
    indenter.setTestMode(true);

    indenter.setAdaptiveIndent(true);
    indenter.setAdaptiveIndentEnd(5);
    String result = indenter.indent(-1, -1);

    log.debug("Ref:\n" + ref);
    log.debug("====");
    log.debug("Result:\n" + result);
    log.debug("====");

    IndentComparator.compare(log, testname, ref, result);
    LogFactory.removeLogHandle(log);
  }
Beispiel #6
0
  public void testFunctionComment() {
    String ref =
        "class my_class;\n"
            + "\n"
            + "	/**\n"
            + "	 * my_func\n"
            + "	 *\n"
            + "	 */\n"
            + "	function void foobar;\n"
            + "\n"
            + "	endfunction\n"
            + "\n"
            + "endclass\n";

    LogHandle log = LogFactory.getLogHandle("testFunctionComment");
    SVCorePlugin.getDefault().enableDebug(false);

    // Run the indenter over the reference source
    SVIndentScanner scanner = new SVIndentScanner(new StringTextScanner(ref));
    ISVIndenter indenter = SVCorePlugin.getDefault().createIndenter();
    indenter.init(scanner);
    indenter.setTestMode(true);

    String result = indenter.indent(-1, -1);

    log.debug("Ref:\n" + ref);
    log.debug("====");
    log.debug("Result:");
    log.debug(result);
    log.debug("====");

    IndentComparator.compare(log, "testFunctionComment", ref, result);
    LogFactory.removeLogHandle(log);
  }
Beispiel #7
0
  public void testRandomizeWith() {
    String ref =
        "class foo;\n"
            + "	virtual function void build_phase(uvm_phase phase);\n"
            + "		this.randomize(random_int) with\n"
            + "			{ random_int > 0;\n"
            + "				random_int<100;\n"
            + "			};\n"
            + "		this.randomize(random_int) with\n"
            + "			{ random_int > 0;\n"
            + "				random_int<100;\n"
            + "			};\n"
            + "	endfunction\n"
            + "endclass\n";

    SVCorePlugin.getDefault().enableDebug(false);

    // Run the indenter over the reference source
    SVIndentScanner scanner = new SVIndentScanner(new StringTextScanner(ref));
    ISVIndenter indenter = SVCorePlugin.getDefault().createIndenter();
    indenter.init(scanner);
    indenter.setTestMode(true);

    indenter.setAdaptiveIndent(true);
    indenter.setAdaptiveIndentEnd(5);
    String result = indenter.indent(-1, -1);

    fLog.debug("Ref:\n" + ref);
    fLog.debug("====");
    fLog.debug("Result:\n" + result);
    fLog.debug("====");

    IndentComparator.compare(fLog, getName(), ref, result);
  }
Beispiel #8
0
  public void testEmptyForkJoin() {
    String testname = "testEmptyForkJoin";
    String ref =
        "class foo;\n" + "	task bar();\n" + "		fork\n" + "		join\n" + "	endtask\n" + "endclass\n";

    SVCorePlugin.getDefault().enableDebug(false);
    LogHandle log = LogFactory.getLogHandle(testname);

    // Run the indenter over the reference source
    SVIndentScanner scanner = new SVIndentScanner(new StringTextScanner(ref));
    ISVIndenter indenter = SVCorePlugin.getDefault().createIndenter();
    indenter.init(scanner);
    indenter.setTestMode(true);

    indenter.setAdaptiveIndent(true);
    indenter.setAdaptiveIndentEnd(5);
    String result = indenter.indent(-1, -1);

    log.debug("Ref:\n" + ref);
    log.debug("====");
    log.debug("Result:\n" + result);
    log.debug("====");

    IndentComparator.compare(log, testname, ref, result);
    LogFactory.removeLogHandle(log);
  }
  @Override
  protected void tearDown() throws Exception {
    SVCorePlugin.getDefault().getSVDBIndexRegistry().close();
    SVCorePlugin.getJobMgr().dispose();

    super.tearDown();
  }
Beispiel #10
0
  public void testSpecifySpecparam() {
    SVCorePlugin.getDefault().enableDebug(false);
    String content =
        "module m;\n"
            + "\n"
            + "specify\n"
            + "if (someSig[0] == 1'b0)\n"
            + "(CLK => Q[15])=(1.000, 1.000);\n"
            + "if (someSig[0] == 1'b0)\n"
            + "(CLK => Q[15])=(1.000, 1.000);\n"
            + "endspecify\n"
            + "endmodule\n";
    String expected =
        "module m;\n"
            + "\n"
            + "	specify\n"
            + "		if (someSig[0] == 1'b0)\n"
            + "			(CLK => Q[15])=(1.000, 1.000);\n"
            + "		if (someSig[0] == 1'b0)\n"
            + "			(CLK => Q[15])=(1.000, 1.000);\n"
            + "	endspecify\n"
            + "endmodule\n";

    SVIndentScanner scanner = new SVIndentScanner(new StringTextScanner(content));

    ISVIndenter indenter = SVCorePlugin.getDefault().createIndenter();
    indenter.init(scanner);
    indenter.setTestMode(true);

    String result = indenter.indent();

    fLog.debug("Result:");
    fLog.debug(result);
    IndentComparator.compare(getName(), expected, result);
  }
Beispiel #11
0
  @Override
  protected void tearDown() throws Exception {
    super.tearDown();

    for (ITextEditor t : fEditors) {
      t.close(false);
    }

    // Wait for the editors to close
    while (Display.getDefault().readAndDispatch()) {}

    SVDBIndexRegistry rgy = SVCorePlugin.getDefault().getSVDBIndexRegistry();
    rgy.save_state();

    SVCorePlugin.getJobMgr().dispose();

    for (IProject p : fProjects) {
      TestUtils.deleteProject(p);
    }

    if (fTmpDir != null && fTmpDir.exists()) {
      TestUtils.delete(fTmpDir);
    }

    cleanupWorkspace();
  }
Beispiel #12
0
  public void testIfInFunction() {
    String ref =
        "class xbus_bus_monitor;\n"
            + // 1
            "\n"
            + // 2
            "		function void ignored();\n"
            + // 3
            "		endfunction\n"
            + // 4
            "\n"
            + // 5
            "		// perform_transfer_coverage\n"
            + // 6
            "		function void perform_transfer_coverage();\n"
            + "			if (trans_collected.read_write != NOP) begin\n"
            + "				-> cov_transaction;\n"
            + "				for (int unsigned i = 0; i < trans_collected.size; i++) begin\n"
            + "					addr = trans_collected.addr + i;\n"
            + "					data = trans_collected.data[i];\n"
            + "					wait_state = trans_collected.wait_state[i];\n"
            + "					-> cov_transaction_beat;\n"
            + "				end\n"
            + "			end\n"
            + "		endfunction : perform_transfer_coverage\n"
            + "\n"
            + "endclass : xbus_bus_monitor\n";

    SVCorePlugin.getDefault().enableDebug(false);
    LogHandle log = LogFactory.getLogHandle("testIfInFunction");

    // Run the indenter over the reference source
    SVIndentScanner scanner = new SVIndentScanner(new StringTextScanner(ref));
    ISVIndenter indenter = SVCorePlugin.getDefault().createIndenter();
    indenter.init(scanner);
    indenter.setTestMode(true);

    indenter.setAdaptiveIndent(true);
    indenter.setAdaptiveIndentEnd(5);
    String result = indenter.indent(-1, -1);

    log.debug("Ref:\n" + ref);
    log.debug("====");
    log.debug("Result:\n" + result);
    log.debug("====");

    IndentComparator.compare(log, "testIfInFunction", ref, result);
    LogFactory.removeLogHandle(log);
  }
Beispiel #13
0
  public void testMultiBlankLine() {
    LogHandle log = LogFactory.getLogHandle("testMultiBlankLine");
    String ref =
        "class my_component1 extends ovm_component;\n"
            + "	\n"
            + "	\n"
            + "	function new(string name, ovm_component parent);\n"
            + "		super.new(name, parent);\n"
            + "	endfunction\n"
            + "	\n"
            + "	\n"
            + "endclass\n";

    // Run the indenter over the reference source
    SVIndentScanner scanner = new SVIndentScanner(new StringTextScanner(ref));
    ISVIndenter indenter = SVCorePlugin.getDefault().createIndenter();
    indenter.init(scanner);
    indenter.setTestMode(true);

    String result = indenter.indent(-1, -1);

    log.debug("Ref:\n" + ref);
    log.debug("====");
    log.debug("Result:");
    log.debug(result);
    log.debug("====");

    IndentComparator.compare(log, "testMultiBlankLine", ref, result);
    LogFactory.removeLogHandle(log);
  }
  public void testCovergroupTypeOptionMergeInstances() {
    String doc =
        "class my_class1;\n"
            + // 1
            "\n"
            + "    covergroup foo;\n"
            + "        type_option.mer<<MARK>>\n"
            + "    endgroup\n"
            + "endclass\n";

    SVCorePlugin.getDefault().enableDebug(false);
    Tuple<SVDBFile, TextTagPosUtils> ini = contentAssistSetup(doc);

    StringBIDITextScanner scanner = new StringBIDITextScanner(ini.second().getStrippedData());
    TestCompletionProcessor cp = new TestCompletionProcessor(ini.first(), fIndexMgr);

    scanner.seek(ini.second().getPosMap().get("MARK"));

    ISVDBIndexIterator index_it = cp.getIndexIterator();
    SVDBIndexValidator v = new SVDBIndexValidator();

    v.validateIndex(index_it, SVDBIndexValidator.ExpectErrors);

    IndexTestUtils.assertFileHasElements(index_it, "my_class1" /*, "my_class1::foo"*/);

    cp.computeProposals(scanner, ini.first(), ini.second().getLineMap().get("MARK"));
    List<SVCompletionProposal> proposals = cp.getCompletionProposals();

    assertEquals(1, proposals.size());

    // TODO: at some point, my_class1 and my_class2 will not be proposals,
    // since they are types not variables
    validateResults(new String[] {"merge_instances"}, proposals);
  }
Beispiel #15
0
  public void testNoBlockIf() throws BadLocationException {
    AutoEditTester tester = UiReleaseTests.createAutoEditTester();
    SVCorePlugin.getDefault().enableDebug(false);

    tester.type("\n\n");
    tester.type("class foobar;\n");
    tester.type("\nfunction void foobar();\n");
    tester.type("if (foo)\n");
    tester.type("$display(\"Hello\");\n");
    tester.type("else\n");
    tester.type("$display(\"Goodbye\");\n");
    tester.type("$display(\"World\");\n");
    tester.type("endfunction\n\n");
    tester.type("endclass\n");

    String content = tester.getContent();

    String expected =
        "\n\n"
            + "class foobar;\n"
            + "\t\n"
            + "\tfunction void foobar();\n"
            + "\t\tif (foo)\n"
            + "\t\t\t$display(\"Hello\");\n"
            + "\t\telse\n"
            + "\t\t\t$display(\"Goodbye\");\n"
            + "\t\t$display(\"World\");\n"
            + "\tendfunction\n"
            + "\t\n"
            + "endclass\n";

    fLog.debug("Result:\n" + content);
    IndentComparator.compare(getName(), expected, content);
  }
  public void testParamListFunctionWithPkg() throws SVParseException {
    String content =
        "function automatic void foobar(\n"
            + "        input int foobar,\n"
            + "        ref object bar,\n"
            + "        int foo);\n"
            + "    a_type foo, bar;\n"
            + "    b_type foo_q[$];\n"
            + "    int i, j, k;\n"
            + "    uvm_pkg::uvm_resource_db #(my_pkg::my_iface_container #(virtual my_iface)) "
            + "        ::set(\"my_ifaces\", $sformatf(\"my_iface_%01d\",0), ifc) ;"
            + "    for (int i=0; i<5; i++) begin\n"
            + "        a = 5;\n"
            + "    end\n"
            + "endfunction\n";

    SVCorePlugin.getDefault().enableDebug(false);

    SVDBTask func = parse_tf(content, "testParamListFunction");

    ISVDBChildItem c = func.getParams().get(1).getChildren().iterator().next();

    assertEquals("bar", SVDBItem.getName(c));
    assertEquals(SVDBParamPortDecl.Direction_Ref, func.getParams().get(1).getDir());
  }
  public void testParamListFunction() throws SVParseException {
    String content =
        "function automatic void foobar(\n"
            + // 1
            "        input int foobar,\n"
            + // 2
            "        ref object bar,\n"
            + // 3
            "        int foo);\n"
            + // 4
            "    a_type foo, bar;\n"
            + // 5
            "    b_type foo_q[$];\n"
            + // 6
            "    b_cls #(foobar, bar) elem;\n"
            + "    int i, j, k;\n"
            + "    for (int i=0; i<5; i++) begin\n"
            + "        a = 5;\n"
            + "    end\n"
            + "endfunction\n";

    SVCorePlugin.getDefault().enableDebug(false);

    SVDBTask func = parse_tf(content, "testParamListFunction");

    ISVDBChildItem c = func.getParams().get(1).getChildren().iterator().next();

    assertEquals("bar", SVDBItem.getName(c));
    assertEquals(SVDBParamPortDecl.Direction_Ref, func.getParams().get(1).getDir());
  }
  // Tests that local variables are correctly recognized and that
  // cast expressions are skipped appropriately
  public void testLocalVarsWithCast() throws SVParseException {
    String content =
        "function void foobar();\n"
            + "    int a = integer'(5);\n"
            + "    int b = longint'(6);\n"
            + "    a = 5;\n"
            + "endfunction\n";

    SVCorePlugin.getDefault().enableDebug(false);

    SVDBTask func = parse_tf(content, "testLocalVarsWithCast");

    assertEquals(3, SVDBUtil.getChildrenSize(func));
    SVDBVarDeclItem a = null, b = null;
    for (ISVDBItemBase it_t : func.getChildren()) {
      if (it_t.getType() == SVDBItemType.VarDeclStmt) {
        SVDBVarDeclStmt v = (SVDBVarDeclStmt) it_t;
        for (ISVDBChildItem vi : v.getChildren()) {
          if (SVDBItem.getName(vi).equals("a")) {
            a = (SVDBVarDeclItem) vi;
          } else if (SVDBItem.getName(vi).equals("b")) {
            b = (SVDBVarDeclItem) vi;
          }
        }
      }
    }
    assertNotNull(a);
    assertNotNull(b);
  }
Beispiel #19
0
  public void testGenerate() {
    LogHandle log = LogFactory.getLogHandle("testGenerate");
    String content =
        "module t;\n"
            + "parameter a = 0;\n"
            + "generate\n"
            + "if(a == 0) begin\n"
            + "// ...\n"
            + "end\n"
            + "if(a == 1) begin\n"
            + "// ...\n"
            + "end\n"
            + "endgenerate\n"
            + "generate\n"
            + "begin:bob\n"
            + "if(a == 0) begin\n"
            + "// ...\n"
            + "end\n"
            + "if(a == 1) begin\n"
            + "// ...\n"
            + "end\n"
            + "end\n"
            + "endgenerate\n"
            + "endmodule\n";
    String expected =
        "module t;\n"
            + "	parameter a = 0;\n"
            + "	generate\n"
            + "		if(a == 0) begin\n"
            + "			// ...\n"
            + "		end\n"
            + "		if(a == 1) begin\n"
            + "			// ...\n"
            + "		end\n"
            + "	endgenerate\n"
            + "	generate\n"
            + "	begin:bob\n"
            + "		if(a == 0) begin\n"
            + "			// ...\n"
            + "		end\n"
            + "		if(a == 1) begin\n"
            + "			// ...\n"
            + "		end\n"
            + "	end\n"
            + "	endgenerate\n"
            + "endmodule\n";

    SVIndentScanner scanner = new SVIndentScanner(new StringTextScanner(content));

    ISVIndenter indenter = SVCorePlugin.getDefault().createIndenter();
    indenter.init(scanner);
    indenter.setTestMode(true);

    String result = indenter.indent();

    log.debug("Result:");
    log.debug(result);
    IndentComparator.compare("testGenerate", expected, result);
    LogFactory.removeLogHandle(log);
  }
Beispiel #20
0
  public void testBasicModuleWire() {
    LogHandle log = LogFactory.getLogHandle("testBasicModuleWire");
    String content =
        "module top;\n"
            + "// comment1\n"
            + "logic a;\n"
            + "logic b;\n"
            + "// comment2\n"
            + "endmodule\n";
    String expected =
        "module top;\n"
            + "	// comment1\n"
            + "	logic a;\n"
            + "	logic b;\n"
            + "	// comment2\n"
            + "endmodule\n";

    SVIndentScanner scanner = new SVIndentScanner(new StringTextScanner(content));

    ISVIndenter indenter = SVCorePlugin.getDefault().createIndenter();
    indenter.init(scanner);
    indenter.setTestMode(true);

    String result = indenter.indent();

    log.debug("Result:");
    log.debug(result);
    IndentComparator.compare("testBasicModuleWire", expected, result);
    LogFactory.removeLogHandle(log);
  }
  public void testTypedClassParameters() {
    String content =
        "`define PARAMS \\\n"
            + "    #(int A=5, \\\n"
            + "      bit[foo:0] B=pkg::func(a*7), \\\n"
            + "      int C=7)\n"
            + "\n"
            + "class foobar `PARAMS;\n"
            + "\n"
            + "    function void foo_func();\n"
            + "        a = 5;\n"
            + "        b = 6;\n"
            + "    endfunction\n"
            + // endfunction without : <name>
            "\n"
            + "    function void foo_func_e();\n"
            + "        c = 5;\n"
            + "        d = 6;\n"
            + "    endfunction:foo_func_e\n"
            + // endfunction without : <name>
            "\n"
            + "    task foo_task();\n"
            + "    endtask\n"
            + "endclass\n";

    SVCorePlugin.getDefault().enableDebug(false);

    runTest(
        "testTypedClassParameters",
        content,
        new String[] {"foobar", "foo_func", "foo_func_e", "foo_task"});
  }
Beispiel #22
0
  public void testEnumVar() {
    String testname = "testEnumVar";
    LogHandle log = LogFactory.getLogHandle(testname);
    String content =
        "module t;\n" + "enum {\n" + "A,\n" + "B\n" + "} e;\n" + "logic b;\n" + "endmodule\n";
    String expected =
        "module t;\n"
            + "	enum {\n"
            + "		A,\n"
            + "		B\n"
            + "	} e;\n"
            + "	logic b;\n"
            + "endmodule\n";
    log.debug("--> " + testname);

    SVIndentScanner scanner = new SVIndentScanner(new StringTextScanner(content));

    ISVIndenter indenter = SVCorePlugin.getDefault().createIndenter();
    indenter.init(scanner);
    indenter.setTestMode(true);

    String result = indenter.indent();

    log.debug("Result:");
    log.debug(result);
    IndentComparator.compare(testname, expected, result);
    log.debug("<-- " + testname);

    LogFactory.removeLogHandle(log);
  }
Beispiel #23
0
  public void testInitialBlock() {
    LogHandle log = LogFactory.getLogHandle("testInitialBlock");
    String content =
        "module t;\n" + "logic a;\n" + "initial begin\n" + "a = 5;\n" + "end\n" + "endmodule\n";
    String expected =
        "module t;\n"
            + "	logic a;\n"
            + "	initial begin\n"
            + "		a = 5;\n"
            + "	end\n"
            + "endmodule\n";
    log.debug("--> testInitialBlock");

    SVIndentScanner scanner = new SVIndentScanner(new StringTextScanner(content));

    ISVIndenter indenter = SVCorePlugin.getDefault().createIndenter();
    indenter.init(scanner);
    indenter.setTestMode(true);

    String result = indenter.indent();

    log.debug("Result:");
    log.debug(result);
    IndentComparator.compare("testInitialBlock", expected, result);
    log.debug("<-- testInitialBlock");

    LogFactory.removeLogHandle(log);
  }
  public void testUSBHostSlave() throws CoreException {
    SVCorePlugin.getDefault().enableDebug(false);

    runTest(
        "testDMA",
        "/usbhostslave.zip",
        "usbhostslave",
        new String[] {"${workspace_loc}/usbhostslave/usb.f"});
  }
  private void runTest(
      String testname, String zipfile_path, String proj_path, String arg_file_paths[])
      throws CoreException {
    LogHandle log = LogFactory.getLogHandle(testname);
    CoreReleaseTests.clearErrors();
    BundleUtils utils = new BundleUtils(SVCoreTestsPlugin.getDefault().getBundle());

    cleanupWorkspace();

    // Create a new project for the
    File test_dir = new File(fTmpDir, testname);
    File db_dir = new File(fTmpDir, "db");
    if (test_dir.exists()) {
      assertTrue(test_dir.delete());
    }
    assertTrue(test_dir.mkdirs());

    if (db_dir.exists()) {
      assertTrue(db_dir.delete());
    }
    assertTrue(db_dir.mkdirs());

    utils.unpackBundleZipToFS(zipfile_path, test_dir);
    File project_path = new File(test_dir, proj_path);

    fProject = TestUtils.createProject(project_path.getName(), project_path);

    // Setup appropriate project settings
    SVDBProjectManager p_mgr = SVCorePlugin.getDefault().getProjMgr();
    SVDBProjectData p_data = p_mgr.getProjectData(fProject);

    // Add an argument-file paths
    SVProjectFileWrapper p_wrapper = p_data.getProjectFileWrapper().duplicate();
    if (arg_file_paths != null) {
      for (String arg_file : arg_file_paths) {
        p_wrapper.getArgFilePaths().add(new SVDBPath(arg_file));
        p_wrapper.getArgFilePaths().add(new SVDBPath(arg_file));
      }
    }
    p_data.setProjectFileWrapper(p_wrapper);

    SVDBIndexCollection project_index = p_data.getProjectIndexMgr();
    assertNoErrors(log, project_index);

    // force index loading
    project_index.loadIndex(new NullProgressMonitor());

    IndexTestUtils.assertNoErrWarn(log, project_index);

    for (Exception e : CoreReleaseTests.getErrors()) {
      System.out.println("TEST: " + getName() + " " + e.getMessage());
    }

    assertEquals(0, CoreReleaseTests.getErrors().size());
    project_index.dispose();
    LogFactory.removeLogHandle(log);
  }
Beispiel #26
0
  public void testAutoIndentIfThenElse() throws BadLocationException {

    SVCorePlugin.getDefault().enableDebug(false);

    String content =
        "module t();\n"
            + "if (foo)\n"
            + "a = 5;\n"
            + "else if (bar)\n"
            + "b = 6;\n"
            + "\n"
            + "if (foo) begin\n"
            + "a = 5;\n"
            + "end else if (bar) begin\n"
            + "b = 6;\n"
            + "end\n"
            + "\n"
            + "if (foo)\n"
            + "begin\n"
            + "a = 5;\n"
            + "end\n"
            + "else\n"
            + "begin\n"
            + "b = 6;\n"
            + "end\n"
            + "endmodule\n";
    String expected =
        "module t();\n"
            + "	if (foo)\n"
            + "		a = 5;\n"
            + "	else if (bar)\n"
            + "		b = 6;\n"
            + "\n"
            + "	if (foo) begin\n"
            + "		a = 5;\n"
            + "	end else if (bar) begin\n"
            + "		b = 6;\n"
            + "	end\n"
            + "\n"
            + "	if (foo)\n"
            + "	begin\n"
            + "		a = 5;\n"
            + "	end\n"
            + "	else\n"
            + "	begin\n"
            + "		b = 6;\n"
            + "	end\n"
            + "endmodule\n";

    AutoEditTester tester = UiReleaseTests.createAutoEditTester();
    tester.type(content);

    String result = tester.getContent();

    fLog.debug("Result:\n" + content);
    IndentComparator.compare("", expected, result);
  }
  public void testEthernetMac() throws CoreException {
    SVCorePlugin.getDefault().enableDebug(false);

    runTest(
        "testEthernetMac",
        "/wb_ethmac.zip",
        "wb_ethmac",
        new String[] {"${workspace_loc}/wb_ethmac/wb_ethmac.f"});
  }
Beispiel #28
0
  // This test checks constraints
  public void testIndentConstraint() throws BadLocationException {
    //	String input =
    //			"class someclass;\n" +
    //			"constraint clock {\n" +
    //			"clk_cfg.period dist {\n" +
    //			"[1:10  ] :/ 1,\n" +
    //			"11       := 1,\n" +
    //			"12       := 1,\n" +
    //			"[13: 15] :/ 1\n" +
    //			"};\n" +
    //			"clk_cfg.jitter < (3 * 1000);\n" +
    //			"}\n" +
    //			"function void my_func;\n" +
    //			"my_class cls1; \n" +
    //			"assert(cls1.randomize() with {\n" +
    //			"cls1.a == 2;\n" +
    //			"})\n" +
    //			"else $display (\"ERROR\");\n" +
    //			"endfunction\n" +
    //			"endclass\n"
    //			;

    String expected =
        "class someclass;\n"
            + "	constraint clock {\n"
            + "		clk_cfg.period dist {\n"
            + "			[1:10  ] :/ 1,\n"
            + "			11       := 1,\n"
            + "			12       := 1,\n"
            + "			[13: 15] :/ 1\n"
            + "		};\n"
            + "		clk_cfg.jitter < (3 * 1000);\n"
            + "	}\n"
            + "	function void my_func;\n"
            + "		my_class cls1; \n"
            + "		assert(cls1.randomize() with {\n"
            + "				cls1.a == 2;\n"
            + "				})\n"
            + "		else $display (\"ERROR\");\n"
            + "	endfunction\n"
            + "endclass\n";

    String input = IndentTests.removeLeadingWS(expected).toString();

    AutoEditTester tester = UiReleaseTests.createAutoEditTester();
    tester.type(input);
    String result_type = tester.getContent();

    IndentComparator.compare("testIndentConstraint - type", expected, result_type);
    tester.paste(input);
    String result_paste = tester.getContent();

    SVCorePlugin.getDefault().enableDebug(false);

    IndentComparator.compare("testIndentConstraint - paste", expected, result_paste);
  }
  /** ************* Utility Methods ******************* */
  private Tuple<SVDBFile, TextTagPosUtils> contentAssistSetup(String doc) {
    TextTagPosUtils tt_utils = new TextTagPosUtils(new StringInputStream(doc));
    ISVDBFileFactory factory = SVCorePlugin.createFileFactory();

    List<SVDBMarker> markers = new ArrayList<SVDBMarker>();
    SVDBFile file = factory.parse(tt_utils.openStream(), "doc", markers);
    fIndex.setFile(file);

    return new Tuple<SVDBFile, TextTagPosUtils>(file, tt_utils);
  }
  public SVDBProjectData getProjectData() {
    IProject p = findDestProject();
    if (p == null) {
      return null;
    }

    SVDBProjectData pdata = SVCorePlugin.getDefault().getProjMgr().getProjectData(p);

    return pdata;
  }