Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Report AlwaysFalseConstraints as CF errors #341

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
e8613b2
add unsat verification to test infrastructure
d367wang Jul 6, 2021
6bf6317
update error messages for different kinds of failure
d367wang Jul 8, 2021
5209dc4
refactor
d367wang Jul 13, 2021
d5a9672
Apply suggestions from code review
d367wang Jul 14, 2021
5c21828
add comments
d367wang Jul 14, 2021
576d9b4
adapt CFInferenceTest
d367wang Jul 15, 2021
fad7c62
change back to max2type solver
d367wang Jul 15, 2021
9fee375
Merge branch 'master' of https://github.com/opprop/checker-framework-…
d367wang Jul 21, 2021
318a92a
Merge branch 'master' of https://github.com/opprop/checker-framework-…
d367wang Aug 27, 2021
49c3cf5
tweaks
d367wang Aug 27, 2021
5f840ed
remove -Awarn flag
d367wang Aug 31, 2021
5440175
Merge branch 'master' of https://github.com/opprop/checker-framework-…
d367wang Sep 16, 2021
8a6b53b
Merge branch 'master' of https://github.com/opprop/checker-framework-…
d367wang Sep 20, 2021
10fe1b2
enable -Awarn
d367wang Dec 17, 2021
64ab800
Update Unsat.java
d367wang Dec 17, 2021
ec5c793
Merge branch 'master' of https://github.com/opprop/checker-framework-…
d367wang Dec 17, 2021
f34d071
Merge branch 'unsat-verify' of github.com:d367wang/checker-framework-…
d367wang Dec 17, 2021
fbffe45
Merge branch 'master' into unsat-verify
wmdietl Jan 26, 2022
0f57b21
Merge branch 'master' of https://github.com/opprop/checker-framework-…
d367wang Apr 24, 2022
a517708
Merge branch 'unsat-verify' of github.com:d367wang/checker-framework-…
d367wang Apr 24, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions testdata/ostrusted-unsat-test/Unsat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import ostrusted.qual.OsUntrusted;
import ostrusted.qual.OsTrusted;

class Unsat {
d367wang marked this conversation as resolved.
Show resolved Hide resolved

void foo(@OsTrusted String s) {}

@OsUntrusted
String bar() { return ""; }
d367wang marked this conversation as resolved.
Show resolved Hide resolved

void m() {
String s = bar();
// :: error: (argument.type.incompatible)
foo(s);
}
}
31 changes: 31 additions & 0 deletions tests/checkers/inference/OsTrustedUnsatTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package checkers.inference;

import checkers.inference.solver.SolverEngine;
import checkers.inference.test.CFInferenceUnsatTest;
import org.checkerframework.framework.test.TestUtilities;
import org.checkerframework.javacutil.Pair;
import org.junit.runners.Parameterized;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class OsTrustedUnsatTest extends CFInferenceUnsatTest {

public OsTrustedUnsatTest(File testFile) {
super(testFile, ostrusted.OsTrustedChecker.class, "ostrusted",
"-Anomsgtext", "-Astubs=src/ostrusted/jdk.astub", "-d", "tests/build/outputdir");
}

@Override
public Pair<String, List<String>> getSolverNameAndOptions() {
return Pair.<String, List<String>>of(SolverEngine.class.getCanonicalName(), new ArrayList<String>());
}

@Parameterized.Parameters
public static List<File> getTestFiles(){
List<File> testfiles = new ArrayList<>();//InferenceTestUtilities.findAllSystemTests();
testfiles.addAll(TestUtilities.findRelativeNestedJavaFiles("testdata", "ostrusted-unsat-test"));
return testfiles;
}
}
4 changes: 4 additions & 0 deletions tests/checkers/inference/test/CFInferenceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ testFile, testDataDir, checkerName, checkerOptions, getAdditionalInferenceOption
solverArgs.second, useHacks(), shouldEmitDebugInfo, getPathToAfuScripts(), getPathToInferenceScript());

InferenceTestResult testResult = new InferenceTestExecutor().runTest(config);
postProcessResult(testResult);
}

protected void postProcessResult(InferenceTestResult testResult) {
d367wang marked this conversation as resolved.
Show resolved Hide resolved
InferenceTestUtilities.assertResultsAreValid(testResult);
}
}
33 changes: 33 additions & 0 deletions tests/checkers/inference/test/CFInferenceUnsatTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package checkers.inference.test;

import org.checkerframework.javacutil.SystemUtil;

import javax.annotation.processing.AbstractProcessor;
import java.io.File;

/**
* This test suite runs inference individually on target files that are unsatisfiable. This means each
* test case is expected to pass the initial check phase while fail at the inference phase and terminate.
d367wang marked this conversation as resolved.
Show resolved Hide resolved
*
* The use of this class is the same as {@link CFInferenceTest}. Note that the target directory of the test
* cases can only contain unsatisfiable cases.
*/
public abstract class CFInferenceUnsatTest extends CFInferenceTest{
public CFInferenceUnsatTest(File testFile, Class<? extends AbstractProcessor> checker,
String testDir, String... checkerOptions) {
super(testFile, checker, testDir, checkerOptions);
}

@Override
protected void postProcessResult(InferenceTestResult testResult) {
final InferenceTestPhase lastPhaseRun = testResult.getLastPhaseRun();
if (lastPhaseRun == InferenceTestPhase.INITIAL_TYPECHECK) {
InferenceTestUtilities.assertResultsAreValid(testResult);

} else if (lastPhaseRun == InferenceTestPhase.FINAL_TYPECHECK) {
String summary = "Inference is expected to fail, but succeeded on source files: \n"
+ SystemUtil.join("\n", testResult.getConfiguration().getInitialTypecheckConfig().getTestSourceFiles()) + "\n\n";
InferenceTestUtilities.assertFail(InferenceTestPhase.INFER, summary);
}
}
}