-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #211 from litmuschaos/CHAOS-4611
chore: [CHAOS-4611]: writing initial fuzz testing for chaos runner
- Loading branch information
Showing
7 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package utils | ||
|
||
import ( | ||
"strings" | ||
"testing" | ||
) | ||
|
||
func FuzzRandomString(f *testing.F) { | ||
f.Add(6) | ||
f.Fuzz(func(t *testing.T, n int) { | ||
randomString := RandomString(n) | ||
// Perform checks on the generated string | ||
// Check if the length matches the expected length | ||
if n >= 0 && len(randomString) != n { | ||
t.Errorf("Generated string length doesn't match expected length") | ||
} | ||
|
||
// Check if the string contains only valid characters | ||
if !isValidString(randomString) { | ||
t.Errorf("Generated string contains invalid characters") | ||
} | ||
}) | ||
|
||
} | ||
|
||
func isValidString(s string) bool { | ||
// Define the set of valid characters | ||
validChars := "abcdefghijklmnopqrstuvwxyz0123456789" | ||
|
||
// Iterate over each character in the string | ||
for _, char := range s { | ||
// Check if the character is not in the set of valid characters | ||
if !strings.ContainsRune(validChars, char) { | ||
return false | ||
} | ||
} | ||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
pkg/utils/testdata/fuzz/FuzzSetWatchChaosContainerForCompletion/582528ddfad69eb5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
go test fuzz v1 | ||
[]byte("0") |