blob: 51eaf1c77de35ba05d8608ba939c9bf743d46ef1 [file] [log] [blame]
Václav Kubernátd1beedc2020-09-07 12:09:05 +02001set -eux
Václav Kubernátd1beedc2020-09-07 12:09:05 +02002
3if [[ $(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
6fi
7
8if [[ -z "$SYSREPO_SHM_PREFIX" ]]; then
9 echo '$SYSREPO_SHM_PREFIX is empty! Aborting.'
10 exit 1
11fi
12
13rm -rf "$SYSREPO_REPOSITORY_PATH"
14rm -rf "/dev/shm/$SYSREPO_SHM_PREFIX"*
15cp -r "@SYSREPO_SR_REPO_PATH@" "$SYSREPO_REPOSITORY_PATH"
16
17SYSREPOCTL="@SYSREPOCTL_EXECUTABLE@"
18SYSREPOCFG="@SYSREPOCFG_EXECUTABLE@"
19
20MODULE="$1"
21YANG_DIR=$(dirname "$1")
22shift
23
24# Install the module
25"$SYSREPOCTL" --search-dirs "$YANG_DIR" --install "$MODULE" -a
26
27BACKEND="$1"
28shift
29if [[ "$BACKEND" = "netconf" ]]; then
30 NETOPEER2="@NETOPEER2_EXECUTABLE@"
31 # Setup netopeer config
32 "$SYSREPOCFG" --import --datastore=running --format=xml --module=ietf-netconf-server <<< ""
33
34 # Disable nacm
35 for datastore in startup running; do
36 "$SYSREPOCFG" --import="@CMAKE_CURRENT_SOURCE_DIR@/tests/disable-nacm.xml" --datastore="$datastore" --format=xml --module=ietf-netconf-acm
37 done
38
Václav Kubernát634e24a2020-11-19 01:20:27 +010039 # I need to run netopeer in the foreground, because I want to get its standard outputs. However, ctest doesn't like
40 # when child processes don't exit and always waits fot them. The `setsid` command runs a program in a separate
41 # session and also forks, which means it becomes invisible to ctest. I want the name of the process to be
42 # recognizable. For that `exec -a` can be used. Unfortunately `exec` is shell-builtin, so I need to run bash instead
43 # of running `exec` directly. Finally, I redirect its stdout and stderr to a file.
Jan Kundrát805d02c2020-11-13 20:20:44 +010044 NETOPEER_PIDFILE="@CMAKE_CURRENT_BINARY_DIR@/test_netopeer_files/$SYSREPO_SHM_PREFIX.pid"
Václav Kubernát634e24a2020-11-19 01:20:27 +010045 setsid -f \
Jan Kundrát805d02c2020-11-13 20:20:44 +010046 bash -c "exec -a '${SYSREPO_SHM_PREFIX}_netopeer2-server' '$NETOPEER2' -d -v2 '-U$NETOPEER_SOCKET' -p'$NETOPEER_PIDFILE'" \
Václav Kubernát634e24a2020-11-19 01:20:27 +010047 < /dev/null &> "@CMAKE_CURRENT_BINARY_DIR@/test_netopeer_outputs/$SYSREPO_SHM_PREFIX.out"
Václav Kubernátd1beedc2020-09-07 12:09:05 +020048 sleep 5
49fi