From 3ef01532b940f4d8af6fe368b9c44a73d75adf8d Mon Sep 17 00:00:00 2001 From: Ben Sander Date: Mon, 24 Apr 2017 11:06:54 -0500 Subject: [PATCH] Add negative testing for memory full condition. [ROCm/hip commit: dc001ef9b41ee8ae3125c7acacaffc5ff71414de] --- .../tests/src/runtimeApi/memory/hipMemoryAllocate.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/projects/hip/tests/src/runtimeApi/memory/hipMemoryAllocate.cpp b/projects/hip/tests/src/runtimeApi/memory/hipMemoryAllocate.cpp index 1f7599491a..0a256d6362 100644 --- a/projects/hip/tests/src/runtimeApi/memory/hipMemoryAllocate.cpp +++ b/projects/hip/tests/src/runtimeApi/memory/hipMemoryAllocate.cpp @@ -56,5 +56,15 @@ int main(){ HIPCHECK_API(hipFree(NULL) , hipSuccess); HIPCHECK_API(hipHostFree(NULL) , hipSuccess); + + { + // Some negative testing - request a too-big allocation and verify it fails: + // Someday when we support virtual memory may need to refactor these: + size_t tooBig = 128LL*1024*1024*1024*1024; // 128 TB; + void *p; + HIPCHECK_API ( hipMalloc(&p, tooBig), hipErrorMemoryAllocation ); + HIPCHECK_API ( hipHostMalloc(&p, tooBig), hipErrorMemoryAllocation ); + } + passed(); }