[PATCH libdrm 4/4] amdgpu: Add memory over allocation test.
Andrey Grodzovsky
andrey.grodzovsky at amd.com
Fri Nov 10 04:30:03 UTC 2017
Allocates 1 TB of memory. Test is disabled by default
since it's triggers OOM killer.
Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky at amd.com>
---
tests/amdgpu/amdgpu_test.c | 4 ++++
tests/amdgpu/bo_tests.c | 20 ++++++++++++++++++++
2 files changed, 24 insertions(+)
diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c
index 91010dc..3b10f82 100644
--- a/tests/amdgpu/amdgpu_test.c
+++ b/tests/amdgpu/amdgpu_test.c
@@ -417,6 +417,10 @@ static void amdgpu_disable_suits()
*/
if (amdgpu_set_test_active(DEADLOCK_TESTS_STR, "compute ring block test", CU_FALSE))
fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
+
+ /* This test triggers OOM killer terminating the tester itself */
+ if (amdgpu_set_test_active(BO_TESTS_STR, "Memory fail alloc Test", CU_FALSE))
+ fprintf(stderr, "test deactivation failed - %s\n", CU_get_error_msg());
}
/* The main() function for setting up and running the tests.
diff --git a/tests/amdgpu/bo_tests.c b/tests/amdgpu/bo_tests.c
index 4545196..c6d89aa 100644
--- a/tests/amdgpu/bo_tests.c
+++ b/tests/amdgpu/bo_tests.c
@@ -47,6 +47,7 @@ static void amdgpu_bo_export_import(void);
static void amdgpu_bo_metadata(void);
static void amdgpu_bo_map_unmap(void);
static void amdgpu_memory_alloc(void);
+static void amdgpu_memory_fail_alloc(void);
CU_TestInfo bo_tests[] = {
{ "Export/Import", amdgpu_bo_export_import },
@@ -55,6 +56,7 @@ CU_TestInfo bo_tests[] = {
#endif
{ "CPU map/unmap", amdgpu_bo_map_unmap },
{ "Memory alloc Test", amdgpu_memory_alloc },
+ { "Memory fail alloc Test", amdgpu_memory_fail_alloc },
CU_TEST_INFO_NULL,
};
@@ -244,3 +246,21 @@ static void amdgpu_memory_alloc(void)
r = gpu_mem_free(bo, va_handle, bo_mc, 4096);
CU_ASSERT_EQUAL(r, 0);
}
+
+static void amdgpu_memory_fail_alloc(void)
+{
+ amdgpu_bo_handle bo;
+ amdgpu_va_handle va_handle;
+ uint64_t bo_mc;
+ int r;
+
+ /* Test impossible mem allocation, 1TB */
+ bo = gpu_mem_alloc(device_handle, 0xE8D4A51000, 4096,
+ AMDGPU_GEM_DOMAIN_VRAM,
+ AMDGPU_GEM_CREATE_NO_CPU_ACCESS,
+ &bo_mc, &va_handle);
+
+ r = gpu_mem_free(bo, va_handle, bo_mc, 0xE8D4A51000);
+ CU_ASSERT_EQUAL(r, 0);
+}
+
--
2.7.4
More information about the dri-devel
mailing list