FreeBSD modifications: Configure, makefiles and test scripts modification for Freebsd

This commit is contained in:
Olof Hagsand 2019-10-20 09:03:31 -10:00
parent 1fa45067a7
commit d7bb96b9cf
15 changed files with 56 additions and 40 deletions

View file

@ -57,7 +57,7 @@
* Code in kill_session is removed where this fact was used to actually kill the client process. * Code in kill_session is removed where this fact was used to actually kill the client process.
* XPATH canonical form implemented for NETCONF get and get-config. This means that all callbacks (including state callbacks) will have the prefixes that corresponds to module prefixes. If an xpath have other prefixes (or null as default), they will be translated to canonical form before any callbacks. * XPATH canonical form implemented for NETCONF get and get-config. This means that all callbacks (including state callbacks) will have the prefixes that corresponds to module prefixes. If an xpath have other prefixes (or null as default), they will be translated to canonical form before any callbacks.
* Example of a canonical form: `/a:x/a:y`, then symbols must belong to a yang module with prefix `a`. * Example of a canonical form: `/a:x/a:y`, then symbols must belong to a yang module with prefix `a`.
* Configure and test modification for better Freebsd port * FreeBSD modifications: Configure, makefiles and test scripts modification for Freebsd
### Corrected Bugs ### Corrected Bugs
* See "Stricter handling of multi-namespace handling" in API-changes above. * See "Stricter handling of multi-namespace handling" in API-changes above.

View file

@ -52,13 +52,19 @@ INSTALL = @INSTALL@
INCLUDES = -I. -I@srcdir@ @INCLUDES@ INCLUDES = -I. -I@srcdir@ @INCLUDES@
SHELL = /bin/sh SHELL = /bin/sh
SUBDIRS = lib apps include etc yang SUBDIRS1 = include lib
SUBDIRS2 = apps etc yang # without include lib for circular dependency
SUBDIRS= $(SUBDIRS1) $(SUBDIRS2)
.PHONY: doc example all clean depend $(SUBDIRS) install loc TAGS .config.status docker test .PHONY: doc example all clean depend $(SUBDIRS) install loc TAGS .config.status docker test
all: $(SUBDIRS) all: $(SUBDIRS2)
$(SUBDIRS): include lib # Cannot build app before lib (for parallel make -j) # May cause circular include->include,lib
$(SUBDIRS2): include lib # Cannot build app before lib (for parallel make -j)
(cd $@ && $(MAKE) $(MFLAGS) all)
$(SUBDIRS1):
(cd $@ && $(MAKE) $(MFLAGS) all) (cd $@ && $(MAKE) $(MFLAGS) all)
depend: depend:

View file

@ -56,7 +56,7 @@ CLIXON_MAJOR = @CLIXON_VERSION_MAJOR@
CLIXON_MINOR = @CLIXON_VERSION_MINOR@ CLIXON_MINOR = @CLIXON_VERSION_MINOR@
# Use this clixon lib for linking # Use this clixon lib for linking
CLIXON_LIB = libclixon.so.$(CLIXON_MAJOR).$(CLIXON_MINOR) CLIXON_LIB = libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR)
# For dependency. A little strange that we rely on it being built in the src dir # For dependency. A little strange that we rely on it being built in the src dir
# even though it may exist in $(libdir). But the new version may not have been installed yet. # even though it may exist in $(libdir). But the new version may not have been installed yet.

View file

@ -55,7 +55,7 @@ CLIXON_MAJOR = @CLIXON_VERSION_MAJOR@
CLIXON_MINOR = @CLIXON_VERSION_MINOR@ CLIXON_MINOR = @CLIXON_VERSION_MINOR@
# Use this clixon lib for linking # Use this clixon lib for linking
CLIXON_LIB = libclixon.so.$(CLIXON_MAJOR).$(CLIXON_MINOR) CLIXON_LIB = libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR)
# For dependency # For dependency
LIBDEPS = $(top_srcdir)/lib/src/$(CLIXON_LIB) LIBDEPS = $(top_srcdir)/lib/src/$(CLIXON_LIB)

View file

@ -59,12 +59,12 @@ CLIXON_MAJOR = @CLIXON_VERSION_MAJOR@
CLIXON_MINOR = @CLIXON_VERSION_MINOR@ CLIXON_MINOR = @CLIXON_VERSION_MINOR@
# Use this clixon lib for linking # Use this clixon lib for linking
CLIXON_LIB = libclixon.so.$(CLIXON_MAJOR).$(CLIXON_MINOR) CLIXON_LIB = libclixon$(SH_SUFFIX).$(CLIXON_MAJOR).$(CLIXON_MINOR)
# For dependency # For dependency
LIBDEPS = $(top_srcdir)/lib/src/$(CLIXON_LIB) LIBDEPS = $(top_srcdir)/lib/src/$(CLIXON_LIB)
LIBS = -L$(top_srcdir)/lib/src @LIBS@ -l:$(CLIXON_LIB) LIBS = -L$(top_srcdir)/lib/src @LIBS@ $(top_srcdir)/lib/src/$(CLIXON_LIB)
CPPFLAGS = @CPPFLAGS@ -fPIC CPPFLAGS = @CPPFLAGS@ -fPIC

View file

@ -225,6 +225,7 @@ api_root(clicon_handle h,
goto done; goto done;
} }
FCGX_SetExitStatus(200, r->out); /* OK */ FCGX_SetExitStatus(200, r->out); /* OK */
FCGX_FPrintF(r->out, "Status: 200 OK\r\n");
FCGX_FPrintF(r->out, "Cache-Control: no-cache\r\n"); FCGX_FPrintF(r->out, "Cache-Control: no-cache\r\n");
FCGX_FPrintF(r->out, "Content-Type: %s\r\n", restconf_media_int2str(media_out)); FCGX_FPrintF(r->out, "Content-Type: %s\r\n", restconf_media_int2str(media_out));

View file

@ -50,7 +50,7 @@ YANG_INSTALLDIR = @YANG_INSTALLDIR@
CLIXON_DEFAULT_CONFIG = @CLIXON_DEFAULT_CONFIG@ CLIXON_DEFAULT_CONFIG = @CLIXON_DEFAULT_CONFIG@
CC = @CC@ CC = @CC@
CFLAGS = @CFLAGS@ -rdynamic -fPIC CFLAGS = @CFLAGS@ -fPIC
INSTALLFLAGS = @INSTALLFLAGS@ INSTALLFLAGS = @INSTALLFLAGS@
with_restconf = @with_restconf@ with_restconf = @with_restconf@

View file

@ -49,7 +49,7 @@ YANG_INSTALLDIR = @YANG_INSTALLDIR@
CLIXON_DEFAULT_CONFIG = @CLIXON_DEFAULT_CONFIG@ CLIXON_DEFAULT_CONFIG = @CLIXON_DEFAULT_CONFIG@
CC = @CC@ CC = @CC@
CFLAGS = @CFLAGS@ -rdynamic -fPIC CFLAGS = @CFLAGS@ -fPIC
INSTALLFLAGS = @INSTALLFLAGS@ INSTALLFLAGS = @INSTALLFLAGS@
with_restconf = @with_restconf@ with_restconf = @with_restconf@

View file

@ -180,7 +180,7 @@ distclean: clean
.SUFFIXES: .c .o .SUFFIXES: .c .o
.c.o: $(GENSRC) .c.o: $(GENSRC)
$(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $< rm -f $@ && $(CC) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -c $<
.PHONY: build.c .PHONY: build.c
build.c: build.c:

View file

@ -98,20 +98,20 @@ echo "</x></config></edit-config></rpc>]]>]]>" >> $fconfig
# Now take large config file and write it via netconf to candidate # Now take large config file and write it via netconf to candidate
new "netconf write large config" new "netconf write large config"
expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg" "$fconfig" "^<rpc-reply><ok/></rpc-reply>]]>]]>$" expecteof_file "time $clixon_netconf -qf $cfg" "$fconfig" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
# Here, there are $perfnr entries in candidate # Here, there are $perfnr entries in candidate
new "netconf write large config again" new "netconf write large config again"
expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg" "$fconfig" "^<rpc-reply><ok/></rpc-reply>]]>]]>$" expecteof_file "time $clixon_netconf -qf $cfg" "$fconfig" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
# Now commit it from candidate to running # Now commit it from candidate to running
new "netconf commit large config" new "netconf commit large config"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$" expecteof "time $clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
# Now commit it again from candidate (validation takes time when # Now commit it again from candidate (validation takes time when
# comparing to existing) # comparing to existing)
new "netconf commit large config again" new "netconf commit large config again"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$" expecteof "time $clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
# Having a large db, get and put single entries many times # Having a large db, get and put single entries many times
# Note same entries in the range alreay there, db has same size # Note same entries in the range alreay there, db has same size
@ -164,13 +164,13 @@ done } 2>&1 | awk '/real/ {print $2}'
# Instead of many small entries, get one large in netconf and restconf # Instead of many small entries, get one large in netconf and restconf
# cli? # cli?
new "netconf get large config" new "netconf get large config"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" '^<rpc-reply><data><x xmlns="urn:example:clixon"><y><a>0</a><b>0</b></y><y><a>1</a><b>1</b></y><y><a>2</a><b>2</b></y><y><a>3</a><b>3</b></y>' expecteof "time $clixon_netconf -qf $cfg" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" '^<rpc-reply><data><x xmlns="urn:example:clixon"><y><a>0</a><b>0</b></y><y><a>1</a><b>1</b></y><y><a>2</a><b>2</b></y><y><a>3</a><b>3</b></y>'
new "restconf get large config" new "restconf get large config"
/usr/bin/time -f %e curl -sG http://localhost/restconf/data > /dev/null time curl -sG http://localhost/restconf/data > /dev/null
new "cli get large config" new "cli get large config"
/usr/bin/time -f %e $clixon_cli -1f $cfg show config xml> /dev/null time $clixon_cli -1f $cfg show config xml> /dev/null
# Delete entries (last since entries are removed from db) # Delete entries (last since entries are removed from db)
# netconf # netconf
@ -208,10 +208,10 @@ done
echo "</x></config></edit-config></rpc>]]>]]>" >> $fconfig2 echo "</x></config></edit-config></rpc>]]>]]>" >> $fconfig2
new "netconf replace large list-leaf config" new "netconf replace large list-leaf config"
expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg" "$fconfig2" "^<rpc-reply><ok/></rpc-reply>]]>]]>$" expecteof_file "time $clixon_netconf -qf $cfg" "$fconfig2" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf commit large leaf-list config" new "netconf commit large leaf-list config"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$" expecteof "time $clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf add $perfreq small leaf-list config" new "netconf add $perfreq small leaf-list config"
time -p for (( i=0; i<$perfreq; i++ )); do time -p for (( i=0; i<$perfreq; i++ )); do
@ -220,13 +220,13 @@ time -p for (( i=0; i<$perfreq; i++ )); do
done | $clixon_netconf -qf $cfg > /dev/null done | $clixon_netconf -qf $cfg > /dev/null
new "netconf add small leaf-list config" new "netconf add small leaf-list config"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><x xmlns="urn:example:clixon"><c>x</c></x></config></edit-config></rpc>]]>]]>' "^<rpc-reply><ok/></rpc-reply>]]>]]>$" expecteof "time $clixon_netconf -qf $cfg" 0 '<rpc><edit-config><target><candidate/></target><config><x xmlns="urn:example:clixon"><c>x</c></x></config></edit-config></rpc>]]>]]>' "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf commit small leaf-list config" new "netconf commit small leaf-list config"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$" expecteof "time $clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
new "netconf get large leaf-list config" new "netconf get large leaf-list config"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" '^<rpc-reply><data><x xmlns="urn:example:clixon"><c>0</c><c>1</c>' expecteof "time $clixon_netconf -qf $cfg" 0 "<rpc><get-config><source><candidate/></source></get-config></rpc>]]>]]>" '^<rpc-reply><data><x xmlns="urn:example:clixon"><c>0</c><c>1</c>'
new "Kill restconf daemon" new "Kill restconf daemon"
stop_restconf stop_restconf

View file

@ -76,11 +76,11 @@ echo "</interfaces></config></edit-config></rpc>]]>]]>" >> $fconfig
# Now take large config file and write it via netconf to candidate # Now take large config file and write it via netconf to candidate
new "netconf write large config" new "netconf write large config"
expecteof_file "/usr/bin/time -f %e $clixon_netconf -qf $cfg" "$fconfig" "^<rpc-reply><ok/></rpc-reply>]]>]]>$" expecteof_file "time $clixon_netconf -qf $cfg" "$fconfig" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
# Now commit it from candidate to running # Now commit it from candidate to running
new "netconf commit large config" new "netconf commit large config"
expecteof "/usr/bin/time -f %e $clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$" expecteof "time $clixon_netconf -qf $cfg" 0 "<rpc><commit/></rpc>]]>]]>" "^<rpc-reply><ok/></rpc-reply>]]>]]>$"
# START actual tests # START actual tests
# Having a large db, get single entries many times # Having a large db, get single entries many times
@ -128,13 +128,13 @@ done } 2>&1 | awk '/real/ {print $2}'
# Get config in one large get # Get config in one large get
new "netconf get large config" new "netconf get large config"
/usr/bin/time -f %e echo "<rpc><get> <filter type=\"xpath\" select=\"/if:interfaces\" xmlns:if=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\"/></get></rpc>]]>]]>" | $clixon_netconf -qf $cfg > /tmp/netconf time echo "<rpc><get> <filter type=\"xpath\" select=\"/if:interfaces\" xmlns:if=\"urn:ietf:params:xml:ns:yang:ietf-interfaces\"/></get></rpc>]]>]]>" | $clixon_netconf -qf $cfg > /tmp/netconf
new "restconf get large config" new "restconf get large config"
/usr/bin/time -f %e curl -sG http://localhost/restconf/data/ietf-interfaces:interfaces | wc time curl -sG http://localhost/restconf/data/ietf-interfaces:interfaces | wc
new "cli get large config" new "cli get large config"
/usr/bin/time -f %e $clixon_cli -1f $cfg show state xml interfaces | wc time $clixon_cli -1f $cfg show state xml interfaces | wc
new "Kill restconf daemon" new "Kill restconf daemon"
stop_restconf stop_restconf

View file

@ -30,11 +30,16 @@ cat <<EOF > $cfg
</clixon-config> </clixon-config>
EOF EOF
# Create a pre-set running, startup and (extra) config. # Create a pre-set running, startup and (extra) config.
# The configs are identified by an interface called run, startup, extra. # The configs are identified by an interface called run, startup, extra.
# Depending on startup mode (init, none, running, or startup) # Depending on startup mode (init, none, running, or startup)
# expect different output of an initial get-config of running # expect different output of an initial get-config of running
# Arguments:
# 1: startuser: Start backend as this user
# 2: backend user: Drop to this after initial run as startuser
# 3: expected user: Expected user after drop (or no drop then startuser)
# 4: privileged mode (none, drop_perm, drop_temp)
# 5: expect error: 0 or 1
testrun(){ testrun(){
startuser=$1 startuser=$1
beuser=$2 beuser=$2
@ -64,7 +69,7 @@ testrun(){
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
err err
fi fi
sleep 1 # wait for backend to exit
pid=$(pgrep -f clixon_backend) pid=$(pgrep -f clixon_backend)
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
if [ $expecterr -eq 1 ]; then if [ $expecterr -eq 1 ]; then
@ -72,6 +77,7 @@ testrun(){
fi fi
err err
fi fi
new "waiting" new "waiting"
wait_backend wait_backend
@ -79,8 +85,8 @@ testrun(){
err "Expected error" err "Expected error"
fi fi
# Get uid now, and compare with expected user # Get uid now, and compare with expected user (tail to skip hdr)
u=$(ps -p $pid -uh | awk '{print $1}') u=$(ps -p $pid -u | tail -1 | awk '{print $1}')
if [ $u != $expectuser ]; then if [ $u != $expectuser ]; then
err "$expectuser but user is $u" err "$expectuser but user is $u"
fi fi
@ -116,7 +122,7 @@ testrun root root root drop_perm 0
new "Start as root, set user but dont drop (expect still root)" new "Start as root, set user but dont drop (expect still root)"
testrun root $BUSER root none 0 testrun root $BUSER root none 0
new "Start as non-privileged, try to drop" new "Start as non-privileged, try to drop (but fail)"
testrun $(whoami) $BUSER $BUSER drop_perm 1 testrun $(whoami) $BUSER $BUSER drop_perm 1
sudo rm -rf $dir sudo rm -rf $dir

View file

@ -48,6 +48,9 @@ if [ $BE -ne 0 ]; then
start_backend -s init -f $cfg -- -s start_backend -s init -f $cfg -- -s
fi fi
new "waiting"
wait_backend
new "kill old restconf daemon" new "kill old restconf daemon"
sudo pkill -u $wwwuser clixon_restconf sudo pkill -u $wwwuser clixon_restconf
@ -55,7 +58,6 @@ new "start restconf daemon"
start_restconf -f $cfg start_restconf -f $cfg
new "waiting" new "waiting"
wait_backend
wait_restconf wait_restconf
new "restconf root discovery. RFC 8040 3.1 (xml+xrd)" new "restconf root discovery. RFC 8040 3.1 (xml+xrd)"

View file

@ -217,10 +217,10 @@ if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
nr=$(echo "$ret" | grep -c "data:") nr=$(echo "$ret" | grep -c "data:")
if [ $nr -lt 3 -o $nr -gt 4 ]; then #if [ $nr -lt 3 -o $nr -gt 4 ]; then
if [ $nr -lt 3 ]; then
err 4 "$nr" err 4 "$nr"
fi fi
sleep 1 sleep 1
# 2d) start sub 8s - replay from start -8s to stop +4s - expect 3 notifications # 2d) start sub 8s - replay from start -8s to stop +4s - expect 3 notifications
@ -232,7 +232,8 @@ if [ -z "$match" ]; then
err "$expect" "$ret" err "$expect" "$ret"
fi fi
nr=$(echo "$ret" | grep -c "data:") nr=$(echo "$ret" | grep -c "data:")
if [ $nr -lt 4 -o $nr -gt 10 ]; then #if [ $nr -lt 4 -o $nr -gt 10 ]; then
if [ $nr -lt 4 ]; then
err 6 "$nr" err 6 "$nr"
fi fi

View file

@ -198,14 +198,14 @@ testrange(){
post=$4 post=$4
if [ $t = "string" ]; then # special case for string type error msg if [ $t = "string" ]; then # special case for string type error msg
len=$(echo -n "$eval" | wc -c) len=$(echo -n "$eval" | wc -c | awk '{print $1}'; )
errmsg="String length $len out of range: 1$post - 10$post, 14$post - 20$post" errmsg="String length $len out of range: 1$post - 10$post, 14$post - 20$post"
else else
errmsg="Number $eval$post out of range: 1$post - 10$post, 14$post - 20$post" errmsg="Number $eval$post out of range: 1$post - 10$post, 14$post - 20$post"
fi fi
new "generated cli set $t leaf invalid" new "generated cli set $t leaf invalid"
expectfn "$clixon_cli -1f $cfg -l o set l$t $eval" 255 "$errmsg"; expectpart "$(clixon_cli -1f $cfg -l o set l$t $eval)" 255 "$errmsg"
new "generated cli set $t leaf OK" new "generated cli set $t leaf OK"
expectfn "$clixon_cli -1f $cfg -l o set l$t $val" 0 '^$' expectfn "$clixon_cli -1f $cfg -l o set l$t $val" 0 '^$'
@ -219,7 +219,7 @@ testrange(){
# (SAME AS FIRST ^) # (SAME AS FIRST ^)
new "generated cli set $t leaf invalid" new "generated cli set $t leaf invalid"
expectfn "$clixon_cli -1f $cfg -l o set l$t $eval" 255 "$errmsg" expectfn "$clixon_cli -1f $cfg -l o set l$t $eval" 255 "$errmsg"
new "manual cli set $t leaf OK" new "manual cli set $t leaf OK"
expectfn "$clixon_cli -1f $cfg -l o man h$t $val" 0 '^$' expectfn "$clixon_cli -1f $cfg -l o man h$t $val" 0 '^$'