diff --git a/src/hip_memory.cpp b/src/hip_memory.cpp index 3c9b1616af..e166a84aa0 100644 --- a/src/hip_memory.cpp +++ b/src/hip_memory.cpp @@ -2271,8 +2271,6 @@ hipError_t hipMemGetInfo(size_t* free, size_t* total) { auto device = ctx->getWriteableDevice(); if (total) { *total = device->_props.totalGlobalMem; - } else { - e = hipErrorInvalidValue; } if (free) { @@ -2295,8 +2293,6 @@ hipError_t hipMemGetInfo(size_t* free, size_t* total) { } else { return ihipLogStatus(hipErrorInvalidValue); } - } else { - e = hipErrorInvalidValue; } } else { diff --git a/tests/src/Negative/memory/hipMemcpyFromSymbol.cpp b/tests/src/Negative/memory/hipMemcpyFromSymbol.cpp new file mode 100644 index 0000000000..10f8c51a6d --- /dev/null +++ b/tests/src/Negative/memory/hipMemcpyFromSymbol.cpp @@ -0,0 +1,46 @@ +/* +Copyright (c) 2015-Present Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* HIT_START + * BUILD: %t %s ../../test_common.cpp + * TEST: %t + * HIT_END + */ + +#include "test_common.h" +#define SIZE 1024 + +int main(){ + + void *Sd; + hipError_t e; + char S[SIZE]="This is not a device symbol"; + + HIPCHECK(hipMalloc(&Sd,SIZE)); + + e = hipMemcpyFromSymbol(S, HIP_SYMBOL(Sd), SIZE, 0, hipMemcpyDeviceToHost); + HIPASSERT(e==hipErrorInvalidSymbol); + + e = hipMemcpyFromSymbol(S, NULL, SIZE, 0, hipMemcpyDeviceToHost); + HIPASSERT(e==hipErrorInvalidSymbol); + + HIPCHECK(hipFree(Sd)); + + passed(); +} diff --git a/tests/src/Negative/memory/hipMemcpyFromSymbolAsync.cpp b/tests/src/Negative/memory/hipMemcpyFromSymbolAsync.cpp new file mode 100644 index 0000000000..fa341c6cea --- /dev/null +++ b/tests/src/Negative/memory/hipMemcpyFromSymbolAsync.cpp @@ -0,0 +1,49 @@ +/* +Copyright (c) 2015-Present Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* HIT_START + * BUILD: %t %s ../../test_common.cpp + * TEST: %t + * HIT_END + */ + +#include "test_common.h" +#define SIZE 1024 + +int main(){ + + void *Sd; + hipError_t e; + char S[SIZE]="This is not a device symbol"; + + HIPCHECK(hipMalloc(&Sd,SIZE)); + + hipStream_t stream; + HIPCHECK(hipStreamCreate(&stream)); + + e = hipMemcpyFromSymbolAsync(S, HIP_SYMBOL(Sd), SIZE, 0, hipMemcpyDeviceToHost, stream); + HIPASSERT(e==hipErrorInvalidSymbol); + + e = hipMemcpyFromSymbolAsync(S, NULL, SIZE, 0, hipMemcpyDeviceToHost, stream); + HIPASSERT(e==hipErrorInvalidSymbol); + + HIPCHECK(hipFree(Sd)); + + passed(); +} diff --git a/tests/src/Negative/memory/hipMemcpyToSymbol.cpp b/tests/src/Negative/memory/hipMemcpyToSymbol.cpp new file mode 100644 index 0000000000..8626c2c34f --- /dev/null +++ b/tests/src/Negative/memory/hipMemcpyToSymbol.cpp @@ -0,0 +1,46 @@ +/* +Copyright (c) 2015-Present Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* HIT_START + * BUILD: %t %s ../../test_common.cpp + * TEST: %t + * HIT_END + */ + +#include "test_common.h" +#define SIZE 1024 + +int main(){ + + void *Sd; + hipError_t e; + char S[SIZE]="This is not a device symbol"; + + HIPCHECK(hipMalloc(&Sd,SIZE)); + + e = hipMemcpyToSymbol(HIP_SYMBOL(Sd), S, SIZE, 0, hipMemcpyHostToDevice); + HIPASSERT(e==hipErrorInvalidSymbol); + + e = hipMemcpyToSymbol(NULL, S, SIZE, 0, hipMemcpyHostToDevice); + HIPASSERT(e==hipErrorInvalidSymbol); + + HIPCHECK(hipFree(Sd)); + + passed(); +} diff --git a/tests/src/Negative/memory/hipMemcpyToSymbolAsync.cpp b/tests/src/Negative/memory/hipMemcpyToSymbolAsync.cpp new file mode 100644 index 0000000000..832e4336be --- /dev/null +++ b/tests/src/Negative/memory/hipMemcpyToSymbolAsync.cpp @@ -0,0 +1,49 @@ +/* +Copyright (c) 2015-Present Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* HIT_START + * BUILD: %t %s ../../test_common.cpp + * TEST: %t + * HIT_END + */ + +#include "test_common.h" +#define SIZE 100 + +int main(){ + + void *Sd; + hipError_t e; + char S[SIZE]="This is not a device symbol"; + + HIPCHECK(hipMalloc(&Sd,SIZE)); + + hipStream_t stream; + HIPCHECK(hipStreamCreate(&stream)); + + e = hipMemcpyToSymbolAsync(HIP_SYMBOL(Sd), S, SIZE, 0, hipMemcpyHostToDevice, stream); + HIPASSERT(e==hipErrorInvalidSymbol); + + e = hipMemcpyToSymbolAsync(NULL, S, SIZE, 0, hipMemcpyHostToDevice, stream); + HIPASSERT(e==hipErrorInvalidSymbol); + + HIPCHECK(hipFree(Sd)); + + passed(); +} diff --git a/tests/src/Negative/memory/hipMemory.cpp b/tests/src/Negative/memory/hipMemory.cpp new file mode 100644 index 0000000000..b062d05cc1 --- /dev/null +++ b/tests/src/Negative/memory/hipMemory.cpp @@ -0,0 +1,43 @@ +/* +Copyright (c) 2015-Present Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* HIT_START + * BUILD: %t %s ../../test_common.cpp + * TEST: %t + * HIT_END + */ + +#include "test_common.h" +#define SIZE 100 + +int main(){ + hipError_t e; + char str[SIZE]="Hi, I am Ellesemere. What is ur name?"; + + e = hipMemcpy(0, str, SIZE, hipMemcpyHostToDevice); + HIPASSERT(e==hipErrorInvalidValue); + + e = hipMemcpy(NULL, str, SIZE, hipMemcpyHostToDevice); + HIPASSERT(e==hipErrorInvalidValue); + + e = hipMemset(0,99,80); + HIPASSERT(e==hipErrorInvalidValue); + + passed(); +} diff --git a/tests/src/Negative/stream/hipStreamCreateWithFlags.cpp b/tests/src/Negative/stream/hipStreamCreateWithFlags.cpp new file mode 100644 index 0000000000..8a1dc07b62 --- /dev/null +++ b/tests/src/Negative/stream/hipStreamCreateWithFlags.cpp @@ -0,0 +1,40 @@ +/* +Copyright (c) 2015-Present Advanced Micro Devices, Inc. All rights reserved. +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +*/ + +/* HIT_START + * BUILD: %t %s ../../test_common.cpp + * TEST: %t + * HIT_END + */ + +#include "test_common.h" + +int main(){ + + hipError_t e; + hipStream_t stream; + + e = hipStreamCreateWithFlags(&stream, -1); + HIPASSERT(e==hipErrorInvalidValue); + + e = hipStreamCreateWithFlags(&stream, 2); + HIPASSERT(e==hipErrorInvalidValue); + + passed(); +}