Search in sources :

Example 1 with SpecScanner

use of org.btrplace.safeplace.spec.SpecScanner in project scheduler by btrplace.

the class DSN method newScanner.

public TestScanner newScanner() throws Exception {
    SpecScanner specScanner = new SpecScanner();
    List<Constraint> l = specScanner.scan();
    Bench.mode = Bench.Mode.REPLAY;
    return new TestScanner(l);
}
Also used : Constraint(org.btrplace.safeplace.spec.Constraint) TestScanner(org.btrplace.safeplace.testing.TestScanner) SpecScanner(org.btrplace.safeplace.spec.SpecScanner)

Example 2 with SpecScanner

use of org.btrplace.safeplace.spec.SpecScanner in project scheduler by btrplace.

the class DSN method funcFrequency.

// @Test
public void funcFrequency() throws Exception {
    SpecScanner sc = new SpecScanner();
    List<Constraint> l = sc.scan();
    Pattern p = Pattern.compile("([a-zA-Z]+\\()+");
    Map<String, Integer> map = new HashMap<>();
    for (Constraint c : l) {
        String prop = c.proposition().toString();
        Matcher m = p.matcher(prop);
        System.out.println(prop);
        int start = 0;
        while (m.find(start)) {
            String name = prop.substring(m.start(), m.end() - 1);
            if (Character.isLowerCase(name.charAt(0))) {
                if (!map.containsKey(name)) {
                    map.put(name, 1);
                } else {
                    map.put(name, map.get(name) + 1);
                }
            }
            System.out.println("\t" + prop.substring(m.start(), m.end() - 1));
            start = m.end();
        }
    }
    System.out.println(map);
    Path out = Paths.get(root, "func-freq.csv");
    Files.deleteIfExists(out);
    String cnt = "name;freq\n" + map.entrySet().stream().map(e -> e.getKey() + ";" + e.getValue() + "\n").collect(Collectors.joining());
    Files.write(out, cnt.getBytes());
}
Also used : Path(java.nio.file.Path) Pattern(java.util.regex.Pattern) Constraint(org.btrplace.safeplace.spec.Constraint) Matcher(java.util.regex.Matcher) SpecScanner(org.btrplace.safeplace.spec.SpecScanner) Constraint(org.btrplace.safeplace.spec.Constraint)

Example 3 with SpecScanner

use of org.btrplace.safeplace.spec.SpecScanner in project scheduler by btrplace.

the class TestSafePlace method launcher.

// @Test
public void launcher() throws Exception {
    SpecScanner specScanner = new SpecScanner();
    List<Constraint> l = specScanner.scan();
    TestScanner sc = new TestScanner(l);
    List<TestCampaign> campaigns = sc.test(TestSafePlace.class);
    // List<TestCampaign> campaigns = sc.testGroups("_resourceCapacity");
    if (campaigns.isEmpty()) {
        Assert.fail("Nothing to test");
    }
    campaigns.forEach(tc -> {
        // .setVerbosity(1);
        tc.schedulerParams().doRepair(false);
        tc.onDefect(DefectHooks.ignore);
        tc.limits().clear().tests(1000);
        System.out.println(tc.go());
    });
}
Also used : Constraint(org.btrplace.safeplace.spec.Constraint) SpecScanner(org.btrplace.safeplace.spec.SpecScanner)

Example 4 with SpecScanner

use of org.btrplace.safeplace.spec.SpecScanner in project scheduler by btrplace.

the class DSN method specLength.

// @Test
public void specLength() throws Exception {
    SpecScanner sc = new SpecScanner();
    List<Constraint> l = sc.scan();
    System.out.println(l.stream().map(Constraint::pretty).collect(Collectors.joining("\n")));
    Path path = Paths.get(root, "inv.csv");
    String out = l.stream().map(c -> Integer.toString(c.proposition().toString().length())).collect(Collectors.joining("\n"));
    Files.write(path, out.getBytes());
    List<Integer> funcs = new ArrayList<>();
    List<Path> paths = Files.list(Paths.get("safeplace/src/main/java/org/btrplace/safeplace/spec/term/func")).filter(Files::isRegularFile).collect(Collectors.toList());
    for (Path p : paths) {
        try (InputStream in = Files.newInputStream(p)) {
            CompilationUnit cu = JavaParser.parse(in);
            new FunctionVisitor(funcs).visit(cu, null);
        }
    }
    path = Paths.get(root, "func.csv");
    out = funcs.stream().map(c -> Integer.toString(c)).collect(Collectors.joining("\n"));
    Files.write(path, out.getBytes());
}
Also used : Path(java.nio.file.Path) CSVReport(org.btrplace.safeplace.testing.reporting.CSVReport) java.util(java.util) VoidVisitorAdapter(com.github.javaparser.ast.visitor.VoidVisitorAdapter) AnnotationExpr(com.github.javaparser.ast.expr.AnnotationExpr) Restriction(org.btrplace.safeplace.testing.fuzzer.Restriction) Constraint(org.btrplace.safeplace.spec.Constraint) Matcher(java.util.regex.Matcher) Assert(org.testng.Assert) CompilationUnit(com.github.javaparser.ast.CompilationUnit) SpecScanner(org.btrplace.safeplace.spec.SpecScanner) Path(java.nio.file.Path) SpecVerifier(org.btrplace.safeplace.testing.verification.spec.SpecVerifier) TestScanner(org.btrplace.safeplace.testing.TestScanner) Files(java.nio.file.Files) PrettyPrinterConfiguration(com.github.javaparser.printer.PrettyPrinterConfiguration) Verifier(org.btrplace.safeplace.testing.verification.Verifier) Collectors(java.util.stream.Collectors) Bench(org.btrplace.safeplace.testing.Bench) StoredReport(org.btrplace.safeplace.testing.reporting.StoredReport) MethodDeclaration(com.github.javaparser.ast.body.MethodDeclaration) Paths(java.nio.file.Paths) Result(org.btrplace.safeplace.testing.Result) TestCampaign(org.btrplace.safeplace.testing.TestCampaign) Pattern(java.util.regex.Pattern) CheckerVerifier(org.btrplace.safeplace.testing.verification.btrplace.CheckerVerifier) JavaParser(com.github.javaparser.JavaParser) InputStream(java.io.InputStream) CompilationUnit(com.github.javaparser.ast.CompilationUnit) Constraint(org.btrplace.safeplace.spec.Constraint) InputStream(java.io.InputStream) SpecScanner(org.btrplace.safeplace.spec.SpecScanner)

Example 5 with SpecScanner

use of org.btrplace.safeplace.spec.SpecScanner in project scheduler by btrplace.

the class TestScannerTest method newScanner.

public TestScanner newScanner() throws Exception {
    SpecScanner specScanner = new SpecScanner();
    List<Constraint> l = specScanner.scan();
    return new TestScanner(l);
}
Also used : Constraint(org.btrplace.safeplace.spec.Constraint) SpecScanner(org.btrplace.safeplace.spec.SpecScanner)

Aggregations

Constraint (org.btrplace.safeplace.spec.Constraint)5 SpecScanner (org.btrplace.safeplace.spec.SpecScanner)5 Path (java.nio.file.Path)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 TestScanner (org.btrplace.safeplace.testing.TestScanner)2 JavaParser (com.github.javaparser.JavaParser)1 CompilationUnit (com.github.javaparser.ast.CompilationUnit)1 MethodDeclaration (com.github.javaparser.ast.body.MethodDeclaration)1 AnnotationExpr (com.github.javaparser.ast.expr.AnnotationExpr)1 VoidVisitorAdapter (com.github.javaparser.ast.visitor.VoidVisitorAdapter)1 PrettyPrinterConfiguration (com.github.javaparser.printer.PrettyPrinterConfiguration)1 InputStream (java.io.InputStream)1 Files (java.nio.file.Files)1 Paths (java.nio.file.Paths)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 Bench (org.btrplace.safeplace.testing.Bench)1 Result (org.btrplace.safeplace.testing.Result)1 TestCampaign (org.btrplace.safeplace.testing.TestCampaign)1