-#include <stdio.h>
-#include <stddef.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <setjmp.h>
-#include <unistd.h>
-#include <cmocka.h>
-#include <fcntl.h>
-#include <gio/gio.h>
-#include <pkgmgr-info.h>
-
+#include "test_common.h"
#include "dumpsys-system.c"
GDBusConnection* __wrap_g_bus_get_sync(GBusType type, GCancellable *cancellable, GError **error)
return 345;
}
-GUnixFDList* __wrap_g_dbus_message_get_unix_fd_list(GDBusMessage *msg)
-{
- return mock_ptr_type(GUnixFDList*);
-}
-
int __wrap_g_unix_fd_list_get(GUnixFDList *list, int fd, GError *error)
{
check_expected(list);
return mock_type(int);
}
-gboolean __wrap_g_dbus_connection_send_message (GDBusConnection *connection,
- GDBusMessage *message,
- GDBusSendMessageFlags flags,
- volatile guint32 *out_serial,
- GError **error)
-{
- check_expected(connection);
- check_expected(flags);
- return mock_type(gboolean);
-}
-
GDBusMessage* __wrap_g_dbus_connection_send_message_with_reply_sync(GDBusConnection *conn,
- GDBusMessage *message,
- GDBusSendMessageFlags flags,
- gint timeout_msec,
- volatile guint32 *out_serial,
- GCancellable *cancellable,
- GError **error)
+ GDBusMessage *message,
+ GDBusSendMessageFlags flags,
+ gint timeout_msec,
+ volatile guint32 *out_serial,
+ GCancellable *cancellable,
+ GError **error)
{
check_expected_ptr(conn);
check_expected(flags);
g_dbus_message_set_body(test_message, test_params);
GUnixFDList *test_list1 = g_unix_fd_list_new();
+ expect_value(__wrap_g_dbus_message_get_unix_fd_list, message, test_message);
will_return(__wrap_g_dbus_message_get_unix_fd_list, test_list1);
expect_value(__wrap_g_unix_fd_list_get, list, test_list1);
will_return(__wrap_g_unix_fd_list_get, 123);
-#include <stdio.h>
-#include <stddef.h>
-#include <stdarg.h>
-#include <stdbool.h>
-#include <setjmp.h>
-#include <unistd.h>
-#include <cmocka.h>
-#include <fcntl.h>
-#include <gio/gio.h>
-#include <pkgmgr-info.h>
-
+#include "test_common.h"
#include "libdumpsys.c"
GDBusConnection* __wrap_g_bus_get_sync(GBusType bus_type, GCancellable *cancellable, GError **error)
return mock_type(GDBusMessageType);
}
-GUnixFDList* __wrap_g_dbus_message_get_unix_fd_list(GDBusMessage *message)
-{
- check_expected(message);
- return mock_type(GUnixFDList*);
-}
-
gint __wrap_g_unix_fd_list_get(GUnixFDList *list,
gint index,
GError **error)
return mock_type(gint);
}
+void setup_connection_send_message_with_reply_sync(GDBusConnection *t_connection, GDBusMessage *t_reply)
+{
+ expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, conn, t_connection);
+ expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, flags, G_DBUS_SEND_MESSAGE_FLAGS_NONE);
+ expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, timeout_msec, SERVICE_TIMEOUT_MS);
+ expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, cancellable, NULL);
+ expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, *error, NULL);
+ will_return(__wrap_g_dbus_connection_send_message_with_reply_sync, NULL);
+ will_return(__wrap_g_dbus_connection_send_message_with_reply_sync, t_reply);
+}
+
+void setup_get_sync(GDBusConnection *t_connection)
+{
+ expect_value(__wrap_g_bus_get_sync, bus_type, G_BUS_TYPE_SYSTEM);
+ expect_value(__wrap_g_bus_get_sync, cancellable, NULL);
+ expect_value(__wrap_g_bus_get_sync, *error, NULL);
+ will_return(__wrap_g_bus_get_sync, t_connection);
+}
+
void dumpsys_dump_ok(void **state)
{
static const char *t_service_name = "some.serivce.name";
expect_value(__wrap_g_bus_get_sync, *error, NULL);
will_return(__wrap_g_bus_get_sync, t_connection);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, conn, t_connection);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, flags, G_DBUS_SEND_MESSAGE_FLAGS_NONE);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, timeout_msec, SERVICE_TIMEOUT_MS);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, cancellable, NULL);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, *error, NULL);
- will_return(__wrap_g_dbus_connection_send_message_with_reply_sync, NULL);
- will_return(__wrap_g_dbus_connection_send_message_with_reply_sync, t_reply);
+ setup_connection_send_message_with_reply_sync(t_connection, t_reply);
expect_value(__wrap_g_dbus_message_get_message_type, message, t_reply);
will_return(__wrap_g_dbus_message_get_message_type, G_DBUS_MESSAGE_TYPE_METHOD_RETURN);
will_return(__wrap_g_dbus_connection_send_message_with_reply_sync, g_error_new(1, 2, "error")); // some error
will_return(__wrap_g_dbus_connection_send_message_with_reply_sync, t_reply);
-
-
expect_value(__wrap_g_dbus_message_get_message_type, message, t_reply);
will_return(__wrap_g_dbus_message_get_message_type, G_DBUS_MESSAGE_TYPE_METHOD_RETURN);
g_dbus_message_set_unix_fd_list(t_reply, t_fd_list);
int t_out_fd;
- expect_value(__wrap_g_bus_get_sync, bus_type, G_BUS_TYPE_SYSTEM);
- expect_value(__wrap_g_bus_get_sync, cancellable, NULL);
- expect_value(__wrap_g_bus_get_sync, *error, NULL);
- will_return(__wrap_g_bus_get_sync, t_connection);
+ setup_get_sync(t_connection);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, conn, t_connection);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, flags, G_DBUS_SEND_MESSAGE_FLAGS_NONE);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, timeout_msec, SERVICE_TIMEOUT_MS);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, cancellable, NULL);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, *error, NULL);
- will_return(__wrap_g_dbus_connection_send_message_with_reply_sync, NULL);
- will_return(__wrap_g_dbus_connection_send_message_with_reply_sync, t_reply);
+ setup_connection_send_message_with_reply_sync(t_connection, t_reply);
expect_value(__wrap_g_dbus_message_get_message_type, message, t_reply);
will_return(__wrap_g_dbus_message_get_message_type, G_DBUS_MESSAGE_TYPE_METHOD_RETURN);
g_dbus_message_set_unix_fd_list(t_reply, t_fd_list);
int t_out_fd;
- expect_value(__wrap_g_bus_get_sync, bus_type, G_BUS_TYPE_SYSTEM);
- expect_value(__wrap_g_bus_get_sync, cancellable, NULL);
- expect_value(__wrap_g_bus_get_sync, *error, NULL);
- will_return(__wrap_g_bus_get_sync, t_connection);
+ setup_get_sync(t_connection);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, conn, t_connection);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, flags, G_DBUS_SEND_MESSAGE_FLAGS_NONE);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, timeout_msec, SERVICE_TIMEOUT_MS);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, cancellable, NULL);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, *error, NULL);
- will_return(__wrap_g_dbus_connection_send_message_with_reply_sync, NULL);
- will_return(__wrap_g_dbus_connection_send_message_with_reply_sync, t_reply);
+ setup_connection_send_message_with_reply_sync(t_connection, t_reply);
expect_value(__wrap_g_dbus_message_get_message_type, message, t_reply);
will_return(__wrap_g_dbus_message_get_message_type, G_DBUS_MESSAGE_TYPE_METHOD_RETURN);
g_dbus_message_set_unix_fd_list(t_reply, t_fd_list);
int t_out_fd;
- expect_value(__wrap_g_bus_get_sync, bus_type, G_BUS_TYPE_SYSTEM);
- expect_value(__wrap_g_bus_get_sync, cancellable, NULL);
- expect_value(__wrap_g_bus_get_sync, *error, NULL);
- will_return(__wrap_g_bus_get_sync, t_connection);
+ setup_get_sync(t_connection);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, conn, t_connection);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, flags, G_DBUS_SEND_MESSAGE_FLAGS_NONE);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, timeout_msec, SERVICE_TIMEOUT_MS);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, cancellable, NULL);
- expect_value(__wrap_g_dbus_connection_send_message_with_reply_sync, *error, NULL);
- will_return(__wrap_g_dbus_connection_send_message_with_reply_sync, NULL);
- will_return(__wrap_g_dbus_connection_send_message_with_reply_sync, t_reply);
+ setup_connection_send_message_with_reply_sync(t_connection, t_reply);
expect_value(__wrap_g_dbus_message_get_message_type, message, t_reply);
will_return(__wrap_g_dbus_message_get_message_type, G_DBUS_MESSAGE_TYPE_METHOD_RETURN);