Václav Kubernát | d1beedc | 2020-09-07 12:09:05 +0200 | [diff] [blame] | 1 | set -eux |
Václav Kubernát | d1beedc | 2020-09-07 12:09:05 +0200 | [diff] [blame] | 2 | |
| 3 | if [[ $(dirname "$(dirname "$(realpath "$SYSREPO_REPOSITORY_PATH")")") != "@CMAKE_CURRENT_BINARY_DIR@" ]]; then |
| 4 | echo "\$SYSREPO_REPOSITORY_PATH is not inside the build dir! Aborting. ($SYSREPO_REPOSITORY_PATH)" |
| 5 | exit 1 |
| 6 | fi |
| 7 | |
| 8 | if [[ -z "$SYSREPO_SHM_PREFIX" ]]; then |
| 9 | echo '$SYSREPO_SHM_PREFIX is empty! Aborting.' |
| 10 | exit 1 |
| 11 | fi |
| 12 | |
| 13 | rm -rf "$SYSREPO_REPOSITORY_PATH" |
| 14 | rm -rf "/dev/shm/$SYSREPO_SHM_PREFIX"* |
| 15 | cp -r "@SYSREPO_SR_REPO_PATH@" "$SYSREPO_REPOSITORY_PATH" |
| 16 | |
| 17 | SYSREPOCTL="@SYSREPOCTL_EXECUTABLE@" |
| 18 | SYSREPOCFG="@SYSREPOCFG_EXECUTABLE@" |
| 19 | |
| 20 | MODULE="$1" |
| 21 | YANG_DIR=$(dirname "$1") |
| 22 | shift |
| 23 | |
Václav Kubernát | 5e1bb4a | 2022-04-07 01:19:19 +0200 | [diff] [blame] | 24 | # Uninstall the module |
| 25 | "$SYSREPOCTL" --uninstall "$(basename "$MODULE" ".yang")" -v3 || true |
| 26 | |
Václav Kubernát | d1beedc | 2020-09-07 12:09:05 +0200 | [diff] [blame] | 27 | # Install the module |
Václav Kubernát | cfdb922 | 2021-07-07 22:36:24 +0200 | [diff] [blame] | 28 | "$SYSREPOCTL" --search-dirs "$YANG_DIR" --install "$MODULE" -v3 |
Václav Kubernát | d1beedc | 2020-09-07 12:09:05 +0200 | [diff] [blame] | 29 | |
| 30 | BACKEND="$1" |
| 31 | shift |
| 32 | if [[ "$BACKEND" = "netconf" ]]; then |
Václav Kubernát | a1b52a0 | 2021-11-25 03:57:05 +0100 | [diff] [blame] | 33 | # Kill previous instances of Netopeer2 that are associated with this test. These can appear when you run tests and |
| 34 | # press CTRL-C before let the cleanup tests run. |
| 35 | pkill -f "${SYSREPO_SHM_PREFIX}_netopeer2-server" || true |
| 36 | |
Václav Kubernát | d1beedc | 2020-09-07 12:09:05 +0200 | [diff] [blame] | 37 | NETOPEER2="@NETOPEER2_EXECUTABLE@" |
| 38 | # Setup netopeer config |
| 39 | "$SYSREPOCFG" --import --datastore=running --format=xml --module=ietf-netconf-server <<< "" |
| 40 | |
| 41 | # Disable nacm |
| 42 | for datastore in startup running; do |
| 43 | "$SYSREPOCFG" --import="@CMAKE_CURRENT_SOURCE_DIR@/tests/disable-nacm.xml" --datastore="$datastore" --format=xml --module=ietf-netconf-acm |
| 44 | done |
| 45 | |
Václav Kubernát | 634e24a | 2020-11-19 01:20:27 +0100 | [diff] [blame] | 46 | # I need to run netopeer in the foreground, because I want to get its standard outputs. However, ctest doesn't like |
| 47 | # when child processes don't exit and always waits fot them. The `setsid` command runs a program in a separate |
| 48 | # session and also forks, which means it becomes invisible to ctest. I want the name of the process to be |
| 49 | # recognizable. For that `exec -a` can be used. Unfortunately `exec` is shell-builtin, so I need to run bash instead |
| 50 | # of running `exec` directly. Finally, I redirect its stdout and stderr to a file. |
Jan Kundrát | 805d02c | 2020-11-13 20:20:44 +0100 | [diff] [blame] | 51 | NETOPEER_PIDFILE="@CMAKE_CURRENT_BINARY_DIR@/test_netopeer_files/$SYSREPO_SHM_PREFIX.pid" |
Václav Kubernát | 634e24a | 2020-11-19 01:20:27 +0100 | [diff] [blame] | 52 | setsid -f \ |
Jan Kundrát | 805d02c | 2020-11-13 20:20:44 +0100 | [diff] [blame] | 53 | bash -c "exec -a '${SYSREPO_SHM_PREFIX}_netopeer2-server' '$NETOPEER2' -d -v2 '-U$NETOPEER_SOCKET' -p'$NETOPEER_PIDFILE'" \ |
Václav Kubernát | 634e24a | 2020-11-19 01:20:27 +0100 | [diff] [blame] | 54 | < /dev/null &> "@CMAKE_CURRENT_BINARY_DIR@/test_netopeer_outputs/$SYSREPO_SHM_PREFIX.out" |
Václav Kubernát | d1beedc | 2020-09-07 12:09:05 +0200 | [diff] [blame] | 55 | sleep 5 |
| 56 | fi |