Updated negative tests for hipStreamGetPriority (#2517)

Bu işleme şunda yer alıyor:
Finlay
2022-05-25 07:20:59 +01:00
işlemeyi yapan: GitHub
ebeveyn 74bfcf5f87
işleme 99a23cfd45
4 değiştirilmiş dosya ile 86 ekleme ve 49 silme
+52 -34
Dosyayı Görüntüle
@@ -1,5 +1,5 @@
/*
Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved.
Copyright (c) 2022 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
@@ -16,59 +16,77 @@ 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.
*/
/**
/*
Testcase Scenarios :
1) Negative tests for hipStreamGetPriority api.
2) Create stream and check default priority of stream is within range.
3) Create stream with high or low priority and check priority is set as expected.
4) Create stream with higher priority or lower priority for the priority range returned.
4) Create stream with higher priority or lower priority for the priority range returned, the stream
priority should be clamped to the priority range.
5) Create stream with CUMask and check priority is returned as expected.
*/
#include <hip_test_common.hh>
/**
* Negative tests for hipStreamGetPriority api.
* Check the error returned when an invalid pointer to a priority is used.
*/
TEST_CASE("Unit_hipStreamGetPriority_Negative") {
hipStream_t stream = 0;
REQUIRE(hipStreamGetPriority(stream, nullptr) == hipErrorInvalidValue);
TEST_CASE("Unit_hipStreamGetPriority_InvalidPriorityPointer") {
hipStream_t stream{};
HIP_CHECK(hipStreamCreate(&stream));
HIP_CHECK_ERROR(hipStreamGetPriority(stream, nullptr), hipErrorInvalidValue);
HIP_CHECK(hipStreamDestroy(stream));
}
/**
* Create stream with higher priority for the priority range returned.
* Create stream and check priority.
*/
TEST_CASE("Unit_hipStreamGetPriority_higher") {
TEST_CASE("Unit_hipStreamGetPriority_happy") {
int priority_low = 0;
int priority_high = 0;
int devID = GENERATE(range(0, HipTest::getDeviceCount()));
HIP_CHECK(hipSetDevice(devID));
HIP_CHECK(hipDeviceGetStreamPriorityRange(&priority_low, &priority_high));
hipStream_t stream;
HIP_CHECK(hipStreamCreateWithPriority(&stream, hipStreamNonBlocking,
priority_high-1));
hipStream_t stream{};
int priority = 0;
HIP_CHECK(hipStreamGetPriority(stream, &priority));
REQUIRE(priority == priority_high);
HIP_CHECK(hipStreamDestroy(stream));
}
/**
* Create stream with lower priority for the priority range returned.
*/
TEST_CASE("Unit_hipStreamGetPriority_lower") {
int priority_low = 0;
int priority_high = 0;
int devID = GENERATE(range(0, HipTest::getDeviceCount()));
HIP_CHECK(hipSetDevice(devID));
HIP_CHECK(hipDeviceGetStreamPriorityRange(&priority_low, &priority_high));
hipStream_t stream;
HIP_CHECK(hipStreamCreateWithPriority(&stream, hipStreamNonBlocking,
priority_low+1));
int priority = 0;
HIP_CHECK(hipStreamGetPriority(stream, &priority));
REQUIRE(priority_low == priority);
HIP_CHECK(hipStreamDestroy(stream));
SECTION("Null Stream") {
HIP_CHECK(hipStreamGetPriority(nullptr, &priority));
// valid priority
REQUIRE(priority_low >= priority);
REQUIRE(priority >= priority_high);
}
SECTION("Created Stream") {
SECTION("Default Priority") {
HIP_CHECK(hipStreamCreate(&stream));
HIP_CHECK(hipStreamGetPriority(stream, &priority));
// valid priority
// Lower the value higher the priority, higher the value lower the priority
REQUIRE(priority_low >= priority);
REQUIRE(priority >= priority_high);
}
SECTION("High Priority") {
HIP_CHECK(hipStreamCreateWithPriority(&stream, hipStreamDefault, priority_high));
HIP_CHECK(hipStreamGetPriority(stream, &priority));
REQUIRE(priority == priority_high);
}
SECTION("Higher Priority") {
HIP_CHECK(hipStreamCreateWithPriority(&stream, hipStreamNonBlocking, priority_high - 1));
HIP_CHECK(hipStreamGetPriority(stream, &priority));
REQUIRE(priority == priority_high);
}
SECTION("Low Priority") {
HIP_CHECK(hipStreamCreateWithPriority(&stream, hipStreamDefault, priority_low));
HIP_CHECK(hipStreamGetPriority(stream, &priority));
REQUIRE(priority_low == priority);
}
SECTION("Lower Priority") {
HIP_CHECK(hipStreamCreateWithPriority(&stream, hipStreamNonBlocking, priority_low + 1));
HIP_CHECK(hipStreamGetPriority(stream, &priority));
REQUIRE(priority_low == priority);
}
HIP_CHECK(hipStreamDestroy(stream));
}
}
#if HT_AMD
@@ -76,7 +94,7 @@ TEST_CASE("Unit_hipStreamGetPriority_lower") {
* Create stream with CUMask and check priority is returned as expected.
*/
TEST_CASE("Unit_hipStreamGetPriority_StreamsWithCUMask") {
hipStream_t stream;
hipStream_t stream{};
int priority = 0;
int priority_normal = 0;
int priority_low = 0;