aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/test_memlock.py
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2025-08-19 13:23:59 +0200
committerThomas Huth <thuth@redhat.com>2025-08-27 09:46:55 +0200
commit1917d47dd78adbd30abd462712458d0a0b583308 (patch)
tree18bb444d7e1942aca6317aae61df07682699457e /tests/functional/test_memlock.py
parente76291a65457b1fe18b6bf7a90b1d022fa15bf9d (diff)
downloadqemu-1917d47dd78adbd30abd462712458d0a0b583308.zip
qemu-1917d47dd78adbd30abd462712458d0a0b583308.tar.gz
qemu-1917d47dd78adbd30abd462712458d0a0b583308.tar.bz2
tests/functional: Move x86_64 tests into target-specific folder
The tests/functional folder has become quite crowded, thus move the x86_64 tests into a target-specific subfolder. Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Signed-off-by: Thomas Huth <thuth@redhat.com> Message-ID: <20250819112403.432587-23-thuth@redhat.com>
Diffstat (limited to 'tests/functional/test_memlock.py')
-rwxr-xr-xtests/functional/test_memlock.py79
1 files changed, 0 insertions, 79 deletions
diff --git a/tests/functional/test_memlock.py b/tests/functional/test_memlock.py
deleted file mode 100755
index 2b515ff..0000000
--- a/tests/functional/test_memlock.py
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/usr/bin/env python3
-#
-# Functional test that check overcommit memlock options
-#
-# Copyright (c) Yandex Technologies LLC, 2025
-#
-# Author:
-# Alexandr Moshkov <dtalexundeer@yandex-team.ru>
-#
-# SPDX-License-Identifier: GPL-2.0-or-later
-
-import re
-
-from typing import Dict
-
-from qemu_test import QemuSystemTest
-from qemu_test import skipLockedMemoryTest
-
-
-STATUS_VALUE_PATTERN = re.compile(r'^(\w+):\s+(\d+) kB', re.MULTILINE)
-
-
-@skipLockedMemoryTest(2_097_152) # 2GB
-class MemlockTest(QemuSystemTest):
- """
- Runs a guest with memlock options.
- Then verify, that this options is working correctly
- by checking the status file of the QEMU process.
- """
-
- def common_vm_setup_with_memlock(self, memlock):
- self.vm.add_args('-overcommit', f'mem-lock={memlock}')
- self.vm.launch()
-
- def test_memlock_off(self):
- self.common_vm_setup_with_memlock('off')
-
- status = self.get_process_status_values(self.vm.get_pid())
-
- self.assertTrue(status['VmLck'] == 0)
-
- def test_memlock_on(self):
- self.common_vm_setup_with_memlock('on')
-
- status = self.get_process_status_values(self.vm.get_pid())
-
- # VmLck > 0 kB and almost all memory is resident
- self.assertTrue(status['VmLck'] > 0)
- self.assertTrue(status['VmRSS'] >= status['VmSize'] * 0.70)
-
- def test_memlock_onfault(self):
- self.common_vm_setup_with_memlock('on-fault')
-
- status = self.get_process_status_values(self.vm.get_pid())
-
- # VmLck > 0 kB and only few memory is resident
- self.assertTrue(status['VmLck'] > 0)
- self.assertTrue(status['VmRSS'] <= status['VmSize'] * 0.30)
-
- def get_process_status_values(self, pid: int) -> Dict[str, int]:
- result = {}
- raw_status = self._get_raw_process_status(pid)
-
- for line in raw_status.split('\n'):
- if m := STATUS_VALUE_PATTERN.match(line):
- result[m.group(1)] = int(m.group(2))
-
- return result
-
- def _get_raw_process_status(self, pid: int) -> str:
- try:
- with open(f'/proc/{pid}/status', 'r') as f:
- return f.read()
- except FileNotFoundError:
- self.skipTest("Can't open status file of the process")
-
-
-if __name__ == '__main__':
- MemlockTest.main()