Implements support build/run/test only for one kernel
This commit is contained in:
parent
e3692b9df1
commit
7a68de16ba
@ -38,3 +38,9 @@ If you already have Go, Qemu and Docker installed, there's cross-platform instal
|
||||
$ cd ../kernel-module
|
||||
$ # test kernel module
|
||||
$ out-of-tree pew
|
||||
|
||||
## Examples
|
||||
|
||||
Test only with one kernel:
|
||||
|
||||
$ out-of-tree pew --kernel='Ubuntu:4.10.0-30-generic'
|
||||
|
22
main.go
22
main.go
@ -405,7 +405,7 @@ func exists(path string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func pewHandler(workPath, kcfgPath string) (err error) {
|
||||
func pewHandler(workPath, kcfgPath, overridedKernel string) (err error) {
|
||||
ka, err := readArtifactConfig(workPath + "/.out-of-tree.toml")
|
||||
if err != nil {
|
||||
return
|
||||
@ -415,6 +415,22 @@ func pewHandler(workPath, kcfgPath string) (err error) {
|
||||
ka.SourcePath = workPath
|
||||
}
|
||||
|
||||
if overridedKernel != "" {
|
||||
parts := strings.Split(overridedKernel, ":")
|
||||
if len(parts) != 2 {
|
||||
return errors.New("Kernel is not 'distroType:regex'")
|
||||
}
|
||||
|
||||
var dt distroType
|
||||
err = dt.UnmarshalTOML([]byte(parts[0]))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
km := kernelMask{DistroType: dt, ReleaseMask: parts[1]}
|
||||
ka.SupportedKernels = []kernelMask{km}
|
||||
}
|
||||
|
||||
kcfg, err := readKernelConfig(kcfgPath)
|
||||
if err != nil {
|
||||
return
|
||||
@ -444,11 +460,13 @@ func main() {
|
||||
kcfg := kcfgFlag.Envar("OUT_OF_TREE_KCFG").Required().ExistingFile()
|
||||
|
||||
pewCommand := app.Command("pew", "Build, run and test module/exploit")
|
||||
pewKernelCmd := pewCommand.Flag("kernel", "Override kernel regex")
|
||||
pewKernel := pewKernelCmd.String()
|
||||
|
||||
var err error
|
||||
switch kingpin.MustParse(app.Parse(os.Args[1:])) {
|
||||
case pewCommand.FullCommand():
|
||||
err = pewHandler(*path, *kcfg)
|
||||
err = pewHandler(*path, *kcfg, *pewKernel)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user