From e8eff449ec5ff05fcb60bea61ea73a93002df93a Mon Sep 17 00:00:00 2001 From: Aditya Atluri Date: Tue, 27 Sep 2016 11:38:31 -0500 Subject: [PATCH] added negative testing for device APIs Change-Id: I7bfcdd777f240d36b29eca987f7bc9da7614d704 [ROCm/hip commit: 4d56ac99e4622225bfb98a245e649455ce847fc3] --- .../src/Functional/Negative/Device/hipDeviceUtil.h | 10 ++++++++++ .../src/Functional/Negative/Device/hipGetDevice.cpp | 10 ++++++++++ .../src/Functional/Negative/Device/hipSetDevice.cpp | 10 ++++++++++ 3 files changed, 30 insertions(+) create mode 100644 projects/hip/tests/src/Functional/Negative/Device/hipDeviceUtil.h create mode 100644 projects/hip/tests/src/Functional/Negative/Device/hipGetDevice.cpp create mode 100644 projects/hip/tests/src/Functional/Negative/Device/hipSetDevice.cpp diff --git a/projects/hip/tests/src/Functional/Negative/Device/hipDeviceUtil.h b/projects/hip/tests/src/Functional/Negative/Device/hipDeviceUtil.h new file mode 100644 index 0000000000..392aa8c277 --- /dev/null +++ b/projects/hip/tests/src/Functional/Negative/Device/hipDeviceUtil.h @@ -0,0 +1,10 @@ +#ifndef HIPDEVICEUTIL_H +#define HIPDEVICEUTIL_H + +#include +#include + +#define HIP_CHECK(status, func) \ + std::cout<<#func<<" returned "< +#include +#include"hipDeviceUtil.h" + +int main() +{ + int device; + HIP_CHECK(hipGetDevice(NULL), hipGetDevice); + HIP_CHECK(hipGetDevice(&device), hipGetDevice); +} diff --git a/projects/hip/tests/src/Functional/Negative/Device/hipSetDevice.cpp b/projects/hip/tests/src/Functional/Negative/Device/hipSetDevice.cpp new file mode 100644 index 0000000000..4269627ad5 --- /dev/null +++ b/projects/hip/tests/src/Functional/Negative/Device/hipSetDevice.cpp @@ -0,0 +1,10 @@ +#include +#include +#include"hipDeviceUtil.h" + +int main() +{ + HIP_CHECK(hipSetDevice(0), hipSetDevice); + HIP_CHECK(hipSetDevice(1026), hipSetDevice); + HIP_CHECK(hipSetDevice(-1), hipSetDevice); +}