From 993126259cc1499e347e429d8572305c9095a2d6 Mon Sep 17 00:00:00 2001 From: Shukui Yang Date: Sat, 24 Sep 2016 12:20:52 +0800 Subject: [PATCH 1/2] Remove the workaround which add a -- flag to runc ps command and add integration for ps -eaf Signed-off-by: Shukui Yang --- ps.go | 7 +------ tests/integration/ps.bats | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 tests/integration/ps.bats diff --git a/ps.go b/ps.go index 433308505..6101bfad7 100644 --- a/ps.go +++ b/ps.go @@ -16,7 +16,7 @@ import ( var psCommand = cli.Command{ Name: "ps", Usage: "ps displays the processes running inside a container", - ArgsUsage: ` [-- ps options]`, + ArgsUsage: ` [ps options]`, Flags: []cli.Flag{ cli.StringFlag{ Name: "format, f", @@ -47,11 +47,6 @@ var psCommand = cli.Command{ // psArgs: [ps_arg1 ps_arg2 ...] // psArgs := context.Args()[1:] - - if len(psArgs) > 0 && psArgs[0] == "--" { - psArgs = psArgs[1:] - } - if len(psArgs) == 0 { psArgs = []string{"-ef"} } diff --git a/tests/integration/ps.bats b/tests/integration/ps.bats new file mode 100644 index 000000000..01fae7a28 --- /dev/null +++ b/tests/integration/ps.bats @@ -0,0 +1,28 @@ +#!/usr/bin/env bats + +load helpers + +function setup() { + teardown_busybox + setup_busybox +} + +function teardown() { + teardown_busybox +} + +@test "ps -eaf" { + # start busybox detached + runc run -d --console /dev/pts/ptmx test_busybox + [ "$status" -eq 0 ] + + # check state + wait_for_container 15 1 test_busybox + + testcontainer test_busybox running + + runc ps test_busybox -eaf + [ "$status" -eq 0 ] + [[ ${lines[0]} =~ UID\ +PID\ +PPID\ +C\ +STIME\ +TTY\ +TIME\ +CMD+ ]] + [[ "${lines[1]}" == *"root"*[0-9]* ]] +} From cc0e2d567fd60cf22afe61e01bc49c5ef4432b69 Mon Sep 17 00:00:00 2001 From: Shukui Yang Date: Sat, 24 Sep 2016 12:21:50 +0800 Subject: [PATCH 2/2] Remove the workaround which add a -- flag to runc exec command and add integration for exec ls -la Signed-off-by: Shukui Yang --- exec.go | 5 +---- tests/integration/exec.bats | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/exec.go b/exec.go index db1f72651..a0b4f4f4e 100644 --- a/exec.go +++ b/exec.go @@ -18,7 +18,7 @@ import ( var execCommand = cli.Command{ Name: "exec", Usage: "execute new process inside the container", - ArgsUsage: ` -- [command options] + ArgsUsage: ` [command options] Where "" is the name for the instance of the container and "" is the command to be executed in the container. @@ -158,9 +158,6 @@ func getProcess(context *cli.Context, bundle string) (*specs.Process, error) { } p := spec.Process p.Args = context.Args()[1:] - if len(p.Args) > 1 && p.Args[0] == "--" { - p.Args = p.Args[1:] - } // override the cwd, if passed if context.String("cwd") != "" { p.Cwd = context.String("cwd") diff --git a/tests/integration/exec.bats b/tests/integration/exec.bats index 4754da272..b5da57702 100644 --- a/tests/integration/exec.bats +++ b/tests/integration/exec.bats @@ -43,3 +43,17 @@ function teardown() { [ "$status" -eq 0 ] [[ ${lines[0]} =~ [0-9]+ ]] } + +@test "runc exec ls -la" { + # run busybox detached + runc run -d --console /dev/pts/ptmx test_busybox + [ "$status" -eq 0 ] + + wait_for_container 15 1 test_busybox + + runc exec test_busybox ls -la + [ "$status" -eq 0 ] + [[ ${lines[0]} == *"total"* ]] + [[ ${lines[1]} == *"."* ]] + [[ ${lines[2]} == *".."* ]] +}