diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2021-11-17 12:36:48 +0000 |
|---|---|---|
| committer | Aleksandr Nogikh <wp32pw@gmail.com> | 2021-11-19 19:06:55 +0100 |
| commit | 780b27623e2c0284dfb0c8e0392463d1eef00e92 (patch) | |
| tree | c8dcefe94021fc3e0a5693e082a9c3751c64997f /tools/syz-testbed/testbed.go | |
| parent | 3a9d0024ba818c5b37058d9ac6fdfc0ddfa78be6 (diff) | |
tools/syz-testbed: support per-checkout syz-manager configs
Let the user of the tool specify individual syz-manager configs for
checkouts. A base config is specified as previously and then individual
parts of jsons are applied to that base config, e.g.
<...>
"checkouts": [
{
"name": "first",
"repo": "https://github.com/google/syzkaller.git",
},
{
"name": "second",
"repo": "https://github.com/google/syzkaller.git",
"manager_config": {
"kernel_obj": "/tmp/linux-stable2"
}
}
],
"manager_config": {
"target": "linux/amd64",
"kernel_obj": "/tmp/linux-stable",
<...>
}
<...>
Diffstat (limited to 'tools/syz-testbed/testbed.go')
| -rw-r--r-- | tools/syz-testbed/testbed.go | 40 |
1 files changed, 23 insertions, 17 deletions
diff --git a/tools/syz-testbed/testbed.go b/tools/syz-testbed/testbed.go index e67dd6883..dee9ffc73 100644 --- a/tools/syz-testbed/testbed.go +++ b/tools/syz-testbed/testbed.go @@ -46,14 +46,14 @@ type DurationConfig struct { } type CheckoutConfig struct { - Name string `json:"name"` - Repo string `json:"repo"` - Branch string `json:"branch"` + Name string `json:"name"` + Repo string `json:"repo"` + Branch string `json:"branch"` + ManagerConfig json.RawMessage `json:"manager_config"` // a patch to manager config } type TestbedContext struct { Config *TestbedConfig - ManagerConfig *mgrconfig.Config Checkouts []*Checkout NextRestart time.Time NextCheckoutID int @@ -76,24 +76,14 @@ func main() { if err != nil { tool.Failf("invalid config: %s", err) } - - managerCfg, err := mgrconfig.LoadPartialData(cfg.ManagerConfig) - if err != nil { - tool.Failf("failed to parse manager config: %s", err) - } - if managerCfg.HTTP == "" { - // Actually we don't care much about the specific ports of syz-managers. - managerCfg.HTTP = ":0" - } - ctx := TestbedContext{ - Config: cfg, - ManagerConfig: managerCfg, + Config: cfg, } go ctx.setupHTTPServer() for _, checkoutCfg := range cfg.Checkouts { - co, err := ctx.NewCheckout(&checkoutCfg) + mgrCfg := ctx.MakeMgrConfig(cfg.ManagerConfig, checkoutCfg.ManagerConfig) + co, err := ctx.NewCheckout(&checkoutCfg, mgrCfg) if err != nil { tool.Failf("checkout failed: %s", err) } @@ -117,6 +107,22 @@ func main() { ctx.Loop(shutdown) } +func (ctx *TestbedContext) MakeMgrConfig(base, patch json.RawMessage) *mgrconfig.Config { + mergedConfig, err := config.MergeJSONData(base, patch) + if err != nil { + tool.Failf("failed to apply a patch to the base manager config: %s", err) + } + mgrCfg, err := mgrconfig.LoadPartialData(mergedConfig) + if err != nil { + tool.Failf("failed to parse base manager config: %s", err) + } + if mgrCfg.HTTP == "" { + // Actually, we don't care much about the specific ports of syz-managers. + mgrCfg.HTTP = ":0" + } + return mgrCfg +} + func (ctx *TestbedContext) GetStatViews() ([]StatView, error) { groupsCompleted := []RunResultGroup{} groupsAll := []RunResultGroup{} |
