From d0fc18c07a9ce28c5ffe95f09a73dbc00d2baf99 Mon Sep 17 00:00:00 2001 From: vdutta Date: Fri, 18 Feb 2022 10:56:24 +0530 Subject: [PATCH] Use relative paths for the module tests --- .gitlab-ci.yml | 11 ++++++----- gitlab-ci/functional-api-test.sh | 5 +++++ gitlab-ci/functional-test.sh | 5 +++++ gitlab-ci/iopsys-supervisord.conf | 6 ++++-- gitlab-ci/libbbf_ubus_api_test.sh | 6 +++++- gitlab-ci/memory-test.sh | 9 +++++++-- gitlab-ci/setup.sh | 5 +---- gitlab-ci/shared.sh | 4 ++++ gitlab-ci/unit-test.sh | 7 ++++++- supervisord.conf | 18 ++++++++++++++++++ test/cmocka/unit_test_bbfd.c | 4 ++-- 11 files changed, 63 insertions(+), 17 deletions(-) create mode 100644 supervisord.conf diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 729f3174..61a29eb5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -2,6 +2,12 @@ include: - project: 'iopsys/gitlab-ci-pipeline' file: '/static-code-analysis.yml' +variables: + DEBUG: 'TRUE' + SOURCE_FOLDER: "." + COMMON_IMAGE: iopsys/code-analysis:0.26 + RUN_CPPCHECK: "cppcheck --enable=style --error-exitcode=1 -DBBF_VENDOR_IOPSYS -DBBF_VENDOR_OPENWRT --suppress=unreadVariable --suppress=knownConditionTrueFalse --suppress=nullPointerRedundantCheck --suppress=unknownMacro --suppress=internalAstError" + stages: - static_code_analysis - unit_test @@ -9,11 +15,6 @@ stages: - memory_test - uspd -variables: - DEBUG: 'TRUE' - SOURCE_FOLDER: "." - RUN_CPPCHECK: "cppcheck --enable=all --error-exitcode=1 -DBBF_VENDOR_IOPSYS -DBBF_VENDOR_OPENWRT --include=/usr/local/include/json-c/json.h -I./include/ --suppress=unusedFunction --suppress=unreadVariable --suppress=knownConditionTrueFalse --suppress=nullPointerRedundantCheck --suppress=unknownMacro --suppress=internalAstError" - run_unit_test: stage: unit_test image: iopsys/code-analysis:latest diff --git a/gitlab-ci/functional-api-test.sh b/gitlab-ci/functional-api-test.sh index 757d6c45..be86acf3 100755 --- a/gitlab-ci/functional-api-test.sh +++ b/gitlab-ci/functional-api-test.sh @@ -4,6 +4,11 @@ echo "Functional API Tests" pwd source ./gitlab-ci/shared.sh +echo "Starting supervisor in current directory" +supervisorctl shutdown +sleep 1 +supervisord -c supervisord.conf + # compile and install libbbf install_libbbf diff --git a/gitlab-ci/functional-test.sh b/gitlab-ci/functional-test.sh index 4b4040f8..ee28c2b4 100755 --- a/gitlab-ci/functional-test.sh +++ b/gitlab-ci/functional-test.sh @@ -4,6 +4,11 @@ echo "Functional Tests" pwd source ./gitlab-ci/shared.sh +echo "Starting supervisor in current directory" +supervisorctl shutdown +sleep 1 +supervisord -c supervisord.conf + # compile and install libbbf install_libbbf diff --git a/gitlab-ci/iopsys-supervisord.conf b/gitlab-ci/iopsys-supervisord.conf index 92b43a4d..38549ef3 100755 --- a/gitlab-ci/iopsys-supervisord.conf +++ b/gitlab-ci/iopsys-supervisord.conf @@ -1,17 +1,19 @@ [program:ubusd] autorestart=false +numprocs_start=0 startretries=0 priority=1 command=/bin/bash -c "/usr/sbin/ubusd" [program:rpcd] autorestart=false +numprocs_start=1 startretries=0 priority=2 command=/bin/bash -c "/usr/sbin/rpcd" [program:bbf_ubus] autorestart=false +numprocs_start=2 priority=3 -stdout_logfile=/builds/iopsys/bbf/log_file -command=/bin/bash -c "/usr/bin/valgrind --xml=yes --xml-file=/builds/iopsys/bbf/memory-report.xml --leak-check=full --show-reachable=yes --show-leak-kinds=all --errors-for-leak-kinds=all --error-exitcode=1 --track-origins=yes --leak-resolution=high --show-error-list=yes --child-silent-after-fork=yes /builds/iopsys/bbf/test/dynamicdm_ubus_test/bbf_ubus" +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 --leak-resolution=high --show-error-list=yes --child-silent-after-fork=yes ./test/dynamicdm_ubus_test/bbf_ubus" diff --git a/gitlab-ci/libbbf_ubus_api_test.sh b/gitlab-ci/libbbf_ubus_api_test.sh index 8f71ac97..e4ead8fa 100755 --- a/gitlab-ci/libbbf_ubus_api_test.sh +++ b/gitlab-ci/libbbf_ubus_api_test.sh @@ -2,9 +2,13 @@ echo "$0 preparation script" pwd - source ./gitlab-ci/shared.sh +echo "Starting supervisor in current directory" +supervisorctl shutdown +sleep 1 +supervisord -c supervisord.conf + # clean and make # compile and install libbbf install_libbbf diff --git a/gitlab-ci/memory-test.sh b/gitlab-ci/memory-test.sh index fa8838fa..08ca1282 100755 --- a/gitlab-ci/memory-test.sh +++ b/gitlab-ci/memory-test.sh @@ -2,7 +2,12 @@ echo "Functional API Tests" pwd -source ./gitlab-ci/shared.sh +. ./gitlab-ci/shared.sh + +echo "Starting supervisor in current directory" +supervisorctl shutdown +sleep 1 +supervisord -c supervisord.conf # install required packages exec_cmd apt update @@ -27,7 +32,7 @@ ret=0 function run_valgrind() { echo "Running bbf_dm $1 in valgrind" - valgrind --xml=yes --xml-file=/builds/iopsys/bbf/$2 --leak-check=full --show-reachable=yes --show-leak-kinds=all --errors-for-leak-kinds=all --error-exitcode=1 --track-origins=yes /builds/iopsys/bbf/test/bbf_test/bbf_dm $1 > /builds/iopsys/bbf/$3 + valgrind --xml=yes --xml-file=$2 --leak-check=full --show-reachable=yes --show-leak-kinds=all --errors-for-leak-kinds=all --error-exitcode=1 --track-origins=yes ./test/bbf_test/bbf_dm $1 > $3 ret=$(( ret + $? )) } diff --git a/gitlab-ci/setup.sh b/gitlab-ci/setup.sh index e93379de..e650b4c2 100755 --- a/gitlab-ci/setup.sh +++ b/gitlab-ci/setup.sh @@ -1,7 +1,6 @@ #!/bin/bash echo "preparation script" - pwd # link '/bin/sh' to bash instead of dash @@ -13,7 +12,5 @@ cp -r ./test/files/var/* /var/ cp -r ./test/files/tmp/* /tmp/ cp -r ./test/files/lib/* /lib/ -cp ./gitlab-ci/iopsys-supervisord.conf /etc/supervisor/conf.d/ - ls /etc/config/ -ls /etc/supervisor/conf.d/ + diff --git a/gitlab-ci/shared.sh b/gitlab-ci/shared.sh index 71acaabf..81dacbaa 100755 --- a/gitlab-ci/shared.sh +++ b/gitlab-ci/shared.sh @@ -1,5 +1,9 @@ #!/bin/bash +if [ -z "${CI_PROJECT_PATH}" ]; then + CI_PROJECT_PATH=${PWD} +fi + function check_ret() { ret=$1 diff --git a/gitlab-ci/unit-test.sh b/gitlab-ci/unit-test.sh index c9737400..765b1f5e 100755 --- a/gitlab-ci/unit-test.sh +++ b/gitlab-ci/unit-test.sh @@ -2,7 +2,12 @@ echo "Unit Tests" pwd -source ./gitlab-ci/shared.sh +. ./gitlab-ci/shared.sh + +echo "Starting supervisor in current directory" +supervisorctl shutdown +sleep 1 +supervisord -c supervisord.conf # compile and install libbbf install_libbbf diff --git a/supervisord.conf b/supervisord.conf new file mode 100644 index 00000000..f9d1afc5 --- /dev/null +++ b/supervisord.conf @@ -0,0 +1,18 @@ +[supervisord] +logfile=/tmp/supervisord.log ; (main log file;default $CWD/supervisord.log) +pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) +nodaemon=false ; true to run in foreground + +[unix_http_server] +file=/var/run/supervisor.sock ; (the path to the socket file) +chmod=0700 ; sockef file mode (default 0700) + +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[supervisorctl] +serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket + +[include] +files = ./gitlab-ci/iopsys-supervisord.conf + diff --git a/test/cmocka/unit_test_bbfd.c b/test/cmocka/unit_test_bbfd.c index e2ea9e5d..f16af7fd 100644 --- a/test/cmocka/unit_test_bbfd.c +++ b/test/cmocka/unit_test_bbfd.c @@ -7,9 +7,9 @@ #include #include -#define DROPBEAR_FILE_PATH "/builds/iopsys/bbf/test/files/etc/bbfdm/json/X_IOPSYS_EU_Dropbear.json" +#define DROPBEAR_FILE_PATH "../files/etc/bbfdm/json/X_IOPSYS_EU_Dropbear.json" #define DROPBEAR_JSON_PATH "/etc/bbfdm/json/X_IOPSYS_EU_Dropbear.json" -#define LIBBBF_TEST_PATH "/builds/iopsys/bbf/test/bbf_test/libbbf_test.so" +#define LIBBBF_TEST_PATH "../bbf_test/libbbf_test.so" #define LIBBBF_TEST_BBFDM_PATH "/usr/lib/bbfdm/libbbf_test.so" static struct ubus_context *ubus_ctx = NULL;