diff --git a/.gitignore b/.gitignore index 2d05627..27d890a 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,5 @@ missing /config.sub /libtool /ltmain.sh - +*.gcno +*.gcda diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5ff79e6..4b85292 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -42,3 +42,4 @@ run_api_test: - timestamp.log - api-test-coverage.xml - memory-report.xml + - api-result.log diff --git a/gitlab-ci/functional-api-test.sh b/gitlab-ci/functional-api-test.sh index 352ebcd..3b79970 100755 --- a/gitlab-ci/functional-api-test.sh +++ b/gitlab-ci/functional-api-test.sh @@ -9,30 +9,28 @@ trap cleanup SIGINT date +%s > timestamp.log echo "Compiling icmwp" -autoreconf -i -./configure --enable-acs=multi --enable-debug -make clean -make -check_ret $? +build_cwmp echo "Starting dependent services" supervisorctl status all supervisorctl update supervisorctl restart all -ubus wait_for usp.raw +exec_cmd ubus wait_for usp.raw tr069 supervisorctl status all echo "Running the api test cases" -ubus call tr069 status +ubus-api-validator -f ./test/api/json/tr069.validation.json > ./api-result.log +check_ret $? -echo "Stop dependent services" +echo "Stop all services" supervisorctl stop all -#report part -#GitLab-CI output -gcovr -r . # Artefact -gcovr -r . --xml -o ./api-test-coverage.xml +#gcovr -r . --xml -o ./api-test-coverage.xml +#GitLab-CI output +#gcovr -r . +#report part +exec_cmd tap-junit --input ./api-result.log --output report echo "Checking memory leaks ..." grep -q "UninitCondition" memory-report.xml diff --git a/gitlab-ci/setup.sh b/gitlab-ci/setup.sh index d5720d0..bb34744 100755 --- a/gitlab-ci/setup.sh +++ b/gitlab-ci/setup.sh @@ -6,3 +6,6 @@ pwd cp ./gitlab-ci/iopsys-supervisord.conf /etc/supervisor/conf.d/ cp -rf ./test/files/* / +# copy schema for validation test +cp -r ./schemas/ubus/*.json /usr/share/rpcd/schemas/ + diff --git a/gitlab-ci/shared.sh b/gitlab-ci/shared.sh index d2cbfae..5cbebbe 100644 --- a/gitlab-ci/shared.sh +++ b/gitlab-ci/shared.sh @@ -34,4 +34,19 @@ function exec_cmd() echo "Failed to execute $@" exit 1 fi -} \ No newline at end of file +} + +function build_cwmp() +{ + COV_CFLAGS='-g -O0' + #COV_CFLAGS='-g -O0 -fprofile-arcs -ftest-coverage' + #COV_LDFLAGS='--coverage' + + make clean >/dev/null 2>&1 + + # compile obuspa + autoreconf -i + ./configure CFLAGS="$COV_CFLAGS" LDFLAGS="$COV_LDFLAGS" --enable-acs=multi --enable-debug + make + check_ret $? +} diff --git a/test/api/json/tr069.validation.json b/test/api/json/tr069.validation.json new file mode 100644 index 0000000..c1139b3 --- /dev/null +++ b/test/api/json/tr069.validation.json @@ -0,0 +1,210 @@ +{ + "object": "tr069", + "methods": [ + { + "method": "hello", + "rc": 3 + }, + { + "method": "status", + "rc": 0 + }, + { + "method": "command", + "args": { + }, + "rc": 2 + }, + { + "method": "status", + "rc": 0 + }, + { + "method": "inform", + "args": { + }, + "rc": 0 + }, + { + "method": "status", + "rc": 0 + }, + { + "method": "inform", + "args": { + "GetRPCMethods": "true" + }, + "rc": 0 + }, + { + "method": "status", + "rc": 0 + }, + { + "method": "inform", + "args": { + "GetRPCMethods": "false" + }, + "rc": 0 + }, + { + "method": "inform", + "args": { + "event": "1 BOOT" + }, + "rc": 0 + }, + { + "method": "inform", + "args": { + "event": "2 PERIODIC" + }, + "rc": 0 + }, + { + "method": "inform", + "args": { + "event": "3 SCHEDULED" + }, + "rc": 0 + }, + { + "method": "status", + "rc": 0 + }, + { + "method": "inform", + "args": { + "event": "4 VALUE CHANGE" + }, + "rc": 0 + }, + { + "method": "inform", + "args": { + "event": "6 CONNECTION REQUEST" + }, + "rc": 0 + }, + { + "method": "status", + "rc": 0 + }, + { + "method": "inform", + "args": { + "event": "8 DIAGNOSTICS COMPLETE" + }, + "rc": 0 + }, + { + "method": "status", + "rc": 0 + }, + { + "method": "inform", + "args": { + "GetRPCMethods": "true", + "event": "1 BOOT" + }, + "rc": 0 + }, + { + "method": "status", + "rc": 0 + }, + { + "method": "inform", + "args": { + "GetRPCMethods": "true", + "event": "2 PERIODIC" + }, + "rc": 0 + }, + { + "method": "inform", + "args": { + "GetRPCMethods": "true", + "event": "3 SCHEDULED" + }, + "rc": 0 + }, + { + "method": "status", + "rc": 0 + }, + { + "method": "inform", + "args": { + "GetRPCMethods": "true", + "event": "4 VALUE CHANGE" + }, + "rc": 0 + }, + { + "method": "inform", + "args": { + "GetRPCMethods": "true", + "event": "6 CONNECTION REQUEST" + }, + "rc": 0 + }, + { + "method": "status", + "rc": 0 + }, + { + "method": "inform", + "args": { + "GetRPCMethods": "true", + "event": "8 DIAGNOSTICS COMPLETE" + }, + "rc": 0 + }, + { + "method": "inform", + "args": { + "event": "0 garbage" + }, + "rc": 0 + }, + { + "method": "status", + "rc": 0 + }, + { + "method": "command", + "args": { + "command": "reload_end_session" + }, + "rc": 0 + }, + { + "method": "status", + "rc": 0 + }, + { + "method": "command", + "args": { + "command": "action_end_session" + }, + "rc": 0 + }, + { + "method": "status", + "rc": 0 + }, + { + "method": "command", + "args": { + "command": "garbage" + }, + "rc": 0 + }, + { + "method": "status", + "rc": 0 + } + ] +} + diff --git a/test/uspd/uspd.config b/test/uspd/uspd.config deleted file mode 100644 index ec28bfe..0000000 --- a/test/uspd/uspd.config +++ /dev/null @@ -1,4 +0,0 @@ -config uspd 'usp' - option granularitylevel '0' - option debug '0' - option loglevel '1' diff --git a/test/uspd/uspd.init b/test/uspd/uspd.init deleted file mode 100644 index 157a542..0000000 --- a/test/uspd/uspd.init +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh /etc/rc.common - -START=98 -STOP=10 - -USE_PROCD=1 -PROG=/usr/sbin/uspd - -validate_uspd_usp_section() -{ - uci_validate_section uspd uspd "usp" \ - 'enabled:bool:true' \ - 'granularitylevel:uinteger' \ - 'debug:bool:false' \ - 'loglevel:uinteger' \ - 'sock:string' \ - 'transaction_timeout:string' -} - -configure_uspd() -{ - local enabled debug sock transaction_timeout - - config_load uspd - - validate_uspd_usp_section || { - log "Validation of usp section failed" - return 1; - } - - [ ${enabled} -eq 0 ] && exit 0 - - if [ ${debug} -eq 1 ]; then - procd_set_param stdout 1 - procd_set_param stderr 1 - fi - - if [ -n "${sock}" ]; then - procd_append_param command -s ${sock} - fi - - if [ -n "${transaction_timeout}" ]; then - procd_append_param command -t ${transaction_timeout} - fi -} - -start_service() { - procd_open_instance usp - procd_set_param command ${PROG} - configure_uspd - procd_set_param respawn - procd_close_instance -} - -reload_service() { - stop - start -} - -service_triggers() -{ - procd_add_config_trigger "config.change" "uspd" /etc/init.d/uspd restart -}