Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 0 additions & 15 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,6 @@ jobs:
ref: ${{ inputs.ref || github.sha }}
package-namespace: ${{ needs.infos.outputs.package-namespace }}

build-modules:
name: Build
needs:
- checks
- builder
- infos
uses: ./.github/workflows/build-modules.yml
secrets: inherit
with:
builder-tag: ${{ needs.builder.outputs.builder-tag }}
ref: ${{ inputs.ref || github.sha }}
package-namespace: ${{ needs.infos.outputs.package-namespace }}

build-agent:
name: Build
needs:
Expand All @@ -125,8 +112,6 @@ jobs:
name: Tests
needs:
- checks
- build-sdk
- build-modules
- builder
- infos
uses: ./.github/workflows/test.yml
Expand Down
63 changes: 25 additions & 38 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,8 @@ jobs:
with:
ref: ${{ inputs.ref }}

- name: Download test modules
uses: actions/download-artifact@v4
with:
name: test-modules-${{ matrix.name }}-${{ matrix.platform }}-${{ github.run_id }}
path: test_modules/

- name: Download Python SDK
uses: actions/download-artifact@v4
with:
name: python-sdk-${{ matrix.name }}-${{ matrix.platform }}-${{ github.run_id }}
path: py-sdk

- name: Set permissions
run: chmod +x test_modules/*.elf

# We need to build dependencies independently as we don't want the same
# build flags i.e. `-Og -Werror` flag
- name: Build dependencies
run: |
make -j$((`nproc` * 2)) \
Expand All @@ -73,37 +60,28 @@ jobs:
TOOL=clang \
depend

- name: Build agent
# We need to build the modules independently as we don't want the same
# build flags i.e. `-Werror` flag
- name: Build modules
run: |
make -j$((`nproc` * 2))\
KBUILD_DEFCONFIG=configs/unit-test-all-hubs-wasm.config\
TOOL=clang \
SANITIZER=ENABLED \
COVERAGE=ccov \
CFLAGS="-g -Og -Werror" \

- name: Build tests
run: |
make -C test -j$((`nproc` * 2))\
TOOL=clang \
SANITIZER=ENABLED \
COVERAGE=ccov \
CFLAGS="-g -Og -Werror" \
LDFLAGS="-fuse-ld=lld -g" \
build

- name: Install the Python SDK
run: |
python3 -m venv .venv
. .venv/bin/activate
pip3 install py-sdk/*.whl

test_modules/tests

- name: Run tests
env:
ASAN_OPTIONS: detect_leaks=1:detect_stack_use_after_return=1
UBSAN_OPTIONS: print_stacktrace=1
TERM: xterm
run: . .venv/bin/activate && make -C test -j RUNFLAGS='-c -t 60'
run: |
make test -j$((`nproc` * 2))\
KBUILD_DEFCONFIG=configs/unit-test-all-hubs-wasm.config\
TOOL=clang \
SANITIZER=ENABLED \
COVERAGE=ccov \
CFLAGS="-g -Og -Werror" \
LDFLAGS="-g" \
RUNFLAGS='-c -t 60'

- name: Report summary blob profiling
if: always()
Expand Down Expand Up @@ -141,6 +119,15 @@ jobs:
path: test/logs/**/*.log
retention-days: ${{ job.status == 'success' && '7' || '14' }}

- uses: actions/upload-artifact@v4
with:
name: test-modules-${{ matrix.name }}-${{ matrix.platform }}-${{ github.run_id }}
path: |
test_modules/*.elf
test_modules/*.wasm
test_modules/*.wasm.*
test_modules/python/*.zip

- name: Upload coverage results
uses: actions/upload-artifact@v4
with:
Expand Down
28 changes: 23 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,17 @@ depend sdk src libs: lib bin deps.mk include/version.h .config
libs depend: FORCE
+cd src && $(MAKE) $@

libs: sdk

sdk: FORCE
+cd src && $(MAKE) libevp-app-sdk

pysdk: sdk
+cd src && $(MAKE) python-evp-app-sdk

lib bin:
mkdir -p $@

wasm_test_modules: sdk
+cd test_modules && $(MAKE) elf wasm

check: FORCE
$(MAKE) -f check.mk $@

Expand All @@ -38,11 +40,27 @@ check_test_config: FORCE
exit 1;\
fi

test: check_test_config libs test_modules
test: check_test_config libs test_modules/tests pysdk

test_modules: sdk

signed_test_modules: test_modules
# NOTE: Kept for backward compatibility with private tests
signed_test_modules: test_modules/signed

test_modules/tests: sdk
+cd test_modules && $(MAKE) elf wasm python

test_modules/wasm: sdk
+cd test_modules && $(MAKE) wasm

test_modules/elf:
+cd test_modules && $(MAKE) elf

test_modules/python:
+cd test_modules && $(MAKE) python
.PHONY: test_modules/python

test_modules/signed: test_modules
+cd test_modules && $(MAKE) signed

include/version.h: FORCE
Expand Down
63 changes: 53 additions & 10 deletions docs/testing/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -183,13 +183,13 @@ one matching parameter of a variable length argument list.
Special patterns
^^^^^^^^^^^^^^^^

Suboject pattern
""""""""""""""""
Subobject pattern
"""""""""""""""""

.. code:: C

verify_json(txt,
"suboject={"
"subobject={"
" key1=%s,"
" key2=%s}",
"value3", "value4");
Expand All @@ -206,7 +206,7 @@ The previous example would match something like:
{
"key1": "value1",
"key2": "value2",
"suboject": {
"subobject": {
"key1": "value3",
"key2": "value4"
}
Expand All @@ -215,8 +215,8 @@ The previous example would match something like:
Subobject patterns can be nested.


Suboject pattern
""""""""""""""""
String subobject pattern
""""""""""""""""""""""""

.. code:: C

Expand All @@ -226,7 +226,7 @@ Suboject pattern
" key2=%s}",
"value3", "value4");

This pattern is similar to the suboject pattern,
This pattern is similar to the subobject pattern,
but in this case
the preceding dot expression must point to a JSON string value
that contains a literal JSON object.
Expand Down Expand Up @@ -296,7 +296,7 @@ The full list of checks enabled is:
fsanitize=vla-bound

More information about every specific option can be found in the
`Clang Undefined behavior sanitizer` and `Clang Address sanitizer` documentation.
``Clang Undefined behavior sanitizer`` and ``Clang Address sanitizer`` documentation.
More information about how this is done
can be found in :ref:`toolchain`.

Expand All @@ -305,15 +305,58 @@ Code coverage

The tests are designed to cover
as much code as possible
and the coverage level is measured using `llvm-cov`.
and the coverage level is measured using ``llvm-cov``.
When the tests are compiled for the CI execution
they are instrumented to generate output `llvm-cov` coverage information
they are instrumented to generate output ``llvm-cov`` coverage information
that later is processed by some scripts and
reported to the CI
to ensure that the minimun coverage level is matched.
More information about how this is done
can be found in :ref:`toolchain`.

Execution
*********

The tests must be compiled with ``unit-test-all-hubs-wasm.config``.

.. code:: shell

make config KBUILD_DEFCONFIG=configs/unit-test-all-hubs-wasm.config

Tests can then be run with the single make target ``test``.

.. code:: shell

make test KBUILD_DEFCONFIG=configs/unit-test-all-hubs-wasm.config

This target will build everything the tests require,
create a virtual environment (``.venv``),
install the python sdk,
and execute all tests in parallel inside
the virtual environment.

The completed tests will be reported
as ``PASS`` or ``FAIL`` upon completion,
and a global summary will show the test results:

.. code:: shell

make test
...
PASS EVP1 src/systest/test_instance_state.elf
FAIL TB src/systest/test_python_mod_zombie.elf
PASS EVP1 src/systest/test_capture_mode.elf
PASS TB src/systest/test_capture_mode.elf
PASS TB src/st-nohub/test_start_stop.elf
FAIL TB src/evp2-tb/test_embed_backdoor.elf
----------- SUMMARY -----------
RUN 203
PASSED 201
FAILED 2
FAIL TB src/systest/test_python_mod_zombie.elf
FAIL TB src/evp2-tb/test_embed_backdoor.elf


--------------

.. _Cmocka: https://cmocka.org
Expand Down
1 change: 1 addition & 0 deletions scripts/cmake-flatcc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ cmake \
-DFLATCC_TEST=0 \
-DFLATCC_INSTALL=ON \
-DFLATCC_DEBUG_CLANG_SANITIZE=OFF \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
..

trap "" EXIT INT TERM HUP
1 change: 1 addition & 0 deletions scripts/cmake-libweb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ cmake \
-DCMAKE_C_COMPILER="${CC:-cc}" \
-DCMAKE_CXX_COMPILER="${CXX:-c++}" \
-DCMAKE_C_FLAGS="${CFLAGS}" \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
..

trap "" EXIT INT TERM HUP
1 change: 1 addition & 0 deletions scripts/cmake-mbedtls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cmake \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DENABLE_TESTING=OFF \
-DENABLE_PROGRAMS=OFF \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
${MBEDTLS_USER_CONFIG_FILE:+-DMBEDTLS_USER_CONFIG_FILE="$MBEDTLS_USER_CONFIG_FILE"} \
..

Expand Down
1 change: 1 addition & 0 deletions scripts/cmake-wasm-micro-runtime.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ cmake \
-DWAMR_BUILD_BULK_MEMORY=1 \
-DWAMR_DISABLE_WRITE_GS_BASE=1 \
-DCMAKE_STRIP=0 \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
..

trap "" EXIT INT TERM HUP
2 changes: 1 addition & 1 deletion scripts/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
all:

# Macros related to the version of the agent
VERSION = 1.43.0
VERSION = 1.45.0
SDK_VERSION = 1.0.0

# Default value for configuration macros
Expand Down
22 changes: 15 additions & 7 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@

PROJECTDIR = ..

EVP_LIBS = \
libevp-agent\
libevp-utils\
libevp-app-sdk \

DIRS = \
evp_agent\
libparson\
sdkenc\
$(EVP_LIBS)
libevp-agent\
libevp-utils\
libevp-app-sdk\
python-evp-app-sdk\

include $(PROJECTDIR)/scripts/rules.mk
-include $(PROJECTDIR)/deps.mk
-include $(PROJECTDIR)/.config

EVP_LIBS-y += \
libevp-agent\
libevp-utils\

EVP_LIBS-$(CONFIG_EVP_SDK_SOCKET) +=\
libevp-app-sdk\

# After build try to remove the cmake directory that
# some cmake projects create in the top directory
Expand All @@ -25,10 +31,12 @@ all: evp_agent libs

depend: $(LIBDIRS)

libs: $(EVP_LIBS)
libs: $(EVP_LIBS-y)

libevp-agent libevp-app-sdk: $(LIBDIRS)

python-evp-app-sdk: libevp-app-sdk

libevp-agent: libevp-utils

evp_agent: libevp-agent libevp-utils
Expand Down
8 changes: 4 additions & 4 deletions src/libevp-agent/xmqtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ mqtt_prepare_poll(struct mqtt_client *client, bool *want_writep)
const time_t now_sec = MQTT_PAL_TIME();
const uint64_t now_ms = gettime_ms();
uint64_t abs_timeout_ms;
xlog_info("%s: abs_timeout_sec=%ju, "
"now_sec=%ju\n",
__func__, (uintmax_t)abs_timeout_sec,
(uintmax_t)now_sec);
xlog_trace("%s: abs_timeout_sec=%ju, "
"now_sec=%ju\n",
__func__, (uintmax_t)abs_timeout_sec,
(uintmax_t)now_sec);
if (abs_timeout_sec >= now_sec) {
uint64_t delta_sec = abs_timeout_sec - now_sec;
abs_timeout_ms = now_ms + delta_sec * 1000;
Expand Down
Loading