Implements reliablity threshold for exit code
This commit is contained in:
parent
5bad772125
commit
365c9d0e95
5
main.go
5
main.go
@ -120,6 +120,9 @@ func main() {
|
|||||||
dockerRegistryFlag := app.Flag("docker-registry", "Registry for docker")
|
dockerRegistryFlag := app.Flag("docker-registry", "Registry for docker")
|
||||||
dockerRegistry := dockerRegistryFlag.Default(conf.Docker.Registry).String()
|
dockerRegistry := dockerRegistryFlag.Default(conf.Docker.Registry).String()
|
||||||
|
|
||||||
|
thresholdFlag := app.Flag("threshold", "Reliablity threshold for exit code")
|
||||||
|
threshold := thresholdFlag.Default("1.00").Float64()
|
||||||
|
|
||||||
pewCommand := app.Command("pew", "Build, run and test module/exploit")
|
pewCommand := app.Command("pew", "Build, run and test module/exploit")
|
||||||
|
|
||||||
pewMax := pewCommand.Flag("max", "Test no more than X kernels").
|
pewMax := pewCommand.Flag("max", "Test no more than X kernels").
|
||||||
@ -332,7 +335,7 @@ func main() {
|
|||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if somethingFailed {
|
if successRate(state) < *threshold {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
15
pew.go
15
pew.go
@ -26,7 +26,17 @@ import (
|
|||||||
"code.dumpstack.io/tools/out-of-tree/qemu"
|
"code.dumpstack.io/tools/out-of-tree/qemu"
|
||||||
)
|
)
|
||||||
|
|
||||||
var somethingFailed = false
|
type runstate struct {
|
||||||
|
Overall, Success float64
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
state runstate
|
||||||
|
)
|
||||||
|
|
||||||
|
func successRate(state runstate) float64 {
|
||||||
|
return state.Success / state.Overall
|
||||||
|
}
|
||||||
|
|
||||||
const pathDevNull = "/dev/null"
|
const pathDevNull = "/dev/null"
|
||||||
|
|
||||||
@ -134,11 +144,12 @@ func testKernelExploit(q *qemu.System, ka config.Artifact,
|
|||||||
}
|
}
|
||||||
|
|
||||||
func genOkFail(name string, ok bool) (aurv aurora.Value) {
|
func genOkFail(name string, ok bool) (aurv aurora.Value) {
|
||||||
|
state.Overall += 1
|
||||||
if ok {
|
if ok {
|
||||||
|
state.Success += 1
|
||||||
s := " " + name + " SUCCESS "
|
s := " " + name + " SUCCESS "
|
||||||
aurv = aurora.BgGreen(aurora.Black(s))
|
aurv = aurora.BgGreen(aurora.Black(s))
|
||||||
} else {
|
} else {
|
||||||
somethingFailed = true
|
|
||||||
s := " " + name + " FAILURE "
|
s := " " + name + " FAILURE "
|
||||||
aurv = aurora.BgRed(aurora.Gray(aurora.Bold(s)))
|
aurv = aurora.BgRed(aurora.Gray(aurora.Bold(s)))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user