Skip to content
Snippets Groups Projects
Commit def76d13 authored by Anjan Chanda's avatar Anjan Chanda
Browse files

gitlab-ci: add CI and fix initial warnings

parent 07047b06
No related branches found
No related tags found
No related merge requests found
include:
- project: 'iopsys/gitlab-ci-pipeline'
file: '/static-code-analysis.yml'
ref: '0.27'
stages:
- static_code_analysis
- compile_test
variables:
DEBUG: 'TRUE'
SOURCE_FOLDER: "."
RUN_CPPCHECK: "cppcheck --enable=all --error-exitcode=1 --suppress=unusedFunction --suppress=unreadVariable --suppress=variableScope --suppress=syntaxError ."
CPPCHECK_OPTIONS: "--enable=all --error-exitcode=1 --suppress=unusedFunction --suppress=unreadVariable --suppress=uninitvar --suppress=variableScope --suppress=syntaxError ."
RUN_CPD: "/home/user/pmd-bin-6.19.0/bin/run.sh cpd --minimum-tokens 200 --language c --exclude ./test/cmocka --exclude ./src/tests --exclude ./src/extensions --files"
COMMON_IMAGE: iopsys/code-analysis:0.25
run_compile_test:
stage: compile_test
image: dev.iopsys.eu:5050/iopsys/gitlab-ci-pipeline/code-analysis:latest
allow_failure: false
script:
- "./gitlab-ci/install-dependencies.sh"
- "./gitlab-ci/compile.sh"
artifacts:
when: always
paths:
- functional-test-coverage.xml
- timestamp.log
- coverage.tar.gz
#!/bin/bash
set -e
echo "compile stage"
pwd
cd src/
make
#!/bin/bash
echo "install dependencies"
home=$(pwd)
function exec_cmd()
{
echo "executing $@"
$@ >/dev/null 2>&1
local ret=$?
if [ "${ret}" -ne 0 ]; then
echo "Failed to execute $@ ret (${ret})"
exit 1
fi
}
exec_cmd apt update
exec_cmd apt install -y iproute2
# libwifi-*.so + libeasy.so
rm -fr libeasy
mkdir -p /usr/include/easy
exec_cmd git clone -b devel https://dev.iopsys.eu/iopsys/libeasy.git
cd libeasy
exec_cmd make CFLAGS+="-I/usr/include/libnl3"
exec_cmd cp -a libeasy*.so* /usr/lib
exec_cmd cp -a easy.h event.h utils.h if_utils.h debug.h hlist.h /usr/include/easy/
cd /opt/dev
rm -fr libwifi
exec_cmd git clone -b devel https://dev.iopsys.eu/iopsys/libwifi.git
cd libwifi
exec_cmd make HAS_WIFI=1 WIFI_TYPE=TEST
exec_cmd cp wifidefs.h wifiutils.h wifiops.h wifi.h /usr/include
exec_cmd cp -a libwifi*.so* /usr/lib
# wifimngr
cd /opt/dev
rm -fr wifimngr
exec_cmd git clone -b devel https://dev.iopsys.eu/iopsys/wifimngr.git
cd wifimngr
exec_cmd ./gitlab-ci/install-dependencies.sh
exec_cmd ./gitlab-ci/setup.sh
exec_cmd make
exec_cmd cp wifimngr /usr/sbin/
# libnfnetlink.so libmnl.so libnetfilter-conntrack.so
cd /opt/dev
rm -fr libnfnetlink*
rm -fr libmnl*
rm -fr libnetfilter_conntrack*
mkdir -p /usr/include/libnfnetlink
mkdir -p /usr/include/libmnl
mkdir -p /usr/include/libnetfilter_conntrack
exec_cmd wget https://www.netfilter.org/projects/libnfnetlink/files/libnfnetlink-1.0.2.tar.bz2
exec_cmd bzip2 -d libnfnetlink-1.0.2.tar.bz2
exec_cmd tar -xvf libnfnetlink-1.0.2.tar
exec_cmd wget https://www.netfilter.org/projects/libmnl/files/libmnl-1.0.5.tar.bz2
exec_cmd bzip2 -d libmnl-1.0.5.tar.bz2
exec_cmd tar -xvf libmnl-1.0.5.tar
exec_cmd wget https://www.netfilter.org/projects/libnetfilter_conntrack/files/libnetfilter_conntrack-1.0.9.tar.bz2
exec_cmd bzip2 -d libnetfilter_conntrack-1.0.9.tar.bz2
exec_cmd tar -xvf libnetfilter_conntrack-1.0.9.tar
cd libnfnetlink-1.0.2
exec_cmd "./configure"
exec_cmd "make"
exec_cmd cp -a include/libnfnetlink/libnfnetlink.h /usr/include/libnfnetlink/
exec_cmd cp -a include/libnfnetlink/linux_nfnetlink.h /usr/include/libnfnetlink/
exec_cmd cp -a include/libnfnetlink/linux_nfnetlink_compat.h /usr/include/libnfnetlink/
exec_cmd cp -a src/.libs/libnfnetlink.so* /usr/lib/
exec_cmd cp -a src/.libs/libnfnetlink.la /usr/lib/
cd ../libmnl-1.0.5
exec_cmd "./configure"
exec_cmd "make"
exec_cmd cp -a include/libmnl/libmnl.h /usr/include/libmnl/
exec_cmd cp -a src/.libs/libmnl.so* /usr/lib/
exec_cmd cp -a src/.libs/libmnl.la /usr/lib/
cd ../libnetfilter_conntrack-1.0.9
exec_cmd export LIBNFNETLINK_CFLAGS=/usr/include/libnfnetlink/
exec_cmd export LIBNFNETLINK_LIBS=/usr/lib/
exec_cmd export LIBMNL_CFLAGS=/usr/include/libmnl/
exec_cmd export LIBMNL_LIBS=/usr/lib/
exec_cmd ./configure
exec_cmd "make"
exec_cmd cp -a include/libnetfilter_conntrack/libnetfilter_conntrack.h /usr/include/libnetfilter_conntrack/
exec_cmd cp -a include/libnetfilter_conntrack/linux_nfnetlink_conntrack.h /usr/include/libnetfilter_conntrack/
exec_cmd cp -a include/libnetfilter_conntrack/linux_nf_conntrack_common.h /usr/include/libnetfilter_conntrack/
exec_cmd cp -a src/.libs/libnetfilter_conntrack.so* /usr/lib/
ldconfig
[program:ubusd]
priority=1
autorestart=false
startretries=0
command=/bin/bash -c "/usr/sbin/ubusd"
[program:wifimngr]
priority=2
autorestart=false
startretries=0
command=/bin/bash -c "/usr/sbin/wifimngr"
[program:hostmngr]
priority=3
autorestart=false
startretries=0
command=/bin/bash -c "/usr/bin/valgrind --xml=yes --xml-file=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/hostmngr/src/hostmngr -ddddd"
#!/bin/bash
echo "preparation script"
pwd
cp -r ./test/files/etc/* /etc/
cp -r ./schemas/ubus/* /usr/share/rpcd/schemas
cp ./gitlab-ci/iopsys-supervisord.conf /etc/supervisor/conf.d/
ls /etc/config/
ls /usr/share/rpcd/schemas/
ls /etc/supervisor/conf.d/
...@@ -214,7 +214,7 @@ int read_dhcpv4_lease_table(void **clients, int *num_clients) ...@@ -214,7 +214,7 @@ int read_dhcpv4_lease_table(void **clients, int *num_clients)
char ipv4[24]; char ipv4[24];
char hostname[256]; char hostname[256];
unsigned long leasetime; unsigned long leasetime;
} *hosts = NULL, *tmp = NULL; } *hosts = NULL, *tmp = NULL, *ptr;
FILE *f = NULL; FILE *f = NULL;
char line[256]; char line[256];
int cnt = 0; int cnt = 0;
...@@ -235,13 +235,17 @@ int read_dhcpv4_lease_table(void **clients, int *num_clients) ...@@ -235,13 +235,17 @@ int read_dhcpv4_lease_table(void **clients, int *num_clients)
if (sscanf(line, "%lu %17s %23s %255s %255s", &leasetime, if (sscanf(line, "%lu %17s %23s %255s %255s", &leasetime,
macaddr, ipaddr, hostname, clid) == 5) { macaddr, ipaddr, hostname, clid) == 5) {
hosts = realloc(hosts, (cnt + 1) * sizeof(struct dhcp_clients)); ptr = realloc(hosts, (cnt + 1) * sizeof(struct dhcp_clients));
if (!hosts) { if (!ptr) {
if (hosts)
free(hosts);
*num_clients = 0; *num_clients = 0;
ret = -1; ret = -1;
goto out; goto out;
} }
hosts = ptr;
tmp = hosts + cnt; tmp = hosts + cnt;
memset(tmp, 0, sizeof(struct dhcp_clients)); memset(tmp, 0, sizeof(struct dhcp_clients));
hwaddr_aton(macaddr, tmp->macaddr); hwaddr_aton(macaddr, tmp->macaddr);
... ...
......
...@@ -663,14 +663,18 @@ int topologyd_get_known_neighbors(struct topologyd_private *priv, char *ifname) ...@@ -663,14 +663,18 @@ int topologyd_get_known_neighbors(struct topologyd_private *priv, char *ifname)
ipaddr = rtnl_neigh_get_dst(neigh); ipaddr = rtnl_neigh_get_dst(neigh);
if (ipaddr) { if (ipaddr) {
ip.family = nl_addr_get_family(ipaddr); ip.family = nl_addr_get_family(ipaddr);
/* ignore states for ipv6 entries */
if (ip.family == AF_INET6)
continue;
if (ip.family == AF_INET6 || ip.family == AF_INET) { if (ip.family == AF_INET6 || ip.family == AF_INET) {
memcpy(&ip.addr, nl_addr_get_binary_addr(ipaddr), memcpy(&ip.addr, nl_addr_get_binary_addr(ipaddr),
nl_addr_get_len(ipaddr)); nl_addr_get_len(ipaddr));
} }
/* ignore states for ipv6 entries */
if (ip.family == AF_INET6) {
nl_object_put((struct nl_object *)neigh);
nobj = nl_cache_get_next(nobj);
neigh = (struct rtnl_neigh *)nobj;
continue;
}
} }
ret = neigh_enqueue(&priv->neigh_q, hwaddr, state, ifname, ret = neigh_enqueue(&priv->neigh_q, hwaddr, state, ifname,
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment