Add smarts to test 004 so that it can be run on systems with or without swap.
Signed-off-by: Tom Hromatka <tom.hroma...@oracle.com> --- ftests/004-cgsnapshot-basic_snapshot_v1.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/ftests/004-cgsnapshot-basic_snapshot_v1.py b/ftests/004-cgsnapshot-basic_snapshot_v1.py index 5e5e38bd35ac..9af4ff8be7b7 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]: -- 2.26.2 _______________________________________________ Libcg-devel mailing list Libcg-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/libcg-devel