Merge "Remove unused script"
diff --git a/.zuul.public.yaml b/.zuul.public.yaml
index f8a4675..81b220f 100644
--- a/.zuul.public.yaml
+++ b/.zuul.public.yaml
@@ -1,23 +1,23 @@
 - job:
-    name: f32-gcc-netconf-cli-no-sysrepo
+    name: f33-gcc-netconf-cli-no-sysrepo
     description: |
       Build a minimal version without sysrepo or the test suite
-    parent: f32-gcc
+    parent: f33-gcc
 
 - project:
     check:
       jobs:
-        - f32-gcc-cover:
-            requires: CzechLight-deps-f32-gcc
-        - f32-clang-asan-ubsan:
-            requires: CzechLight-deps-f32-clang-asan-ubsan
-        - f32-clang-tsan:
-            requires: CzechLight-deps-f32-clang-tsan
-        - f32-gcc-netconf-cli-no-sysrepo:
-            requires: CzechLight-deps-f32-gcc
-        - f32-cpp-coverage-diff:
+        - f33-gcc-cover:
+            requires: CzechLight-deps-f33-gcc
+        - f33-clang-asan-ubsan:
+            requires: CzechLight-deps-f33-clang-asan-ubsan
+        - f33-clang-tsan:
+            requires: CzechLight-deps-f33-clang-tsan
+        - f33-gcc-netconf-cli-no-sysrepo:
+            requires: CzechLight-deps-f33-gcc
+        - f33-cpp-coverage-diff:
             voting: false
         - clang-format:
             voting: false
-        - f32-gcc-cover-previous:
-            requires: CzechLight-deps-f32-gcc
+        - f33-gcc-cover-previous:
+            requires: CzechLight-deps-f33-gcc
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 92ab37f..df78b3c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -269,7 +269,8 @@
         target_link_libraries(sysreposubscription PUBLIC datastoreaccess PRIVATE PkgConfig::SYSREPO)
 
         file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test_repositories)
-        file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test_sockets)
+        file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test_netopeer_files)
+        file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/test_netopeer_outputs)
     endif()
 
     configure_file(${CMAKE_CURRENT_SOURCE_DIR}/tests/yang_access_test_vars.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/yang_access_test_vars.hpp @ONLY)
@@ -318,7 +319,7 @@
         set_property(TEST ${TESTNAME} ${TESTNAME}_init ${TESTNAME}_cleanup APPEND PROPERTY ENVIRONMENT
             "SYSREPO_REPOSITORY_PATH=${CMAKE_CURRENT_BINARY_DIR}/test_repositories/${TESTNAME}"
             "SYSREPO_SHM_PREFIX=netconf-cli_${TESTNAME}"
-            "NETOPEER_SOCKET=${CMAKE_CURRENT_BINARY_DIR}/test_sockets/${TESTNAME}.sock"
+            "NETOPEER_SOCKET=${CMAKE_CURRENT_BINARY_DIR}/test_netopeer_files/${TESTNAME}.sock"
             )
 
     endfunction()
@@ -387,7 +388,7 @@
         set_property(TEST test_netconf_cli_py test_netconf_cli_py_init test_netconf_cli_py_cleanup APPEND PROPERTY ENVIRONMENT
             "SYSREPO_REPOSITORY_PATH=${CMAKE_CURRENT_BINARY_DIR}/test_repositories/test_netconf_cli_py"
             "SYSREPO_SHM_PREFIX=netconf-cli_test_netconf_cli_py"
-            "NETOPEER_SOCKET=${CMAKE_CURRENT_BINARY_DIR}/test_sockets/test_netconf_cli_py.sock"
+            "NETOPEER_SOCKET=${CMAKE_CURRENT_BINARY_DIR}/test_netopeer_files/test_netconf_cli_py.sock"
             )
 
         set(sanitizer_active OFF)
diff --git a/ci/build.sh b/ci/build.sh
index d6b75f4..3dacb5f 100755
--- a/ci/build.sh
+++ b/ci/build.sh
@@ -91,7 +91,10 @@
     rm ${PREFIX}/bin/sysrepo*
 fi
 
+mkdir ~/zuul-output/logs/test_netopeer_outputs
+
 cd ${BUILD_DIR}
+ln -s ~/zuul-output/logs/test_netopeer_outputs test_netopeer_outputs
 cmake -GNinja -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE:-Debug} -DCMAKE_INSTALL_PREFIX=${PREFIX} ${CMAKE_OPTIONS} ${ZUUL_PROJECT_SRC_DIR}
 ninja-build
 ctest -j${CI_PARALLEL_JOBS} --output-on-failure
diff --git a/submodules/dependencies b/submodules/dependencies
index ba3de22..174ec68 160000
--- a/submodules/dependencies
+++ b/submodules/dependencies
@@ -1 +1 @@
-Subproject commit ba3de22763cabe419a03a8a1f75447043d43b1d5
+Subproject commit 174ec68e8f90e13bd2fb3c445fec9ab68bf79c08
diff --git a/tests/cleanup_datastore.bash.in b/tests/cleanup_datastore.bash.in
index 66df88c..835ab88 100755
--- a/tests/cleanup_datastore.bash.in
+++ b/tests/cleanup_datastore.bash.in
@@ -17,7 +17,17 @@
     # line, including stuff set by `exec -a`. Otherwise it matches the name in
     # /proc/{pid}/stat and that is usually limited to 15 characters, so
     # netopeer2-server appears as netopeer2-serve
+    NETOPEER_PID="$(pgrep -f "${SYSREPO_SHM_PREFIX}_netopeer2-server")"
     pkill -f "${SYSREPO_SHM_PREFIX}_netopeer2-server"
+
+    # Wait until netopeer actually exits, because I don't want to remove its repository/shm files while it is still
+    # running.
+    #
+    # One would think, that this is a job for the `wait` command, but that one unfortunately only works for child
+    # processes of the current shell. The `tail` command does implement this mechanism, so I can use that.
+    # https://stackoverflow.com/a/41613532
+    tail --pid="$NETOPEER_PID" -f /dev/null
+
     rm "$NETOPEER_SOCKET"
 fi
 
diff --git a/tests/init_datastore.bash.in b/tests/init_datastore.bash.in
index 5aec0c0..a4ac0df 100755
--- a/tests/init_datastore.bash.in
+++ b/tests/init_datastore.bash.in
@@ -37,7 +37,14 @@
         "$SYSREPOCFG" --import="@CMAKE_CURRENT_SOURCE_DIR@/tests/disable-nacm.xml" --datastore="$datastore" --format=xml --module=ietf-netconf-acm
     done
 
-    # Run netopeer. Use exec -a, so that each process has a recognizable name for `pkill`.
-    (exec -a "${SYSREPO_SHM_PREFIX}_netopeer2-server" "$NETOPEER2" -v2 "-U$NETOPEER_SOCKET")
+    # I need to run netopeer in the foreground, because I want to get its standard outputs.  However, ctest doesn't like
+    # when child processes don't exit and always waits fot them.  The `setsid` command runs a program in a separate
+    # session and also forks, which means it becomes invisible to ctest.  I want the name of the process to be
+    # recognizable. For that `exec -a` can be used. Unfortunately `exec` is shell-builtin, so I need to run bash instead
+    # of running `exec` directly. Finally, I redirect its stdout and stderr to a file.
+    NETOPEER_PIDFILE="@CMAKE_CURRENT_BINARY_DIR@/test_netopeer_files/$SYSREPO_SHM_PREFIX.pid"
+    setsid -f \
+        bash -c "exec -a '${SYSREPO_SHM_PREFIX}_netopeer2-server' '$NETOPEER2' -d -v2 '-U$NETOPEER_SOCKET' -p'$NETOPEER_PIDFILE'" \
+        < /dev/null &> "@CMAKE_CURRENT_BINARY_DIR@/test_netopeer_outputs/$SYSREPO_SHM_PREFIX.out"
     sleep 5
 fi