Consolidate application mode tests.

This commit is contained in:
Max Schaefer
2024-01-16 18:08:46 +00:00
parent 692d5e55a2
commit 312dd16956
8 changed files with 49 additions and 86 deletions

View File

@@ -1,26 +0,0 @@
import java
import AutomodelApplicationModeCharacteristics
import TestUtilities.InlineExpectationsTest
module CandidateTest implements TestSig {
string getARelevantTag() { result in ["sourceModel", "sinkModel"] }
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(
Endpoint endpoint, string name, string signature, string input, string output,
string extensibleType
|
isCandidate(endpoint, _, _, _, name, signature, input, output, _, extensibleType, _)
|
endpoint.asTop().getLocation() = location and
endpoint.toString() = element and
tag = extensibleType and
// for source models only the output is relevant, and vice versa for sink models
if extensibleType = "sourceModel"
then value = name + signature + ":" + output
else value = name + signature + ":" + input
)
}
}
import MakeTest<CandidateTest>

View File

@@ -1,27 +0,0 @@
import java
import AutomodelApplicationModeCharacteristics
import TestUtilities.InlineExpectationsTest
module NegativeExampleTest implements TestSig {
string getARelevantTag() { result = "negativeExample" }
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(
Endpoint endpoint, string name, string signature, string input,
string output, string extensibleType
|
isNegativeExample(endpoint, _, _, _, _, _, name, signature, input, output, _,
extensibleType)
|
endpoint.asTop().getLocation() = location and
endpoint.toString() = element and
tag = "negativeExample" and
// for source models only the output is relevant, and vice versa for sink models
if extensibleType = "sourceModel"
then value = name + signature + ":" + output
else value = name + signature + ":" + input
)
}
}
import MakeTest<NegativeExampleTest>

View File

@@ -1,27 +0,0 @@
import java
import AutomodelApplicationModeCharacteristics
import TestUtilities.InlineExpectationsTest
module PositiveExampleTest implements TestSig {
string getARelevantTag() { result = "positiveExample" }
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(
Endpoint endpoint, string endpointType, string name, string signature, string input,
string output, string extensibleType
|
isPositiveExample(endpoint, endpointType, _, _, _, name, signature, input, output, _,
extensibleType)
|
endpoint.asTop().getLocation() = location and
endpoint.toString() = element and
tag = "positiveExample" and
// for source models only the output is relevant, and vice versa for sink models
if extensibleType = "sourceModel"
then value = name + signature + ":" + output + "(" + endpointType + ")"
else value = name + signature + ":" + input + "(" + endpointType + ")"
)
}
}
import MakeTest<PositiveExampleTest>

View File

@@ -0,0 +1,47 @@
import java
import AutomodelApplicationModeCharacteristics
import TestUtilities.InlineExpectationsTest
module Extraction implements TestSig {
string getARelevantTag() {
result in ["sourceModel", "sinkModel", "positiveExample", "negativeExample"]
}
additional predicate selectEndpoint(
Endpoint endpoint, string name, string signature, string input, string output,
string extensibleType, string tag, string suffix
) {
isCandidate(endpoint, _, _, _, name, signature, input, output, _, extensibleType, _) and
tag = extensibleType and
suffix = ""
or
isNegativeExample(endpoint, _, _, _, _, _, name, signature, input, output, _, extensibleType) and
tag = "negativeExample" and
suffix = ""
or
exists(string endpointType |
isPositiveExample(endpoint, endpointType, _, _, _, name, signature, input, output, _,
extensibleType) and
tag = "positiveExample" and
suffix = "(" + endpointType + ")"
)
}
predicate hasActualResult(Location location, string element, string tag, string value) {
exists(
Endpoint endpoint, string name, string signature, string input, string output,
string extensibleType, string suffix
|
selectEndpoint(endpoint, name, signature, input, output, extensibleType, tag, suffix)
|
endpoint.asTop().getLocation() = location and
endpoint.toString() = element and
// for source models only the output is relevant, and vice versa for sink models
if extensibleType = "sourceModel"
then value = name + signature + ":" + output + suffix
else value = name + signature + ":" + input + suffix
)
}
}
import MakeTest<Extraction>

View File

@@ -87,9 +87,9 @@ class TaskUtils {
class MoreTests {
public static void FilesListExample(Path p) throws Exception {
Files.list(
Files.createDirectories( // $ negativeExample=list(Path):Argument[0] // modeled as a flow step
Files.createDirectories(
p // $ positiveExample=createDirectories(Path,FileAttribute[]):Argument[0](path-injection)
) // $ sourceModel=createDirectories(Path,FileAttribute[]):ReturnValue
) // $ sourceModel=createDirectories(Path,FileAttribute[]):ReturnValue negativeExample=list(Path):Argument[0] // modeled as a flow step
); // $ sourceModel=list(Path):ReturnValue
Files.delete(