1
0

Implements the parameter to specify an endless stress script

This commit is contained in:
dump_stack() 2023-05-08 22:01:10 +00:00
parent ca95155ce0
commit 3677adece9
Signed by: dump_stack
GPG Key ID: BE44DA8C062D87DC
2 changed files with 22 additions and 0 deletions

11
pew.go
View File

@ -50,6 +50,7 @@ type PewCmd struct {
Endless bool `help:"endless tests"` Endless bool `help:"endless tests"`
EndlessTimeout time.Duration `help:"timeout between tests" default:"1m"` EndlessTimeout time.Duration `help:"timeout between tests" default:"1m"`
EndlessStress string `help:"endless stress script" type:"existingfile"`
db *sql.DB db *sql.DB
kcfg config.KernelConfig kcfg config.KernelConfig
@ -740,6 +741,16 @@ func (cmd PewCmd) testArtifact(swg *sizedwaitgroup.SizedWaitGroup,
slog.Info().Msg("start endless tests") slog.Info().Msg("start endless tests")
if cmd.EndlessStress != "" {
slog.Debug().Msg("copy and run endless stress script")
err = q.CopyAndRunAsync("root", cmd.EndlessStress)
if err != nil {
q.Stop()
slog.Fatal().Err(err).Msg("cannot copy/run stress")
return
}
}
for { for {
output, err := q.Command("root", remoteTest) output, err := q.Command("root", remoteTest)
if err != nil { if err != nil {

View File

@ -550,6 +550,17 @@ func (q *System) CopyAndRun(user, path string) (output string, err error) {
return q.Command(user, "chmod +x "+remotePath+" && "+remotePath) return q.Command(user, "chmod +x "+remotePath+" && "+remotePath)
} }
// CopyAndRunAsync is copy local file to qemu vm then run it w/o wait for exit
func (q *System) CopyAndRunAsync(user, path string) (err error) {
remotePath := fmt.Sprintf("/tmp/executable_%d", rand.Int())
err = q.CopyFile(user, path, remotePath)
if err != nil {
return
}
return q.AsyncCommand(user, "chmod +x "+remotePath+" && "+remotePath)
}
// Debug is for enable qemu debug and set hostname and port for listen // Debug is for enable qemu debug and set hostname and port for listen
func (q *System) Debug(conn string) { func (q *System) Debug(conn string) {
q.debug = true q.debug = true