Skip to content

Commit

Permalink
test: --ps-tree flag
Browse files Browse the repository at this point in the history
Signed-off-by: Prajwal S N <[email protected]>
  • Loading branch information
snprajwal committed Jun 15, 2023
1 parent debba4f commit 3bbee76
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions checkpointctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
15 changes: 15 additions & 0 deletions test/checkpointctl.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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 ]
Expand All @@ -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" {
Expand Down Expand Up @@ -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"* ]]
}

0 comments on commit 3bbee76

Please sign in to comment.