Skip to content
Snippets Groups Projects
Commit ab556939 authored by Vivek Dutta's avatar Vivek Dutta
Browse files

swmodd: Added compilation test

parent c8cc4a3b
Branches
Tags
1 merge request!1Add static analysis and compilation test
Pipeline #22485 passed with warnings
/swmodd
/*.xml
/*.log
/result
*.swp
*.swo
*.gcda
*.gcno
*.gcov
include:
- project: 'iopsys/gitlab-ci-pipeline'
file: '/static-code-analysis.yml'
stages:
- static_code_analysis
- api_test
variables:
DEBUG: 'TRUE'
SOURCE_FOLDER: "src"
run_api_test:
stage: api_test
image: iopsys/code-analysis:latest
allow_failure: true
script:
- "./gitlab-ci/install-dependencies.sh"
- "./gitlab-ci/setup.sh"
- "./gitlab-ci/functional-api-test.sh"
artifacts:
when: always
reports:
junit: ./report/tap.xml
paths:
- timestamp.log
- api-test-coverage.xml
- memory-report.xml
- api-result.log
PROG = swmodd all:
OBJS = swmod.o swmod_host.o swmod_opkg.o swmod_uci.o tools.o make -C src all
PROG_CFLAGS = $(CFLAGS) -fstrict-aliasing -Wall swmodd:
PROG_LDFLAGS = $(LDFLAGS) -luci -lubus -lubox -ljson-c -lblobmsg_json -luuid make -C src swmodd
ifeq ($(SWMOD_LXC),yes)
OBJS += swmod_lxc.o
PROG_CFLAGS += -DSWMOD_LXC
PROG_LDFLAGS += -llxc
endif
%.o: %.c
$(CC) $(PROG_CFLAGS) $(FPIC) -c -o $@ $<
all: ${PROG}
${PROG}: $(OBJS)
$(CC) $(PROG_CFLAGS) -o $@ $^ $(PROG_LDFLAGS)
clean: clean:
rm -f *.o $(PROG) make -C src clean
-rm -f swmodd
-find -name '*.gcda' -exec rm {} -fv \;
-find -name '*.gcno' -exec rm {} -fv \;
-find -name '*.gcov' -exec rm {} -fv \;
-rm -f *.log *.xml
-rm -rf report
.PHONY: all swmodd clean
#!/bin/bash
echo "$0 preparation script"
pwd
source ./gitlab-ci/shared.sh
trap cleanup EXIT
trap cleanup SIGINT
date +%s > timestamp.log
# clean and make
make clean
make
check_ret $?
supervisorctl status all
supervisorctl update
supervisorctl restart all
exec_cmd ubus -t 10 wait_for usp.raw usp
supervisorctl status all
exec_cmd ubus wait_for swmodule
ubus call swmodule environment
supervisorctl status all
supervisorctl stop all
supervisorctl status
#report part
gcovr -r . --xml -o ./api-test-coverage.xml
gcovr -r .
exec_cmd tap-junit --input ./api-result.log --output report
check_memory_leak memory-report.xml
echo "Functional ubus API test :: PASS"
#!/bin/bash
echo "install dependencies for unit-test script"
pwd
source ./gitlab-ci/shared.sh
echo "Installing required packages"
exec_cmd apt update
exec_cmd apt install -y uuid-dev lxc-dev lxc
echo "Installing uspd"
cd /opt/dev
[ -d uspd ] && rm -fr uspd
exec_cmd git clone https://dev.iopsys.eu/iopsys/uspd.git
cd uspd
#exec_cmd git checkout origin/transaction_id
exec_cmd ./gitlab-ci/install-dependencies.sh
exec_cmd ./gitlab-ci/setup.sh
exec_cmd make
exec_cmd cp uspd /usr/sbin/uspd
[program:ubusd]
autorestart=false
startretries=0
priority=1
command=/bin/bash -c "/usr/sbin/ubusd"
[program:rpcd]
autorestart=false
startretries=0
priority=2
command=/bin/bash -c "/usr/sbin/rpcd"
[program:uspd]
autorestart=false
startretries=0
priority=3
command=/bin/bash -c "/usr/sbin/uspd"
[program:swmodd]
autorestart=false
startretries=0
priority=4
command=/bin/bash -c "/usr/bin/valgrind --xml=yes --xml-file=/builds/iopsys/swmodd/memory-report.xml --leak-check=full --show-reachable=yes --show-leak-kinds=all --errors-for-leak-kinds=all --error-exitcode=1 --track-origins=yes /builds/iopsys/swmodd/swmodd"
#!/bin/bash
echo "preparation script"
pwd
#cp -r ./test/files/* /
cp ./gitlab-ci/iopsys-supervisord.conf /etc/supervisor/conf.d/
#!/bin/bash
function cleanup()
{
echo ""
}
function check_ret()
{
ret=$1
if [ "$ret" -ne 0 ]; then
echo "Validation of last command failed, ret(${ret})"
exit $ret
fi
}
function error_on_zero()
{
ret=$1
if [ "$ret" -eq 0 ]; then
echo "Validation of last command failed, ret(${ret})"
exit $ret
fi
}
function exec_cmd()
{
echo "executing $@"
$@ >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "Failed to execute $@"
exit 1
fi
}
function check_memory_leak()
{
memory_log=${1}
if [ ! -f ${memory_log} ]; then
echo "Memory log ${memory_log} not present for validation"
exit 1;
fi
echo "Checking memory leaks..."
grep -q "UninitCondition" ${memory_log}
error_on_zero $?
grep -q "Leak_DefinitelyLost" ${memory_log}
error_on_zero $?
grep -q "Leak_PossiblyLost" ${memory_log}
error_on_zero $?
grep -q "Leak_StillReachable" ${memory_log}
error_on_zero $?
}
ifeq ($(CP),)
CP := cp -f
endif
PROG = swmodd
OBJS = swmod.o swmod_host.o swmod_opkg.o swmod_uci.o tools.o
PROG_CFLAGS = $(CFLAGS) -fstrict-aliasing -Wall
PROG_LDFLAGS = $(LDFLAGS) -luci -lubus -lubox -ljson-c -lblobmsg_json -luuid
ifeq ($(SWMOD_LXC),yes)
OBJS += swmod_lxc.o
PROG_CFLAGS += -DSWMOD_LXC
PROG_LDFLAGS += -llxc
endif
%.o: %.c
$(CC) $(PROG_CFLAGS) $(FPIC) -c -o $@ $<
all: ${PROG}
${PROG}: $(OBJS)
$(CC) $(PROG_CFLAGS) -o $@ $^ $(PROG_LDFLAGS)
$(CP) ${PROG} ../${PROG}
clean:
rm -f *.o $(PROG)
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
File moved
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment