From 98afb7390a2806e0f56504761d58b691e0b58f42 Mon Sep 17 00:00:00 2001 From: Qiang Huang Date: Thu, 29 Sep 2016 18:33:32 +0800 Subject: [PATCH] Add integration test for ps command Signed-off-by: Qiang Huang --- tests/integration/ps.bats | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/tests/integration/ps.bats b/tests/integration/ps.bats index 01fae7a28..75f955f99 100644 --- a/tests/integration/ps.bats +++ b/tests/integration/ps.bats @@ -11,7 +11,7 @@ function teardown() { teardown_busybox } -@test "ps -eaf" { +@test "ps" { # start busybox detached runc run -d --console /dev/pts/ptmx test_busybox [ "$status" -eq 0 ] @@ -21,8 +21,39 @@ function teardown() { testcontainer test_busybox running - runc ps test_busybox -eaf + runc ps test_busybox [ "$status" -eq 0 ] [[ ${lines[0]} =~ UID\ +PID\ +PPID\ +C\ +STIME\ +TTY\ +TIME\ +CMD+ ]] [[ "${lines[1]}" == *"root"*[0-9]* ]] } + +@test "ps -f json" { + # 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 -f json test_busybox + [ "$status" -eq 0 ] + [[ ${lines[0]} =~ [0-9]+ ]] +} + +@test "ps -e -x" { + # 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 -e -x + [ "$status" -eq 0 ] + [[ ${lines[0]} =~ \ +PID\ +TTY\ +STAT\ +TIME\ +COMMAND+ ]] + [[ "${lines[1]}" =~ [0-9]+ ]] +}