Skip to content

Commit a91887f

Browse files
committed
Fix test scripts
Signed-off-by: Wei Liu <[email protected]>
1 parent 2af2773 commit a91887f

File tree

3 files changed

+68
-46
lines changed

3 files changed

+68
-46
lines changed

sh_script/test/integration_test.py

+59-39
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,12 @@ def test_function_001(device_type):
3636
migtd_dst = "../../Bin/migtd_001.bin"
3737

3838
with migtd_context() as ctx:
39-
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
4039
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
40+
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
4141
ctx.start_user_td(type="src")
4242
ctx.start_user_td(type="dst")
43-
ctx.connect()
43+
if device_type == "vsock":
44+
ctx.connect()
4445
ctx.pre_migration()
4546
ctx.check_migration_result()
4647

@@ -56,11 +57,12 @@ def test_function_002(device_type):
5657
migtd_dst = "../../Bin/migtd_001.bin"
5758

5859
with migtd_context() as ctx:
59-
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
6060
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
61+
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
6162
ctx.start_user_td(type="src")
6263
ctx.start_user_td(type="dst")
63-
ctx.connect()
64+
if device_type == "vsock":
65+
ctx.connect()
6466
ctx.pre_migration()
6567
ctx.check_migration_result()
6668

@@ -76,11 +78,12 @@ def test_function_negative_003(device_type):
7678
migtd_dst = "../../Bin/migtd_001.bin"
7779

7880
with migtd_context() as ctx:
79-
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
8081
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
82+
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
8183
ctx.start_user_td(type="src")
8284
ctx.start_user_td(type="dst")
83-
ctx.connect()
85+
if device_type == "vsock":
86+
ctx.connect()
8487
ctx.pre_migration()
8588
ctx.check_migration_result(negative=True)
8689

@@ -96,11 +99,12 @@ def test_function_004(device_type):
9699
migtd_dst = "../../Bin/migtd_004.bin"
97100

98101
with migtd_context() as ctx:
99-
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
100102
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
103+
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
101104
ctx.start_user_td(type="src")
102105
ctx.start_user_td(type="dst")
103-
ctx.connect()
106+
if device_type == "vsock":
107+
ctx.connect()
104108
ctx.pre_migration()
105109
ctx.check_migration_result()
106110

@@ -116,11 +120,12 @@ def test_function_005(device_type):
116120
migtd_dst = "../../Bin/migtd_005.bin"
117121

118122
with migtd_context() as ctx:
119-
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
120123
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
124+
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
121125
ctx.start_user_td(type="src")
122126
ctx.start_user_td(type="dst")
123-
ctx.connect()
127+
if device_type == "vsock":
128+
ctx.connect()
124129
ctx.pre_migration()
125130
ctx.check_migration_result()
126131

@@ -136,11 +141,12 @@ def test_function_negative_006(device_type):
136141
migtd_dst = "../../Bin/migtd_006.bin"
137142

138143
with migtd_context() as ctx:
139-
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
140144
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
145+
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
141146
ctx.start_user_td(type="src")
142147
ctx.start_user_td(type="dst")
143-
ctx.connect()
148+
if device_type == "vsock":
149+
ctx.connect()
144150
ctx.pre_migration()
145151
ctx.check_migration_result(negative=True)
146152

@@ -156,11 +162,12 @@ def test_function_negative_007(device_type):
156162
migtd_dst = "../../Bin/migtd_no.bin"
157163

158164
with migtd_context() as ctx:
159-
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
160165
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
166+
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
161167
ctx.start_user_td(type="src")
162168
ctx.start_user_td(type="dst")
163-
ctx.connect()
169+
if device_type == "vsock":
170+
ctx.connect()
164171
ctx.pre_migration()
165172
ctx.check_migration_result(negative=True)
166173

@@ -176,11 +183,12 @@ def test_function_negative_008(device_type):
176183
migtd_dst = "../../Bin/migtd_no.bin"
177184

178185
with migtd_context() as ctx:
179-
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
180186
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
187+
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
181188
ctx.start_user_td(type="src")
182189
ctx.start_user_td(type="dst")
183-
ctx.connect()
190+
if device_type == "vsock":
191+
ctx.connect()
184192
ctx.pre_migration()
185193
ctx.check_migration_result(negative=True)
186194

@@ -196,11 +204,12 @@ def test_function_negative_009(device_type):
196204
migtd_dst = "../../Bin/migtd_009.bin"
197205

198206
with migtd_context() as ctx:
199-
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
200207
ctx.start_mig_td(bios_img=migtd_src, type="src", no_device=True, device=device_type)
208+
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
201209
ctx.start_user_td(type="src")
202210
ctx.start_user_td(type="dst")
203-
ctx.connect()
211+
if device_type == "vsock":
212+
ctx.connect()
204213
ctx.pre_migration()
205214
ctx.check_migration_result(negative=True, wait_time=10)
206215

@@ -212,11 +221,12 @@ def test_function_010(device_type):
212221
migtd_dst = "../../Bin/migtd_010.bin"
213222

214223
with migtd_context() as ctx:
215-
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
216224
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
225+
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
217226
ctx.start_user_td(type="src")
218227
ctx.start_user_td(type="dst")
219-
ctx.connect()
228+
if device_type == "vsock":
229+
ctx.connect()
220230
ctx.pre_migration()
221231
ctx.check_migration_result()
222232

@@ -228,11 +238,12 @@ def test_function_011(device_type):
228238
migtd_dst = "../../Bin/migtd_011.bin"
229239

230240
with migtd_context() as ctx:
231-
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
232241
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
242+
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
233243
ctx.start_user_td(type="src")
234244
ctx.start_user_td(type="dst")
235-
ctx.connect()
245+
if device_type == "vsock":
246+
ctx.connect()
236247
ctx.pre_migration()
237248
ctx.check_migration_result()
238249

@@ -248,11 +259,12 @@ def test_function_012(device_type):
248259
migtd_dst = "../../Bin/migtd_dst_012.bin"
249260

250261
with migtd_context() as ctx:
251-
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
252262
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
263+
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
253264
ctx.start_user_td(type="src")
254265
ctx.start_user_td(type="dst")
255-
ctx.connect()
266+
if device_type == "vsock":
267+
ctx.connect()
256268
ctx.pre_migration()
257269
ctx.check_migration_result()
258270

@@ -268,11 +280,12 @@ def test_function_013(device_type):
268280
migtd_dst = "../../Bin/migtd_dst_013.bin"
269281

270282
with migtd_context() as ctx:
271-
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
272283
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
284+
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
273285
ctx.start_user_td(type="src")
274286
ctx.start_user_td(type="dst")
275-
ctx.connect()
287+
if device_type == "vsock":
288+
ctx.connect()
276289
ctx.pre_migration()
277290
ctx.check_migration_result()
278291

@@ -288,11 +301,12 @@ def test_function_negative_014(device_type):
288301
migtd_dst = "../../Bin/migtd_dst_014.bin"
289302

290303
with migtd_context() as ctx:
291-
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
292304
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
305+
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
293306
ctx.start_user_td(type="src")
294307
ctx.start_user_td(type="dst")
295-
ctx.connect()
308+
if device_type == "vsock":
309+
ctx.connect()
296310
ctx.pre_migration()
297311
ctx.check_migration_result(negative=True)
298312

@@ -308,11 +322,12 @@ def test_function_negative_015(device_type):
308322
migtd_dst = "../../Bin/migtd_015.bin"
309323

310324
with migtd_context() as ctx:
311-
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
312325
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
326+
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
313327
ctx.start_user_td(type="src")
314328
ctx.start_user_td(type="dst")
315-
ctx.connect()
329+
if device_type == "vsock":
330+
ctx.connect()
316331
ctx.pre_migration()
317332
ctx.check_migration_result(negative=True)
318333

@@ -328,11 +343,12 @@ def test_function_negative_016(device_type):
328343
migtd_dst = "../../Bin/migtd_016.bin"
329344

330345
with migtd_context() as ctx:
331-
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
332346
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
347+
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
333348
ctx.start_user_td(type="src")
334349
ctx.start_user_td(type="dst")
335-
ctx.connect()
350+
if device_type == "vsock":
351+
ctx.connect()
336352
ctx.pre_migration()
337353
ctx.check_migration_result(negative=True)
338354

@@ -348,11 +364,12 @@ def test_function_negative_017(device_type):
348364
migtd_dst = "../../Bin/migtd_017.bin"
349365

350366
with migtd_context() as ctx:
351-
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
352367
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
368+
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
353369
ctx.start_user_td(type="src")
354370
ctx.start_user_td(type="dst")
355-
ctx.connect()
371+
if device_type == "vsock":
372+
ctx.connect()
356373
ctx.pre_migration()
357374
ctx.check_migration_result(negative=True)
358375

@@ -372,7 +389,8 @@ def test_function_negative_018(device_type):
372389
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
373390
ctx.start_user_td(type="src")
374391
ctx.start_user_td(type="dst")
375-
ctx.connect()
392+
if device_type == "vsock":
393+
ctx.connect()
376394
ctx.pre_migration()
377395
ctx.check_migration_result(negative=True)
378396

@@ -398,11 +416,12 @@ def test_pre_binding(device_type, servtd_hash):
398416
migtd_dst = "../../target/release/migtd.bin"
399417

400418
with migtd_context() as ctx:
401-
ctx.start_user_td(type="src", is_pre_binding=True, hash=servtd_hash)
402419
ctx.start_user_td(type="dst", is_pre_binding=True, hash=servtd_hash)
420+
ctx.start_user_td(type="src", is_pre_binding=True, hash=servtd_hash)
403421
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
404422
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
405-
ctx.connect()
423+
if device_type == "vsock":
424+
ctx.connect()
406425

407426
ctx.pre_migration(is_pre_binding=True)
408427
ctx.check_migration_result()
@@ -417,9 +436,10 @@ def test_cycle(device_type):
417436
migtd_dst = "../../target/release/migtd.bin"
418437

419438
with migtd_context() as ctx:
420-
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
421439
ctx.start_mig_td(bios_img=migtd_dst, type="dst", device=device_type)
422-
ctx.connect()
440+
ctx.start_mig_td(bios_img=migtd_src, type="src", device=device_type)
441+
if device_type == "vsock":
442+
ctx.connect()
423443

424444
for i in range(ctx.stress_test_cycles):
425445
LOG.debug(f"#### Cycle Test: {i} ####")

sh_script/test/mig-td.sh

+5-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
#
77
set -e
88

9-
QEMU_EXEC="/usr/local/bin/qemu-system-x86_64"
9+
QEMU_EXEC="/usr/libexec/qemu-kvm"
1010
GUEST_CID=18
11-
MIGTD="/usr/share/td-migration/migtd.bin"
11+
MIGTD=""
1212
VIRTIO_SERIAL=false
1313
MIGTD_TYPE=""
1414
DEST_IP="127.0.0.1"
@@ -19,6 +19,8 @@ Usage: $(basename "$0") [OPTION]...
1919
-q <qemu path> QEMU path
2020
-m <migtd file> MigTD file
2121
-t <src|dst> Must set migtd type, src or dst
22+
-s Use virtio serial, default is vsock
23+
-i <dest_ip> IP of destination
2224
-h Show this help
2325
EOM
2426
}
@@ -93,7 +95,7 @@ QEMU_CMD="${QEMU_EXEC} \
9395
if [[ $NO_DEVICE != true ]]; then
9496
if [[ ${VIRTIO_SERIAL} == true ]]; then
9597
QEMU_CMD+=" -device virtio-serial-pci,id=virtio-serial0 "
96-
if [[ ${MIGTD_TYPE} == "src" ]]; then
98+
if [[ ${MIGTD_TYPE} == "dst" ]]; then
9799
QEMU_CMD+=" -chardev socket,host=0.0.0.0,port=1236,server=on,id=foo "
98100
else
99101
QEMU_CMD+=" -chardev socket,host=${DEST_IP},port=1236,server=off,id=foo "

sh_script/test/user-td.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,11 @@
66
#
77
set -e
88

9-
QEMU_EXEC="/usr/local/bin/qemu-system-x86_64"
9+
QEMU_EXEC="/usr/libexec/qemu-kvm"
1010
TD_TYPE=""
1111
KERNEL=""
1212
GUEST_IMG=""
13-
OVMF="/home/env/OVMF.fd"
13+
OVMF="/usr/share/qemu/OVMF.fd"
1414
BOOT_TYPE="direct"
1515
TARGET_PID=""
1616
ROOT_PARTITION="/dev/vda3"
@@ -31,7 +31,7 @@ Usage: $(basename "$0") [OPTION]...
3131
-k <kernel file> Kernel file
3232
-b [direct|grub] Boot type, default is "direct" which requires kernel binary specified via "-k"
3333
-p incoming port
34-
-q [tdvmcall|vsock] Support for TD quote using tdvmcall or vsock
34+
-a [tdvmcall|vsock] Support for TD quote using tdvmcall or vsock
3535
-r <root partition> root partition for direct boot, default is /dev/vda1
3636
-t <src|dst> Must set userTD type, src or dst
3737
-g [true|false] Use pre-binding or not, default is "false"
@@ -41,7 +41,7 @@ EOM
4141
}
4242

4343
process_args() {
44-
while getopts "i:k:b:o:p:q:r:t:g:m:h" option; do
44+
while getopts "i:k:b:o:p:q:a:r:t:g:m:h" option; do
4545
case "${option}" in
4646
i) GUEST_IMG=$OPTARG;;
4747
k) KERNEL=$OPTARG;;

0 commit comments

Comments
 (0)