hs-test: add test suite features
[vpp.git] / extras / hs-test / container.go
1 package main
2
3 import (
4         "fmt"
5
6         "github.com/edwarnicke/exechelper"
7 )
8
9 type Container struct {
10         name string
11 }
12
13 func (c *Container) run() error {
14         if c.name == "" {
15                 return fmt.Errorf("create volume failed: container name is blank")
16         }
17
18         exechelper.Run(fmt.Sprintf("mkdir -p /tmp/%s/sync", c.name))
19         syncPath := fmt.Sprintf("-v /tmp/%s/sync:/tmp/sync", c.name)
20         cmd := "docker run --cap-add=all -d --privileged --network host --rm "
21         cmd += syncPath
22         cmd += " --name " + c.name + " hs-test/vpp"
23         fmt.Println(cmd)
24         err := exechelper.Run(cmd)
25         if err != nil {
26                 return fmt.Errorf("create volume failed: %s", err)
27         }
28
29         return nil
30 }
31