tests: do not reuse the same directory between two tests
By accident, both health_output-led and sysrepo_system-leds tried to put
their temporary sysfs-ish sample files into a subdirectory with the same
name. That is prone to races, and races I saw (unrelated output removed):
Start 22: sysrepo:prep:sysrepo_system-leds
11/58 Test #22: sysrepo:prep:sysrepo_system-leds ........................... Passed 0.20 sec
Start 21: test-sysrepo_system-leds
Start 4: test-health_output-led
32/58 Test #4: test-health_output-led ..................................... Passed 0.05 sec
36/58 Test #21: test-sysrepo_system-leds ...................................***Failed 0.28 sec
50.970 [749106 system W] Failed reading state of the LED 'line:red': File '/home/jkt/work/prog/_build/czechlight-asan-ubsan-ly2/velia/tests/leds/line:red/brightness' does not exist.
I pondered using __FILE__ for this, but since __FILE_NAME__ is only in
clang and I don't feel like spending too much time here, a simple
hardcoded thingy will have to suffice.
Change-Id: Ib0cde221a844a662aa58f8dee88500d34b533201
diff --git a/tests/health_output-led.cpp b/tests/health_output-led.cpp
index 3139be7..63eb0d8 100644
--- a/tests/health_output-led.cpp
+++ b/tests/health_output-led.cpp
@@ -39,7 +39,7 @@
using namespace std::literals;
TEST_INIT_LOGS;
- auto fakeSysfsDir = std::filesystem::path {CMAKE_CURRENT_BINARY_DIR + "/tests/leds/"s};
+ auto fakeSysfsDir = std::filesystem::path {CMAKE_CURRENT_BINARY_DIR + "/tests/health_output-led/"s};
auto fakeBrightnessFile = fakeSysfsDir / "brightness";
removeDirectoryTreeIfExists(fakeSysfsDir);