<div dir="ltr"><br><div class="gmail_extra"><br clear="all"><div><div dir="ltr"><br>Best Regards, Tikhomirov Pavel.</div></div>
<br><br><div class="gmail_quote">2014-01-29 Tikhomirov Pavel <span dir="ltr">&lt;<a href="mailto:snorcht@gmail.com" target="_blank">snorcht@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Signed-off-by: Tikhomirov Pavel &lt;<a href="mailto:snorcht@gmail.com">snorcht@gmail.com</a>&gt;<br>
---<br>
 test/mem-snap/run-snap-dedup-on-restore.sh | 87 ++++++++++++++++++++++++++++++<br>
 1 file changed, 87 insertions(+)<br>
 create mode 100755 test/mem-snap/run-snap-dedup-on-restore.sh<br>
<br>
diff --git a/test/mem-snap/run-snap-dedup-on-restore.sh b/test/mem-snap/run-snap-dedup-on-restore.sh<br>
new file mode 100755<br>
index 0000000..70c9bb8<br>
--- /dev/null<br>
+++ b/test/mem-snap/run-snap-dedup-on-restore.sh<br>
@@ -0,0 +1,87 @@<br>
+#!/bin/bash<br>
+<br>
+source ../env.sh || exit 1<br>
+<br>
+USEPS=0<br>
+<br>
+if [ &quot;$1&quot; = &quot;-s&quot; ]; then<br>
+       echo &quot;Will test via page-server&quot;<br>
+       USEPS=1<br>
+       shift<br>
+fi<br>
+<br>
+NRSNAP=${1:-3}<br>
+SPAUSE=${2:-4}<br>
+PORT=12345<br>
+<br>
+function fail {<br>
+       echo &quot;$@&quot;<br>
+       exit 1<br>
+}<br>
+set -x<br>
+<br>
+IMGDIR=&quot;dump/&quot;<br>
+<br>
+rm -rf &quot;$IMGDIR&quot;<br>
+mkdir &quot;$IMGDIR&quot;<br>
+<br>
+echo &quot;Launching test&quot;<br>
+cd ../zdtm/live/static/<br>
+make cleanout<br>
+make mem-touch<br>
+make mem-touch.pid || fail &quot;Can&#39;t start test&quot;<br>
+PID=$(cat mem-touch.pid)<br>
+kill -0 $PID || fail &quot;Test didn&#39;t start&quot;<br>
+cd -<br>
+<br>
+echo &quot;Making $NRSNAP snapshots&quot;<br>
+<br>
+for SNAP in $(seq 1 $NRSNAP); do<br>
+       sleep $SPAUSE<br>
+       mkdir &quot;$IMGDIR/$SNAP/&quot;<br>
+       if [ $SNAP -eq 1 ] ; then<br>
+               # First snapshot -- no parent, keep running<br>
+               args=&quot;--track-mem -R&quot;<br>
+       elif [ $SNAP -eq $NRSNAP ]; then<br>
+               # Last snapshot -- has parent, kill afterwards<br>
+               args=&quot;--prev-images-dir=../$((SNAP - 1))/ --track-mem --auto-dedup&quot;<br>
+       else<br>
+               # Other snapshots -- have parent, keep running<br>
+               args=&quot;--prev-images-dir=../$((SNAP - 1))/ --track-mem -R&quot;<br></blockquote><div><br></div><div>here i&#39;ve lost --auto-dedup, need to be:</div><div>               args=&quot;--prev-images-dir=../$((SNAP - 1))/ --track-mem -R --auto-dedup&quot;</div>
<div>it&#39;s needed to make sure that all pages images are of size 0 in the end.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

+       fi<br>
+<br>
+       if [ $USEPS -eq 1 ]; then<br>
+               ${CRIU} page-server -D &quot;${IMGDIR}/$SNAP/&quot; -o ps.log --auto-dedup --port ${PORT} -v4 &amp;<br>
+               PS_PID=$!<br>
+               ps_args=&quot;--page-server --address 127.0.0.1 --port=${PORT}&quot;<br>
+       else<br>
+               ps_args=&quot;&quot;<br>
+       fi<br>
+<br>
+       ${CRIU} dump -D &quot;${IMGDIR}/$SNAP/&quot; -o dump.log -t ${PID} -v4 $args $ps_args || fail &quot;Fail to dump&quot;<br>
+       if [ $USEPS -eq 1 ]; then<br>
+               wait $PS_PID<br>
+       fi<br>
+done<br>
+<br>
+echo &quot;Restoring&quot;<br>
+${CRIU} restore -D &quot;${IMGDIR}/$NRSNAP/&quot; -o restore.log --auto-dedup -d -v4 || fail &quot;Fail to restore server&quot;<br>
+<br>
+size_last3=$(du -sh -BK dump/3/pages-*.img | grep -Eo &#39;[0-9]+&#39; | head -1)<br>
+size_last2=$(du -sh -BK dump/2/pages-*.img | grep -Eo &#39;[0-9]+&#39; | head -1)<br>
+size_last1=$(du -sh -BK dump/1/pages-*.img | grep -Eo &#39;[0-9]+&#39; | head -1)<br>
+<br>
+restore_dedup_ok=0<br>
+if [[ $size_last1 -ne 0 || $size_last2 -ne 0 || $size_last3 -ne 0 ]]; then<br>
+       restore_dedup_ok=1<br>
+fi<br>
+<br>
+cd ../zdtm/live/static/<br>
+make mem-touch.out<br>
+cat mem-touch.out | fgrep PASS || fail &quot;Test failed&quot;<br>
+<br>
+if [ $restore_dedup_ok -ne 0 ]; then<br>
+       fail &quot;Dedup test failed&quot;<br>
+fi<br>
+<br>
+echo &quot;Test PASSED&quot;<br>
<span class=""><font color="#888888">--<br>
1.8.3.2<br>
<br>
</font></span></blockquote></div><br></div></div>