cmake: tests: simplify sysrepo fixtures

In rousette, we've adapted a much simplified approach for preparing the
isolated sysrepo environment. Let's pick it up in this project as well.

Change-Id: I2cd1bfaf7b76b834a144886021d20c77954da60c
See-also: https://gerrit.cesnet.cz/c/CzechLight/rousette/+/6572
See-also: https://gerrit.cesnet.cz/c/CzechLight/rousette/+/6804
See-also: https://gerrit.cesnet.cz/c/CzechLight/rousette/+/6805
See-also: https://gerrit.cesnet.cz/c/CzechLight/rousette/+/6806
See-also: https://gerrit.cesnet.cz/c/CzechLight/rousette/+/6807
See-also: https://gerrit.cesnet.cz/c/CzechLight/rousette/+/6808
See-also: https://gerrit.cesnet.cz/c/CzechLight/rousette/+/6809
diff --git a/cmake/SysrepoClean.cmake b/cmake/SysrepoClean.cmake
new file mode 100644
index 0000000..8edf1b5
--- /dev/null
+++ b/cmake/SysrepoClean.cmake
@@ -0,0 +1,14 @@
+foreach(var THIS_BINARY_DIR TEST_NAME SYSREPO_SHM_PREFIX)
+    if(NOT ${var})
+        message(FATAL_ERROR "${var} not specified")
+    endif()
+endforeach()
+
+set(shm_files_pattern "/dev/shm/${SYSREPO_SHM_PREFIX}*")
+file(GLOB shm_files ${shm_files_pattern})
+set(dummy_nonexisting_file_to_silence_warnings ${CMAKE_CURRENT_BUILD_DIR}/sysrepo-dummy-non-existing-file-for-cleanup)
+
+message(STATUS "Removing ${shm_files_pattern}")
+file(REMOVE ${shm_files} ${dummy_nonexisting_file_to_silence_warnings})
+message(STATUS "Removing ${THIS_BINARY_DIR}/test_repositories/test_${TEST_NAME}")
+file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/test_repositories/test_${TEST_NAME}")