feat: parameters to specify kernel/distro for debug/test
This commit is contained in:
parent
ad5254ded3
commit
cdfa480479
31
cmd/debug.go
31
cmd/debug.go
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2018 Mikhail Klementev. All rights reserved.
|
// Copyright 2024 Mikhail Klementev. All rights reserved.
|
||||||
// Use of this source code is governed by a AGPLv3 license
|
// Use of this source code is governed by a AGPLv3 license
|
||||||
// (or later) that can be found in the LICENSE file.
|
// (or later) that can be found in the LICENSE file.
|
||||||
|
|
||||||
@ -22,8 +22,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type DebugCmd struct {
|
type DebugCmd struct {
|
||||||
Kernel string `help:"regexp (first match)" required:""`
|
KernelRegex string `required:"" help:"set kernel regex"`
|
||||||
Gdb string `help:"gdb listen address" default:"tcp::1234"`
|
DistroID string `required:"" help:"set distribution"`
|
||||||
|
DistroRelease string `required:"" help:"set distribution release"`
|
||||||
|
|
||||||
|
Gdb string `help:"gdb listen address" default:"tcp::1234"`
|
||||||
|
|
||||||
SshAddr string `help:"ssh address to listen" default:"127.0.0.1"`
|
SshAddr string `help:"ssh address to listen" default:"127.0.0.1"`
|
||||||
SshPort int `help:"ssh port to listen" default:"50022"`
|
SshPort int `help:"ssh port to listen" default:"50022"`
|
||||||
@ -63,7 +66,17 @@ func (cmd *DebugCmd) Run(g *Globals) (err error) {
|
|||||||
ka.SourcePath = g.WorkDir
|
ka.SourcePath = g.WorkDir
|
||||||
}
|
}
|
||||||
|
|
||||||
ki, err := firstSupported(kcfg, ka, cmd.Kernel)
|
var km artifact.Target
|
||||||
|
km.Distro.ID, err = distro.NewID(cmd.DistroID)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
km.Distro.Release = cmd.DistroRelease
|
||||||
|
km.Kernel.Regex = cmd.KernelRegex
|
||||||
|
|
||||||
|
ka.Targets = []artifact.Target{km}
|
||||||
|
|
||||||
|
ki, err := firstSupported(kcfg, ka)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -223,15 +236,7 @@ func (cmd *DebugCmd) Run(g *Globals) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func firstSupported(kcfg config.KernelConfig, ka artifact.Artifact,
|
func firstSupported(kcfg config.KernelConfig, ka artifact.Artifact) (ki distro.KernelInfo, err error) {
|
||||||
kernel string) (ki distro.KernelInfo, err error) {
|
|
||||||
|
|
||||||
km, err := kernelMask(kernel)
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
ka.Targets = []artifact.Target{km}
|
|
||||||
|
|
||||||
for _, ki = range kcfg.Kernels {
|
for _, ki = range kcfg.Kernels {
|
||||||
var supported bool
|
var supported bool
|
||||||
|
63
cmd/pew.go
63
cmd/pew.go
@ -1,4 +1,4 @@
|
|||||||
// Copyright 2023 Mikhail Klementev. All rights reserved.
|
// Copyright 2024 Mikhail Klementev. All rights reserved.
|
||||||
// Use of this source code is governed by a AGPLv3 license
|
// Use of this source code is governed by a AGPLv3 license
|
||||||
// (or later) that can be found in the LICENSE file.
|
// (or later) that can be found in the LICENSE file.
|
||||||
|
|
||||||
@ -64,7 +64,6 @@ func successRate(state runstate) float64 {
|
|||||||
type PewCmd struct {
|
type PewCmd struct {
|
||||||
Max int64 `help:"test no more than X kernels" default:"100500"`
|
Max int64 `help:"test no more than X kernels" default:"100500"`
|
||||||
Runs int64 `help:"runs per each kernel" default:"1"`
|
Runs int64 `help:"runs per each kernel" default:"1"`
|
||||||
Kernel string `help:"override kernel regex"`
|
|
||||||
RootFS string `help:"override rootfs image" type:"existingfile"`
|
RootFS string `help:"override rootfs image" type:"existingfile"`
|
||||||
Guess bool `help:"try all defined kernels"`
|
Guess bool `help:"try all defined kernels"`
|
||||||
Shuffle bool `help:"randomize kernels test order"`
|
Shuffle bool `help:"randomize kernels test order"`
|
||||||
@ -75,6 +74,10 @@ type PewCmd struct {
|
|||||||
Tag string `help:"log tagging"`
|
Tag string `help:"log tagging"`
|
||||||
Timeout time.Duration `help:"timeout after tool will not spawn new tests"`
|
Timeout time.Duration `help:"timeout after tool will not spawn new tests"`
|
||||||
|
|
||||||
|
KernelRegex string `help:"set kernel regex"`
|
||||||
|
DistroID string `help:"set distribution"`
|
||||||
|
DistroRelease string `help:"set distribution release"`
|
||||||
|
|
||||||
ArtifactConfig string `help:"path to artifact config" type:"path"`
|
ArtifactConfig string `help:"path to artifact config" type:"path"`
|
||||||
|
|
||||||
QemuTimeout time.Duration `help:"timeout for qemu"`
|
QemuTimeout time.Duration `help:"timeout for qemu"`
|
||||||
@ -220,14 +223,47 @@ func (cmd *PewCmd) Run(g *Globals) (err error) {
|
|||||||
ka.SourcePath = g.WorkDir
|
ka.SourcePath = g.WorkDir
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd.Kernel != "" {
|
if cmd.KernelRegex != "" {
|
||||||
var km artifact.Target
|
var km artifact.Target
|
||||||
km, err = kernelMask(cmd.Kernel)
|
km.Kernel.Regex = cmd.KernelRegex
|
||||||
|
|
||||||
|
if cmd.DistroID == "" {
|
||||||
|
err = errors.New("--distro-id is required")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var dt distro.ID
|
||||||
|
dt, err = distro.NewID(cmd.DistroID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
km.Distro.ID = dt
|
||||||
|
|
||||||
|
if cmd.DistroRelease != "" {
|
||||||
|
km.Distro.Release = cmd.DistroRelease
|
||||||
|
}
|
||||||
|
|
||||||
ka.Targets = []artifact.Target{km}
|
ka.Targets = []artifact.Target{km}
|
||||||
|
} else if cmd.DistroID != "" {
|
||||||
|
var km artifact.Target
|
||||||
|
|
||||||
|
var dt distro.ID
|
||||||
|
dt, err = distro.NewID(cmd.DistroID)
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
km.Distro.ID = dt
|
||||||
|
|
||||||
|
if cmd.DistroRelease != "" {
|
||||||
|
km.Distro.Release = cmd.DistroRelease
|
||||||
|
}
|
||||||
|
|
||||||
|
ka.Targets = []artifact.Target{km}
|
||||||
|
} else if cmd.DistroRelease != "" {
|
||||||
|
err = errors.New("--distro-release has no use on its own")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if ka.Qemu.Timeout.Duration == 0 {
|
if ka.Qemu.Timeout.Duration == 0 {
|
||||||
@ -495,25 +531,6 @@ func (cmd PewCmd) performCI(ka artifact.Artifact) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func kernelMask(kernel string) (km artifact.Target, err error) {
|
|
||||||
parts := strings.Split(kernel, ":")
|
|
||||||
if len(parts) != 2 {
|
|
||||||
err = errors.New("kernel is not 'distroType:regex'")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
dt, err := distro.NewID(parts[0])
|
|
||||||
if err != nil {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
km = artifact.Target{
|
|
||||||
Distro: distro.Distro{ID: dt},
|
|
||||||
Kernel: artifact.Kernel{Regex: parts[1]},
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
func genOkFail(name string, ok bool) (aurv aurora.Value) {
|
func genOkFail(name string, ok bool) (aurv aurora.Value) {
|
||||||
s := " " + name
|
s := " " + name
|
||||||
if name == "" {
|
if name == "" {
|
||||||
|
Loading…
Reference in New Issue
Block a user