EXSWCPHIPT-125 - Add tests for hipGetDeviceCount and restructure some SpawnProc tests (#2765)

This commit is contained in:
Jatin Chaudhary
2022-07-11 10:32:51 +01:00
committed by GitHub
parent 28acc1421d
commit f072dfd60b
12 changed files with 144 additions and 33 deletions
+23
View File
@@ -23,6 +23,7 @@ THE SOFTWARE.
*/
#include <hip_test_common.hh>
#include <hip_test_process.hh>
/**
* hipGetDeviceCount tests
@@ -32,3 +33,25 @@ TEST_CASE("Unit_hipGetDeviceCount_NegTst") {
// Scenario1
REQUIRE_FALSE(hipGetDeviceCount(nullptr) == hipSuccess);
}
TEST_CASE("Unit_hipGetDeviceCount_HideDevices") {
int deviceCount = HipTest::getDeviceCount();
if (deviceCount < 2) {
HipTest::HIP_SKIP_TEST("This test requires more than 2 GPUs. Skipping.");
return;
}
for (int i = deviceCount; i >= 1; i--) {
std::string visibleStr;
for (int j = 0; j < i; j++) { // Generate a string which has first i devices
visibleStr += std::to_string(j);
if (j != (i - 1)) {
visibleStr += ",";
}
}
hip::SpawnProc proc("getDeviceCount", true);
INFO("Output from process : " << proc.getOutput());
REQUIRE(proc.run(visibleStr) == i);
}
}