From 396680d0b3072231e131781e3001533db73202d9 Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Thu, 10 Feb 2022 18:00:40 +0100 Subject: [PATCH] CI: removed evhtp dependency Test: simplified test_helloworld.sh for it to run on openwrt --- .github/workflows/ci.yml | 6 ++--- test/test_helloworld.sh | 49 +++++++++++++++++++++++++++++++++++----- 2 files changed, 45 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f2399103..18c53565 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,10 +16,8 @@ jobs: # 1) checkout and compile natively - name: install cligen run: (git clone https://github.com/clicon/cligen.git && cd cligen && ./configure && make && sudo make install) - - name: install libevent, ssl and nghttp2 - run: sudo apt install -y libevent-dev libssl-dev libnghttp2-dev - - name: install libevhtp - run: (git clone https://github.com/clicon/clixon-libevhtp.git && cd clixon-libevhtp && ./configure && make && sudo make install) + - name: install ssl and nghttp2 + run: sudo apt install -y libssl-dev libnghttp2-dev - name: configure run: ./configure # 2) Use docker for tests diff --git a/test/test_helloworld.sh b/test/test_helloworld.sh index dbdb0573..cb224c06 100755 --- a/test/test_helloworld.sh +++ b/test/test_helloworld.sh @@ -5,6 +5,8 @@ # but this test is (more or less) self-contained for as little external dependencies as possible # The test is free of plugins because that would require compilation, or pre-built plugins # Restconf is internal native http port 80 +# The minimality extends to the test macros that use advanced grep, and therefore more +# primitive pattern macthing is made # Magic line must be first in script (see README.md) s="$_" ; . ./lib.sh || if [ "$s" = $0 ]; then exit 0; else return 0; fi @@ -120,19 +122,54 @@ new "wait restconf" wait_restconf new "cli configure" -expectpart "$($clixon_cli -1 -f $cfg set hello world)" 0 "^$" +#expectpart "$($clixon_cli -1 -f $cfg set hello world)" 0 "^$" +ret=$($clixon_cli -1 -f $cfg set hello world) +if [ $? -ne 0 ]; then + err 0 $r +fi new "cli show config" -expectpart "$($clixon_cli -1 -f $cfg show config)" 0 "hello" "world" +ret=$($clixon_cli -1 -f $cfg show config) +if [ $? -ne 0 ]; then + err 0 $r +fi +if [ "$ret" != "hello world;" ]; then + err "$ret" "hello world;" +fi new "netconf edit-config" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +ret=$(echo "$DEFAULTHELLO]]>]]>" | $clixon_netconf -qf $cfg) +if [ $? -ne 0 ]; then + err 0 $r +fi +if [ "$ret" != "]]>]]>" ]; then + err "$ret" "]]>]]>" +fi new "netconf commit" -expecteof "$clixon_netconf -qf $cfg" 0 "$DEFAULTHELLO]]>]]>" "^]]>]]>$" +ret=$(echo "$DEFAULTHELLO]]>]]>" | $clixon_netconf -qf $cfg) +if [ $? -ne 0 ]; then + err 0 $r +fi +if [ "$ret" != "]]>]]>" ]; then + err "$ret" "]]>]]>" +fi new "restconf GET" -expectpart "$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/clixon-hello:hello)" 0 "HTTP/$HVER 200" "{\"clixon-hello:hello\":{\"world\":{}}}" +ret=$(curl $CURLOPTS -X GET $RCPROTO://localhost/restconf/data/clixon-hello:hello) +if [ $? -ne 0 ]; then + err 0 $r +fi + +res=$(echo "$ret"|grep "HTTP/$HVER 200") +if [ -z "$res" ]; then + err "$ret" "HTTP/$HVER 200" +fi + +res=$(echo "$ret"|grep '{"clixon-hello:hello":{"world":{}}}') +if [ -z "$res" ]; then + err "$ret" "{"clixon-hello:hello":{"world":{}}}" +fi if [ $RC -ne 0 ]; then new "Kill restconf daemon" @@ -142,7 +179,7 @@ fi if [ $BE -ne 0 ]; then new "Kill backend" # Check if premature kill - pid=$(pgrep -u root -f clixon_backend) + pid=$(pgrep -f clixon_backend) if [ -z "$pid" ]; then err "backend already dead" fi