Add a helper module for fuzzing CLI parsers

This commit is contained in:
Zahary Karadjov 2020-10-01 22:04:53 +03:00
parent 2e8040ec5e
commit 5c81aab54d
No known key found for this signature in database
GPG Key ID: C8936F8A3073D609
2 changed files with 17 additions and 0 deletions

View File

@ -0,0 +1,15 @@
import
strutils,
stew/byteutils, testutils/fuzzing,
../confutils
template fuzzCliParsing*(Conf: type) =
test:
block:
try:
let cfg = Conf.load(cmdLine = split(fromBytes(string, payload)),
printUsage = false,
quitOnFailure = false)
except ConfigurationError as err:
discard

View File

@ -2,6 +2,8 @@ import std/parseutils
import stew/shims/net as stewNet
export stewNet
export ValidIpAddress
func parseCmdArg*(T: type ValidIpAddress, s: TaintedString): T =
ValidIpAddress.init(string s)