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
47 changes: 47 additions & 0 deletions .github/workflows/L1-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: L1-tests

on:
workflow_call:

permissions:
contents: read

jobs:
L1-tests:
name: Build and run L1 unit tests
runs-on: ubuntu-22.04
container:
image: ghcr.io/rdkcentral/docker-rdk-ci:latest
steps:
- name: Checkout sys_mon_tools
uses: actions/checkout@v4

- name: Prepare RDK build dependencies
run: ./build_dependencies.sh

- name: Install coverage tools
run: |
apt-get update
apt-get install -y lcov

- name: Build and run L1 tests
run: bash ./tests/run_l1_tests.sh
Comment thread
hgfell683 marked this conversation as resolved.

- name: Generate coverage report
if: success()
run: |
lcov --capture --directory . --output-file coverage.info
lcov --remove coverage.info '/usr/*' '*/tests/*' '*/stubs/*' --output-file filtered_coverage.info
genhtml filtered_coverage.info --output-directory coverage --title "sys_mon_tools L1 coverage"
lcov --summary filtered_coverage.info

- name: Upload L1 artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: artifacts-L1-sys_mon_tools
path: |
coverage/
filtered_coverage.info
tests/test-suite.log
if-no-files-found: warn
15 changes: 15 additions & 0 deletions .github/workflows/tests-trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: tests-trigger

on:
push:
branches: [ main, develop, 'sprint/**', 'release/**' ]
pull_request:
branches: [ main, develop, 'sprint/**', 'release/**', 'topic/RDK*', 'feature/RDK*' ]
workflow_dispatch:

permissions:
contents: read

jobs:
trigger-L1:
uses: ./.github/workflows/L1-tests.yml
2 changes: 1 addition & 1 deletion cov_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,4 @@ standaloneBuildConfigure
#cp $IARMMGRS_PATH/mfr/common/include/mfrApi.h /usr/local/include

make VERBOSE=1 AM_CPPFLAGS="-I${WORKDIR}/stubs -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libsoup-3.0 -I/usr/local/include -I${IARMMGRS_PATH}/sysmgr/include -I${IARMBUS_PATH}/core -I${IARMBUS_PATH}/core/include -I${IARMMGRS_PATH}/hal/include -I${IARMMGRS_PATH}/mfr/include -I${IARMMGRS_PATH}/mfr/common/include -I$ROOT/devicesettings/rpc/include -I$ROOT/rdk-halif-device_settings/include" \
AM_LDFLAGS="-L/usr/local/lib -lIARMBus -lWPEFrameworkPowerController" CXXFLAGS="-fpermissive -I${WORKDIR}/stubs"
AM_LDFLAGS="-L/usr/local/lib -lIARMBus -lWPEFrameworkPowerController" CXXFLAGS="-fpermissive -I${WORKDIR}/stubs"
13 changes: 13 additions & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
EXTRA_DIST = \
Comment thread
hgfell683 marked this conversation as resolved.
run_l1_tests.sh \
test_iarm_event_sender.c \
test_key_simulator.c \
test_legacy_key_simulator.c \
test_mfr_utils.c \
test_power_state_monitor.c \
test_query_power_state.c \
test_set_power_state.c \
test_uinput.c \
test_uinput_main.c \
mocks/libCMAF.h \
mocks/uidev.h
21 changes: 21 additions & 0 deletions tests/mocks/libCMAF.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#ifndef TEST_MOCK_LIB_CMAF_H
#define TEST_MOCK_LIB_CMAF_H

#include <stddef.h>

typedef enum {
CMAF_RESULT_SUCCESS = 0,
CMAF_RESULT_INVALID_PARAM = 1
} CMAF_Result_t;

typedef enum {
CMAF_MEMTYPE_PROCESSSHARE = 0
} CMAF_MemType_t;

typedef int CMAF_EventId_t;

CMAF_Result_t CMAF_Init(const char *group_name, const char *program_name, void **context);
CMAF_Result_t CMAF_Malloc(void *context, CMAF_MemType_t memory_type, size_t size, void **buffer);
CMAF_Result_t CMAF_NotifyEvent(void *context, CMAF_EventId_t event_id, void *event_data);

#endif
19 changes: 19 additions & 0 deletions tests/mocks/uidev.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef TEST_MOCK_UIDEV_H
#define TEST_MOCK_UIDEV_H

#define UIDEV_PROCESSGROUP_NAME "UIEventSimulator"
#define UIDEV_EVENT_IRKEY 1

typedef struct {
int keyType;
int keyCode;
} UIDev_IRKeyData_t;

typedef struct {
int id;
union {
UIDev_IRKeyData_t irkey;
} data;
} UIDev_EventData_t;

#endif
34 changes: 34 additions & 0 deletions tests/run_l1_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
set -ex

WORKDIR="$(pwd)"
ROOT=/usr
IARMBUS_PATH="$ROOT/iarmbus"
IARMMGRS_PATH="$ROOT/iarmmgrs"

export CFLAGS="-O2 -Wall -fPIC --coverage -I./include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include -I/usr/local/include -I${WORKDIR}/stubs -I/usr/include/dbus-1.0 -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/libsoup-2.4 -I/usr/include/gssdp-1.0"
export CC=gcc

BUILD_AM_CPPFLAGS="-I${WORKDIR}/stubs -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/include/libsoup-3.0 -I/usr/local/include -I${IARMMGRS_PATH}/sysmgr/include -I${IARMBUS_PATH}/core -I${IARMBUS_PATH}/core/include -I${IARMMGRS_PATH}/hal/include -I${IARMMGRS_PATH}/mfr/include -I${IARMMGRS_PATH}/mfr/common/include -I${ROOT}/devicesettings/rpc/include -I${ROOT}/rdk-halif-device_settings/include"

GLIB_CFLAGS="$(pkg-config --cflags glib-2.0)"
GLIB_LIBS="$(pkg-config --libs glib-2.0)"

build_and_run()
{
test_name="$1"
test_source="$2"
test_cflags="$3"
test_libs="$4"
${CC} ${CFLAGS} ${BUILD_AM_CPPFLAGS} ${test_cflags} -o "${WORKDIR}/tests/${test_name}" "${WORKDIR}/tests/${test_source}" ${test_libs}
"${WORKDIR}/tests/${test_name}"
}

build_and_run l1_uinput_tests test_uinput_main.c "-DUINPUT_VERSION=5 -I${WORKDIR}/key_simulator" ""
build_and_run test_set_power_state test_set_power_state.c "" "-lpthread"
build_and_run test_query_power_state test_query_power_state.c "" ""
build_and_run test_mfr_utils test_mfr_utils.c "" ""
build_and_run test_key_simulator test_key_simulator.c "-I${WORKDIR}/key_simulator" ""
build_and_run test_iarm_event_sender test_iarm_event_sender.c "${GLIB_CFLAGS}" "${GLIB_LIBS}"
build_and_run test_power_state_monitor test_power_state_monitor.c "${GLIB_CFLAGS}" "${GLIB_LIBS} -lpthread"
build_and_run test_legacy_key_simulator test_legacy_key_simulator.c "-I${WORKDIR}/key_simulator -I${WORKDIR}/tests/mocks" ""
Loading
Loading