Skip to content

Commit 1a5e554

Browse files
committed
Add pfc-memcmp-1 regression test to CI
1 parent 572ab0e commit 1a5e554

4 files changed

Lines changed: 108 additions & 1 deletion

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
digraph {
2+
0 [ label = "Start" ]
3+
1 [ label = "Attempt(Connect(ConnectAttempt { addr: 192.2.2.2:502 }))" ]
4+
2 [ label = "Attempt(Send(SendAttempt { payload: [0, 1, 0, 0, 0, 6, 1, 3, 0, 0, 0, 2] }))" ]
5+
3 [ label = "Attempt(Recv(RecvAttempt { payload: [0, 1, 0, 0, 0, 6, 1, 3, 0, 0, 0, 2] }))" ]
6+
4 [ label = "End" ]
7+
5 [ label = "Attempt(Send(SendAttempt { payload: [0, 2, 0, 0, 0, 11, 1, 16, 0, 0, 0, 2, 4, 0, 0, 0, 0] }))" ]
8+
6 [ label = "Attempt(Recv(RecvAttempt { payload: [0, 2, 0, 0, 0, 11, 1, 16, 0, 0, 0, 2, 4, 0, 0, 0, 0] }))" ]
9+
7 [ label = "End" ]
10+
8 [ label = "End" ]
11+
9 [ label = "End" ]
12+
10 [ label = "End" ]
13+
11 [ label = "End" ]
14+
12 [ label = "End" ]
15+
0 -> 1 [ label = "None" ]
16+
1 -> 2 [ label = "Connect(ConnectReact { success: true })" ]
17+
2 -> 3 [ label = "Send(SendReact { success: true })" ]
18+
3 -> 4 [ label = "Recv(Payload([0, 1, 0, 0, 0, 7, 1, 3, 4, 0, 0, 0, 0]))" ]
19+
3 -> 5 [ label = "Recv(Payload([0, 1, 0, 0, 0, 7, 1, 3, 4, 87, 111, 114, 108]))" ]
20+
5 -> 6 [ label = "Send(SendReact { success: true })" ]
21+
6 -> 7 [ label = "Recv(Payload([0, 2, 0, 0, 0, 6, 1, 16, 0, 0, 0, 2]))" ]
22+
6 -> 8 [ label = "Recv(SocketError)" ]
23+
5 -> 9 [ label = "Send(SendReact { success: false })" ]
24+
3 -> 10 [ label = "Recv(SocketError)" ]
25+
2 -> 11 [ label = "Send(SendReact { success: false })" ]
26+
1 -> 12 [ label = "Connect(ConnectReact { success: false })" ]
27+
}
Binary file not shown.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
2+
# Specify the target binary, its path and expected output.
3+
$Target = "prove_fuzzing_capability_memcmp_1.exe"
4+
$TargetPath = "tests\prove_fuzzing_capability_memcmp_1\$Target"
5+
$expected = Get-Content "tests\prove_fuzzing_capability_memcmp_1\digraph_prove_fuzzing_capability_memcmp_1.txt"
6+
7+
# Check that the DynamoRio bin directory env variable is set.
8+
if (-not $Env:DYNAMORIO_BIN) {
9+
Write-Error "Error: DYNAMORIO_BIN environment variable must be set"
10+
exit 1
11+
}
12+
13+
# Define command-line arguments.
14+
$DynamoBin = $env:DYNAMORIO_BIN
15+
$ClientLib = "$PWD\inject\build64\Release\inject.dll"
16+
$MutatorLib = "$PWD\winafl-netspoof\build64\bin\Release\mutator.dll"
17+
$TargetOpts = "`"192.2.2.2`""
18+
$FuzzIterations = 3000
19+
$Parallel = 5
20+
21+
Write-Host "Running test binary $Target with CLI arguments:"
22+
Write-Host "--dynamorio-bin-dir=$DynamoBin"
23+
Write-Host "--dr-client-lib=$ClientLib"
24+
Write-Host "--mutator-lib=$MutatorLib"
25+
Write-Host "--target-module=$Target"
26+
Write-Host "--target-path=$TargetPath"
27+
Write-Host "--target-opts=$TargetOpts"
28+
Write-Host "--fuzz-iterations=$FuzzIterations"
29+
Write-Host "--parallel=$Parallel"
30+
31+
# Check that expected files/paths exist.
32+
if (Test-Path -Path $DynamoBin) {
33+
Write-Host "Path exists: $DynamoBin"
34+
} else {
35+
Write-Host "Path doesn't exist: $DynamoBin"
36+
}
37+
if (Test-Path $ClientLib -PathType Leaf) {
38+
Write-Host "File exists: $ClientLib"
39+
} else {
40+
Write-Host "File doesn't exist: $ClientLib"
41+
}
42+
if (Test-Path $MutatorLib -PathType Leaf) {
43+
Write-Host "File exists: $MutatorLib"
44+
} else {
45+
Write-Host "File doesn't exist: $MutatorLib"
46+
}
47+
if (Test-Path $TargetPath -PathType Leaf) {
48+
Write-Host "File exists: $TargetPath"
49+
} else {
50+
Write-Host "File doesn't exist: $TargetPath"
51+
}
52+
53+
# Ensure the output file does not already exist.
54+
$OutputFile = "digraph.txt"
55+
Remove-Item $OutputFile -ErrorAction Ignore
56+
57+
# Run navigator.exe, and get the process ID.
58+
$process = Start-Process ".\target\debug\navigator.exe" -ArgumentList "--dynamorio-bin-dir=$DynamoBin --mutator-lib=$MutatorLib --coverage-module=$Target --target-module=$Target --nargs=2 --target-path=$TargetPath --target-opts=$TargetOpts --fuzz-iterations=$FuzzIterations --parallel=$Parallel" -PassThru -Wait
59+
$ExitCode = $process.ExitCode
60+
61+
if ($ExitCode -ne 0) {
62+
Write-Error "Test app failed with exit code: $ExitCode"
63+
}
64+
65+
if (Test-Path $OutputFile -PathType Leaf) {
66+
Write-Host "Found output file: $OutputFile"
67+
} else {
68+
Write-Host "Output file doesn't exist: $OutputFile"
69+
}
70+
71+
# Compare the output file to the expected output.
72+
$actual = Get-Content $OutputFile
73+
74+
if (-not (Compare-Object $actual $expected -SyncWindow 0)) {
75+
Write-Host "PASSED: digraph.txt matches expectated output"
76+
} else {
77+
Write-Error "FAILED: mismatch between digraph.txt and expected output"
78+
}

tests/run_tests.ps1

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
$tests = @(
2-
"only_connect"
2+
"only_connect",
3+
"prove_fuzzing_capability_cmp_inline_1",
4+
"prove_fuzzing_capability_memcmp_1"
35
)
46

57
foreach ($t in $tests) {

0 commit comments

Comments
 (0)