aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAndrey Grodzovsky2017-11-13 11:01:42 -0600
committerChristian König2017-11-14 07:26:25 -0600
commit9ad9b7e91ee8af621bb80bb80ecd0f76eba7c51c (patch)
tree165cb471720c314f64111361a908f2944c26a0f2 /tests
parent818a0d4245801edd9a85ea95429bac4eb6ec2ef8 (diff)
downloadexternal-libgbm-9ad9b7e91ee8af621bb80bb80ecd0f76eba7c51c.tar.gz
external-libgbm-9ad9b7e91ee8af621bb80bb80ecd0f76eba7c51c.tar.xz
external-libgbm-9ad9b7e91ee8af621bb80bb80ecd0f76eba7c51c.zip
amdgpu: Add memory over allocation test.
Allocates 1 TB of memory. Test is disabled by default since it's triggers OOM killer. v2: FIx the test to only alloc the BO and assert if return value not equal to -ENOMEM and remove test disable on start. Signed-off-by: Andrey Grodzovsky <andrey.grodzovsky@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/amdgpu/bo_tests.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/amdgpu/bo_tests.c b/tests/amdgpu/bo_tests.c
index 45451960..53e76c1b 100644
--- a/tests/amdgpu/bo_tests.c
+++ b/tests/amdgpu/bo_tests.c
@@ -47,6 +47,7 @@ static void amdgpu_bo_export_import(void);
47static void amdgpu_bo_metadata(void); 47static void amdgpu_bo_metadata(void);
48static void amdgpu_bo_map_unmap(void); 48static void amdgpu_bo_map_unmap(void);
49static void amdgpu_memory_alloc(void); 49static void amdgpu_memory_alloc(void);
50static void amdgpu_mem_fail_alloc(void);
50 51
51CU_TestInfo bo_tests[] = { 52CU_TestInfo bo_tests[] = {
52 { "Export/Import", amdgpu_bo_export_import }, 53 { "Export/Import", amdgpu_bo_export_import },
@@ -55,6 +56,7 @@ CU_TestInfo bo_tests[] = {
55#endif 56#endif
56 { "CPU map/unmap", amdgpu_bo_map_unmap }, 57 { "CPU map/unmap", amdgpu_bo_map_unmap },
57 { "Memory alloc Test", amdgpu_memory_alloc }, 58 { "Memory alloc Test", amdgpu_memory_alloc },
59 { "Memory fail alloc Test", amdgpu_mem_fail_alloc },
58 CU_TEST_INFO_NULL, 60 CU_TEST_INFO_NULL,
59}; 61};
60 62
@@ -244,3 +246,25 @@ static void amdgpu_memory_alloc(void)
244 r = gpu_mem_free(bo, va_handle, bo_mc, 4096); 246 r = gpu_mem_free(bo, va_handle, bo_mc, 4096);
245 CU_ASSERT_EQUAL(r, 0); 247 CU_ASSERT_EQUAL(r, 0);
246} 248}
249
250static void amdgpu_mem_fail_alloc(void)
251{
252 amdgpu_bo_handle bo;
253 int r;
254 struct amdgpu_bo_alloc_request req = {0};
255 amdgpu_bo_handle buf_handle;
256
257 /* Test impossible mem allocation, 1TB */
258 req.alloc_size = 0xE8D4A51000;
259 req.phys_alignment = 4096;
260 req.preferred_heap = AMDGPU_GEM_DOMAIN_VRAM;
261 req.flags = AMDGPU_GEM_CREATE_NO_CPU_ACCESS;
262
263 r = amdgpu_bo_alloc(device_handle, &req, &buf_handle);
264 CU_ASSERT_EQUAL(r, -ENOMEM);
265
266 if (!r) {
267 r = amdgpu_bo_free(bo);
268 CU_ASSERT_EQUAL(r, 0);
269 }
270}