From 3bbee76f2cd16a4fff2f9d3fba42c8cdff4095d2 Mon Sep 17 00:00:00 2001 From: Prajwal S N Date: Fri, 2 Jun 2023 17:39:48 +0530 Subject: [PATCH] test: `--ps-tree` flag Signed-off-by: Prajwal S N --- checkpointctl.go | 1 + test/checkpointctl.bats | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/checkpointctl.go b/checkpointctl.go index 3d7c7814..af3a2751 100644 --- a/checkpointctl.go +++ b/checkpointctl.go @@ -96,6 +96,7 @@ func show(cmd *cobra.Command, args []string) error { if showAll { stats = true mounts = true + psTree = true } if fullPaths && !mounts { return fmt.Errorf("Cannot use --full-paths without --mounts/--all option") diff --git a/test/checkpointctl.bats b/test/checkpointctl.bats index 3b6c575c..c974e731 100644 --- a/test/checkpointctl.bats +++ b/test/checkpointctl.bats @@ -169,6 +169,8 @@ function teardown() { cp data/spec.dump "$TEST_TMP_DIR1" cp test-imgs/stats-dump "$TEST_TMP_DIR1" mkdir "$TEST_TMP_DIR1"/checkpoint + cp test-imgs/pstree.img \ + test-imgs/core-*.img "$TEST_TMP_DIR1"/checkpoint ( cd "$TEST_TMP_DIR1" && tar cf "$TEST_TMP_DIR2"/test.tar . ) checkpointctl show "$TEST_TMP_DIR2"/test.tar --all [ "$status" -eq 0 ] @@ -179,6 +181,8 @@ function teardown() { [[ ${lines[13]} == *"CRIU dump statistics"* ]] [[ ${lines[15]} == *"MEMWRITE TIME"* ]] [[ ${lines[17]} =~ [1-9]+" us" ]] + [[ ${lines[19]} == *"Process tree"* ]] + [[ ${lines[21]} == *"piggie"* ]] } @test "Run checkpointctl show with tar file and missing --mounts/--all and --full-paths" { @@ -254,3 +258,14 @@ function teardown() { [[ ${lines[2]} == *"ROOT FS DIFF SIZE"* ]] } +@test "Run checkpointctl show with tar file and --ps-tree" { + cp data/config.dump \ + data/spec.dump "$TEST_TMP_DIR1" + mkdir "$TEST_TMP_DIR1"/checkpoint + cp test-imgs/pstree.img \ + test-imgs/core-*.img "$TEST_TMP_DIR1"/checkpoint + ( cd "$TEST_TMP_DIR1" && tar cf "$TEST_TMP_DIR2"/test.tar . ) + checkpointctl show "$TEST_TMP_DIR2"/test.tar --ps-tree + [ "$status" -eq 0 ] + [[ ${lines[8]} == *"piggie"* ]] +}