mirror of
https://github.com/checkpoint-restore/criu
synced 2025-09-02 15:25:21 +00:00
zdtm: Check pages stats after dump
After dump command -- verify that the amount of bytes counted in stats-dump matches the real sizes of pages-*.img files. Signed-off-by: Pavel Emelyanov <xemul@virtuozzo.com> Acked-by: Cyrill Gorcunov <gorcunov@gmail.com> Signed-off-by: Andrei Vagin <avagin@gmail.com>
This commit is contained in:
committed by
Andrei Vagin
parent
72ce634f43
commit
b336fa2e32
26
test/zdtm.py
26
test/zdtm.py
@@ -1098,13 +1098,32 @@ class criu:
|
|||||||
else:
|
else:
|
||||||
raise test_fail_exc("CRIU %s" % action)
|
raise test_fail_exc("CRIU %s" % action)
|
||||||
|
|
||||||
|
def __stats_file(self, action):
|
||||||
|
return os.path.join(self.__ddir(), "stats-%s" % action)
|
||||||
|
|
||||||
def show_stats(self, action):
|
def show_stats(self, action):
|
||||||
if not self.__show_stats:
|
if not self.__show_stats:
|
||||||
return
|
return
|
||||||
|
|
||||||
subprocess.Popen([self.__crit_bin, "show",
|
subprocess.Popen([self.__crit_bin, "show", self.__stats_file(action)]).wait()
|
||||||
os.path.join(self.__dump_path,
|
|
||||||
str(self.__iter), "stats-%s" % action)]).wait()
|
def check_pages_counts(self):
|
||||||
|
stats_written = -1
|
||||||
|
with open(self.__stats_file("dump"), 'rb') as stfile:
|
||||||
|
stats = crpc.images.load(stfile)
|
||||||
|
stent = stats['entries'][0]['dump']
|
||||||
|
stats_written = int(stent['shpages_written']) + int(stent['pages_written'])
|
||||||
|
|
||||||
|
real_written = 0
|
||||||
|
for f in os.listdir(self.__ddir()):
|
||||||
|
if f.startswith('pages-'):
|
||||||
|
real_written += os.path.getsize(os.path.join(self.__ddir(), f))
|
||||||
|
|
||||||
|
r_pages = real_written / 4096
|
||||||
|
r_off = real_written % 4096
|
||||||
|
if (stats_written != r_pages) or (r_off != 0):
|
||||||
|
print("ERROR: bad page counts, stats = %d real = %d(%d)" % (stats_written, r_pages, r_off))
|
||||||
|
raise test_fail_exc("page counts mismatch")
|
||||||
|
|
||||||
def dump(self, action, opts = []):
|
def dump(self, action, opts = []):
|
||||||
self.__iter += 1
|
self.__iter += 1
|
||||||
@@ -1152,6 +1171,7 @@ class criu:
|
|||||||
self.__criu_act("dedup", opts = [])
|
self.__criu_act("dedup", opts = [])
|
||||||
|
|
||||||
self.show_stats("dump")
|
self.show_stats("dump")
|
||||||
|
self.check_pages_counts()
|
||||||
|
|
||||||
if self.__leave_stopped:
|
if self.__leave_stopped:
|
||||||
pstree_check_stopped(self.__test.getpid())
|
pstree_check_stopped(self.__test.getpid())
|
||||||
|
Reference in New Issue
Block a user