@@ -67,21 +67,33 @@ function teardown() {
6767 # setting terminal and root:readonly: to false
6868 sed -i ' s;"terminal": true;"terminal": false;' config.json
6969 sed -i ' s;"readonly": true;"readonly": false;' config.json
70- sed -i ' s/"sh"/"sh","-c","while : ; do date; sleep 1 ; done"/' config.json
70+ sed -i ' s/"sh"/"sh","-c","for i in `seq 10` ; do read xxx || continue; echo ponG $xxx ; done"/' config.json
7171
72- (
73- # run busybox (not detached)
74- runc run test_busybox
75- [ " $status " -eq 0 ]
76- ) &
72+ # The following code creates pipes for stdin and stdout.
73+ # CRIU can't handle fifo-s, so we need all these tricks.
74+ fifo=` mktemp -u /tmp/runc-fifo-XXXXXX`
75+ mkfifo $fifo
7776
78- # check state
79- wait_for_container 15 1 test_busybox
77+ # stdout
78+ cat $fifo | cat $fifo &
79+ pid=$!
80+ exec 50< /proc/$pid /fd/0
81+ exec 51> /proc/$pid /fd/0
8082
81- runc state test_busybox
82- [ " $status " -eq 0 ]
83- [[ " ${output} " == * " running" * ]]
83+ # stdin
84+ cat $fifo | cat $fifo &
85+ pid=$!
86+ exec 60< /proc/$pid /fd/0
87+ exec 61> /proc/$pid /fd/0
88+
89+ echo -n > $fifo
90+ unlink $fifo
8491
92+ # run busybox (not detached)
93+ __runc run -d test_busybox < & 60 >&51 2>&51
94+ [ $? -eq 0 ]
95+
96+ testcontainer test_busybox running
8597
8698 # test checkpoint pre-dump
8799 mkdir parent-dir
@@ -95,24 +107,32 @@ function teardown() {
95107
96108 # checkpoint the running container
97109 mkdir image-dir
98- runc --criu " $CRIU " checkpoint --parent-path ./parent-dir --image-path ./image-dir test_busybox
110+ mkdir work-dir
111+ runc --criu " $CRIU " checkpoint --parent-path ./parent-dir --work-path ./work-dir --image-path ./image-dir test_busybox
112+ cat ./work-dir/dump.log | grep -B 5 Error || true
99113 [ " $status " -eq 0 ]
100114
101115 # after checkpoint busybox is no longer running
102116 runc state test_busybox
103117 [ " $status " -ne 0 ]
104118
105119 # restore from checkpoint
106- (
107- runc --criu " $CRIU " restore --image-path ./image-dir test_busybox
108- [ " $status " -eq 0 ]
109- ) &
110-
111- # check state
112- wait_for_container 15 1 test_busybox
120+ __runc --criu " $CRIU " restore -d --work-path ./work-dir --image-path ./image-dir test_busybox < & 60 >&51 2>&51
121+ ret=$?
122+ cat ./work-dir/restore.log | grep -B 5 Error || true
123+ [ $ret -eq 0 ]
113124
114125 # busybox should be back up and running
115- runc state test_busybox
126+ testcontainer test_busybox running
127+
128+ runc exec --cwd /bin test_busybox echo ok
116129 [ " $status " -eq 0 ]
117- [[ " ${output} " == * " running" * ]]
130+ [[ ${output} == " ok" ]]
131+
132+ echo Ping >&61
133+ exec 61>& -
134+ exec 51>& -
135+ run cat < & 50
136+ [ " $status " -eq 0 ]
137+ [[ " ${output} " == * " ponG Ping" * ]]
118138}
0 commit comments