Skip to content

Commit 0fa5031

Browse files
committed
test: add tests for diff --sockets flag
Signed-off-by: Hamza Dogar <hxadogar@gmail.com>
1 parent 34133a3 commit 0fa5031

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

test/checkpointctl.bats

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,77 @@ function teardown() {
10601060
fi
10611061
}
10621062

1063+
@test "Run checkpointctl diff with --sockets flag" {
1064+
cp data/config.dump data/spec.dump "$TEST_TMP_DIR1"
1065+
mkdir "$TEST_TMP_DIR1"/checkpoint
1066+
1067+
if [ -f "test-imgs/pstree.img" ]; then
1068+
cp test-imgs/pstree.img \
1069+
test-imgs/core-*.img \
1070+
test-imgs/files.img \
1071+
test-imgs/ids-*.img \
1072+
test-imgs/fdinfo-*.img "$TEST_TMP_DIR1"/checkpoint
1073+
1074+
( cd "$TEST_TMP_DIR1" && tar cf "$TEST_TMP_DIR2"/test1.tar . )
1075+
( cd "$TEST_TMP_DIR1" && tar cf "$TEST_TMP_DIR2"/test2.tar . )
1076+
1077+
checkpointctl diff "$TEST_TMP_DIR2"/test1.tar "$TEST_TMP_DIR2"/test2.tar --sockets
1078+
[ "$status" -eq 0 ]
1079+
[[ "$output" == *"Socket Changes"* ]]
1080+
else
1081+
skip "test-imgs directory not populated"
1082+
fi
1083+
}
1084+
1085+
@test "Run checkpointctl diff with --sockets flag (json format)" {
1086+
cp data/config.dump data/spec.dump "$TEST_TMP_DIR1"
1087+
mkdir "$TEST_TMP_DIR1"/checkpoint
1088+
1089+
if [ -f "test-imgs/pstree.img" ]; then
1090+
cp test-imgs/pstree.img \
1091+
test-imgs/core-*.img \
1092+
test-imgs/files.img \
1093+
test-imgs/ids-*.img \
1094+
test-imgs/fdinfo-*.img "$TEST_TMP_DIR1"/checkpoint
1095+
1096+
( cd "$TEST_TMP_DIR1" && tar cf "$TEST_TMP_DIR2"/test1.tar . )
1097+
( cd "$TEST_TMP_DIR1" && tar cf "$TEST_TMP_DIR2"/test2.tar . )
1098+
1099+
test_has_socket_changes() { jq -e '.socket_changes != null'; }
1100+
export -f test_has_socket_changes
1101+
1102+
run bash -c "$CHECKPOINTCTL diff $TEST_TMP_DIR2/test1.tar $TEST_TMP_DIR2/test2.tar --sockets --format=json | test_has_socket_changes"
1103+
[ "$status" -eq 0 ]
1104+
else
1105+
skip "test-imgs directory not populate"
1106+
fi
1107+
}
1108+
1109+
@test "Run checkpointctl diff with --files and --sockets flags" {
1110+
cp data/config.dump data/spec.dump "$TEST_TMP_DIR1"
1111+
mkdir "$TEST_TMP_DIR1"/checkpoint
1112+
1113+
if [ -f "test-imgs/pstree.img" ]; then
1114+
cp test-imgs/pstree.img \
1115+
test-imgs/core-*.img \
1116+
test-imgs/files.img \
1117+
test-imgs/fs-*.img \
1118+
test-imgs/ids-*.img \
1119+
test-imgs/fdinfo-*.img "$TEST_TMP_DIR1"/checkpoint
1120+
1121+
( cd "$TEST_TMP_DIR1" && tar cf "$TEST_TMP_DIR2"/test1.tar . )
1122+
( cd "$TEST_TMP_DIR1" && tar cf "$TEST_TMP_DIR2"/test2.tar . )
1123+
1124+
checkpointctl diff "$TEST_TMP_DIR2"/test1.tar "$TEST_TMP_DIR2"/test2.tar --files --sockets
1125+
[ "$status" -eq 0 ]
1126+
[[ "$output" == *"File Descriptor Changes"* ]]
1127+
[[ "$output" == *"Socket Changes"* ]]
1128+
else
1129+
skip "test-imgs directory not populated"
1130+
fi
1131+
}
1132+
1133+
10631134
@test "Run checkpointctl diff json output validation" {
10641135
cp data/config.dump "$TEST_TMP_DIR1"
10651136
cp data/spec.dump "$TEST_TMP_DIR1"

0 commit comments

Comments
 (0)