Václav Kubernát | d1beedc | 2020-09-07 12:09:05 +0200 | [diff] [blame] | 1 | set -eux |
| 2 | export UBSAN_OPTIONS=halt_on_error=1 # UBSan doesn't stop on errors by default. |
| 3 | |
| 4 | if [[ $(dirname "$(dirname "$(realpath "$SYSREPO_REPOSITORY_PATH")")") != "@CMAKE_CURRENT_BINARY_DIR@" ]]; then |
| 5 | echo "\$SYSREPO_REPOSITORY_PATH is not inside the build dir! Aborting. ($SYSREPO_REPOSITORY_PATH)" |
| 6 | exit 1 |
| 7 | fi |
| 8 | |
| 9 | if [[ -z "$SYSREPO_SHM_PREFIX" ]]; then |
| 10 | echo '$SYSREPO_SHM_PREFIX is empty! Aborting.' |
| 11 | exit 1 |
| 12 | fi |
| 13 | |
| 14 | rm -rf "$SYSREPO_REPOSITORY_PATH" |
| 15 | rm -rf "/dev/shm/$SYSREPO_SHM_PREFIX"* |
| 16 | cp -r "@SYSREPO_SR_REPO_PATH@" "$SYSREPO_REPOSITORY_PATH" |
| 17 | |
| 18 | SYSREPOCTL="@SYSREPOCTL_EXECUTABLE@" |
| 19 | SYSREPOCFG="@SYSREPOCFG_EXECUTABLE@" |
| 20 | |
| 21 | MODULE="$1" |
| 22 | YANG_DIR=$(dirname "$1") |
| 23 | shift |
| 24 | |
| 25 | # Install the module |
| 26 | "$SYSREPOCTL" --search-dirs "$YANG_DIR" --install "$MODULE" -a |
| 27 | |
| 28 | BACKEND="$1" |
| 29 | shift |
| 30 | if [[ "$BACKEND" = "netconf" ]]; then |
| 31 | NETOPEER2="@NETOPEER2_EXECUTABLE@" |
| 32 | # Setup netopeer config |
| 33 | "$SYSREPOCFG" --import --datastore=running --format=xml --module=ietf-netconf-server <<< "" |
| 34 | |
| 35 | # Disable nacm |
| 36 | for datastore in startup running; do |
| 37 | "$SYSREPOCFG" --import="@CMAKE_CURRENT_SOURCE_DIR@/tests/disable-nacm.xml" --datastore="$datastore" --format=xml --module=ietf-netconf-acm |
| 38 | done |
| 39 | |
Václav Kubernát | 634e24a | 2020-11-19 01:20:27 +0100 | [diff] [blame] | 40 | # I need to run netopeer in the foreground, because I want to get its standard outputs. However, ctest doesn't like |
| 41 | # when child processes don't exit and always waits fot them. The `setsid` command runs a program in a separate |
| 42 | # session and also forks, which means it becomes invisible to ctest. I want the name of the process to be |
| 43 | # recognizable. For that `exec -a` can be used. Unfortunately `exec` is shell-builtin, so I need to run bash instead |
| 44 | # 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] | 45 | 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] | 46 | setsid -f \ |
Jan Kundrát | 805d02c | 2020-11-13 20:20:44 +0100 | [diff] [blame] | 47 | 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] | 48 | < /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] | 49 | sleep 5 |
| 50 | fi |