Skip to content

Commit cbac9bb

Browse files
committed
test: add tests for memparse sub-command
Signed-off-by: Kouame Behouba Manasse <[email protected]>
1 parent 54ae5da commit cbac9bb

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

test/checkpointctl.bats

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,3 +506,60 @@ function teardown() {
506506
[[ ${lines[6]} == *"Podman"* ]]
507507
[[ ${lines[14]} == *"Podman"* ]]
508508
}
509+
510+
@test "Run checkpointctl memparse with tar file" {
511+
cp data/config.dump \
512+
data/spec.dump "$TEST_TMP_DIR1"
513+
mkdir "$TEST_TMP_DIR1"/checkpoint
514+
cp test-imgs/pstree.img \
515+
test-imgs/core-*.img \
516+
test-imgs/pagemap-*.img \
517+
test-imgs/mm-*.img "$TEST_TMP_DIR1"/checkpoint
518+
( cd "$TEST_TMP_DIR1" && tar cf "$TEST_TMP_DIR2"/test.tar . )
519+
checkpointctl memparse "$TEST_TMP_DIR2"/test.tar
520+
[ "$status" -eq 0 ]
521+
[[ ${lines[4]} == *"piggie"* ]]
522+
}
523+
524+
@test "Run checkpointctl memparse with tar file and missing pstree.img" {
525+
cp data/config.dump \
526+
data/spec.dump "$TEST_TMP_DIR1"
527+
mkdir "$TEST_TMP_DIR1"/checkpoint
528+
cp test-imgs/core-*.img \
529+
test-imgs/pagemap-*.img \
530+
test-imgs/mm-*.img "$TEST_TMP_DIR1"/checkpoint
531+
( cd "$TEST_TMP_DIR1" && tar cf "$TEST_TMP_DIR2"/test.tar . )
532+
checkpointctl memparse "$TEST_TMP_DIR2"/test.tar
533+
[ "$status" -eq 1 ]
534+
[[ ${lines[0]} == *"no such file or directory"* ]]
535+
}
536+
537+
@test "Run checkpointctl memparse with tar file and valid PID" {
538+
cp data/config.dump \
539+
data/spec.dump "$TEST_TMP_DIR1"
540+
mkdir "$TEST_TMP_DIR1"/checkpoint
541+
cp test-imgs/pstree.img \
542+
test-imgs/core-*.img \
543+
test-imgs/pagemap-*.img \
544+
test-imgs/pages-*.img \
545+
test-imgs/mm-*.img "$TEST_TMP_DIR1"/checkpoint
546+
( cd "$TEST_TMP_DIR1" && tar cf "$TEST_TMP_DIR2"/test.tar . )
547+
checkpointctl memparse "$TEST_TMP_DIR2"/test.tar --pid=1
548+
[ "$status" -eq 0 ]
549+
[[ ${lines[3]} == *"....H...H.../..H"* ]]
550+
}
551+
552+
@test "Run checkpointctl memparse with tar file and invalid PID" {
553+
cp data/config.dump \
554+
data/spec.dump "$TEST_TMP_DIR1"
555+
mkdir "$TEST_TMP_DIR1"/checkpoint
556+
cp test-imgs/pstree.img \
557+
test-imgs/core-*.img \
558+
test-imgs/pagemap-*.img \
559+
test-imgs/pages-*.img \
560+
test-imgs/mm-*.img "$TEST_TMP_DIR1"/checkpoint
561+
( cd "$TEST_TMP_DIR1" && tar cf "$TEST_TMP_DIR2"/test.tar . )
562+
checkpointctl memparse "$TEST_TMP_DIR2"/test.tar --pid=9999
563+
[ "$status" -eq 1 ]
564+
[[ ${lines[0]} == *"no process with PID 9999"* ]]
565+
}

0 commit comments

Comments
 (0)