From: Tom Hromatka Date: Thu, 25 Mar 2021 20:03:35 +0000 (+0000) Subject: ftests: Allow test 004 to run on systems w/ or w/o swap X-Git-Tag: v2.0.3~11^2^2~17^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2f6b92f9061b5848735bb8982d0a2709acd2e8ec;p=thirdparty%2Flibcgroup.git ftests: Allow test 004 to run on systems w/ or w/o swap Add smarts to test 004 so that it can be run on systems with or without swap. Signed-off-by: Tom Hromatka --- diff --git a/ftests/004-cgsnapshot-basic_snapshot_v1.py b/ftests/004-cgsnapshot-basic_snapshot_v1.py index 5e5e38bd..9af4ff8b 100755 --- a/ftests/004-cgsnapshot-basic_snapshot_v1.py +++ b/ftests/004-cgsnapshot-basic_snapshot_v1.py @@ -24,6 +24,7 @@ from cgroup import Cgroup, CgroupVersion import consts import ftests import os +from run import Run import sys CONTROLLER='memory' @@ -48,12 +49,17 @@ CGSNAPSHOT = """group 004cgsnapshot { memory.kmem.limit_in_bytes="9223372036854771712"; memory.use_hierarchy="1"; memory.kmem.tcp.limit_in_bytes="9223372036854771712"; - memory.memsw.failcnt="0"; +""" + +CGSNAPSHOT_SWAP = """ memory.memsw.failcnt="0"; memory.memsw.limit_in_bytes="9223372036854771712"; memory.memsw.max_usage_in_bytes="0"; } }""" +CGSNAPSHOT_NOSWAP = """ } + }""" + def prereqs(config): result = consts.TEST_PASSED cause = None @@ -77,7 +83,16 @@ def test(config): result = consts.TEST_PASSED cause = None - expected = Cgroup.snapshot_to_dict(CGSNAPSHOT) + try: + # check if the memsw.failcnt file exists. if so, add it to the + # expected snapshot + Cgroup.get(config, setting="memory.memsw.failcnt", cgname=CGNAME) + expected_str = CGSNAPSHOT + CGSNAPSHOT_SWAP + except: + # memsw files don't exist. exclude them from the snapshot + expected_str = CGSNAPSHOT + CGSNAPSHOT_NOSWAP + + expected = Cgroup.snapshot_to_dict(expected_str) actual = Cgroup.snapshot(config, controller=CONTROLLER) if expected[CGNAME] != actual[CGNAME]: