diff options
Diffstat (limited to 'tst/stubs')
-rw-r--r-- | tst/stubs/dlt/dlt-stub.c | 141 | ||||
-rw-r--r-- | tst/stubs/dlt/dlt-stub.h | 51 | ||||
-rw-r--r-- | tst/stubs/gen/nhm-dbus-info-stub.c | 97 | ||||
-rw-r--r-- | tst/stubs/gen/nhm-dbus-info-stub.h | 62 | ||||
-rw-r--r-- | tst/stubs/gen/nsm-dbus-consumer-stub.c | 98 | ||||
-rw-r--r-- | tst/stubs/gen/nsm-dbus-consumer-stub.h | 58 | ||||
-rw-r--r-- | tst/stubs/gen/nsm-dbus-lc-consumer-stub.c | 78 | ||||
-rw-r--r-- | tst/stubs/gen/nsm-dbus-lc-consumer-stub.h | 54 | ||||
-rw-r--r-- | tst/stubs/gen/nsm-dbus-lc-control-stub.c | 123 | ||||
-rw-r--r-- | tst/stubs/gen/nsm-dbus-lc-control-stub.h | 68 | ||||
-rw-r--r-- | tst/stubs/gio/gio-stub.c | 422 | ||||
-rw-r--r-- | tst/stubs/gio/gio-stub.h | 161 | ||||
-rw-r--r-- | tst/stubs/nhm/nhm-systemd-stub.c | 48 | ||||
-rw-r--r-- | tst/stubs/nhm/nhm-systemd-stub.h | 33 | ||||
-rw-r--r-- | tst/stubs/persistence/persistence_client_library_key-stub.c | 103 | ||||
-rw-r--r-- | tst/stubs/persistence/persistence_client_library_key-stub.h | 52 | ||||
-rw-r--r-- | tst/stubs/systemd/sd-daemon-stub.c | 50 | ||||
-rw-r--r-- | tst/stubs/systemd/sd-daemon-stub.h | 42 |
18 files changed, 1741 insertions, 0 deletions
diff --git a/tst/stubs/dlt/dlt-stub.c b/tst/stubs/dlt/dlt-stub.c new file mode 100644 index 0000000..6a1d091 --- /dev/null +++ b/tst/stubs/dlt/dlt-stub.c @@ -0,0 +1,141 @@ +/* NHM - NodeHealthMonitor + * + * Implementation of stubs for dlt + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +/******************************************************************************* +* +* Header includes +* +*******************************************************************************/ + +#include <dlt/dlt.h> /* Header of real sd daemon */ +#include <tst/stubs/dlt/dlt-stub.h> /* Header of stub sd daemon */ + +/******************************************************************************* +* +* Interfaces. Exported functions. +* +*******************************************************************************/ + +int +dlt_register_app_stub(const char *appid, + const char *description) +{ + return 0; +} + +/** + * dlt_check_library_version_stub: + * + * Stub for dlt_check_library_version() + */ +int +dlt_check_library_version_stub(const char *user_major_version, + const char *user_minor_version) +{ + return 0; +} + +/** + * dlt_register_context_stub: + * + * Stub for dlt_register_context() + */ +int +dlt_register_context_stub(DltContext *handle, + const char *contextid, + const char * description) +{ + return 0; +} + +/** + * dlt_unregister_context_stub: + * + * Stub for dlt_unregister_context() + */ +int +dlt_unregister_context_stub(DltContext *handle) +{ + return 0; +} + +/** + * dlt_unregister_app_stub: + * + * Stub for dlt_unregister_app() + */ +int +dlt_unregister_app_stub(void) +{ + return 0; +} + +/** + * dlt_user_log_write_start_stub: + * + * Stub for dlt_user_log_write_start() + */ +int +dlt_user_log_write_start_stub(DltContext *handle, + DltContextData *log, + DltLogLevelType loglevel) +{ + return 0; +} + +/** + * dlt_user_log_write_finish_stub: + * + * Stub for dlt_user_log_write_finish() + */ +int +dlt_user_log_write_finish_stub(DltContextData *log) +{ + return 0; +} + +/** + * dlt_user_log_write_string_stub: + * + * Stub for dlt_user_log_write_string() + */ +int +dlt_user_log_write_string_stub(DltContextData *log, + const char *text) +{ + return 0; +} + +/** + * dlt_user_log_write_int_stub: + * + * Stub for dlt_user_log_write_int() + */ +int +dlt_user_log_write_int_stub(DltContextData *log, + int data) +{ + return 0; +} + +/** + * dlt_user_log_write_uint_stub: + * + * Stub for dlt_user_log_write_uint() + */ +int +dlt_user_log_write_uint_stub(DltContextData *log, + unsigned int data) +{ + return 0; +} diff --git a/tst/stubs/dlt/dlt-stub.h b/tst/stubs/dlt/dlt-stub.h new file mode 100644 index 0000000..ff1d2cd --- /dev/null +++ b/tst/stubs/dlt/dlt-stub.h @@ -0,0 +1,51 @@ +/* NHM - NodeHealthMonitor + * + * Definition of stubs for dlt + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef DLT_STUB_H +#define DLT_STUB_H + +/******************************************************************************* +* +* Header includes +* +*******************************************************************************/ + +#include <dlt/dlt.h> /* Include header of real dlt */ + +/******************************************************************************* +* +* Exported variables, constants and defines +* +*******************************************************************************/ + +int dlt_register_app_stub (const char *appid, + const char *description); +int dlt_check_library_version_stub(const char *user_major_version, + const char *user_minor_version); +int dlt_register_context_stub (DltContext *handle, + const char *contextid, + const char *description); +int dlt_unregister_context_stub (DltContext *handle); +int dlt_unregister_app_stub (void); +int dlt_user_log_write_start_stub (DltContext *handle, + DltContextData *log, + DltLogLevelType loglevel); +int dlt_user_log_write_finish_stub(DltContextData *log); +int dlt_user_log_write_string_stub(DltContextData *log, + const char *text); +int dlt_user_log_write_int_stub (DltContextData *log, + int data); +int dlt_user_log_write_uint_stub (DltContextData *log, + unsigned int data); + +#endif /* DLT_STUB_H */ diff --git a/tst/stubs/gen/nhm-dbus-info-stub.c b/tst/stubs/gen/nhm-dbus-info-stub.c new file mode 100644 index 0000000..bca004f --- /dev/null +++ b/tst/stubs/gen/nhm-dbus-info-stub.c @@ -0,0 +1,97 @@ +/* NHM - NodeHealthMonitor + * + * Implementation of stubs for the nsm-dbus-consumer + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +/******************************************************************************* +* +* Header includes +* +*******************************************************************************/ + +#include <gio/gio.h> +#include <gen/nhm-dbus-info.h> +#include <tst/stubs/gen/nhm-dbus-info-stub.h> + +/******************************************************************************* +* +* Exported variables and constants +* +*******************************************************************************/ + +gint nhm_dbus_info_complete_read_statistics_stub_CurrentFailCount = 0; +gint nhm_dbus_info_complete_read_statistics_stub_TotalFailures = 0; +gint nhm_dbus_info_complete_read_statistics_stub_TotalLifecycles = 0; +gint nhm_dbus_info_complete_request_node_restart_stub_ErrorStatus = 0; + + +/******************************************************************************* +* +* Interfaces. Exported functions. +* +*******************************************************************************/ + +/** + * nhm_dbus_info_emit_app_health_status_stub: + * + * Stub for nhm_dbus_info_emit_app_health_status() + */ +void +nhm_dbus_info_emit_app_health_status_stub(NhmDbusInfo *object, + const gchar *arg_AppName, + gint arg_AppStatus) +{ + +} + +/** + * nhm_dbus_info_complete_register_app_status_stub: + * + * Stub for nhm_dbus_info_complete_register_app_status() + */ +void +nhm_dbus_info_complete_register_app_status_stub(NhmDbusInfo *object, + GDBusMethodInvocation *invocation) +{ + +} + +/** + * nhm_dbus_info_complete_read_statistics_stub: + * + * Stub for nhm_dbus_info_complete_read_statistics() + */ +void +nhm_dbus_info_complete_read_statistics_stub(NhmDbusInfo *object, + GDBusMethodInvocation *invocation, + guint CurrentFailCount, + guint TotalFailures, + guint TotalLifecycles, + gint ErrorStatus) +{ + nhm_dbus_info_complete_read_statistics_stub_CurrentFailCount = CurrentFailCount; + nhm_dbus_info_complete_read_statistics_stub_TotalFailures = TotalFailures; + nhm_dbus_info_complete_read_statistics_stub_TotalLifecycles = TotalLifecycles; +} + +/** + * nhm_dbus_info_complete_request_node_restart_stub: + * + * Stub for nhm_dbus_info_complete_request_node_restart() + */ +void +nhm_dbus_info_complete_request_node_restart_stub(NhmDbusInfo *object, + GDBusMethodInvocation *invocation, + gint ErrorStatus) +{ + nhm_dbus_info_complete_request_node_restart_stub_ErrorStatus = ErrorStatus; +} + diff --git a/tst/stubs/gen/nhm-dbus-info-stub.h b/tst/stubs/gen/nhm-dbus-info-stub.h new file mode 100644 index 0000000..368593e --- /dev/null +++ b/tst/stubs/gen/nhm-dbus-info-stub.h @@ -0,0 +1,62 @@ +/* NHM - NodeHealthMonitor + * + * Definition of stubs for nhm-dbus-info + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef NHM_DBUS_INFO_STUB_H +#define NHM_DBUS_INFO_STUB_H + +/******************************************************************************* +* +* Header includes +* +*******************************************************************************/ + +#include <gio/gio.h> +#include <gen/nhm-dbus-info.h> /* Header of real nsm-dbus-info */ + +/******************************************************************************* +* +* Exported variables, constants and defines +* +*******************************************************************************/ + +extern gint nhm_dbus_info_complete_read_statistics_stub_CurrentFailCount; +extern gint nhm_dbus_info_complete_read_statistics_stub_TotalFailures; +extern gint nhm_dbus_info_complete_read_statistics_stub_TotalLifecycles; +extern gint nhm_dbus_info_complete_request_node_restart_stub_ErrorStatus; + +/******************************************************************************* +* +* Exported functions +* +*******************************************************************************/ + +void nhm_dbus_info_emit_app_health_status_stub (NhmDbusInfo *object, + const gchar *arg_AppName, + gint arg_AppStatus); + +void nhm_dbus_info_complete_register_app_status_stub (NhmDbusInfo *object, + GDBusMethodInvocation *invocation); + +void nhm_dbus_info_complete_read_statistics_stub (NhmDbusInfo *object, + GDBusMethodInvocation *invocation, + guint CurrentFailCount, + guint TotalFailures, + guint TotalLifecycles, + gint ErrorStatus); + + +void nhm_dbus_info_complete_request_node_restart_stub(NhmDbusInfo *object, + GDBusMethodInvocation *invocation, + gint ErrorStatus); + +#endif /* NHM_DBUS_INFO_STUB_H */ diff --git a/tst/stubs/gen/nsm-dbus-consumer-stub.c b/tst/stubs/gen/nsm-dbus-consumer-stub.c new file mode 100644 index 0000000..03a24a2 --- /dev/null +++ b/tst/stubs/gen/nsm-dbus-consumer-stub.c @@ -0,0 +1,98 @@ +/* NHM - NodeHealthMonitor + * + * Implementation of stubs for the nsm-dbus-consumer + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +/******************************************************************************* +* +* Header includes +* +*******************************************************************************/ + +#include <gio/gio.h> +#include <gen/nsm-dbus-consumer.h> +#include <tst/stubs/gen/nsm-dbus-consumer-stub.h> + +/******************************************************************************* +* +* Exported variables and constants +* +*******************************************************************************/ + +gboolean nsm_dbus_consumer_proxy_new_sync_stub_set_error = FALSE; +gboolean nsm_dbus_consumer_call_register_shutdown_client_sync_stub_set_error = FALSE; +gint nsm_dbus_consumer_call_register_shutdown_client_sync_stub_out_ErrorCode = 0; + + +/******************************************************************************* +* +* Interfaces. Exported functions. +* +*******************************************************************************/ + +/** + * nsm_dbus_consumer_proxy_new_sync_stub: + * + * Stub for nsm_dbus_consumer_proxy_new_sync() + */ +NsmDbusConsumer* +nsm_dbus_consumer_proxy_new_sync_stub(GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error) +{ + NsmDbusConsumer *retval = NULL; + + if(nsm_dbus_consumer_proxy_new_sync_stub_set_error == FALSE) + { + retval = g_object_new(NSM_DBUS_TYPE_CONSUMER_PROXY, NULL); + } + else + { + retval = NULL; + g_set_error(error, G_DBUS_ERROR, G_DBUS_ERROR_DISCONNECTED, NULL); + } + + return retval; +} + +/** + * nsm_dbus_consumer_call_register_shutdown_client_sync_stub: + * + * Stub for nsm_dbus_consumer_call_register_shutdown_client_sync() + */ +gboolean +nsm_dbus_consumer_call_register_shutdown_client_sync_stub(NsmDbusConsumer *proxy, + const gchar *arg_BusName, + const gchar *arg_ObjName, + guint arg_ShutdownMode, + guint arg_TimeoutMs, + gint *out_ErrorCode, + GCancellable *cancellable, + GError **error) +{ + gboolean retval = TRUE; + + if(nsm_dbus_consumer_call_register_shutdown_client_sync_stub_set_error == FALSE) + { + retval = TRUE; + *out_ErrorCode = nsm_dbus_consumer_call_register_shutdown_client_sync_stub_out_ErrorCode; + } + else + { + retval = FALSE; + g_set_error(error, G_DBUS_ERROR, G_DBUS_ERROR_DISCONNECTED, NULL); + } + + return retval; +} diff --git a/tst/stubs/gen/nsm-dbus-consumer-stub.h b/tst/stubs/gen/nsm-dbus-consumer-stub.h new file mode 100644 index 0000000..8dbde6c --- /dev/null +++ b/tst/stubs/gen/nsm-dbus-consumer-stub.h @@ -0,0 +1,58 @@ +/* NHM - NodeHealthMonitor + * + * Definition of stubs for nsm-dbus-consumer + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef NSM_DBUS_CONSUMER_STUB_H +#define NSM_DBUS_CONSUMER_STUB_H + +/******************************************************************************* +* +* Header includes +* +*******************************************************************************/ + +#include <gio/gio.h> +#include <gen/nsm-dbus-consumer.h> /* Header of real nsm-dbus-consumer */ + +/******************************************************************************* +* +* Exported variables, constants and defines +* +*******************************************************************************/ + +extern gboolean nsm_dbus_consumer_proxy_new_sync_stub_set_error; +extern gboolean nsm_dbus_consumer_call_register_shutdown_client_sync_stub_set_error; +extern gint nsm_dbus_consumer_call_register_shutdown_client_sync_stub_out_ErrorCode; + +/******************************************************************************* +* +* Exported functions +* +*******************************************************************************/ + +NsmDbusConsumer* nsm_dbus_consumer_proxy_new_sync_stub (GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + +gboolean nsm_dbus_consumer_call_register_shutdown_client_sync_stub(NsmDbusConsumer *proxy, + const gchar *arg_BusName, + const gchar *arg_ObjName, + guint arg_ShutdownMode, + guint arg_TimeoutMs, + gint *out_ErrorCode, + GCancellable *cancellable, + GError **error); + +#endif /* NSM_DBUS_CONSUMER_STUB_H */ diff --git a/tst/stubs/gen/nsm-dbus-lc-consumer-stub.c b/tst/stubs/gen/nsm-dbus-lc-consumer-stub.c new file mode 100644 index 0000000..82b0195 --- /dev/null +++ b/tst/stubs/gen/nsm-dbus-lc-consumer-stub.c @@ -0,0 +1,78 @@ +/* NHM - NodeHealthMonitor + * + * Implementation of stubs for the nsm-dbus-lc-consumer + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +/******************************************************************************* +* +* Header includes +* +*******************************************************************************/ + +#include <gio/gio.h> +#include <gen/nsm-dbus-lc-consumer.h> +#include <tst/stubs/gen/nsm-dbus-lc-consumer-stub.h> + +/******************************************************************************* +* +* Exported variables and constants +* +*******************************************************************************/ + +gboolean nsm_dbus_lc_consumer_proxy_new_sync_stub_set_error = FALSE; +gint nsm_dbus_lc_consumer_complete_lifecycle_request_stub_ErrorCode = 0; + +/******************************************************************************* +* +* Interfaces. Exported functions. +* +*******************************************************************************/ + +/** + * nsm_dbus_lc_consumer_proxy_new_sync_stub: + * + * Stub for nsm_dbus_lc_consumer_proxy_new_sync() + */ +NsmDbusLcConsumer* +nsm_dbus_lc_consumer_proxy_new_sync_stub(GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error) +{ + NsmDbusLcConsumer *retval = NULL; + + if(nsm_dbus_lc_consumer_proxy_new_sync_stub_set_error == FALSE) + { + retval = g_object_new(NSM_DBUS_LC_TYPE_CONSUMER_PROXY, NULL); + } + else + { + retval = NULL; + g_set_error(error, G_DBUS_ERROR, G_DBUS_ERROR_DISCONNECTED, NULL); + } + + return retval; +} + +/** + * nsm_dbus_lc_consumer_complete_lifecycle_request_stub: + * + * Stub for nsm_dbus_lc_consumer_complete_lifecycle_request() + */ +void +nsm_dbus_lc_consumer_complete_lifecycle_request_stub(NsmDbusLcConsumer *object, + GDBusMethodInvocation *invocation, + gint ErrorCode) +{ + nsm_dbus_lc_consumer_complete_lifecycle_request_stub_ErrorCode = ErrorCode; +} diff --git a/tst/stubs/gen/nsm-dbus-lc-consumer-stub.h b/tst/stubs/gen/nsm-dbus-lc-consumer-stub.h new file mode 100644 index 0000000..5e32057 --- /dev/null +++ b/tst/stubs/gen/nsm-dbus-lc-consumer-stub.h @@ -0,0 +1,54 @@ +/* NHM - NodeHealthMonitor + * + * Definition of stubs for nsm-dbus-lc-consumer + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef NSM_DBUS_LC_CONSUMER_STUB_H +#define NSM_DBUS_LC_CONSUMER_STUB_H + +/******************************************************************************* +* +* Header includes +* +*******************************************************************************/ + +#include <gio/gio.h> +#include <gen/nsm-dbus-lc-consumer.h> /* Header of real nsm-dbus-lc-consumer */ + +/******************************************************************************* +* +* Exported variables, constants and defines +* +*******************************************************************************/ + +extern gboolean nsm_dbus_lc_consumer_proxy_new_sync_stub_set_error; +extern gint nsm_dbus_lc_consumer_complete_lifecycle_request_stub_ErrorCode; + +/******************************************************************************* +* +* Exported functions +* +*******************************************************************************/ + +NsmDbusLcConsumer* nsm_dbus_lc_consumer_proxy_new_sync_stub(GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + +void nsm_dbus_lc_consumer_complete_lifecycle_request_stub (NsmDbusLcConsumer *object, + GDBusMethodInvocation *invocation, + gint ErrorCode); + +#endif /* NSM_DBUS_LC_CONSUMER_STUB_H */ + diff --git a/tst/stubs/gen/nsm-dbus-lc-control-stub.c b/tst/stubs/gen/nsm-dbus-lc-control-stub.c new file mode 100644 index 0000000..14e3096 --- /dev/null +++ b/tst/stubs/gen/nsm-dbus-lc-control-stub.c @@ -0,0 +1,123 @@ +/* NHM - NodeHealthMonitor + * + * Implementation of stubs for the nsm-dbus-lc-control + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +/******************************************************************************* +* +* Header includes +* +*******************************************************************************/ + +#include <gio/gio.h> +#include <gen/nsm-dbus-lc-control.h> +#include <tst/stubs/gen/nsm-dbus-lc-control-stub.h> + +/******************************************************************************* +* +* Exported variables and constants +* +*******************************************************************************/ + +gboolean nsm_dbus_lc_control_proxy_new_sync_stub_set_error = FALSE; +gboolean nsm_dbus_lc_control_call_set_app_health_status_sync_stub_set_error = FALSE; +gboolean nsm_dbus_lc_control_call_request_node_restart_sync_stub_set_error = FALSE; +gint nsm_dbus_lc_control_call_request_node_restart_sync_stub_out_ErrorCode = 0; + +/******************************************************************************* +* +* Interfaces. Exported functions. +* +*******************************************************************************/ + +/** + * nsm_dbus_lc_control_proxy_new_sync_stub: + * + * Stub for nsm_dbus_lc_control_proxy_new_sync() + */ +NsmDbusLcControl* +nsm_dbus_lc_control_proxy_new_sync_stub(GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error) +{ + NsmDbusLcControl* retval = NULL; + + if(nsm_dbus_lc_control_proxy_new_sync_stub_set_error == FALSE) + { + retval = g_object_new(NSM_DBUS_LC_TYPE_CONTROL_PROXY, NULL); + } + else + { + retval = NULL; + g_set_error(error, G_DBUS_ERROR, G_DBUS_ERROR_DISCONNECTED, NULL); + } + + return retval; +} + +/** + * nsm_dbus_lc_control_call_set_app_health_status_sync_stub: + * + * Stub for nsm_dbus_lc_control_call_set_app_health_status_sync() + */ +gboolean +nsm_dbus_lc_control_call_set_app_health_status_sync_stub(NsmDbusLcControl *proxy, + const gchar *arg_AppName, + gboolean arg_AppRunning, + gint *out_ErrorCode, + GCancellable *cancellable, + GError **error) +{ + gboolean retval = FALSE; + + if(nsm_dbus_lc_control_call_set_app_health_status_sync_stub_set_error == FALSE) + { + retval = TRUE; + } + else + { + retval = FALSE; + g_set_error(error, G_DBUS_ERROR, G_DBUS_ERROR_DISCONNECTED, NULL); + } + + return retval; +} + +/** + * nsm_dbus_lc_control_call_request_node_restart_sync_stub: + * + * Stub for nsm_dbus_lc_control_call_request_node_restart_sync() + */ +gboolean +nsm_dbus_lc_control_call_request_node_restart_sync_stub(NsmDbusLcControl *proxy, + gint arg_RestartReason, + guint arg_RestartType, + gint *out_ErrorCode, + GCancellable *cancellable, + GError **error) +{ + gboolean retval = FALSE; + + if(nsm_dbus_lc_control_call_request_node_restart_sync_stub_set_error == FALSE) + { + *out_ErrorCode = nsm_dbus_lc_control_call_request_node_restart_sync_stub_out_ErrorCode; + } + else + { + retval = FALSE; + g_set_error(error, G_DBUS_ERROR, G_DBUS_ERROR_DISCONNECTED, NULL); + } + + return retval; +} diff --git a/tst/stubs/gen/nsm-dbus-lc-control-stub.h b/tst/stubs/gen/nsm-dbus-lc-control-stub.h new file mode 100644 index 0000000..80a554d --- /dev/null +++ b/tst/stubs/gen/nsm-dbus-lc-control-stub.h @@ -0,0 +1,68 @@ +/* NHM - NodeHealthMonitor + * + * Definition of stubs for nsm-dbus-lc-control + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef NSM_DBUS_LC_CONTROL_STUB_H +#define NSM_DBUS_LC_CONTROL_STUB_H + +/******************************************************************************* +* +* Header includes +* +*******************************************************************************/ + +#include <gio/gio.h> +#include <gen/nsm-dbus-lc-control.h> /* Header of real nsm-dbus-lc-control */ + +/******************************************************************************* +* +* Exported variables, constants and defines +* +*******************************************************************************/ + +extern gboolean nsm_dbus_lc_control_proxy_new_sync_stub_set_error; +extern gboolean nsm_dbus_lc_control_call_set_app_health_status_sync_stub_set_error; +extern gboolean nsm_dbus_lc_control_call_request_node_restart_sync_stub_set_error; +extern gint nsm_dbus_lc_control_call_request_node_restart_sync_stub_out_ErrorCode; + +/******************************************************************************* +* +* Exported functions +* +*******************************************************************************/ + +NsmDbusLcControl* nsm_dbus_lc_control_proxy_new_sync_stub (GDBusConnection *connection, + GDBusProxyFlags flags, + const gchar *name, + const gchar *object_path, + GCancellable *cancellable, + GError **error); + + + +gboolean nsm_dbus_lc_control_call_set_app_health_status_sync_stub(NsmDbusLcControl *proxy, + const gchar *arg_AppName, + gboolean arg_AppRunning, + gint *out_ErrorCode, + GCancellable *cancellable, + GError **error); + + +gboolean nsm_dbus_lc_control_call_request_node_restart_sync_stub (NsmDbusLcControl *proxy, + gint arg_RestartReason, + guint arg_RestartType, + gint *out_ErrorCode, + GCancellable *cancellable, + GError **error); + + +#endif /* NSM_DBUS_LC_CONTROL_STUB_H */ diff --git a/tst/stubs/gio/gio-stub.c b/tst/stubs/gio/gio-stub.c new file mode 100644 index 0000000..6cf8fb1 --- /dev/null +++ b/tst/stubs/gio/gio-stub.c @@ -0,0 +1,422 @@ +/* NHM - NodeHealthMonitor + * + * Implementation of stubs for gio + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +/******************************************************************************* +* +* Header includes +* +*******************************************************************************/ + +#include <stdio.h> /* NULL */ +#include <string.h> /* strcmp */ +#include <gio/gio.h> /* Header of real gio */ +#include <tst/stubs/gio/gio-stub.h> /* Header of stub gio */ + + +/******************************************************************************* +* +* Exported variables and constants +* +*******************************************************************************/ + +gboolean g_bus_get_sync_set_error = FALSE; +gboolean g_dbus_interface_skeleton_export_stub_set_error = FALSE; +gboolean g_main_loop_quit_stub_called = FALSE; +guint g_timeout_add_seconds_called_interval = 0; +gboolean g_timeout_add_seconds_called = FALSE; +gboolean g_dbus_connection_new_for_address_sync_stub_set_error = FALSE; +GdbusConnectionCallSyncStubControl g_dbus_connection_call_sync_stub_control; + + +/******************************************************************************* +* +* File local variables and constants +* +*******************************************************************************/ + +static guint folder_file_idx = 0; +static gchar *folder_files[] = {"0000", "0001", NULL}; + +/******************************************************************************* +* +* Interfaces. Exported functions. +* +*******************************************************************************/ + +/** + * g_file_test_stub: + * + * Stub for g_file_test() + */ +gboolean +g_file_test_stub(const gchar *filename, + GFileTest test) +{ + return (g_strcmp0(filename, "existing_file") == 0); +} + +/** + * g_file_read_link_stub: + * + * Stub for g_file_read_link() + */ +gchar* +g_file_read_link_stub(const gchar *filename, + GError **error) +{ + gchar *linked_file = NULL; + + if(strcmp("/proc/0000/exe", filename) == 0) + { + linked_file = g_strdup("/usr/bin/valid_prog1"); + } + else if(strcmp("/proc/0001/exe", filename) == 0) + { + linked_file = g_strdup("/usr/bin/valid_prog2"); + } + else + { + linked_file = NULL; + } + + return linked_file; +} + +/** + * g_dir_open_stub: + * + * Stub for g_dir_open() + */ +GDir* +g_dir_open_stub(const gchar *path, + guint flags, + GError **error) +{ + folder_file_idx = 0; + return (GDir*) folder_files; +} + +/** + * g_dir_read_name_stub: + * + * Stub for g_dir_read_name() + */ +const gchar* +g_dir_read_name_stub(GDir *dir) +{ + gchar *file_name = NULL; + + if(folder_file_idx < sizeof(folder_files)/sizeof(gchar*)) + { + file_name = folder_files[folder_file_idx]; + folder_file_idx++; + } + + return file_name; +} + +/** + * g_dir_close_stub: + * + * Stub for g_dir_close() + */ +void +g_dir_close_stub(GDir *dir) +{ + folder_file_idx = 0; +} + + +/** + * g_bus_get_sync_stub: + * + * Stub for g_bus_get_sync() + */ +GDBusConnection* +g_bus_get_sync_stub(GBusType bus_type, + GCancellable *cancellable, + GError **error) +{ + gpointer retval = FALSE; + + if(g_bus_get_sync_set_error == FALSE) + { + retval = g_object_new(G_TYPE_DBUS_CONNECTION, NULL); + } + else + { + retval = NULL; + g_set_error(error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, NULL); + } + + return retval; +} + +/** + * g_bus_own_name_stub: + * + * Stub for g_bus_own_name() + */ +guint +g_bus_own_name_stub(GBusType bus_type, + const gchar *name, + GBusNameOwnerFlags flags, + GBusAcquiredCallback bus_acquired_handler, + GBusNameAcquiredCallback name_acquired_handler, + GBusNameLostCallback name_lost_handler, + gpointer user_data, + GDestroyNotify user_data_free_func) +{ + return 0; +} + +/** + * g_dbus_connection_get_unique_name_stub: + * + * Stub for g_dbus_connection_get_unique_name() + */ +const gchar* +g_dbus_connection_get_unique_name_stub(GDBusConnection *connection) +{ + return NULL; +} + +/** + * g_dbus_interface_skeleton_export_stub: + * + * Stub for g_dbus_interface_skeleton_export() + */ +gboolean +g_dbus_interface_skeleton_export_stub(GDBusInterfaceSkeleton *interface_, + GDBusConnection *connection, + const gchar *object_path, + GError **error) +{ + gboolean retval = FALSE; + + if(g_dbus_interface_skeleton_export_stub_set_error == FALSE) + { + retval = TRUE; + } + else + { + retval = FALSE; + g_set_error(error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, NULL); + } + + return retval; +} + + +/** + * g_dbus_connection_new_for_address_sync_stub: + * + * Stub for g_dbus_connection_new_for_address_sync() + */ +GDBusConnection* +g_dbus_connection_new_for_address_sync_stub(const gchar *address, + GDBusConnectionFlags flags, + GDBusAuthObserver *observer, + GCancellable *cancellable, + GError **error) +{ + GDBusConnection *retval = NULL; + + if(g_dbus_connection_new_for_address_sync_stub_set_error == FALSE) + { + retval = g_object_new(G_TYPE_DBUS_CONNECTION, NULL); + } + else + { + retval = NULL; + g_set_error(error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, NULL); + } + + return retval; +} + + +/** + * g_dbus_connection_call_sync_stub: + * + * Stub for g_dbus_connection_call_sync() + */ +GVariant* +g_dbus_connection_call_sync_stub(GDBusConnection *connection, + const gchar *bus_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + const GVariantType *reply_type, + GDBusCallFlags flags, + gint timeout_msec, + GCancellable *cancellable, + GError **error) +{ + GVariant *rval = NULL; + guint control_array_idx = 0; + GdbusConnectionCallSyncStubCalls *call = NULL; + + for(control_array_idx = 0; + (control_array_idx < g_dbus_connection_call_sync_stub_control.count) + && (call == NULL); + control_array_idx++) + { + if(g_strcmp0(g_dbus_connection_call_sync_stub_control.calls[control_array_idx].method, + method_name) == 0) + { + call = &g_dbus_connection_call_sync_stub_control.calls[control_array_idx]; + } + } + + if(call != NULL) + { + rval = call->rval; + + if((rval == NULL) && (error != NULL)) + { + g_set_error(error, G_DBUS_ERROR, G_DBUS_ERROR_FAILED, NULL); + } + } + + return rval; +} + + +/** + * g_dbus_connection_signal_subscribe_stub: + * + * Stub for g_dbus_connection_signal_subscribe() + */ +guint +g_dbus_connection_signal_subscribe_stub(GDBusConnection *connection, + const gchar *sender, + const gchar *interface_name, + const gchar *member, + const gchar *object_path, + const gchar *arg0, + GDBusSignalFlags flags, + GDBusSignalCallback callback, + gpointer user_data, + GDestroyNotify user_data_free_func) +{ + return 0; +} + + +/** + * g_dbus_connection_signal_unsubscribe_stub: + * + * Stub for g_dbus_connection_signal_unsubscribe() + */ +void +g_dbus_connection_signal_unsubscribe_stub(GDBusConnection *connection, + guint subscription_id) +{ + +} + + +/** + * g_main_loop_run_stub: + * + * Stub for g_main_loop_run() + */ +void +g_main_loop_run_stub(GMainLoop *loop) +{ +} + +/** + * g_main_loop_quit_stub: + * + * Stub for g_main_loop_quit() + */ +void +g_main_loop_quit_stub(GMainLoop *loop) +{ + g_main_loop_quit_stub_called = TRUE; +} + +/** + * g_timeout_add_seconds_stub: + * + * Stub for g_timeout_add_seconds() + */ +guint +g_timeout_add_seconds_stub(guint interval, + GSourceFunc function, + gpointer data) +{ + g_timeout_add_seconds_called_interval = interval; + g_timeout_add_seconds_called = TRUE; + + return 0; +} + +/** + * g_signal_connect_data_stub: + * + * Stub for g_signal_connect_data() + */ +gulong +g_signal_connect_data_stub(gpointer instance, + const gchar *detailed_signal, + GCallback c_handler, + gpointer data, + GClosureNotify destroy_data, + GConnectFlags connect_flags) +{ + return 0; +} + +/** + * g_spawn_sync_stub: + * + * Stub for g_spawn_sync() + */ +gboolean +g_spawn_sync_stub(const gchar *working_directory, + gchar **argv, + gchar **envp, + GSpawnFlags flags, + GSpawnChildSetupFunc child_setup, + gpointer user_data, + gchar **standard_output, + gchar **standard_error, + gint *exit_status, + GError **error) +{ + gboolean retval = FALSE; + + if(strcmp(argv[0], "valid_proc") == 0) + { + retval = TRUE; + *exit_status = 0; + *error = NULL; + } + else if(strcmp(argv[0], "failing_proc") == 0) + { + retval = TRUE; + *exit_status = -1; + *error = NULL; + } + else + { + retval = FALSE; + g_set_error(error, G_SPAWN_ERROR, G_SPAWN_ERROR_FAILED, NULL); + } + + return retval; +} diff --git a/tst/stubs/gio/gio-stub.h b/tst/stubs/gio/gio-stub.h new file mode 100644 index 0000000..fbb4d0e --- /dev/null +++ b/tst/stubs/gio/gio-stub.h @@ -0,0 +1,161 @@ +/* NHM - NodeHealthMonitor + * + * Definition of stubs for gio + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef GIO_STUB_H +#define GIO_STUB_H + +/******************************************************************************* +* +* Header includes +* +*******************************************************************************/ + +#include <gio/gio.h> /* Include header of real gio */ + +/******************************************************************************* +* +* Exported variables, constants and defines +* +*******************************************************************************/ + +typedef struct +{ + gchar *method; + GVariant *rval; +} GdbusConnectionCallSyncStubCalls; + +typedef struct +{ + guint count; + GdbusConnectionCallSyncStubCalls *calls; +} GdbusConnectionCallSyncStubControl; + + +extern gboolean g_main_loop_quit_stub_called; +extern gboolean g_bus_get_sync_set_error; +extern guint g_timeout_add_seconds_called_interval; +extern gboolean g_timeout_add_seconds_called; +extern gboolean g_dbus_interface_skeleton_export_stub_set_error; +extern gboolean g_dbus_connection_new_for_address_sync_stub_set_error; +extern gboolean g_dbus_connection_call_sync_stub_set_error; +extern GdbusConnectionCallSyncStubControl g_dbus_connection_call_sync_stub_control; + + +/******************************************************************************* +* +* Exported functions +* +*******************************************************************************/ + +/* File and folder reading */ +gboolean g_file_test_stub (const gchar *filename, + GFileTest test); +gchar *g_file_read_link_stub (const gchar *filename, + GError **error); +GDir *g_dir_open_stub (const gchar *path, + guint flags, + GError **error); +const gchar *g_dir_read_name_stub (GDir *dir); +void g_dir_close_stub (GDir *dir); + +/* Mainloop handling */ +void g_main_loop_run_stub (GMainLoop *loop); +void g_main_loop_quit_stub (GMainLoop *loop); + +/* Dbus handling */ +GDBusConnection *g_bus_get_sync_stub (GBusType bus_type, + GCancellable *cancellable, + GError **error); +const gchar *g_dbus_connection_get_unique_name_stub(GDBusConnection *connection); +guint g_bus_own_name_stub (GBusType bus_type, + const gchar *name, + GBusNameOwnerFlags flags, + GBusAcquiredCallback bus_acquired_handler, + GBusNameAcquiredCallback name_acquired_handler, + GBusNameLostCallback name_lost_handler, + gpointer user_data, + GDestroyNotify user_data_free_func); + + +gboolean g_dbus_interface_skeleton_export_stub (GDBusInterfaceSkeleton *interface_, + GDBusConnection *connection, + const gchar *object_path, + GError **error); + +GDBusConnection *g_dbus_connection_new_for_address_sync_stub(const gchar *address, + GDBusConnectionFlags flags, + GDBusAuthObserver *observer, + GCancellable *cancellable, + GError **error); + +GVariant *g_dbus_connection_call_sync_stub (GDBusConnection *connection, + const gchar *bus_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + const GVariantType *reply_type, + GDBusCallFlags flags, + gint timeout_msec, + GCancellable *cancellable, + GError **error); +guint g_dbus_connection_signal_subscribe_stub (GDBusConnection *connection, + const gchar *sender, + const gchar *interface_name, + const gchar *member, + const gchar *object_path, + const gchar *arg0, + GDBusSignalFlags flags, + GDBusSignalCallback callback, + gpointer user_data, + GDestroyNotify user_data_free_func); +void g_dbus_connection_signal_unsubscribe_stub (GDBusConnection *connection, + guint subscription_id); +GVariant *g_dbus_connection_call_sync_stub (GDBusConnection *connection, + const gchar *bus_name, + const gchar *object_path, + const gchar *interface_name, + const gchar *method_name, + GVariant *parameters, + const GVariantType *reply_type, + GDBusCallFlags flags, + gint timeout_msec, + GCancellable *cancellable, + GError **error); + +/* Timer and signals */ +guint g_timeout_add_seconds_stub (guint interval, + GSourceFunc function, + gpointer data); + +gulong g_signal_connect_data_stub (gpointer instance, + const gchar *detailed_signal, + GCallback c_handler, + gpointer data, + GClosureNotify destroy_data, + GConnectFlags connect_flags); + +/* Process handling */ +gboolean g_spawn_sync_stub (const gchar *working_directory, + gchar **argv, + gchar **envp, + GSpawnFlags flags, + GSpawnChildSetupFunc child_setup, + gpointer user_data, + gchar **standard_output, + gchar **standard_error, + gint *exit_status, + GError **error); + + +#endif /* GIO_STUB_H */ diff --git a/tst/stubs/nhm/nhm-systemd-stub.c b/tst/stubs/nhm/nhm-systemd-stub.c new file mode 100644 index 0000000..658f032 --- /dev/null +++ b/tst/stubs/nhm/nhm-systemd-stub.c @@ -0,0 +1,48 @@ +/* NHM - NodeHealthMonitor + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + */ + +/****************************************************************************** +* +* Header includes +* +******************************************************************************/ + +#include <gio/gio.h> /* Use gtypes */ +#include <src/nhm-systemd.h> /* Original header */ + +/****************************************************************************** +* +* Interfaces. Exported functions. See Header for detailed description. +* +******************************************************************************/ + + +/** + * nhm_systemd_connect_stub: + * + * Stub for nhm_systemd_connect() + */ +gboolean +nhm_systemd_connect_stub(NhmSystemdAppStatusCb app_status_cb) +{ + return TRUE; +} + +/** + * nhm_systemd_disconnect_stub: + * + * Stub for nhm_systemd_disconnect() + */ +void +nhm_systemd_disconnect_stub(void) +{ + +} diff --git a/tst/stubs/nhm/nhm-systemd-stub.h b/tst/stubs/nhm/nhm-systemd-stub.h new file mode 100644 index 0000000..a236cb7 --- /dev/null +++ b/tst/stubs/nhm/nhm-systemd-stub.h @@ -0,0 +1,33 @@ +#ifndef NHM_SYSTEMD_STUB_H +#define NHM_SYSTEMD_STUB_H + +/* NHM - NodeHealthMonitor + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +/******************************************************************************* +* +* Header includes +* +*******************************************************************************/ + +#include <gio/gio.h> /* Use gtypes */ +#include <src/nhm-systemd.h> /* Original header */ + +/******************************************************************************* +* +* Exported functions +* +*******************************************************************************/ + +gboolean nhm_systemd_connect_stub (NhmSystemdAppStatusCb app_status_cb); +void nhm_systemd_disconnect_stub(void); + +#endif /* NHM_SYSTEMD_STUB_H */ diff --git a/tst/stubs/persistence/persistence_client_library_key-stub.c b/tst/stubs/persistence/persistence_client_library_key-stub.c new file mode 100644 index 0000000..9a88d3f --- /dev/null +++ b/tst/stubs/persistence/persistence_client_library_key-stub.c @@ -0,0 +1,103 @@ +/* NHM - NodeHealthMonitor + * + * Implementation of stubs for the persistence client library + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +/******************************************************************************* +* +* Header includes +* +*******************************************************************************/ + +/* Own header */ +#include <stdio.h> +#include <string.h> +#include <tst/stubs/persistence/persistence_client_library_key-stub.h> + +/******************************************************************************* +* +* Exported variables and constants +* +*******************************************************************************/ + +int pclInitLibrary_stub_return = 0; +int pclKeyWriteData_stub_return = 0; +int pclKeyWriteData_stub_WriteVal = 0; +int pclKeyReadData_stub_return = 0; +int pclKeyReadData_stub_ReadVal = 0; +int pclDeinitLibrary_stub_return = 0; + +/******************************************************************************* +* +* Interfaces. Exported functions. +* +*******************************************************************************/ + + +/** + * pclInitLibrary_stub: + * + * Stub for pclInitLibrary() + */ +int +pclInitLibrary_stub(const char *appname, + int shutdownMode) +{ + return pclInitLibrary_stub_return; +} + + +/** + * pclKeyWriteData_stub: + * + * Stub for pclKeyWriteData() + */ +int +pclKeyWriteData_stub(unsigned int ldbid, + const char* resource_id, + unsigned int user_no, + unsigned int seat_no, + unsigned char* buffer, + int buffer_size) +{ + memcpy(&pclKeyWriteData_stub_WriteVal, buffer, buffer_size); + + return pclKeyWriteData_stub_return; +} + +/** + * pclKeyReadData_stub: + * + * Stub for pclKeyReadData() + */ +int pclKeyReadData_stub(unsigned int ldbid, + const char* resource_id, + unsigned int user_no, + unsigned int seat_no, + unsigned char* buffer, + int buffer_size) +{ + memcpy(buffer, &pclKeyReadData_stub_ReadVal, buffer_size); + + return pclKeyReadData_stub_return; +} + + +/** + * pclDeinitLibrary_stub: + * + * Stub for pclDeinitLibrary() + */ +int +pclDeinitLibrary_stub(void) +{ + return pclDeinitLibrary_stub_return; +} diff --git a/tst/stubs/persistence/persistence_client_library_key-stub.h b/tst/stubs/persistence/persistence_client_library_key-stub.h new file mode 100644 index 0000000..f85062c --- /dev/null +++ b/tst/stubs/persistence/persistence_client_library_key-stub.h @@ -0,0 +1,52 @@ +/* NHM - NodeHealthMonitor + * + * Definition of stubs for the persistence client library + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef PERSISTENCE_CLIENT_LIBRARY_KEY_STUB_H +#define PERSISTENCE_CLIENT_LIBRARY_KEY_STUB_H + +/******************************************************************************* +* +* Exported variables, constants and defines +* +*******************************************************************************/ + +extern int pclInitLibrary_stub_return; +extern int pclKeyWriteData_stub_return; +extern int pclKeyWriteData_stub_WriteVal; +extern int pclKeyReadData_stub_ReadVal; +extern int pclKeyReadData_stub_return; +extern int pclDeinitLibrary_stub_return; + +/******************************************************************************* +* +* Exported functions +* +*******************************************************************************/ + +int pclInitLibrary_stub (const char *appname, + int shutdownMode); +int pclKeyWriteData_stub (unsigned int ldbid, + const char *resource_id, + unsigned int user_no, + unsigned int seat_no, + unsigned char *buffer, + int buffer_size); +int pclKeyReadData_stub (unsigned int ldbid, + const char *resource_id, + unsigned int user_no, + unsigned int seat_no, + unsigned char *buffer, + int buffer_size); +int pclDeinitLibrary_stub(void); + +#endif /* PERSISTENCE_CLIENT_LIBRARY_KEY_STUB_H */ diff --git a/tst/stubs/systemd/sd-daemon-stub.c b/tst/stubs/systemd/sd-daemon-stub.c new file mode 100644 index 0000000..0c23eca --- /dev/null +++ b/tst/stubs/systemd/sd-daemon-stub.c @@ -0,0 +1,50 @@ +/* NHM - NodeHealthMonitor + * + * Implementation of stubs for the sd daemon + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +/******************************************************************************* +* +* Header includes +* +*******************************************************************************/ + +#include <gio/gio.h> +#include <systemd/sd-daemon.h> /* Header of real sd daemon */ +#include <tst/stubs/systemd/sd-daemon-stub.h> /* Header of stub sd daemon */ + +/******************************************************************************* +* +* Exported variables and constants +* +*******************************************************************************/ + +gboolean sd_notify_stub_called = FALSE; + +/******************************************************************************* +* +* Interfaces. Exported functions. +* +*******************************************************************************/ + +/** + * sd_notify_stub: + * + * Stub for sd_notify() + */ +int +sd_notify_stub(int unset_environment, + const char *state) +{ + sd_notify_stub_called = TRUE; + + return 0; +} diff --git a/tst/stubs/systemd/sd-daemon-stub.h b/tst/stubs/systemd/sd-daemon-stub.h new file mode 100644 index 0000000..dca9a5e --- /dev/null +++ b/tst/stubs/systemd/sd-daemon-stub.h @@ -0,0 +1,42 @@ +/* NHM - NodeHealthMonitor + * + * Definition of stubs for the sd daemon + * + * Author: Jean-Pierre Bogler <Jean-Pierre.Bogler@continental-corporation.com> + * + * Copyright (C) 2013 Continental Automotive Systems, Inc. + * + * This Source Code Form is subject to the terms of the Mozilla Public License, + * v. 2.0. If a copy of the MPL was not distributed with this file, You can + * obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef SD_DAEMON_STUB_H +#define SD_DAEMON_STUB_H + +/******************************************************************************* +* +* Header includes +* +*******************************************************************************/ + +#include <gio/gio.h> +#include <systemd/sd-daemon.h> /* Include header of real sd daemon */ + +/******************************************************************************* +* +* Exported variables, constants and defines +* +*******************************************************************************/ + +extern gboolean sd_notify_stub_called; + +/******************************************************************************* +* +* Exported functions +* +*******************************************************************************/ + +int sd_notify_stub(int unset_environment, const char *state); + +#endif /* SD_DAEMON_STUB_H */ |