Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
npoltorapavlo committed Feb 14, 2024
1 parent d72e51c commit e1a42a6
Show file tree
Hide file tree
Showing 46 changed files with 2,747 additions and 2,323 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/L0-PersistentStore-grpc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: L0-PersistentStore-grpc

on:
push:
paths:
- PersistentStore/grpc/**
pull_request:
paths:
- PersistentStore/grpc/**

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
path: ${{github.repository}}

- name: Install valgrind, coverage, cmake, protoc, grpc_cpp_plugin, grpc
run: |
sudo apt update
sudo apt install -y valgrind lcov cmake protobuf-compiler protobuf-compiler-grpc libgrpc++-dev
- name: Build Thunder
working-directory: ${{github.workspace}}
run: sh +x ${GITHUB_REPOSITORY}/.github/workflows/BuildThunder.sh

- name: Build
working-directory: ${{github.workspace}}
run: |
cmake -S ${GITHUB_REPOSITORY}/PersistentStore/grpc/l0test -B build/grpcl0test -DCMAKE_INSTALL_PREFIX="install/usr" -DCMAKE_CXX_FLAGS="--coverage -Wall -Werror"
cmake --build build/grpcl0test --target install
- name: Run
working-directory: ${{github.workspace}}
run: PATH=${PWD}/install/usr/bin:${PATH} LD_LIBRARY_PATH=${PWD}/install/usr/lib:${LD_LIBRARY_PATH} valgrind --tool=memcheck --log-file=valgrind_log --leak-check=yes --show-reachable=yes --track-fds=yes --fair-sched=try grpcl0test

- name: Generate coverage
working-directory: ${{github.workspace}}
run: |
lcov -c -o coverage.info -d build/grpcl0test
genhtml -o coverage coverage.info
- name: Upload artifacts
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v4
with:
name: artifacts
path: |
coverage/
valgrind_log
if-no-files-found: warn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: L1-PersistentStore
name: L0-PersistentStore

on:
push:
Expand All @@ -13,43 +13,41 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
path: rdkservices
path: ${{github.repository}}

- name: Install valgrind, coverage, cmake, sqlite
- name: Install valgrind, coverage, cmake
run: |
sudo apt update
sudo apt install -y valgrind lcov cmake libsqlite3-dev
sudo apt install -y valgrind lcov cmake
- name: Build Thunder
working-directory: ${{github.workspace}}
run: sh +x rdkservices/.github/workflows/BuildThunder.sh

- name: Configure
working-directory: ${{github.workspace}}
run: cmake -S rdkservices/PersistentStore/l1test -B build/persistentstorel1test -DCMAKE_INSTALL_PREFIX="install/usr" -DCMAKE_CXX_FLAGS="--coverage -Wall -Werror"
run: sh +x ${GITHUB_REPOSITORY}/.github/workflows/BuildThunder.sh

- name: Build
working-directory: ${{github.workspace}}
run: cmake --build build/persistentstorel1test --target install
run: |
cmake -S ${GITHUB_REPOSITORY}/PersistentStore/l0test -B build/persistentstorel0test -DCMAKE_INSTALL_PREFIX="install/usr" -DCMAKE_CXX_FLAGS="--coverage -Wall -Werror"
cmake --build build/persistentstorel0test --target install
- name: Run
working-directory: ${{github.workspace}}
run: PATH=${PWD}/install/usr/bin:${PATH} LD_LIBRARY_PATH=${PWD}/install/usr/lib:${LD_LIBRARY_PATH} valgrind --tool=memcheck --log-file=valgrind_log --leak-check=yes --show-reachable=yes --track-fds=yes --fair-sched=try persistentstorel1test
run: PATH=${PWD}/install/usr/bin:${PATH} LD_LIBRARY_PATH=${PWD}/install/usr/lib:${LD_LIBRARY_PATH} valgrind --tool=memcheck --log-file=valgrind_log --leak-check=yes --show-reachable=yes --track-fds=yes --fair-sched=try persistentstorel0test

- name: Generate coverage
working-directory: ${{github.workspace}}
run: |
lcov -c -o coverage.info -d build/persistentstorel1test
lcov -c -o coverage.info -d build/persistentstorel0test
genhtml -o coverage coverage.info
- name: Upload artifacts
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: artifacts
path: |
coverage/
valgrind_log
if-no-files-found: warn
if-no-files-found: warn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: L1-Sqlite
name: L1-PersistentStore-sqlite

on:
push:
Expand All @@ -13,9 +13,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
path: rdkservices
path: ${{github.repository}}

- name: Install valgrind, coverage, cmake, sqlite
run: |
Expand All @@ -24,15 +24,13 @@ jobs:
- name: Build Thunder
working-directory: ${{github.workspace}}
run: sh +x rdkservices/.github/workflows/BuildThunder.sh

- name: Configure
working-directory: ${{github.workspace}}
run: cmake -S rdkservices/PersistentStore/sqlite/l1test -B build/sqlitel1test -DCMAKE_INSTALL_PREFIX="install/usr" -DCMAKE_CXX_FLAGS="--coverage -Wall -Werror"
run: sh +x ${GITHUB_REPOSITORY}/.github/workflows/BuildThunder.sh

- name: Build
working-directory: ${{github.workspace}}
run: cmake --build build/sqlitel1test --target install
run: |
cmake -S ${GITHUB_REPOSITORY}/PersistentStore/sqlite/l1test -B build/sqlitel1test -DCMAKE_INSTALL_PREFIX="install/usr" -DCMAKE_CXX_FLAGS="--coverage -Wall -Werror"
cmake --build build/sqlitel1test --target install
- name: Run
working-directory: ${{github.workspace}}
Expand All @@ -46,10 +44,10 @@ jobs:
- name: Upload artifacts
if: ${{ !env.ACT }}
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: artifacts
path: |
coverage/
valgrind_log
if-no-files-found: warn
if-no-files-found: warn
12 changes: 6 additions & 6 deletions PersistentStore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ find_package(WPEFramework)

project_version(1.0.0)

set(MODULE_NAME ${NAMESPACE}${PROJECT_NAME})
set(MODULE_NAME ${NAMESPACE} ${PROJECT_NAME})

message("Setup ${MODULE_NAME} v${PROJECT_VERSION}")

Expand Down Expand Up @@ -54,14 +54,14 @@ endif ()
add_library(${MODULE_NAME} SHARED
PersistentStore.cpp
PersistentStoreJsonRpc.cpp
sqlite/Handle.cpp
ServiceRegistration.cpp
Module.cpp
)
)

set_target_properties(${MODULE_NAME} PROPERTIES
CXX_STANDARD 11
CXX_STANDARD_REQUIRED YES
)
)

add_definitions(${SQLITE_CFLAGS_OTHER})
link_directories(${SQLITE_LIBRARY_DIRS})
Expand All @@ -71,14 +71,14 @@ target_include_directories(${MODULE_NAME} PRIVATE
${SQLITE_INCLUDE_DIRS}
${IARMBUS_INCLUDE_DIRS}
${IARMSYS_INCLUDE_DIRS}
)
)

target_link_libraries(${MODULE_NAME} PRIVATE
${NAMESPACE}Plugins::${NAMESPACE}Plugins
${NAMESPACE}Definitions::${NAMESPACE}Definitions
${SQLITE_LIBRARIES}
${IARMBUS_LIBRARIES}
)
)

install(TARGETS ${MODULE_NAME}
DESTINATION lib/${STORAGE_DIRECTORY}/plugins)
Expand Down
7 changes: 7 additions & 0 deletions PersistentStore/Module.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,12 @@
#include <interfaces/definitions.h>
#endif

#define URI_ENV "PERSISTENTSTORE_URI"
#define PATH_ENV "PERSISTENTSTORE_PATH"
#define MAXSIZE_ENV "PERSISTENTSTORE_MAXSIZE"
#define MAXVALUE_ENV "PERSISTENTSTORE_MAXVALUE"
#define LIMIT_ENV "PERSISTENTSTORE_LIMIT"
#define CLOCKSYNC_ENV "PERSISTENTSTORE_CLOCKSYNC"

#undef EXTERNAL
#define EXTERNAL
58 changes: 18 additions & 40 deletions PersistentStore/PersistentStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,6 @@
*/

#include "PersistentStore.h"

#include "sqlite/Handle.h"
#include "sqlite/Store2Type.h"
#include "sqlite/Store2WithReconnectType.h"
#if defined(WITH_CLOCK_SYNC)
#include "sqlite/Store2WithClockSyncType.h"
#endif
#include "sqlite/StoreCacheType.h"
#include "sqlite/StoreInspectorType.h"
#include "sqlite/StoreLimitType.h"

#include <fstream>

#define API_VERSION_NUMBER_MAJOR 1
Expand All @@ -52,25 +41,6 @@ namespace {

namespace Plugin {

#if defined(WITH_CLOCK_SYNC)
class SqliteStore2 : public Sqlite::Store2WithClockSyncType<Sqlite::Store2WithReconnectType<Sqlite::Store2Type<Sqlite::Handle>>> {
};
#else
class SqliteStore2 : public Sqlite::Store2WithReconnectType<Sqlite::Store2Type<Sqlite::Handle>> {
};
#endif
class SqliteStoreCache : public Sqlite::StoreCacheType<Sqlite::Handle> {
};
class SqliteStoreInspector : public Sqlite::StoreInspectorType<Sqlite::Handle> {
};
class SqliteStoreLimit : public Sqlite::StoreLimitType<Sqlite::Handle> {
};

SERVICE_REGISTRATION(SqliteStore2, 1, 0);
SERVICE_REGISTRATION(SqliteStoreCache, 1, 0);
SERVICE_REGISTRATION(SqliteStoreInspector, 1, 0);
SERVICE_REGISTRATION(SqliteStoreLimit, 1, 0);

SERVICE_REGISTRATION(PersistentStore, API_VERSION_NUMBER_MAJOR, API_VERSION_NUMBER_MINOR, API_VERSION_NUMBER_PATCH);

const string PersistentStore::Initialize(PluginHost::IShell* service)
Expand All @@ -82,16 +52,12 @@ namespace Plugin {
auto configLine = service->ConfigLine();
_config.FromString(configLine);

ASSERT(!_config.Path.Value().empty());

{
Core::File file(_config.Path.Value());
Core::File oldFile(_config.LegacyPath.Value());
if (file.Name() != oldFile.Name()) {
if (oldFile.Exists()) {
if (!file.Exists()) {
// Rename will fail if the files are not on the same filesystem
// Make a copy and then remove the original file
std::ifstream in(oldFile.Name(), std::ios::in | std::ios::binary);
std::ofstream out(file.Name(), std::ios::out | std::ios::binary);
out << in.rdbuf();
Expand All @@ -109,15 +75,27 @@ namespace Plugin {

uint32_t connectionId;

Store2::ScopeMapType initList1 = {
{ Exchange::IStore2::ScopeType::DEVICE, service->Root<Exchange::IStore2>(connectionId, 2000, _T("SqliteStore2")) }
};
Store2::ScopeMapType initList1;
auto deviceStore2 = service->Root<Exchange::IStore2>(connectionId, 2000, _T("DeviceStore2"));
if (deviceStore2 != nullptr) {
initList1.emplace(Exchange::IStore2::ScopeType::DEVICE, deviceStore2);
}
auto accountStore2 = service->Root<Exchange::IStore2>(connectionId, 2000, _T("AccountStore2"));
if (accountStore2 != nullptr) {
initList1.emplace(Exchange::IStore2::ScopeType::ACCOUNT, accountStore2);
}
_store2 = Core::Service<Store2>::Create<Exchange::IStore2>(initList1);
if (deviceStore2 != nullptr) {
deviceStore2->Release();
}
if (accountStore2 != nullptr) {
accountStore2->Release();
}
_store2->Register(&_store2Sink);
_store = Core::Service<Store>::Create<Exchange::IStore>(_store2);
_storeCache = service->Root<Exchange::IStoreCache>(connectionId, 2000, _T("SqliteStoreCache"));
_storeInspector = service->Root<Exchange::IStoreInspector>(connectionId, 2000, _T("SqliteStoreInspector"));
_storeLimit = service->Root<Exchange::IStoreLimit>(connectionId, 2000, _T("SqliteStoreLimit"));
_storeCache = service->Root<Exchange::IStoreCache>(connectionId, 2000, _T("DeviceStoreCache"));
_storeInspector = service->Root<Exchange::IStoreInspector>(connectionId, 2000, _T("DeviceStoreInspector"));
_storeLimit = service->Root<Exchange::IStoreLimit>(connectionId, 2000, _T("DeviceStoreLimit"));

return result;
}
Expand Down
3 changes: 3 additions & 0 deletions PersistentStore/PersistentStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,9 @@ namespace Plugin {
Store2(const ScopeMapType& map)
: _scopeMap(map)
{
for (auto const& x : _scopeMap) {
x.second->AddRef();
}
}
~Store2() override
{
Expand Down
Loading

0 comments on commit e1a42a6

Please sign in to comment.