Skip to content

Commit

Permalink
WIP: Fix #556
Browse files Browse the repository at this point in the history
Signed-off-by: Liang Chenye <[email protected]>
  • Loading branch information
liangchenye committed Jan 22, 2018
1 parent a0a410a commit ae63341
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
24 changes: 23 additions & 1 deletion validation/util/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,16 @@ func (r *Runtime) SetID(id string) {
}

// Create a container
func (r *Runtime) Create() (stderr []byte, err error) {
func (r *Runtime) Create(consoleSocket string, pidFile string) (stderr []byte, err error) {
var args []string
args = append(args, "create")
if consoleSocket != "" {
args = append(args, "--console-socket", consoleSocket)
}
if pidFile != "" {
args = append(args, "--pid-file", pidFile)
}

if r.ID != "" {
args = append(args, r.ID)
}
Expand Down Expand Up @@ -141,6 +148,21 @@ func (r *Runtime) State() (rspecs.State, error) {
return state, err
}

// Kill a container
func (r *Runtime) Kill(signal string) error {
var args []string
args = append(args, "kill")
if signal != "" {
args = append(args, signal)
}
if r.ID != "" {
args = append(args, r.ID)
}

cmd := exec.Command(r.RuntimeCommand, args...)
return cmd.Run()
}

// Delete a container
func (r *Runtime) Delete() error {
var args []string
Expand Down
4 changes: 2 additions & 2 deletions validation/util/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func RuntimeInsideValidate(g *generate.Generator, f PreFunc) (err error) {
}

r.SetID(uuid.NewV4().String())
stderr, err := r.Create()
stderr, err := r.Create("", "")
if err != nil {
os.Stderr.WriteString("failed to create the container\n")
os.Stderr.Write(stderr)
Expand Down Expand Up @@ -166,7 +166,7 @@ func RuntimeOutsideValidate(g *generate.Generator, f AfterFunc) error {
}

r.SetID(uuid.NewV4().String())
stderr, err := r.Create()
stderr, err := r.Create("", "")
if err != nil {
os.Stderr.WriteString("failed to create the container\n")
os.Stderr.Write(stderr)
Expand Down

0 comments on commit ae63341

Please sign in to comment.