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

Tagging of test suites #350

Merged
merged 40 commits into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from 32 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
b19b06c
tagging up to unit tests
katrinafyi Mar 6, 2025
5c4abaa
add standardsystemtests and comment for annotatetestcase
katrinafyi Mar 6, 2025
cf69e97
ci: check for test tagging
katrinafyi Mar 6, 2025
3f73558
ci: use tags to run tests
katrinafyi Mar 6, 2025
334b182
Merge remote-tracking branch 'origin/main' into scalatest-grouping
katrinafyi Mar 6, 2025
aae397f
scalafmt
katrinafyi Mar 6, 2025
d7e02b7
ci: update message
katrinafyi Mar 6, 2025
c1a0524
use cancel() instead of assume(false)
katrinafyi Mar 6, 2025
4ef3f7f
DifferentialTest marking. added TestCustomisation mixin
katrinafyi Mar 7, 2025
de8f664
tag remaining tests
katrinafyi Mar 7, 2025
96ce9f5
add script. add some missing tags
katrinafyi Mar 7, 2025
1da085b
Merge remote-tracking branch 'origin/main' into scalatest-grouping
katrinafyi Mar 7, 2025
9ec8ae6
ci: add durations to test runner output
katrinafyi Mar 7, 2025
dc3ae4e
SATTest: remove smt.timeout option (it is set by command line)
katrinafyi Mar 7, 2025
fd9d70b
disable stack_pointer cases in memory region tests
katrinafyi Mar 7, 2025
585bf05
extra spec tests
katrinafyi Mar 7, 2025
09fd1e0
indirect call tests
katrinafyi Mar 7, 2025
88b0873
tweak customised test messages, fix SimplifyMemorySystemTests
katrinafyi Mar 7, 2025
43a81e4
fix testcustomisation case oopsie, use self-type instead of AnyFunSuite
katrinafyi Mar 7, 2025
93abe5a
print current outcome of xfail tests
katrinafyi Mar 7, 2025
15e8801
review: split ExpectFailure into TempFailure and NotImplemented
katrinafyi Mar 11, 2025
a77724a
move TestCustomisation into its own file
katrinafyi Mar 11, 2025
e407854
Merge remote-tracking branch 'origin/main' into scalatest-grouping
katrinafyi Mar 11, 2025
efa63f4
tests: update indirect call test modes after merge
katrinafyi Mar 11, 2025
9a3e55b
scalafmt
katrinafyi Mar 11, 2025
6f92d39
add script to execute scalatest runner
katrinafyi Mar 11, 2025
86b0d89
IndirectCallTests: add remarks from review
katrinafyi Mar 12, 2025
3684717
Merge remote-tracking branch 'origin/main' into scalatest-grouping
katrinafyi Mar 12, 2025
25a25ca
add Slow tag, make check-test-tagging stricter
katrinafyi Mar 12, 2025
bf327c6
tag IntervalDSATest
katrinafyi Mar 12, 2025
bdc5055
IndirectCallTests: move to Analysis and un-mark some not implemented
katrinafyi Mar 12, 2025
4160752
add some helpful commands to scalatest.sh
katrinafyi Mar 12, 2025
6589b32
docs: add testing.md to describe some testing infrastructure
katrinafyi Mar 12, 2025
44b7a36
IntervalDSATest: mark as broken
katrinafyi Mar 12, 2025
4f475f2
Merge remote-tracking branch 'origin/main' into scalatest-grouping
katrinafyi Mar 12, 2025
cf92db5
IntervalDSATest: unbreak one test
katrinafyi Mar 12, 2025
1eee5f9
Merge remote-tracking branch 'origin/main' into scalatest-grouping
katrinafyi Mar 12, 2025
9e65f20
Merge remote-tracking branch 'origin/main' into scalatest-grouping
katrinafyi Mar 12, 2025
01ed37d
Merge remote-tracking branch 'origin/main' into scalatest-grouping
katrinafyi Mar 13, 2025
62f0aa5
IntervalDSATest: unbreak
katrinafyi Mar 13, 2025
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
33 changes: 33 additions & 0 deletions .github/workflows/check-test-tagging.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash -eu

set -o pipefail

test_dir=src/test

echo '::group::All test suites:'
tests="$(./mill test.testOnly -- -t '' -oW | tr -d ':' | sort)"
echo "$tests"
echo '::endgroup::'
echo
echo '::group::Disabled test suites:'
grep --color=always '@test_util\.tags\.DisabledTest' --context=1 -R $test_dir
echo '::endgroup::'
echo

ok=true
echo '::group::Test suites with no tag annotations:'
for t in $tests; do
defn="$(grep 'class\s\+'"$t"'[ (]' --before-context=2 -R $test_dir)"
# search for lines which are entirely "@test_util.tags.*Test"
# leading - is produced by grep to mark prefixes
if ! grep -q -- '-@test_util\.tags\..\+Test$' <<< "$defn"; then
echo 'test suite has no `@test_util.tags.*Test` annotation:' >&2
grep --color=always 'class\s\+'"$t"'[ (]' --before-context=2 -R $test_dir
echo
ok=false
fi
done
echo '::endgroup::'

$ok

68 changes: 20 additions & 48 deletions .github/workflows/run-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,18 @@ on:
- main
workflow_dispatch:
jobs:
CheckTestTagging:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- run: './mill test.compile'
- name: Check all test suites have at least one tag
run: .github/workflows/check-test-tagging.sh

Scalafmt:
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -52,8 +64,9 @@ jobs:
- run: sudo apt-get install -y z3='4.8.12-*'
- run: dotnet tool install --global boogie --version '3.4.3'

- name: System Tests
run: ./mill test.testOnly 'SystemTests*'
- run: ./mill compile
- run: ./scripts/scalatest.sh -oID -n test_util.tags.StandardSystemTest

- uses: actions/upload-artifact@v4
with:
name: testresult-${{ github.run_number }}
Expand Down Expand Up @@ -103,44 +116,11 @@ jobs:
- run: dotnet tool install --global boogie --version '3.4.3'

- run: ./mill test.compile
- run: ./scripts/scalatest.sh -oID -n test_util.tags.UnitTest

# every test with package prefix:
# sbt "show test:definedTests"

# note: tests prefixed with '!' are expected to fail.
# if they are fixed, the '!' should be removed.

- run: ./mill test.testOnly IrreducibleLoop
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly BitVectorAnalysisTests
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly '*IntrusiveListPublicInterfaceTest'
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly util.intrusive_list.IntrusiveListTest
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly DataStructureAnalysisTest
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly ParamAnalysisTests
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly LiveVarsAnalysisTests
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly ir.ToScalaTest
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly ir.IRTest
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly ir.IRToDSLTest
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly ir.CILVisitorTest
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly ir.InterpreterTests
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly ir.InvariantTest
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly ProcedureSummaryTests || true
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly TaintAnalysisTests
if: ${{ ! cancelled() }}

AnalysisSystemTests:
runs-on: ubuntu-latest

Expand All @@ -161,15 +141,7 @@ jobs:
- run: sudo apt-get install -y z3='4.8.12-*'
- run: dotnet tool install --global boogie --version '3.4.3'

- run: echo "All systemtest suites:" & ./mill test.testOnly '*SystemTests*' -- -z 'xxxx'

- run: ./mill test.testOnly DSAMemoryRegionSystemTestsBAP
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly DSAMemoryRegionSystemTestsGTIRB
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly AnalysisSystemTestsBAP
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly AnalysisSystemTestsGTIRB
if: ${{ ! cancelled() }}
- run: ./mill test.testOnly SimplifySystemTests
if: ${{ ! cancelled() }}
- run: echo "All systemtest suites:" && ./mill test.testOnly '*SystemTests*' -- -z 'xxxx'

- run: ./mill compile
- run: ./scripts/scalatest.sh -oID -n test_util.tags.AnalysisSystemTest
33 changes: 33 additions & 0 deletions scripts/scalatest.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

# Executes the full Scalatest runner (https://www.scalatest.org/user_guide/using_the_runner).
#
# This is needed to use some more advanced arguments of the runner, since `./mill test.run`
# silently ignores some arguments (for example, -n and -l).

# NOTE: executing the runner through this script may try to start a GUI.
# to avoid this and use the console, pass -o.

# useful commands
# ---------------
#
# - to include only a specific tag, use -n.
# - to exclude a specific tag, use -l.
# - these can be combined. for example, to select all StandardSystemTest except Slow ones:
#
# ./scripts/scalatest.sh -o -n test_util.tags.StandardSystemTest -l test_util.tags.Slow
#
# - when passing tags through the command line, the fully-qualified name must be used.
# - to print individual test durations, pass D to -o. for example, -oD.
# - to print a summary of failing tests at the end of the output, pass I to -o.
#

classes="$(./mill show test.compile | grep '"classes"' | cut -d'"' -f4 | cut -d: -f4)"

if ! [[ -d "$classes" ]]; then
echo "unable to determine mill class output directory: $classes" >&2
exit 1
fi

exec ./mill test.runMain org.scalatest.tools.Runner -R "$classes" "$@"

2 changes: 1 addition & 1 deletion src/main/scala/translating/IRExpToSMT2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ object BasilIRToSMT2 extends BasilIRExpWithVis[Sexp] {
}

val terms = list(sym("push")) :: BasilIRToSMT2.extractDecls(e)
++ List(assert, list(sym("set-option"), sym(":smt.timeout"), sym("1")), list(sym("check-sat")))
++ List(assert, list(sym("check-sat")))
++ (if (getModel) then
List(list(sym("echo"), sym("\"" + name.getOrElse("") + " :: " + e + "\"")), list(sym("get-model")))
else List())
Expand Down
1 change: 1 addition & 0 deletions src/test/scala/BitVectorAnalysisTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import util.Logger

import scala.runtime.stdLibPatches.Predef.assert

@test_util.tags.UnitTest
class BitVectorAnalysisTests extends AnyFunSuite {

test("BitVector to Natural - should convert BitVector to natural number") {
Expand Down
1 change: 1 addition & 0 deletions src/test/scala/DataStructureAnalysisTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import translating.PrettyPrinter.*
* BASILRESULT.analysis.get.bu is the set of graphs from the end of the bottom-up phase BASILRESULT.analysis.get.td is
* the set of graphs from the end of the top-down phase
*/
@test_util.tags.UnitTest
class DataStructureAnalysisTest extends AnyFunSuite {

def runAnalysis(program: Program): StaticAnalysisContext = {
Expand Down
25 changes: 24 additions & 1 deletion src/test/scala/DifferentialAnalysisTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,28 @@ import util.RunUtils.loadAndTranslate

import scala.collection.mutable

class DifferentialTest extends AnyFunSuite {
abstract class DifferentialTest extends AnyFunSuite, TestCustomisation {

override def customiseTestsByName(name: String) = name match {
case "analysis_differential:floatingpoint/clang:GTIRB" | "analysis_differential:floatingpoint/gcc:GTIRB" =>
Mode.NotImplemented("needs FP_Mul")

case "analysis_differential:function1/gcc_O2:BAP" | "analysis_differential:function1/gcc_O2:GTIRB" |
"analysis_differential:malloc_with_local/gcc_O2:BAP" | "analysis_differential:malloc_with_local/gcc_O2:GTIRB" |
"analysis_differential:malloc_with_local3/gcc_O2:BAP" |
"analysis_differential:malloc_with_local3/gcc_O2:GTIRB" =>
Mode.NotImplemented("needs printf_chk")

case "analysis_differential:syscall/clang:BAP" | "analysis_differential:syscall/clang:GTIRB" |
"analysis_differential:syscall/clang_O2:GTIRB" | "analysis_differential:syscall/gcc:BAP" |
"analysis_differential:syscall/gcc:GTIRB" =>
Mode.NotImplemented("needs fork")

case "analysis_differential:syscall/gcc_O2:BAP" => Mode.TempFailure("traceInit empty")
case "analysis_differential:syscall/gcc_O2:GTIRB" => Mode.NotImplemented("needs fork")

case _ => Mode.Normal
}

Logger.setLevel(LogLevel.WARN)

Expand Down Expand Up @@ -109,6 +130,7 @@ class DifferentialTest extends AnyFunSuite {
}
}

@test_util.tags.AnalysisSystemTest
class DifferentialAnalysisTest extends DifferentialTest {

def runSystemTests(): Unit = {
Expand Down Expand Up @@ -142,6 +164,7 @@ class DifferentialAnalysisTest extends DifferentialTest {
runSystemTests()
}

@test_util.tags.AnalysisSystemTest
class DifferentialAnalysisTestSimplification extends DifferentialTest {

def runSystemTests(): Unit = {
Expand Down
18 changes: 17 additions & 1 deletion src/test/scala/IndirectCallTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,27 @@ import scala.collection.mutable.ArrayBuffer
import scala.collection.mutable
import test_util.BASILTest
import test_util.TestConfig
import test_util.TestCustomisation
import util.DSAAnalysis.Norm

import java.io.{BufferedWriter, File, FileWriter}

class IndirectCallTests extends AnyFunSuite, BASILTest {
@test_util.tags.AnalysisSystemTest
class IndirectCallTests extends AnyFunSuite, BASILTest, TestCustomisation {

override def customiseTestsByName(name: String) = name match {
case "indirect_call_outparam/clang:BAP" | "indirect_call_outparam/clang:GTIRB" | "indirect_call_outparam/gcc:BAP" |
"indirect_call_outparam/gcc:GTIRB" =>
Mode.NotImplemented("indirect call not resolved to correct target -- overapproximate result")

case "jumptable3/clang:GTIRB" | "jumptable3/clang_O2:GTIRB" | "switch2/clang:GTIRB" =>
Mode.NotImplemented("indirect call not resolved to goto -- not yet handled")

case "jumptable/gcc:BAP" | "jumptable/gcc:GTIRB" =>
Mode.NotImplemented("needs specifications about the security level of the jumptable in the binary's data section")

case _ => Mode.Normal
}

/** @param label - the label of the IndirectCall to be resolved
* @param labelProcedure - the name of the procedure containing the IndirectCall to be resolved
Expand Down
1 change: 1 addition & 0 deletions src/test/scala/InterpretTestConstProp.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import util.RunUtils.loadAndTranslate

import scala.collection.mutable

@test_util.tags.StandardSystemTest
class ConstPropInterpreterValidate extends AnyFunSuite with TestValueDomainWithInterpreter[FlatElement[BitVecLiteral]] {

Logger.setLevel(LogLevel.ERROR)
Expand Down
1 change: 1 addition & 0 deletions src/test/scala/IntervalDSATest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import util.{
StaticAnalysisContext
}

@test_util.tags.UnitTest
class IntervalDSATest extends AnyFunSuite {
def runAnalysis(program: Program): StaticAnalysisContext = {
cilvisitor.visit_prog(transforms.ReplaceReturns(), program)
Expand Down
1 change: 1 addition & 0 deletions src/test/scala/IrreducibleLoop.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import test_util.BASILTest.writeToFile
/** Add more tests by simply adding them to the programs directory. Refer to the existing tests for the expected
* directory structure and file-name patterns.
*/
@test_util.tags.UnitTest
class IrreducibleLoop extends AnyFunSuite {
val testPath = "./src/test/irreducible_loops"
Logger.setLevel(LogLevel.ERROR)
Expand Down
1 change: 1 addition & 0 deletions src/test/scala/LiveVarsAnalysisTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import test_util.BASILTest
import util.{BASILResult, StaticAnalysisConfig}
import translating.PrettyPrinter.*

@test_util.tags.UnitTest
class LiveVarsAnalysisTests extends AnyFunSuite, BASILTest {
Logger.setLevel(LogLevel.ERROR)
private val correctPath = "./src/test/correct/"
Expand Down
1 change: 1 addition & 0 deletions src/test/scala/ParamAnalysisTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import org.scalatest.funsuite.AnyFunSuite
import test_util.BASILTest
import util.{BASILResult, StaticAnalysisConfig, Logger, LogLevel}

@test_util.tags.UnitTest
class ParamAnalysisTests extends AnyFunSuite, BASILTest {
private val correctPath = "./src/test/correct/"

Expand Down
1 change: 1 addition & 0 deletions src/test/scala/PointsToTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import java.nio.file.attribute.BasicFileAttributes

import ir.dsl.*

@test_util.tags.DisabledTest
class PointsToTest extends AnyFunSuite with OneInstancePerTest {

def runAnalyses(
Expand Down
1 change: 1 addition & 0 deletions src/test/scala/SATTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import test_util.BASILTest
import util.*
import translating.BasilIRToSMT2

@test_util.tags.UnitTest
class SATTest extends AnyFunSuite {
test(" basic taut ") {
// Logger.setLevel(LogLevel.DEBUG)
Expand Down
1 change: 1 addition & 0 deletions src/test/scala/SVATest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import util.*

import scala.collection.immutable.{AbstractSeq, LinearSeq}

@test_util.tags.UnitTest
class SVATest extends AnyFunSuite {

def runAnalysis(program: Program): StaticAnalysisContext = {
Expand Down
Loading
Loading