Description
We use Catch2 to test an abstraction library for CPU/GPU programming named alpaka. In some parts of the test we need to get a device (CPU/GPU). But sometimes the device is not available. This is expected behavior of our library, because you can compile an application with support for Nvidia, AMD and Intel GPUs, ship the application on different systems and check at runtime if the GPU is available. Therefore the tests needs to work in the same way.
At the moment, we use this code snippet:
TEMPLATE_LIST_TEST_CASE("atomicOperationsWorking", "[atomic]", TestApis)
{
auto cfg = TestType::makeDict();
auto deviceSpec = cfg[object::deviceSpec];
auto exec = cfg[object::exec];
auto devSelector = onHost::makeDeviceSelector(deviceSpec);
if(!devSelector.isAvailable())
{
SUCCEED("No device available for " << deviceSpec.getName());
return;
}
auto device = devSelector.makeDevice(0);
// ...
}
Since getting a device is a function we use very frequently, I would like to move it into a helper function as follows:
auto getDevice(auto cfg)
{
auto deviceSpec = cfg[object::deviceSpec];
auto devSelector = onHost::makeDeviceSelector(deviceSpec);
UNSCOPED_INFO("DeviceSpec: " << getName(deviceSpec));
UNSCOPED_INFO("API: " << deviceSpec.getApi().getName());
if(!devSelector.isAvailable())
{
SKIP("No device available for " << deviceSpec.getName());
}
onHost::Device device = devSelector.makeDevice(0);
UNSCOPED_INFO("Device: " << device.getName());
return device;
}
The problem is that we have test files that contain only tests that rely on a device, and we have test files that also contain tests that do not require a device and are intended to test something device-independent. In the first cases, ctest fails if no device is available. If I set the argument --allow-running-no-tests for all test, it is possible that in the second case tests passes, which does nothing.
I could set the argument --allow-running-no-tests for specific test executables but to be honest, I think this really error prone and we have some developers and contributors, which are not familiar with such Catch2 details.
Is is possible to implement an SKIP macro which does not trigger the no-running-test check? It does not need to be part of Catch2. I'm also fine to implement it as test helper for our library.
Description
We use Catch2 to test an abstraction library for CPU/GPU programming named alpaka. In some parts of the test we need to get a device (CPU/GPU). But sometimes the device is not available. This is expected behavior of our library, because you can compile an application with support for Nvidia, AMD and Intel GPUs, ship the application on different systems and check at runtime if the GPU is available. Therefore the tests needs to work in the same way.
At the moment, we use this code snippet:
Since getting a device is a function we use very frequently, I would like to move it into a helper function as follows:
The problem is that we have test files that contain only tests that rely on a device, and we have test files that also contain tests that do not require a device and are intended to test something device-independent. In the first cases,
ctestfails if no device is available. If I set the argument--allow-running-no-testsfor all test, it is possible that in the second case tests passes, which does nothing.I could set the argument
--allow-running-no-testsfor specific test executables but to be honest, I think this really error prone and we have some developers and contributors, which are not familiar with such Catch2 details.Is is possible to implement an
SKIPmacro which does not trigger the no-running-test check? It does not need to be part of Catch2. I'm also fine to implement it as test helper for our library.