proc: fuzzing expression evaluator and variable loader (#3293)

Add code to fuzz the expression evaluator and variable loader, see
comment to FuzzEvalExpression for how to use this.
This commit is contained in:
Alessandro Arzilli
2023-03-16 20:13:10 +01:00
committed by GitHub
parent 9faf66b7a1
commit 1522382336
6 changed files with 261 additions and 11 deletions

View File

@ -50,7 +50,7 @@ func matchStringOrPrefix(output, target string) bool {
}
}
func assertVariable(t *testing.T, variable *proc.Variable, expected varTest) {
func assertVariable(t testing.TB, variable *proc.Variable, expected varTest) {
if expected.preserveName {
if variable.Name != expected.name {
t.Fatalf("Expected %s got %s\n", expected.name, variable.Name)
@ -511,7 +511,7 @@ func TestComplexSetting(t *testing.T) {
})
}
func TestEvalExpression(t *testing.T) {
func getEvalExpressionTestCases() []varTest {
testcases := []varTest{
// slice/array/string subscript
{"s1[0]", false, "\"one\"", "\"one\"", "string", nil},
@ -845,6 +845,11 @@ func TestEvalExpression(t *testing.T) {
}
}
return testcases
}
func TestEvalExpression(t *testing.T) {
testcases := getEvalExpressionTestCases()
protest.AllowRecording(t)
withTestProcess("testvariables2", t, func(p *proc.Target, grp *proc.TargetGroup, fixture protest.Fixture) {
assertNoError(grp.Continue(), t, "Continue() returned an error")