diff --git a/tests/catch/unit/memory/CMakeLists.txt b/tests/catch/unit/memory/CMakeLists.txt index 23bbd07aae..2a531232a8 100644 --- a/tests/catch/unit/memory/CMakeLists.txt +++ b/tests/catch/unit/memory/CMakeLists.txt @@ -1,3 +1,23 @@ +# Copyright (c) 2021 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. + # Common Tests - Test independent of all platforms if(HIP_PLATFORM MATCHES "amd") set(TEST_SRC @@ -38,6 +58,10 @@ set(TEST_SRC hipMallocManaged.cc hipMemRangeGetAttribute.cc hipHmmOvrSubscriptionTst.cc + hipMemcpyFromSymbol.cc + hipMemcpyFromSymbolAsync.cc + hipMemcpyToSymbol.cc + hipMemcpyToSymbolAsync.cc ) else() set(TEST_SRC @@ -75,6 +99,10 @@ set(TEST_SRC hipMallocManaged.cc hipMemRangeGetAttribute.cc hipHmmOvrSubscriptionTst.cc + hipMemcpyFromSymbol.cc + hipMemcpyFromSymbolAsync.cc + hipMemcpyToSymbol.cc + hipMemcpyToSymbolAsync.cc ) endif() diff --git a/tests/catch/unit/memory/hipMemcpyFromSymbol.cc b/tests/catch/unit/memory/hipMemcpyFromSymbol.cc new file mode 100644 index 0000000000..347b4589a1 --- /dev/null +++ b/tests/catch/unit/memory/hipMemcpyFromSymbol.cc @@ -0,0 +1,43 @@ +/* +Copyright (c) 2021 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. +*/ + +#include +#define SIZE 1024 + +/* Test verifies hipMemcpyFromSymbol API Negative scenarios. + */ + +TEST_CASE("Unit_hipMemcpyFromSymbol_Negative") { + void *Sd; + char S[SIZE]="This is not a device symbol"; + + HIP_CHECK(hipMalloc(&Sd, SIZE)); + + SECTION("Passing void pointer") { + REQUIRE(hipSuccess != hipMemcpyFromSymbol(S, HIP_SYMBOL(Sd), + SIZE, 0, hipMemcpyDeviceToHost)); + } + + SECTION("Passing NULL Pointer") { + REQUIRE(hipSuccess != hipMemcpyFromSymbol(S, nullptr, + SIZE, 0, hipMemcpyDeviceToHost)); + } + + HIP_CHECK(hipFree(Sd)); +} diff --git a/tests/catch/unit/memory/hipMemcpyFromSymbolAsync.cc b/tests/catch/unit/memory/hipMemcpyFromSymbolAsync.cc new file mode 100644 index 0000000000..ae6ebc3e82 --- /dev/null +++ b/tests/catch/unit/memory/hipMemcpyFromSymbolAsync.cc @@ -0,0 +1,47 @@ +/* +Copyright (c) 2021 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. +*/ + +#include +#define SIZE 1024 + +/* Test verifies hipMemcpyFromSymbolAsync API Negative scenarios. + */ + +TEST_CASE("Unit_hipMemcpyFromSymbolAsync_Negative") { + void *Sd; + char S[SIZE]="This is not a device symbol"; + + HIP_CHECK(hipMalloc(&Sd, SIZE)); + + hipStream_t stream; + HIP_CHECK(hipStreamCreate(&stream)); + + SECTION("Passing void pointer") { + REQUIRE(hipSuccess != hipMemcpyFromSymbolAsync(S, HIP_SYMBOL(Sd), + SIZE, 0, hipMemcpyDeviceToHost, stream)); + } + + SECTION("Passing NULL pointer") { + REQUIRE(hipSuccess != hipMemcpyFromSymbolAsync(S, nullptr, + SIZE, 0, hipMemcpyDeviceToHost, stream)); + } + + HIP_CHECK(hipStreamDestroy(stream)); + HIP_CHECK(hipFree(Sd)); +} diff --git a/tests/catch/unit/memory/hipMemcpyToSymbol.cc b/tests/catch/unit/memory/hipMemcpyToSymbol.cc new file mode 100644 index 0000000000..23e5768c3c --- /dev/null +++ b/tests/catch/unit/memory/hipMemcpyToSymbol.cc @@ -0,0 +1,43 @@ +/* +Copyright (c) 2021 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. +*/ + +#include +#define SIZE 1024 + +/* Test verifies hipMemcpyToSymbol API Negative scenarios. + */ + +TEST_CASE("Unit_hipMemcpyToSymbol_Negative") { + void *Sd; + char S[SIZE]="This is not a device symbol"; + + HIP_CHECK(hipMalloc(&Sd, SIZE)); + + SECTION("Passing void pointer") { + REQUIRE(hipSuccess != hipMemcpyToSymbol(HIP_SYMBOL(Sd), S, + SIZE, 0, hipMemcpyDeviceToHost)); + } + + SECTION("Passing NULL Pointer") { + REQUIRE(hipSuccess != hipMemcpyToSymbol(nullptr, S, + SIZE, 0, hipMemcpyDeviceToHost)); + } + + HIP_CHECK(hipFree(Sd)); +} diff --git a/tests/catch/unit/memory/hipMemcpyToSymbolAsync.cc b/tests/catch/unit/memory/hipMemcpyToSymbolAsync.cc new file mode 100644 index 0000000000..42b82128f9 --- /dev/null +++ b/tests/catch/unit/memory/hipMemcpyToSymbolAsync.cc @@ -0,0 +1,47 @@ +/* +Copyright (c) 2021 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. +*/ + +#include +#define SIZE 1024 + +/* Test verifies hipMemcpyToSymbolAsync API Negative scenarios. + */ + +TEST_CASE("Unit_hipMemcpyToSymbolAsync_Negative") { + void *Sd; + char S[SIZE]="This is not a device symbol"; + + HIP_CHECK(hipMalloc(&Sd, SIZE)); + + hipStream_t stream; + HIP_CHECK(hipStreamCreate(&stream)); + + SECTION("Passing void pointer") { + REQUIRE(hipSuccess != hipMemcpyToSymbolAsync(HIP_SYMBOL(Sd), S, + SIZE, 0, hipMemcpyHostToDevice, stream)); + } + + SECTION("Passing NULL pointer") { + REQUIRE(hipSuccess != hipMemcpyToSymbolAsync(nullptr, S, + SIZE, 0, hipMemcpyHostToDevice, stream)); + } + + HIP_CHECK(hipStreamDestroy(stream)); + HIP_CHECK(hipFree(Sd)); +}