Add default time sync object path
The time sync object path is empty by default and is initialized by a
dbus call at runtime.
It works OK in BMC but the unit tests in the repo is broken due to the
empty string used in the sdbus matcht_t.
Add a config option to initialize the default time sync object path, so
that it works both on BMC and in unit tests.
Signed-off-by: Lei YU <yulei.sh@bytedance.com>
Change-Id: Iccdaef58434a1227c4ea73230ba23b4e618a2d2d
diff --git a/.clang-tidy b/.clang-tidy
index de69285..5fca7ce 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -303,7 +303,7 @@
readability-uppercase-literal-suffix'
WarningsAsErrors: '*'
-HeaderFilterRegex: '.*'
+HeaderFilterRegex: '.*.hpp'
CheckOptions:
- { key: readability-identifier-naming.ClassCase, value: CamelCase }
diff --git a/meson.build b/meson.build
index 93a4960..073fe7a 100644
--- a/meson.build
+++ b/meson.build
@@ -42,6 +42,7 @@
conf_data = configuration_data()
conf_data.set('DEFAULT_TIME_MODE', get_option('default_time_mode'))
+conf_data.set_quoted('DEFAULT_TIME_SYNC_OBJECT_PATH', get_option('default_time_sync_object_path'))
configure_file(output: 'config.h', configuration: conf_data)
diff --git a/meson_options.txt b/meson_options.txt
index 92d1f11..d4b7fa6 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -17,3 +17,10 @@
choices: ['Mode::Manual', 'Mode::NTP'],
value : 'Mode::Manual',
description : 'The default time mode')
+
+option(
+ 'default_time_sync_object_path',
+ type: 'string',
+ value: '/xyz/openbmc_project/time/sync_method',
+ description: 'Default object path for time sync setting'
+)
diff --git a/settings.hpp b/settings.hpp
index b7e18bf..a61cae7 100644
--- a/settings.hpp
+++ b/settings.hpp
@@ -1,5 +1,7 @@
#pragma once
+#include "config.h"
+
#include "utils.hpp"
#include <sdbusplus/bus.hpp>
@@ -33,7 +35,7 @@
~Objects() = default;
/** @brief time sync method settings object */
- Path timeSyncMethod;
+ Path timeSyncMethod = DEFAULT_TIME_SYNC_OBJECT_PATH;
};
} // namespace settings