Bladeren bron

Implements global timeout

tags/v1.1.0
dump_stack() 10 maanden geleden
bovenliggende
commit
104e70f861
Getekend door: Mikhail Klementev <blame@dumpstack.io> GPG sleutel-ID: BE44DA8C062D87DC
4 gewijzigde bestanden met toevoegingen van 26 en 7 verwijderingen
  1. 5
    0
      CHANGELOG.md
  2. 10
    2
      main.go
  3. 2
    2
      pack.go
  4. 9
    3
      pew.go

+ 5
- 0
CHANGELOG.md Bestand weergeven

@@ -18,6 +18,11 @@
- Support for (distro-specific) custom docker commands that will be
executed before the base template.

- Parameter for setting up a reliability threshold for exit code.

- Parameter for setting up global timeout, after which no new tasks
will be started.

### Fixed

- Spelling in output.

+ 10
- 2
main.go Bestand weergeven

@@ -111,6 +111,9 @@ func main() {
userKcfgPathEnv := userKcfgPathFlag.Envar("OUT_OF_TREE_KCFG")
userKcfgPath := userKcfgPathEnv.Default(conf.UserKernels).String()

timeoutFlag := app.Flag("timeout", "Timeout after tool will not spawn new tests")
timeout := timeoutFlag.Duration()

qemuTimeoutFlag := app.Flag("qemu-timeout", "Timeout for qemu")
qemuTimeout := qemuTimeoutFlag.Default(conf.Qemu.Timeout).Duration()

@@ -287,10 +290,15 @@ func main() {
}
defer db.Close()

stop := time.Time{} // never stop
if *timeout != 0 {
stop = time.Now().Add(*timeout)
}

switch kingpin.MustParse(app.Parse(os.Args[1:])) {
case pewCommand.FullCommand():
err = pewHandler(kcfg, *path, *pewKernel, *pewBinary,
*pewTest, *pewGuess, *qemuTimeout, *dockerTimeout,
*pewTest, *pewGuess, stop, *qemuTimeout, *dockerTimeout,
*pewMax, *pewRuns, *pewDist, *pewTag, *pewThreads, db)
case kernelListCommand.FullCommand():
err = kernelListHandler(kcfg)
@@ -326,7 +334,7 @@ func main() {
case logMarkdownCommand.FullCommand():
err = logMarkdownHandler(db, *path, *logMarkdownTag)
case packCommand.FullCommand():
err = packHandler(db, *path, *dockerRegistry,
err = packHandler(db, *path, *dockerRegistry, stop,
conf.Docker.Commands, kcfg, *packAutogen,
!*packNoDownload, *packExploitRuns, *packKernelRuns)
}

+ 2
- 2
pack.go Bestand weergeven

@@ -15,7 +15,7 @@ import (
"code.dumpstack.io/tools/out-of-tree/config"
)

func packHandler(db *sql.DB, path, registry string,
func packHandler(db *sql.DB, path, registry string, stop time.Time,
commands []config.DockerCommand, kcfg config.KernelConfig,
autogen, download bool, exploitRuns, kernelRuns int64) (err error) {

@@ -50,7 +50,7 @@ func packHandler(db *sql.DB, path, registry string,
log.Println(f.Name())

pewHandler(kcfg, workPath, "", "", "", false,
dockerTimeout, qemuTimeout,
stop, dockerTimeout, qemuTimeout,
kernelRuns, exploitRuns, pathDevNull, tag, threads, db)
}


+ 9
- 3
pew.go Bestand weergeven

@@ -391,7 +391,8 @@ func shuffleKernels(a []config.KernelInfo) []config.KernelInfo {
}

func performCI(ka config.Artifact, kcfg config.KernelConfig, binaryPath,
testPath string, qemuTimeout, dockerTimeout time.Duration,
testPath string, stop time.Time,
qemuTimeout, dockerTimeout time.Duration,
max, runs int64, dist, tag string, threads int,
db *sql.DB) (err error) {

@@ -413,6 +414,9 @@ func performCI(ka config.Artifact, kcfg config.KernelConfig, binaryPath,
found = true
max--
for i := int64(0); i < runs; i++ {
if !stop.IsZero() && time.Now().After(stop) {
break
}
swg.Add()
go whatever(&swg, ka, kernel, binaryPath,
testPath, qemuTimeout, dockerTimeout,
@@ -468,9 +472,10 @@ func genAllKernels() (sk []config.KernelMask, err error) {
return
}

// TODO: Now too many parameters, move all of them to some structure
func pewHandler(kcfg config.KernelConfig,
workPath, ovrrdKrnl, binary, test string, guess bool,
qemuTimeout, dockerTimeout time.Duration,
stop time.Time, qemuTimeout, dockerTimeout time.Duration,
max, runs int64, dist, tag string, threads int,
db *sql.DB) (err error) {

@@ -500,7 +505,8 @@ func pewHandler(kcfg config.KernelConfig,
}
}

err = performCI(ka, kcfg, binary, test, qemuTimeout, dockerTimeout,
err = performCI(ka, kcfg, binary, test,
stop, qemuTimeout, dockerTimeout,
max, runs, dist, tag, threads, db)
if err != nil {
return

Laden…
Annuleren
Opslaan