diff options
author | Pavel Emelianov <xemul@virtuozzo.com> | 2019-05-23 11:59:05 +0300 |
---|---|---|
committer | Andrei Vagin <avagin@gmail.com> | 2019-09-07 15:59:52 +0300 |
commit | b336fa2e3237f9f93a09aea546fb1164b7c151a1 (patch) | |
tree | 400ae5b2d7a12664be74386063db3240460082c5 /test | |
parent | 72ce634f43f6d241faf064eaccae2be0cb51e7de (diff) |
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>
Diffstat (limited to 'test')
-rwxr-xr-x | test/zdtm.py | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/test/zdtm.py b/test/zdtm.py index fb859d1c7..abe92f9d0 100755 --- a/test/zdtm.py +++ b/test/zdtm.py @@ -1098,13 +1098,32 @@ class criu: else: 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): if not self.__show_stats: return - subprocess.Popen([self.__crit_bin, "show", - os.path.join(self.__dump_path, - str(self.__iter), "stats-%s" % action)]).wait() + subprocess.Popen([self.__crit_bin, "show", self.__stats_file(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 = []): self.__iter += 1 @@ -1152,6 +1171,7 @@ class criu: self.__criu_act("dedup", opts = []) self.show_stats("dump") + self.check_pages_counts() if self.__leave_stopped: pstree_check_stopped(self.__test.getpid()) |