diff options
author | SeongJae Park <sj38.park@gmail.com> | 2024-03-17 11:43:21 -0700 |
---|---|---|
committer | SeongJae Park <sj38.park@gmail.com> | 2024-03-17 11:43:21 -0700 |
commit | 73b2e773f0ff2371adaa4aae6ced49b3165b2200 (patch) | |
tree | ea95adc8292161bb791bc3367faa44139c776d2b | |
parent | 17604a33069683841a16e1258510a3163dcbad9d (diff) | |
download | damo-73b2e773f0ff2371adaa4aae6ced49b3165b2200.tar.gz |
tests/unit/test_damon_dbgfs: Implement a test for write_kdamonds()
Signed-off-by: SeongJae Park <sj38.park@gmail.com>
-rw-r--r-- | tests/unit/test_damon_dbgfs.py | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/unit/test_damon_dbgfs.py b/tests/unit/test_damon_dbgfs.py index 2dbb350a..8030390c 100644 --- a/tests/unit/test_damon_dbgfs.py +++ b/tests/unit/test_damon_dbgfs.py @@ -10,6 +10,7 @@ _test_damo_common.add_damo_dir_to_syspath() import _damon import _damon_dbgfs +import _damo_fs def set_damon_dbgfs_features(): _damon_dbgfs.feature_supports = {'init_regions': True, 'schemes': True, @@ -95,5 +96,59 @@ class TestDamonDbgfs(unittest.TestCase): "4096\t18446744073709551615\t0\t0\t10\t42949\t5\t0\t5368709120\t1000\t0\t3\t7\t1\t1000000\t999\t998\t995"}] }) + def test_files_content_to_kdamonds_io(self): + set_damon_dbgfs_features() + + _damo_fs.debug_dryrun({}) + kdamonds = _damon_dbgfs.files_content_to_kdamonds(json.loads( + json.dumps( + { + "attrs": "5000 100000 1000000 10 1000\n", + "init_regions": "0 1 100\n0 100 200\n", + "kdamond_pid": "none\n", + "mk_contexts": + "read failed (reading /sys/kernel/debug/damon/mk_contexts failed ([Errno 22] Invalid argument))", + "monitor_on": "off\n", + "rm_contexts": + "read failed (reading /sys/kernel/debug/damon/rm_contexts failed ([Errno 22] Invalid argument))", + "schemes": + "4096 18446744073709551615 0 0 10 42949 5 0 584792941 1000 0 0 0 0 0 0 0 0 0 0 0 0 0\n", + "target_ids": "4242\n" + }))) + _damon_dbgfs.write_kdamonds('', kdamonds) + + kdamonds = _damon_dbgfs.files_content_to_kdamonds(json.loads( + json.dumps( + { + "attrs": "5000 100000 1000000 10 1000\n", + "init_regions": "", + "kdamond_pid": "none\n", + "mk_contexts": + "read failed (reading /sys/kernel/debug/damon/mk_contexts failed ([Errno 22] Invalid argument))", + "monitor_on": "off\n", + "rm_contexts": + "read failed (reading /sys/kernel/debug/damon/rm_contexts failed ([Errno 22] Invalid argument))", + "schemes": + "4096 18446744073709551615 0 0 10 42949 5 0 5368709120 1000 0 3 7 1 1000000 999 998 995 0 0 0 0 0\n", + "target_ids": "42\n" + }))) + _damon_dbgfs.write_kdamonds('', kdamonds) + + logs = _damo_fs.debug_get_dryrun_logs() + expected_logs = [ + # First write_kdamonds() + "write '5000 100000 1000000 10 1000' to 'attrs'", + "write '4242' to 'target_ids'", + "write '0 1 100 0 100 200' to 'init_regions'", + "write '4096\t18446744073709551615\t0\t0\t10\t42949\t5\t0\t584792941\t1000\t0\t0\t0\t0\t0\t0\t0\t0' to 'schemes'", + + # Second write_kdamonds() + "write '5000 100000 1000000 10 1000' to 'attrs'", + "write 'paddr' to 'target_ids'", + "write '' to 'init_regions'", + "write '4096\t18446744073709551615\t0\t0\t10\t42949\t5\t0\t5368709120\t1000\t0\t3\t7\t1\t1000000\t999\t998\t995' to 'schemes'", + ] + self.assertEqual(expected_logs, logs) + if __name__ == '__main__': unittest.main() |