From 6559200a0ef13ef2285de3aaae47acee04f675a6 Mon Sep 17 00:00:00 2001 From: Jordi Becares Date: Fri, 4 Apr 2025 12:54:38 +0200 Subject: [PATCH] Edge Virtualization Platform v1.45.0 --- .github/workflows/main.yml | 15 ------- .github/workflows/test.yml | 63 ++++++++++++----------------- Makefile | 28 ++++++++++--- docs/testing/index.rst | 63 ++++++++++++++++++++++++----- scripts/cmake-flatcc.sh | 1 + scripts/cmake-libweb.sh | 1 + scripts/cmake-mbedtls.sh | 1 + scripts/cmake-wasm-micro-runtime.sh | 1 + scripts/rules.mk | 2 +- src/Makefile | 22 ++++++---- src/libevp-agent/xmqtt.c | 8 ++-- src/python-evp-app-sdk/Makefile | 36 +++++++++++++++++ src/python-evp-app-sdk/README.md | 4 +- test/Makefile | 27 +++++++++++-- test_modules/Makefile | 2 +- version.mk | 2 +- 16 files changed, 188 insertions(+), 88 deletions(-) create mode 100644 src/python-evp-app-sdk/Makefile diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index af9d82f3..4fa1255c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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: @@ -125,8 +112,6 @@ jobs: name: Tests needs: - checks - - build-sdk - - build-modules - builder - infos uses: ./.github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6522f7bf..65720cb4 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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)) \ @@ -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() @@ -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: diff --git a/Makefile b/Makefile index 65d42fec..64310bc4 100644 --- a/Makefile +++ b/Makefile @@ -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 $@ @@ -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 diff --git a/docs/testing/index.rst b/docs/testing/index.rst index a33130ef..3d7a3a0c 100644 --- a/docs/testing/index.rst +++ b/docs/testing/index.rst @@ -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"); @@ -206,7 +206,7 @@ The previous example would match something like: { "key1": "value1", "key2": "value2", - "suboject": { + "subobject": { "key1": "value3", "key2": "value4" } @@ -215,8 +215,8 @@ The previous example would match something like: Subobject patterns can be nested. -Suboject pattern -"""""""""""""""" +String subobject pattern +"""""""""""""""""""""""" .. code:: C @@ -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. @@ -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`. @@ -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 diff --git a/scripts/cmake-flatcc.sh b/scripts/cmake-flatcc.sh index bc487530..7a6309fe 100755 --- a/scripts/cmake-flatcc.sh +++ b/scripts/cmake-flatcc.sh @@ -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 diff --git a/scripts/cmake-libweb.sh b/scripts/cmake-libweb.sh index 77716cff..523e74fe 100755 --- a/scripts/cmake-libweb.sh +++ b/scripts/cmake-libweb.sh @@ -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 diff --git a/scripts/cmake-mbedtls.sh b/scripts/cmake-mbedtls.sh index 301b251a..a7becae8 100755 --- a/scripts/cmake-mbedtls.sh +++ b/scripts/cmake-mbedtls.sh @@ -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"} \ .. diff --git a/scripts/cmake-wasm-micro-runtime.sh b/scripts/cmake-wasm-micro-runtime.sh index 9850cbf4..578d7a04 100755 --- a/scripts/cmake-wasm-micro-runtime.sh +++ b/scripts/cmake-wasm-micro-runtime.sh @@ -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 diff --git a/scripts/rules.mk b/scripts/rules.mk index cca57f35..3b44ac59 100644 --- a/scripts/rules.mk +++ b/scripts/rules.mk @@ -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 diff --git a/src/Makefile b/src/Makefile index 65da3f77..dac3f649 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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 @@ -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 diff --git a/src/libevp-agent/xmqtt.c b/src/libevp-agent/xmqtt.c index bea15095..21373b17 100644 --- a/src/libevp-agent/xmqtt.c +++ b/src/libevp-agent/xmqtt.c @@ -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; diff --git a/src/python-evp-app-sdk/Makefile b/src/python-evp-app-sdk/Makefile new file mode 100644 index 00000000..6a91296f --- /dev/null +++ b/src/python-evp-app-sdk/Makefile @@ -0,0 +1,36 @@ +# SPDX-FileCopyrightText: 2023-2024 Sony Semiconductor Solutions Corporation +# +# SPDX-License-Identifier: Apache-2.0 + +PROJECTDIR = ../.. + +include $(PROJECTDIR)/scripts/rules.mk + +DEPS =\ + evp/app/backend.i\ + evp/app/backend.py\ + evp/app/blob.py\ + evp/app/client.py\ + evp/app/command.py\ + evp/app/configuration.py\ + evp/app/exceptions.py\ + evp/app/executor.py\ + evp/app/__init__.py\ + evp/app/state.py\ + evp/app/telemetry.py\ + external/lib/libevp-app-sdk-bundle.a\ + +TARGET = $(LIBDIR)/python + +all: $(TARGET) + +dist: $(DEPS) + CFLAGS='$(CFLAGS)' LDFLAGS='$(LDFLAGS)' CC=$(CC) python -m build + +$(TARGET): dist + mkdir -p $@ + cp dist/* $@ + +clean: + rm -rf $(TARGET) + rm -rf dist diff --git a/src/python-evp-app-sdk/README.md b/src/python-evp-app-sdk/README.md index 1787d668..8faa4be7 100644 --- a/src/python-evp-app-sdk/README.md +++ b/src/python-evp-app-sdk/README.md @@ -16,10 +16,10 @@ make KBUILD_DEFCONFIG=configs/linux-docker.config This will build the dependencies, the SDK and the Agent with support for the "Remote SDK" -Instal cython dependencies: +Install cython dependencies: ```bash -sudo apt-get update && sudo apt-get install -y python3-dev +sudo apt-get update && sudo apt-get install -y python3-dev python3-build ``` Now, build the python package: diff --git a/test/Makefile b/test/Makefile index 2f808d87..14d66677 100644 --- a/test/Makefile +++ b/test/Makefile @@ -4,6 +4,8 @@ PROJECTDIR = .. +VENV = .venv + DIRS =\ certs\ @@ -202,7 +204,7 @@ BINDEPS =\ $(LIBDIR)/libdynstr.a\ $(FILELIBS)\ -all: test +all: test-venv build: $(TESTS) @@ -230,6 +232,14 @@ $(LIBDIR)/libweb.a: libweb $(LIBDIR)/libdynstr.a: libdynstr cp libdynstr/libdynstr.a $@ +# There is a known bug in GNU binutils that causes the build to fail +# when debug options are used. +# This problem was already reported to the binutils community and it was fixed, +# but the fix is not propagated to all supported build environments yet. +# As a workaround, using the LLVM linker avoids the problem with selecting the +# linker by passing `-fuse-ld=lld` +PATCH_LDFLAGS = -fuse-ld=lld + # Overwrite the general rule to generate .elf. We could use other extension # to avoid overriding, but I only thought about using .test, but having things # like test_manifest_evp1.test seemed too much testing to me. @@ -239,12 +249,21 @@ $(LIBDIR)/libdynstr.a: libdynstr gsub(/__wrap_/, "");\ printf ",--wrap=%s", $$3\ }' > $@.wrap - $(CC) $(PROJ_LDFLAGS) -o $@ $@-tmp.o -Wl`cat $@.wrap` $(PROJ_LDLIBS) + $(CC) $(PROJ_LDFLAGS) $(PATCH_LDFLAGS) -o $@ $@-tmp.o -Wl`cat $@.wrap` $(PROJ_LDLIBS) rm $@-tmp.o $@.wrap +$(VENV): FORCE + python -m venv $@ + +test-venv: $(TESTS) $(VENV) FORCE + rm -rf logs + +. $(VENV)/bin/activate && \ + pip install -U --find-links=$(LIBDIR)/python evp-app &&\ + $(MAKE) test-helper + test: FORCE rm -rf logs - +@$(MAKE) test-helper + +$(MAKE) test-helper test-helper: run-ut run-st @awk '\ @@ -291,7 +310,7 @@ run-st-py: $(STESTS_PY) FORCE clean: test -f libweb/Makefile && cd libweb && $(MAKE) clean || true test -f libdynstr/Makefile && cd libdynstr && $(MAKE) clean || true - rm -rf logs + rm -rf logs $(VENV) find . -name '*.o' | xargs rm -f find . -name '*.elf' | xargs rm -f find . -name '*.wrap' | xargs rm -f diff --git a/test_modules/Makefile b/test_modules/Makefile index 31570516..8409d695 100644 --- a/test_modules/Makefile +++ b/test_modules/Makefile @@ -69,7 +69,7 @@ MORE_LDLIBS =\ $(DEPLIBS)\ -lm\ -all: elf wasm aot xip +all: python elf wasm aot xip elf: FORCE $(MAKE) EXT=elf modules diff --git a/version.mk b/version.mk index 7942426b..f9d2a35b 100644 --- a/version.mk +++ b/version.mk @@ -2,7 +2,7 @@ # # SPDX-License-Identifier: Apache-2.0 -VERSION = 1.43.0 +VERSION = 1.45.0 COMMIT_HASH = $(shell git describe --always --abbrev=0 --dirty --match "NOT A TAG") define VERSION_BODY