added more device negative testing

1. Added fallback for nullptr to hipGetDeviceProperties and hipGetDeviceCount
2. Added negative tests for hipGetDeviceProperties and hipGetDeviceCount

Change-Id: Iac93fd53d7d4794fb10546ddadf6ca802b047c87


[ROCm/hip commit: 1b14393a85]
Этот коммит содержится в:
Aditya Atluri
2016-09-27 13:04:35 -05:00
родитель 55dc5b12e8
Коммит 9dd52d97eb
3 изменённых файлов: 44 добавлений и 9 удалений
+20 -9
Просмотреть файл
@@ -52,13 +52,20 @@ hipError_t hipGetDeviceCount(int *count)
{
HIP_INIT_API(count);
*count = g_deviceCnt;
hipError_t e = hipSuccess;
if (*count > 0) {
return ihipLogStatus(hipSuccess);
if(count != nullptr) {
*count = g_deviceCnt;
if (*count > 0) {
e = ihipLogStatus(hipSuccess);
} else {
e = ihipLogStatus(hipErrorNoDevice);
}
} else {
return ihipLogStatus(hipErrorNoDevice);
e = ihipLogStatus(hipErrorNoDevice);
}
return e;
}
hipError_t hipDeviceSetCacheConfig ( hipFuncCache cacheConfig )
@@ -217,12 +224,16 @@ hipError_t hipGetDeviceProperties(hipDeviceProp_t* props, int device)
hipError_t e;
auto * hipDevice = ihipGetDevice(device);
if (hipDevice) {
if(props != nullptr){
auto * hipDevice = ihipGetDevice(device);
if (hipDevice) {
// copy saved props
*props = hipDevice->_props;
e = hipSuccess;
} else {
*props = hipDevice->_props;
e = hipSuccess;
} else {
e = hipErrorInvalidDevice;
}
}else{
e = hipErrorInvalidDevice;
}