Fix codding style 98/245098/1
authorKonrad Kuchciak <k.kuchciak@samsung.com>
Thu, 1 Oct 2020 13:27:13 +0000 (15:27 +0200)
committerKonrad Kuchciak <k.kuchciak@samsung.com>
Thu, 1 Oct 2020 13:28:18 +0000 (15:28 +0200)
Change-Id: Ia08ab4e5d442c8654dd59ab9ec79c184a0bd96da
Signed-off-by: Konrad Kuchciak <k.kuchciak@samsung.com>
18 files changed:
src/library/dbus.c
src/library/dbus.h
src/library/diagnostics.c
src/library/signal.c
src/library/signal.h
src/test/CMakeLists.txt
src/test/test_diagnostics.h
src/test/test_diagnostics_add_function_defs.h
src/test/test_diagnostics_create.c
src/test/test_diagnostics_data_create.c
src/test/test_diagnostics_data_read.c
src/test/test_diagnostics_destroy.c
src/test/test_diagnostics_get_client_id.c
src/test/test_diagnostics_get_data.c
src/test/test_diagnostics_get_report_path.c
src/test/test_diagnostics_request_client_data.c
src/test/test_diagnostics_set_notification_cb.c
src/test/test_diagnostics_signal_handler.c

index 527b5fa..d0fdc64 100644 (file)
@@ -1,18 +1,18 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright (c) 2020 Samsung Electronics Co., Ltd.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
 
 #include <stdlib.h>
 
@@ -23,171 +23,171 @@ static int subscription_id = 0;
 
 static GDBusConnection *dbus_connect()
 {
-    GDBusConnection *conn;
-    GError *err = NULL;
+       GDBusConnection *conn;
+       GError *err = NULL;
 
-    conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
-    if (!conn) {
-        _E("Unable to connect to system bus: %s", err->message);
-        g_error_free(err);
-        return NULL;
-    }
+       conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+       if (!conn) {
+               _E("Unable to connect to system bus: %s", err->message);
+               g_error_free(err);
+               return NULL;
+       }
 
-    return conn;
+       return conn;
 }
 
 MOCKABLE_FOR_TESTS
 int dbus_subscribe(void (*signal_handler)(GDBusConnection *,
-                                          const gchar *,
-                                          const gchar *,
-                                          const gchar *,
-                                          const gchar *,
-                                          GVariant *,
-                                          gpointer))
+                                                                                 const gchar *,
+                                                                                 const gchar *,
+                                                                                 const gchar *,
+                                                                                 const gchar *,
+                                                                                 GVariant *,
+                                                                                 gpointer))
 {
-    GDBusConnection *conn = dbus_connect();
-    int ret;
-
-    if (!conn)
-        return -1;
-
-    ret = g_dbus_connection_signal_subscribe(conn,
-                                             NULL,
-                                             NULL,
-                                             DBUS_MEMBER_CRASH,
-                                             NULL,
-                                             NULL,
-                                             G_DBUS_SIGNAL_FLAGS_NONE,
-                                             signal_handler,
-                                             NULL,
-                                             NULL);
-    if (ret == FALSE) {
-        _E("Unable to subscribe to crash signal");
-        return -EIO;
-    }
-
-    subscription_id = ret;
-
-    return 0;
+       GDBusConnection *conn = dbus_connect();
+       int ret;
+
+       if (!conn)
+               return -1;
+
+       ret = g_dbus_connection_signal_subscribe(conn,
+                                                                                        NULL,
+                                                                                        NULL,
+                                                                                        DBUS_MEMBER_CRASH,
+                                                                                        NULL,
+                                                                                        NULL,
+                                                                                        G_DBUS_SIGNAL_FLAGS_NONE,
+                                                                                        signal_handler,
+                                                                                        NULL,
+                                                                                        NULL);
+       if (ret == FALSE) {
+               _E("Unable to subscribe to crash signal");
+               return -EIO;
+       }
+
+       subscription_id = ret;
+
+       return 0;
 }
 
 void dbus_unsubscribe(void)
 {
-    GDBusConnection *conn = dbus_connect();
+       GDBusConnection *conn = dbus_connect();
 
-    if (!conn)
-        return;
+       if (!conn)
+               return;
 
-    if (subscription_id)
-        g_dbus_connection_signal_unsubscribe(conn, subscription_id);
+       if (subscription_id)
+               g_dbus_connection_signal_unsubscribe(conn, subscription_id);
 
-    subscription_id = 0;
+       subscription_id = 0;
 }
 
 MOCKABLE_FOR_TESTS
 int dbus_get_file_from_report(const char *report_path, const int entry, int *fd)
 {
-    GDBusConnection *conn = dbus_connect();
-    GDBusMessage *message = NULL;
-    GDBusMessage *reply = NULL;
-    GVariant *parameters = NULL;
-    GUnixFDList *fd_list = NULL;
-    GError *error = NULL;
-    int fd_out = -1;
-    int ret = -1;
-
-    if (!conn)
-        goto finish;
-
-    message = g_dbus_message_new_method_call(DBUS_BUS_NAME,
-                                             DBUS_OBJECT_PATH,
-                                             DBUS_INTERFACE_NAME,
-                                             DBUS_METHOD_GET_FILE);
-    parameters = g_variant_new("(si)", report_path, entry);
-    g_dbus_message_set_body(message, parameters);
-
-    reply = g_dbus_connection_send_message_with_reply_sync(conn,
-                message,
-                G_DBUS_SEND_MESSAGE_FLAGS_NONE,
-                10000,
-                NULL,
-                NULL,
-                &error);
-
-    // _D("MESSAGE: \n%s", g_dbus_message_print(message, 4));
-    // _D("REPLY: \n%s", g_dbus_message_print(reply, 4));
-
-    if (reply != NULL && g_dbus_message_get_message_type(reply) == G_DBUS_MESSAGE_TYPE_ERROR)
-        g_dbus_message_to_gerror(reply, &error);
-
-    if (error != NULL) {
-        _E("Send message error: %s\n", error ? error->message : "unknown error");
-        ret = error->code == G_DBUS_ERROR_ACCESS_DENIED ? -EACCES : -1;
-        goto finish;
-    }
-
-    fd_list = g_dbus_message_get_unix_fd_list(reply);
-    if (!fd_list) {
-        _E("Method call get_file() haven't returned file descriptor");
-        ret = -1;
-        goto finish;
-    }
-
-    fd_out = g_unix_fd_list_get(fd_list, 0, &error);
-    if (fd_out == -1 || error) {
-        _E("g_unix_fd_list_get() failed: %s", error ? error->message : "");
-        ret = -1;
-        goto finish;
-    }
-
-    ret = 0;
+       GDBusConnection *conn = dbus_connect();
+       GDBusMessage *message = NULL;
+       GDBusMessage *reply = NULL;
+       GVariant *parameters = NULL;
+       GUnixFDList *fd_list = NULL;
+       GError *error = NULL;
+       int fd_out = -1;
+       int ret = -1;
+
+       if (!conn)
+               goto finish;
+
+       message = g_dbus_message_new_method_call(DBUS_BUS_NAME,
+                                                                                       DBUS_OBJECT_PATH,
+                                                                                       DBUS_INTERFACE_NAME,
+                                                                                       DBUS_METHOD_GET_FILE);
+       parameters = g_variant_new("(si)", report_path, entry);
+       g_dbus_message_set_body(message, parameters);
+
+       reply = g_dbus_connection_send_message_with_reply_sync(conn,
+                               message,
+                               G_DBUS_SEND_MESSAGE_FLAGS_NONE,
+                               10000,
+                               NULL,
+                               NULL,
+                               &error);
+
+       // _D("MESSAGE: \n%s", g_dbus_message_print(message, 4));
+       // _D("REPLY: \n%s", g_dbus_message_print(reply, 4));
+
+       if (reply != NULL && g_dbus_message_get_message_type(reply) == G_DBUS_MESSAGE_TYPE_ERROR)
+               g_dbus_message_to_gerror(reply, &error);
+
+       if (error != NULL) {
+               _E("Send message error: %s\n", error ? error->message : "unknown error");
+               ret = error->code == G_DBUS_ERROR_ACCESS_DENIED ? -EACCES : -1;
+               goto finish;
+       }
+
+       fd_list = g_dbus_message_get_unix_fd_list(reply);
+       if (!fd_list) {
+               _E("Method call get_file() haven't returned file descriptor");
+               ret = -1;
+               goto finish;
+       }
+
+       fd_out = g_unix_fd_list_get(fd_list, 0, &error);
+       if (fd_out == -1 || error) {
+               _E("g_unix_fd_list_get() failed: %s", error ? error->message : "");
+               ret = -1;
+               goto finish;
+       }
+
+       ret = 0;
 
 finish:
-    *fd = fd_out;
-    if (parameters)
-        g_variant_unref(parameters);
-    if (message)
-        g_object_unref(message);
-    if (reply)
-        g_object_unref(reply);
-    if (error)
-        g_error_free(error);
-    return ret;
+       *fd = fd_out;
+       if (parameters)
+               g_variant_unref(parameters);
+       if (message)
+               g_object_unref(message);
+       if (reply)
+               g_object_unref(reply);
+       if (error)
+               g_error_free(error);
+       return ret;
 }
 
 struct dbus_signal_s *dbus_signal_create(const gchar *sender_name,
-                                         const gchar *object_path,
-                                         const gchar *interface_name,
-                                         const gchar *signal_name,
-                                         GVariant *parameters)
+                                                                               const gchar *object_path,
+                                                                               const gchar *interface_name,
+                                                                               const gchar *signal_name,
+                                                                               GVariant *parameters)
 {
-    struct dbus_signal_s *signal;
-
-    signal = calloc(1, sizeof(struct dbus_signal_s));
-    if (!signal) {
-        _E("Unable to allocate memory");
-        return NULL;
-    }
-
-    signal->sender_name = g_strdup(sender_name);
-    signal->object_path = g_strdup(object_path);
-    signal->interface_name = g_strdup(interface_name);
-    signal->signal_name = g_strdup(signal_name);
-    signal->parameters = parameters;
-    g_variant_ref(signal->parameters);
-
-    return signal;
+       struct dbus_signal_s *signal;
+
+       signal = calloc(1, sizeof(struct dbus_signal_s));
+       if (!signal) {
+               _E("Unable to allocate memory");
+               return NULL;
+       }
+
+       signal->sender_name = g_strdup(sender_name);
+       signal->object_path = g_strdup(object_path);
+       signal->interface_name = g_strdup(interface_name);
+       signal->signal_name = g_strdup(signal_name);
+       signal->parameters = parameters;
+       g_variant_ref(signal->parameters);
+
+       return signal;
 }
 
 void dbus_signal_cleanup(struct dbus_signal_s *signal)
 {
-    if (!signal)
-        return;
-
-    g_free(signal->sender_name);
-    g_free(signal->object_path);
-    g_free(signal->interface_name);
-    g_free(signal->signal_name);
-    g_variant_unref(signal->parameters);
-    free(signal);
+       if (!signal)
+               return;
+
+       g_free(signal->sender_name);
+       g_free(signal->object_path);
+       g_free(signal->interface_name);
+       g_free(signal->signal_name);
+       g_variant_unref(signal->parameters);
+       free(signal);
 }
index 69c454a..da0b0cb 100644 (file)
@@ -1,18 +1,18 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright (c) 2020 Samsung Electronics Co., Ltd.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
 
 #ifndef __DBUS_H__
 #define __DBUS_H__
 #endif
 
 struct dbus_signal_s {
-    gchar *sender_name;
-    gchar *object_path;
-    gchar *interface_name;
-    gchar *signal_name;
-    GVariant *parameters;
+       gchar *sender_name;
+       gchar *object_path;
+       gchar *interface_name;
+       gchar *signal_name;
+       GVariant *parameters;
 };
 
 int dbus_subscribe(void (*signal_handler)(GDBusConnection *,
-                                          const gchar *,
-                                          const gchar *,
-                                          const gchar *,
-                                          const gchar *,
-                                          GVariant *,
-                                          gpointer));
+                                                                                 const gchar *,
+                                                                                 const gchar *,
+                                                                                 const gchar *,
+                                                                                 const gchar *,
+                                                                                 GVariant *,
+                                                                                 gpointer));
 void dbus_unsubscribe(void);
 int dbus_get_file_from_report(const char *report_path, const int entry, int *fd);
 struct dbus_signal_s *dbus_signal_create(const gchar *sender_name,
-                                         const gchar *object_path,
-                                         const gchar *interface_name,
-                                         const gchar *signal_name,
-                                         GVariant *parameters);
+                                                                                const gchar *object_path,
+                                                                                const gchar *interface_name,
+                                                                                const gchar *signal_name,
+                                                                                GVariant *parameters);
 void dbus_signal_cleanup(struct dbus_signal_s *signal);
 
 #endif /* __DBUS_H__ */
index 8d5394f..e9dc515 100644 (file)
@@ -1,18 +1,18 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright (c) 2020 Samsung Electronics Co., Ltd.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
 
 #include <diagnostics.h>
 #include <stdlib.h>
@@ -27,7 +27,8 @@
 #include "dbus.h"
 
 #ifndef STATIC
-#define STATIC static
+#define STATIC
+       static
 #endif
 
 #define DIAGNOSTICS_FEATURE "http://tizen.org/feature/diagnostics"
 #define FEATURE_TRUE     1
 
 STATIC struct _diagnostics_cb_info_s {
-    diagnostics_notification_cb cb;
-    void *user_data;
+       diagnostics_notification_cb cb;
+       void *user_data;
 } cb_info = {
-    NULL,
-    NULL
+       NULL,
+       NULL
 };
 
 struct _diagnostics_ctx_s {
-    char *client_id;
-    struct dbus_signal_s *signal;
-    signal_type_e signal_type;
+       char *client_id;
+       struct dbus_signal_s *signal;
+       signal_type_e signal_type;
 };
 
 struct _diagnostics_data_s {
-    int fd;
+       int fd;
 };
 
 STATIC int diagnostics_feature = FEATURE_UNKNOWN;
 
 STATIC bool __is_feature_supported(void)
 {
-    int ret = SYSTEM_INFO_ERROR_NONE;
-    bool feature = false;
+       int ret = SYSTEM_INFO_ERROR_NONE;
+       bool feature = false;
 
-    if (diagnostics_feature == FEATURE_UNKNOWN) {
-        ret = system_info_get_platform_bool(DIAGNOSTICS_FEATURE, &feature);
-        RETVM_IF(ret != SYSTEM_INFO_ERROR_NONE, false, "Failed to get system info");
+       if (diagnostics_feature == FEATURE_UNKNOWN) {
+               ret = system_info_get_platform_bool(DIAGNOSTICS_FEATURE, &feature);
+               RETVM_IF(ret != SYSTEM_INFO_ERROR_NONE, false, "Failed to get system info");
 
-        diagnostics_feature = (feature ? FEATURE_TRUE : FEATURE_FALSE);
-    }
+               diagnostics_feature = (feature ? FEATURE_TRUE : FEATURE_FALSE);
+       }
 
-    return (diagnostics_feature == FEATURE_TRUE ? true : false);
+       return (diagnostics_feature == FEATURE_TRUE ? true : false);
 }
 
 STATIC struct _diagnostics_ctx_s *diagnostics_create(struct dbus_signal_s *signal)
 {
-    RETV_IF(signal == NULL, NULL);
-
-    struct _diagnostics_ctx_s *ctx;
-
-    ctx = calloc(1, sizeof(struct _diagnostics_ctx_s));
-    if (!ctx) {
-        _E("Unable to allocate memory");
-        return NULL;
-    }
-
-    if (signal->signal_name && strcmp(signal->signal_name, DBUS_MEMBER_CRASH) == 0) {
-        ctx->client_id = DBUS_SENDER_CRASH;
-        ctx->signal_type = signal_is_valid_crash(signal) ? SIG_TYPE_CRASH : SIG_TYPE_INVALID;
-    } else {
-        _E("Unknown signal name");
-        free(ctx);
-        return NULL;
-    }
-
-    ctx->signal = signal;
-    return ctx;
+       RETV_IF(signal == NULL, NULL);
+
+       struct _diagnostics_ctx_s *ctx;
+
+       ctx = calloc(1, sizeof(struct _diagnostics_ctx_s));
+       if (!ctx) {
+               _E("Unable to allocate memory");
+               return NULL;
+       }
+
+       if (signal->signal_name && strcmp(signal->signal_name, DBUS_MEMBER_CRASH) == 0) {
+               ctx->client_id = DBUS_SENDER_CRASH;
+               ctx->signal_type = signal_is_valid_crash(signal) ? SIG_TYPE_CRASH : SIG_TYPE_INVALID;
+       } else {
+               _E("Unknown signal name");
+               free(ctx);
+               return NULL;
+       }
+
+       ctx->signal = signal;
+       return ctx;
 }
 
 STATIC struct _diagnostics_data_s *diagnostics_data_create(int fd)
 {
-    RETV_IF(fd < 0, NULL);
+       RETV_IF(fd < 0, NULL);
 
-    struct _diagnostics_data_s *data;
+       struct _diagnostics_data_s *data;
 
-    data = calloc(1, sizeof(struct _diagnostics_data_s));
-    if (!data) {
-        _E("Unable to allocate memory");
-        return NULL;
-    }
+       data = calloc(1, sizeof(struct _diagnostics_data_s));
+       if (!data) {
+               _E("Unable to allocate memory");
+               return NULL;
+       }
 
-    data->fd = fd;
-    return data;
+       data->fd = fd;
+       return data;
 }
 
 STATIC void signal_handler(GDBusConnection *connection,
-                           const gchar *sender_name,
-                           const gchar *object_path,
-                           const gchar *interface_name,
-                           const gchar *signal_name,
-                           GVariant *parameters,
-                           gpointer user_data)
+                                               const gchar *sender_name,
+                                               const gchar *object_path,
+                                               const gchar *interface_name,
+                                               const gchar *signal_name,
+                                               GVariant *parameters,
+                                               gpointer user_data)
 {
-    struct _diagnostics_ctx_s *ctx;
-    struct dbus_signal_s *signal;
-
-    _D("signal_handler");
-    _D("parameters: %s", g_variant_print(parameters, TRUE));
-
-    if (!cb_info.cb) {
-        _E("No user cb set");
-        return;
-    }
-
-    _D("dbus_signal_create");
-    signal = dbus_signal_create(sender_name,
-                                object_path,
-                                interface_name,
-                                signal_name,
-                                parameters);
-    if (!signal) {
-        _E("Unable to create signal structure");
-        return;
-    }
-
-    _D("diagnostics_create");
-    ctx = diagnostics_create(signal);
-    if (!ctx) {
-        _E("Unable to create diagnostics context");
-        dbus_signal_cleanup(signal);
-        return;
-    }
-
-    _D("Fireing user cb!");
-    cb_info.cb(ctx, cb_info.user_data);
+       struct _diagnostics_ctx_s *ctx;
+       struct dbus_signal_s *signal;
+
+       _D("signal_handler");
+       _D("parameters: %s", g_variant_print(parameters, TRUE));
+
+       if (!cb_info.cb) {
+               _E("No user cb set");
+               return;
+       }
+
+       _D("dbus_signal_create");
+       signal = dbus_signal_create(sender_name,
+                                                               object_path,
+                                                               interface_name,
+                                                               signal_name,
+                                                               parameters);
+       if (!signal) {
+               _E("Unable to create signal structure");
+               return;
+       }
+
+       _D("diagnostics_create");
+       ctx = diagnostics_create(signal);
+       if (!ctx) {
+               _E("Unable to create diagnostics context");
+               dbus_signal_cleanup(signal);
+               return;
+       }
+
+       _D("Fireing user cb!");
+       cb_info.cb(ctx, cb_info.user_data);
 }
 
 int diagnostics_set_notification_cb(diagnostics_notification_cb callback, void *user_data)
 {
-    RETVM_IF(__is_feature_supported() == false, DIAGNOSTICS_ERROR_NOT_SUPPORTED, "Diagnostics feature is not supported");
-    RETV_IF(callback == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
+       RETVM_IF(__is_feature_supported() == false, DIAGNOSTICS_ERROR_NOT_SUPPORTED, "Diagnostics feature is not supported");
+       RETV_IF(callback == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
 
-    int ret;
+       int ret;
 
-    _D("diagnostics_set_notification_cb()");
+       _D("diagnostics_set_notification_cb()");
 
-    if (cb_info.cb) {
-        _E("Callback has already been set");
-        return DIAGNOSTICS_ERROR_RESOURCE_BUSY;
-    }
+       if (cb_info.cb) {
+               _E("Callback has already been set");
+               return DIAGNOSTICS_ERROR_RESOURCE_BUSY;
+       }
 
-    ret = dbus_subscribe(signal_handler);
-    if (ret) {
-        _E("Unable to subscribe to dbus signals");
-        return DIAGNOSTICS_ERROR_IO_ERROR;
-    }
+       ret = dbus_subscribe(signal_handler);
+       if (ret) {
+               _E("Unable to subscribe to dbus signals");
+               return DIAGNOSTICS_ERROR_IO_ERROR;
+       }
 
-    cb_info.cb = callback;
-    cb_info.user_data = user_data;
+       cb_info.cb = callback;
+       cb_info.user_data = user_data;
 
-    return DIAGNOSTICS_ERROR_NONE;
+       return DIAGNOSTICS_ERROR_NONE;
 }
 
 int diagnostics_unset_notification_cb(void)
 {
-    RETVM_IF(__is_feature_supported() == false, DIAGNOSTICS_ERROR_NOT_SUPPORTED, "Diagnostics feature is not supported");
+       RETVM_IF(__is_feature_supported() == false, DIAGNOSTICS_ERROR_NOT_SUPPORTED, "Diagnostics feature is not supported");
 
-    _D("diagnostics_unset_notification_cb()");
+       _D("diagnostics_unset_notification_cb()");
 
-    cb_info.cb = NULL;
-    cb_info.user_data = NULL;
+       cb_info.cb = NULL;
+       cb_info.user_data = NULL;
 
-    dbus_unsubscribe();
-    return DIAGNOSTICS_ERROR_NONE;
+       dbus_unsubscribe();
+       return DIAGNOSTICS_ERROR_NONE;
 }
 
 int diagnostics_request_client_data(const char *client_id, const char **params, int params_size, diagnostics_data_h *data)
 {
-    RETVM_IF(__is_feature_supported() == false, DIAGNOSTICS_ERROR_NOT_SUPPORTED, "Diagnostics feature is not supported");
-    RETV_IF(client_id == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
-    RETV_IF(params_size < 0, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
-    RETV_IF(data == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
-
-    int fd = -1;
-    int ret;
-
-    ret = dumpsys_dump(client_id, params_size, params, &fd);
-    if (ret != DIAGNOSTICS_ERROR_NONE) {
-        _E("dumpsys_dump() failed: %d", ret);
-        if (ret == TIZEN_ERROR_PERMISSION_DENIED)
-            return DIAGNOSTICS_ERROR_PERMISSION_DENIED;
-        return DIAGNOSTICS_ERROR_IO_ERROR;
-    }
-
-    *data = diagnostics_data_create(fd);
-    if (*data == NULL) {
-        _E("Unable to create diagnostics_data");
-        return DIAGNOSTICS_ERROR_OUT_OF_MEMORY;
-    }
-
-    return DIAGNOSTICS_ERROR_NONE;
+       RETVM_IF(__is_feature_supported() == false, DIAGNOSTICS_ERROR_NOT_SUPPORTED, "Diagnostics feature is not supported");
+       RETV_IF(client_id == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
+       RETV_IF(params_size < 0, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
+       RETV_IF(data == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
+
+       int fd = -1;
+       int ret;
+
+       ret = dumpsys_dump(client_id, params_size, params, &fd);
+       if (ret != DIAGNOSTICS_ERROR_NONE) {
+               _E("dumpsys_dump() failed: %d", ret);
+               if (ret == TIZEN_ERROR_PERMISSION_DENIED)
+                       return DIAGNOSTICS_ERROR_PERMISSION_DENIED;
+               return DIAGNOSTICS_ERROR_IO_ERROR;
+       }
+
+       *data = diagnostics_data_create(fd);
+       if (*data == NULL) {
+               _E("Unable to create diagnostics_data");
+               return DIAGNOSTICS_ERROR_OUT_OF_MEMORY;
+       }
+
+       return DIAGNOSTICS_ERROR_NONE;
 }
 
 int diagnostics_data_read(diagnostics_data_h data, void *buf, size_t count, int timeout_ms, size_t *bytes_read)
 {
-    RETVM_IF(__is_feature_supported() == false, DIAGNOSTICS_ERROR_NOT_SUPPORTED, "Diagnostics feature is not supported");
-    RETV_IF(data == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
-    RETV_IF(buf == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
-    RETV_IF(bytes_read == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
-
-    struct pollfd poll_fd;
-    int ready;
-    int ret;
-
-    poll_fd.fd = ((struct _diagnostics_data_s *)data)->fd;
-    poll_fd.events = POLLIN;
-
-    ready = poll(&poll_fd, 1, timeout_ms <= 0 ? -1 : timeout_ms);
-
-    if (ready == 0) {
-        _E("poll() timeout");
-        return DIAGNOSTICS_ERROR_TIMED_OUT;
-    }
-
-    if (ready < 0) {
-        _E("poll() failed: %m");
-        return DIAGNOSTICS_ERROR_IO_ERROR;
-    }
-
-    if (poll_fd.revents & POLLIN) {
-        ret = read(poll_fd.fd, buf, count);
-        if (ret < 0) {
-            _E("read() failed: %m, fd: %d", poll_fd.fd);
-            if (errno == EAGAIN)
-                return DIAGNOSTICS_ERROR_TRY_AGAIN;
-            return DIAGNOSTICS_ERROR_IO_ERROR;
-        }
-        *bytes_read = ret;
-        return DIAGNOSTICS_ERROR_NONE;
-    } else if (poll_fd.revents & POLLHUP) {
-        *bytes_read = 0;
-        return DIAGNOSTICS_ERROR_NONE;
-    }
-
-    _E("received event: %d", poll_fd.revents);
-    return DIAGNOSTICS_ERROR_IO_ERROR;
+       RETVM_IF(__is_feature_supported() == false, DIAGNOSTICS_ERROR_NOT_SUPPORTED, "Diagnostics feature is not supported");
+       RETV_IF(data == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
+       RETV_IF(buf == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
+       RETV_IF(bytes_read == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
+
+       struct pollfd poll_fd;
+       int ready;
+       int ret;
+
+       poll_fd.fd = ((struct _diagnostics_data_s *)data)->fd;
+       poll_fd.events = POLLIN;
+
+       ready = poll(&poll_fd, 1, timeout_ms <= 0 ? -1 : timeout_ms);
+
+       if (ready == 0) {
+               _E("poll() timeout");
+               return DIAGNOSTICS_ERROR_TIMED_OUT;
+       }
+
+       if (ready < 0) {
+               _E("poll() failed: %m");
+               return DIAGNOSTICS_ERROR_IO_ERROR;
+       }
+
+       if (poll_fd.revents & POLLIN) {
+               ret = read(poll_fd.fd, buf, count);
+               if (ret < 0) {
+                       _E("read() failed: %m, fd: %d", poll_fd.fd);
+                       if (errno == EAGAIN)
+                               return DIAGNOSTICS_ERROR_TRY_AGAIN;
+                       return DIAGNOSTICS_ERROR_IO_ERROR;
+               }
+               *bytes_read = ret;
+               return DIAGNOSTICS_ERROR_NONE;
+       } else if (poll_fd.revents & POLLHUP) {
+               *bytes_read = 0;
+               return DIAGNOSTICS_ERROR_NONE;
+       }
+
+       _E("received event: %d", poll_fd.revents);
+       return DIAGNOSTICS_ERROR_IO_ERROR;
 }
 
 int diagnostics_get_client_id(diagnostics_ctx_h ctx, char **client_id)
 {
-    RETVM_IF(__is_feature_supported() == false, DIAGNOSTICS_ERROR_NOT_SUPPORTED, "Diagnostics feature is not supported");
-    RETV_IF(ctx == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
-    RETV_IF(client_id == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
+       RETVM_IF(__is_feature_supported() == false, DIAGNOSTICS_ERROR_NOT_SUPPORTED, "Diagnostics feature is not supported");
+       RETV_IF(ctx == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
+       RETV_IF(client_id == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
 
-    *client_id = strdup(((struct _diagnostics_ctx_s *)ctx)->client_id);
+       *client_id = strdup(((struct _diagnostics_ctx_s *)ctx)->client_id);
 
-    return DIAGNOSTICS_ERROR_NONE;
+       return DIAGNOSTICS_ERROR_NONE;
 }
 
 STATIC int get_report_path(diagnostics_ctx_h ctx, const char **path, size_t *len)
 {
-    RETV_IF(ctx == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
-    RETV_IF(path == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
-    RETV_IF(((struct _diagnostics_ctx_s *)ctx)->signal_type != SIG_TYPE_CRASH, DIAGNOSTICS_ERROR_NOT_SUPPORTED);
+       RETV_IF(ctx == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
+       RETV_IF(path == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
+       RETV_IF(((struct _diagnostics_ctx_s *)ctx)->signal_type != SIG_TYPE_CRASH, DIAGNOSTICS_ERROR_NOT_SUPPORTED);
 
-    GVariant *val;
+       GVariant *val;
 
-    val = g_variant_get_child_value(((struct _diagnostics_ctx_s *)ctx)->signal->parameters, SIG_CRASH_REPORTPATH);
-    *path = g_variant_get_string(val, (gsize *)len);
+       val = g_variant_get_child_value(((struct _diagnostics_ctx_s *)ctx)->signal->parameters, SIG_CRASH_REPORTPATH);
+       *path = g_variant_get_string(val, (gsize *)len);
 
-    return DIAGNOSTICS_ERROR_NONE;
+       return DIAGNOSTICS_ERROR_NONE;
 }
 
 int diagnostics_get_data(diagnostics_ctx_h ctx, const char **params, int params_size, diagnostics_data_h *data)
 {
-    RETVM_IF(__is_feature_supported() == false, DIAGNOSTICS_ERROR_NOT_SUPPORTED, "Diagnostics feature is not supported");
-    RETV_IF(ctx == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
-    RETV_IF(params_size < 0, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
-    RETV_IF(data == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
-    RETV_IF(((struct _diagnostics_ctx_s *)ctx)->signal_type != SIG_TYPE_CRASH, DIAGNOSTICS_ERROR_NOT_SUPPORTED);
-
-    const char *report_path;
-    size_t len;
-    int report_id;
-    int fd;
-    int ret;
-
-    /*
-     * TODO: Make this suitable for supporting other clients, not just crash-worker
-     */
-
-    ret = get_report_path(((struct _diagnostics_ctx_s *)ctx), &report_path, &len);
-    if (ret) {
-        _E("diagnostics_get_report_path() failed: %d", ret);
-        return DIAGNOSTICS_ERROR_IO_ERROR;
-    }
-
-    if (params_size < 1)
-        return DIAGNOSTICS_ERROR_NOT_SUPPORTED;
-
-    if (strcmp(params[0], "cs_full") == 0)
-        report_id = 0;
-    else if (strcmp(params[0], "cs_info_json") == 0)
-        report_id = 1;
-    else {
-        _E("Unsupported parameter: %s", params[0]);
-        return DIAGNOSTICS_ERROR_NOT_SUPPORTED;
-    }
-
-    ret = dbus_get_file_from_report(report_path, report_id, &fd);
-    if (ret) {
-        _E("dbus_get_file_from_report() failed: %d", ret);
-        if (ret == -EACCES)
-            return DIAGNOSTICS_ERROR_PERMISSION_DENIED;
-        return DIAGNOSTICS_ERROR_IO_ERROR;
-    }
-
-    *data = diagnostics_data_create(fd);
-    if (*data == NULL) {
-        _E("Unable to create diagnostics_data");
-        close(fd);
-        return DIAGNOSTICS_ERROR_OUT_OF_MEMORY;
-    }
-
-    return DIAGNOSTICS_ERROR_NONE;
+       RETVM_IF(__is_feature_supported() == false, DIAGNOSTICS_ERROR_NOT_SUPPORTED, "Diagnostics feature is not supported");
+       RETV_IF(ctx == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
+       RETV_IF(params_size < 0, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
+       RETV_IF(data == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
+       RETV_IF(((struct _diagnostics_ctx_s *)ctx)->signal_type != SIG_TYPE_CRASH, DIAGNOSTICS_ERROR_NOT_SUPPORTED);
+
+       const char *report_path;
+       size_t len;
+       int report_id;
+       int fd;
+       int ret;
+
+       /*
+       * TODO: Make this suitable for supporting other clients, not just crash-worker
+       */
+
+       ret = get_report_path(((struct _diagnostics_ctx_s *)ctx), &report_path, &len);
+       if (ret) {
+               _E("diagnostics_get_report_path() failed: %d", ret);
+               return DIAGNOSTICS_ERROR_IO_ERROR;
+       }
+
+       if (params_size < 1)
+               return DIAGNOSTICS_ERROR_NOT_SUPPORTED;
+
+       if (strcmp(params[0], "cs_full") == 0)
+               report_id = 0;
+       else if (strcmp(params[0], "cs_info_json") == 0)
+               report_id = 1;
+       else {
+               _E("Unsupported parameter: %s", params[0]);
+               return DIAGNOSTICS_ERROR_NOT_SUPPORTED;
+       }
+
+       ret = dbus_get_file_from_report(report_path, report_id, &fd);
+       if (ret) {
+               _E("dbus_get_file_from_report() failed: %d", ret);
+               if (ret == -EACCES)
+                       return DIAGNOSTICS_ERROR_PERMISSION_DENIED;
+               return DIAGNOSTICS_ERROR_IO_ERROR;
+       }
+
+       *data = diagnostics_data_create(fd);
+       if (*data == NULL) {
+               _E("Unable to create diagnostics_data");
+               close(fd);
+               return DIAGNOSTICS_ERROR_OUT_OF_MEMORY;
+       }
+
+       return DIAGNOSTICS_ERROR_NONE;
 }
 
-int diagnostics_destroy(diagnostics_ctx_h ctx) {
-    RETV_IF(ctx == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
+int diagnostics_destroy(diagnostics_ctx_h ctx)
+{
+       RETV_IF(ctx == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
 
-    dbus_signal_cleanup(((struct _diagnostics_ctx_s *)ctx)->signal);
-    free(ctx);
+       dbus_signal_cleanup(((struct _diagnostics_ctx_s *)ctx)->signal);
+       free(ctx);
 
-    return DIAGNOSTICS_ERROR_NONE;
+       return DIAGNOSTICS_ERROR_NONE;
 }
 
-int diagnostics_data_destroy(diagnostics_data_h data) {
-    RETV_IF(data == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
+int diagnostics_data_destroy(diagnostics_data_h data)
+{
+       RETV_IF(data == NULL, DIAGNOSTICS_ERROR_INVALID_PARAMETER);
 
-    close(((struct _diagnostics_data_s *)data)->fd);
-    free(data);
+       close(((struct _diagnostics_data_s *)data)->fd);
+       free(data);
 
-    return DIAGNOSTICS_ERROR_NONE;
+       return DIAGNOSTICS_ERROR_NONE;
 }
index 78ece6e..88e5d24 100644 (file)
@@ -1,18 +1,18 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright (c) 2020 Samsung Electronics Co., Ltd.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
 
 #include "signal.h"
 #include "log.h"
 
 int signal_is_valid_crash(struct dbus_signal_s *signal)
 {
-    GVariant *extra;
+       GVariant *extra;
 
-    RETV_IF(signal == NULL, FALSE);
-    RETV_IF(g_variant_n_children(signal->parameters) != SIG_CRASH_SIZE, FALSE);
+       RETV_IF(signal == NULL, FALSE);
+       RETV_IF(g_variant_n_children(signal->parameters) != SIG_CRASH_SIZE, FALSE);
 
-    extra = g_variant_get_child_value(signal->parameters, SIG_CRASH_EX);
-    RETV_IF(g_variant_is_container(extra) == FALSE, FALSE);
+       extra = g_variant_get_child_value(signal->parameters, SIG_CRASH_EX);
+       RETV_IF(g_variant_is_container(extra) == FALSE, FALSE);
 
-    return TRUE;
+       return TRUE;
 }
index 98221af..d7a3a39 100644 (file)
@@ -1,18 +1,18 @@
 /*
- * Copyright (c) 2020 Samsung Electronics Co., Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
+* Copyright (c) 2020 Samsung Electronics Co., Ltd.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
 
 #ifndef __SIGNAL_H__
 #define __SIGNAL_H__
 struct dbus_signal_s;
 
 typedef enum {
-    SIG_TYPE_CRASH,
-    /* SIG_TYPE_CRASH_LEGACY ? */
-    SIG_TYPE_INVALID
-}signal_type_e;
+       SIG_TYPE_CRASH,
+       /* SIG_TYPE_CRASH_LEGACY ? */
+       SIG_TYPE_INVALID
+} signal_type_e;
 
 int signal_is_valid_crash(struct dbus_signal_s *signal);
 
index b01331e..94dfb75 100644 (file)
@@ -28,68 +28,68 @@ add_mocked_test(diagnostics_destroy "")
 
 if(ENABLE_COVERAGE)
 function(setup_coverage_target)
-    set(oneValueArgs BASE_DIRECTORY NAME)
-    set(multiValueArgs EXCLUDE EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES LCOV_ARGS GENHTML_ARGS)
-    cmake_parse_arguments(COV "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+       set(oneValueArgs BASE_DIRECTORY NAME)
+       set(multiValueArgs EXCLUDE EXECUTABLE EXECUTABLE_ARGS DEPENDENCIES LCOV_ARGS GENHTML_ARGS)
+       cmake_parse_arguments(COV "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
 
        find_program(GCOV_PATH gcov)
        find_program(LCOV_PATH  NAMES lcov)
        find_program(GENHTML_PATH NAMES genhtml)
 
        if(NOT GCOV_PATH)
-        message(FATAL_ERROR "gcov not found! Aborting...")
-    endif()
+               message(FATAL_ERROR "gcov not found! Aborting...")
+       endif()
 
-    if(NOT LCOV_PATH)
-        message(FATAL_ERROR "lcov not found! Aborting...")
-    endif()
+       if(NOT LCOV_PATH)
+               message(FATAL_ERROR "lcov not found! Aborting...")
+       endif()
 
-    if(NOT GENHTML_PATH)
-        message(FATAL_ERROR "genhtml not found! Aborting...")
-    endif()
+       if(NOT GENHTML_PATH)
+               message(FATAL_ERROR "genhtml not found! Aborting...")
+       endif()
 
-    if(${COV_BASE_DIRECTORY})
-        get_filename_component(BASEDIR ${COV_BASE_DIRECTORY} ABSOLUTE)
-    else()
-        set(BASEDIR ${PROJECT_SOURCE_DIR})
-    endif()
+       if(${COV_BASE_DIRECTORY})
+               get_filename_component(BASEDIR ${COV_BASE_DIRECTORY} ABSOLUTE)
+       else()
+               set(BASEDIR ${PROJECT_SOURCE_DIR})
+       endif()
 
-    set(LCOV_EXCLUDES "")
-    foreach(EXCLUDE ${COV_EXCLUDE} ${COVERAGE_EXCLUDES})
+       set(LCOV_EXCLUDES "")
+       foreach(EXCLUDE ${COV_EXCLUDE} ${COVERAGE_EXCLUDES})
                get_filename_component(EXCLUDE ${EXCLUDE} ABSOLUTE BASE_DIR ${BASEDIR})
-        list(APPEND LCOV_EXCLUDES "${EXCLUDE}")
-    endforeach()
-    list(REMOVE_DUPLICATES LCOV_EXCLUDES)
+               list(APPEND LCOV_EXCLUDES "${EXCLUDE}")
+       endforeach()
+       list(REMOVE_DUPLICATES LCOV_EXCLUDES)
 
-    # Setup target
-    add_custom_target(${COV_NAME}
+       # Setup target
+       add_custom_target(${COV_NAME}
 
-        COMMAND ${LCOV_PATH} ${COV_LCOV_ARGS} --gcov-tool ${GCOV_PATH} -directory . -b ${BASEDIR} --zerocounters
+               COMMAND ${LCOV_PATH} ${COV_LCOV_ARGS} --gcov-tool ${GCOV_PATH} -directory . -b ${BASEDIR} --zerocounters
 
-        COMMAND ${COV_EXECUTABLE} ${COV_EXECUTABLE_ARGS}
+               COMMAND ${COV_EXECUTABLE} ${COV_EXECUTABLE_ARGS}
 
-        COMMAND ${LCOV_PATH} ${COV_LCOV_ARGS} --gcov-tool ${GCOV_PATH} --directory . -b ${BASEDIR} --capture --output-file ${COV_NAME}.total
+               COMMAND ${LCOV_PATH} ${COV_LCOV_ARGS} --gcov-tool ${GCOV_PATH} --directory . -b ${BASEDIR} --capture --output-file ${COV_NAME}.total
 
-        COMMAND ${LCOV_PATH} ${COV_LCOV_ARGS} --gcov-tool ${GCOV_PATH} --remove ${COV_NAME}.total ${LCOV_EXCLUDES} --output-file ${COV_NAME}.info
+               COMMAND ${LCOV_PATH} ${COV_LCOV_ARGS} --gcov-tool ${GCOV_PATH} --remove ${COV_NAME}.total ${LCOV_EXCLUDES} --output-file ${COV_NAME}.info
 
-        COMMAND ${GENHTML_PATH} ${GENHTML_EXTRA_ARGS} ${COV_GENHTML_ARGS} -o ${COV_NAME} ${COV_NAME}.info
+               COMMAND ${GENHTML_PATH} ${GENHTML_EXTRA_ARGS} ${COV_GENHTML_ARGS} -o ${COV_NAME} ${COV_NAME}.info
 
-        BYPRODUCTS
-            ${COV_NAME}.total
-            ${COV_NAME}.info
-            ${COV_NAME}
+               BYPRODUCTS
+                       ${COV_NAME}.total
+                       ${COV_NAME}.info
+                       ${COV_NAME}
 
-        WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
+               WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
 
-        DEPENDS ${COV_DEPENDENCIES}
-    )
+               DEPENDS ${COV_DEPENDENCIES}
+       )
 
 endfunction() # setup_coverage_target
 
 setup_coverage_target(
-    NAME coverage
-    EXECUTABLE make test
-    EXCLUDE "src/test/*" "/usr/include/bits/*"
+       NAME coverage
+       EXECUTABLE make test
+       EXCLUDE "src/test/*" "/usr/include/bits/*"
 )
 
 add_custom_command(TARGET ctest POST_BUILD COMMAND make coverage)
index b7228c6..f7d81c2 100644 (file)
@@ -40,9 +40,9 @@ extern "C" {
 #endif
 
 struct _diagnostics_ctx_s {
-    char *client_id;
-    struct dbus_signal_s *signal;
-    signal_type_e signal_type;
+       char *client_id;
+       struct dbus_signal_s *signal;
+       signal_type_e signal_type;
 };
 
 struct _diagnostics_data_s {
index 82f6890..041d7d2 100644 (file)
@@ -44,4 +44,4 @@ void signal_handler(GDBusConnection *connection,
 }
 #endif
 
-#endif /* __TIZEN_TEST_BUGREPORT_ADD_FUNCTION_DEFS_H__ */
+#endif /* __TIZEN_TEST_DIAGNOSTICS_ADD_FUNCTION_DEFS_H__ */
index 7b6d84d..ca534d4 100644 (file)
 #include "test_diagnostics.h"
 #include "test_diagnostics_add_function_defs.h"
 
-static void test_diagnostics_create_n1(void **state) {
+static void test_diagnostics_create_n1(void **state)
+{
        (void) state;
        struct dbus_signal_s *signal = NULL;
 
        assert_null(diagnostics_create(signal));
 }
 
-static void test_diagnostics_create_n2(void **state) {
+static void test_diagnostics_create_n2(void **state)
+{
        (void) state;
        struct _diagnostics_ctx_s *ctx = build_ctx_crash();
        free(ctx->signal->signal_name);
@@ -47,7 +49,8 @@ static void test_diagnostics_create_n2(void **state) {
        destroy_ctx(ctx);
 }
 
-static void test_diagnostics_create_n3(void **state) {
+static void test_diagnostics_create_n3(void **state)
+{
        (void) state;
        struct _diagnostics_ctx_s *ctx = build_ctx_crash();
        free(ctx->signal->signal_name);
@@ -59,7 +62,8 @@ static void test_diagnostics_create_n3(void **state) {
        destroy_ctx(ctx);
 }
 
-static void test_diagnostics_create_p1(void **state) {
+static void test_diagnostics_create_p1(void **state)
+{
        (void) state;
        struct _diagnostics_ctx_s *ctx = build_ctx_crash();
        struct _diagnostics_ctx_s *result = diagnostics_create(ctx->signal);
@@ -73,7 +77,8 @@ static void test_diagnostics_create_p1(void **state) {
        free(result);
 }
 
-int main(void) {
+int main(void)
+{
        const struct CMUnitTest tests[] = {
                cmocka_unit_test(test_diagnostics_create_n1),
                cmocka_unit_test(test_diagnostics_create_n2),
index 5154d2d..7ce3e4c 100644 (file)
 #include "test_diagnostics.h"
 #include "test_diagnostics_add_function_defs.h"
 
-static void test_diagnostics_data_create_n1(void **state) {
+static void test_diagnostics_data_create_n1(void **state)
+{
        (void) state;
        int fd = -1;
 
        assert_null(diagnostics_data_create(fd));
 }
 
-static void test_diagnostics_data_create_p1(void **state) {
+static void test_diagnostics_data_create_p1(void **state)
+{
        (void) state;
        int fd = 0;
        struct _diagnostics_data_s *result = diagnostics_data_create(fd);
@@ -46,7 +48,8 @@ static void test_diagnostics_data_create_p1(void **state) {
        free(result);
 }
 
-int main(void) {
+int main(void)
+{
        const struct CMUnitTest tests[] = {
                cmocka_unit_test(test_diagnostics_data_create_n1),
                cmocka_unit_test(test_diagnostics_data_create_p1),
index cf00222..bf54d8f 100644 (file)
@@ -30,7 +30,8 @@
 
 #include "test_diagnostics.h"
 
-static void test_diagnostics_data_read_n1(void **state) {
+static void test_diagnostics_data_read_n1(void **state)
+{
        (void) state;
        char buf[256];
        size_t count = sizeof(buf);
@@ -40,7 +41,8 @@ static void test_diagnostics_data_read_n1(void **state) {
        assert_int_equal(diagnostics_data_read(NULL, buf, count, timeout, &bytes_read), DIAGNOSTICS_ERROR_INVALID_PARAMETER);
 }
 
-static void test_diagnostics_data_read_n2(void **state) {
+static void test_diagnostics_data_read_n2(void **state)
+{
        (void) state;
        struct _diagnostics_data_s data;
        char buf[256];
@@ -51,7 +53,8 @@ static void test_diagnostics_data_read_n2(void **state) {
        assert_int_equal(diagnostics_data_read(&data, NULL, count, timeout, &bytes_read), DIAGNOSTICS_ERROR_INVALID_PARAMETER);
 }
 
-static void test_diagnostics_data_read_n4(void **state) {
+static void test_diagnostics_data_read_n4(void **state)
+{
        (void) state;
        struct _diagnostics_data_s data;
        char buf[256];
@@ -61,7 +64,8 @@ static void test_diagnostics_data_read_n4(void **state) {
        assert_int_equal(diagnostics_data_read(&data, buf, count, timeout, NULL), DIAGNOSTICS_ERROR_INVALID_PARAMETER);
 }
 
-static void test_diagnostics_data_read_n5(void **state) {
+static void test_diagnostics_data_read_n5(void **state)
+{
        (void) state;
        struct _diagnostics_data_s data;
        data.fd = -1;
@@ -75,7 +79,8 @@ static void test_diagnostics_data_read_n5(void **state) {
        assert_int_equal(diagnostics_data_read(&data, buf, count, timeout, &bytes_read), DIAGNOSTICS_ERROR_TIMED_OUT);
 }
 
-static void test_diagnostics_data_read_n6(void **state) {
+static void test_diagnostics_data_read_n6(void **state)
+{
        (void) state;
        struct _diagnostics_data_s data;
        data.fd = -1;
@@ -89,7 +94,8 @@ static void test_diagnostics_data_read_n6(void **state) {
        assert_int_equal(diagnostics_data_read(&data, buf, count, timeout, &bytes_read), DIAGNOSTICS_ERROR_IO_ERROR);
 }
 
-static void test_diagnostics_data_read_p1(void **state) {
+static void test_diagnostics_data_read_p1(void **state)
+{
        (void) state;
        struct _diagnostics_data_s data;
        data.fd = 0;
@@ -105,7 +111,8 @@ static void test_diagnostics_data_read_p1(void **state) {
        assert_int_equal(bytes_read, 2);
 }
 
-int main(void) {
+int main(void)
+{
        const struct CMUnitTest tests[] = {
                cmocka_unit_test(test_diagnostics_data_read_n1),
                cmocka_unit_test(test_diagnostics_data_read_n2),
index 1595caf..6cc0b70 100644 (file)
@@ -30,7 +30,8 @@
 
 #include "test_diagnostics.h"
 
-static void test_diagnostics_destroy_n1(void **state) {
+static void test_diagnostics_destroy_n1(void **state)
+{
        (void) state;
        diagnostics_ctx_h ctx = NULL;
        diagnostics_destroy(ctx);
@@ -38,7 +39,8 @@ static void test_diagnostics_destroy_n1(void **state) {
        assert_null(ctx);
 }
 
-static void test_diagnostics_data_destroy_n1(void **state) {
+static void test_diagnostics_data_destroy_n1(void **state)
+{
        (void) state;
        diagnostics_data_h data = NULL;
        diagnostics_data_destroy(data);
@@ -46,21 +48,24 @@ static void test_diagnostics_data_destroy_n1(void **state) {
        assert_null(data);
 }
 
-static void test_diagnostics_destroy_p1(void **state) {
+static void test_diagnostics_destroy_p1(void **state)
+{
        (void) state;
        diagnostics_ctx_h ctx = build_ctx_crash();
 
        diagnostics_destroy(ctx);
 }
 
-static void test_diagnostics_data_destroy_p2(void **state) {
+static void test_diagnostics_data_destroy_p2(void **state)
+{
        (void) state;
        diagnostics_data_h data = calloc(1, sizeof(struct _diagnostics_data_s));
 
        diagnostics_data_destroy(data);
 }
 
-int main(void) {
+int main(void)
+{
        const struct CMUnitTest tests[] = {
                cmocka_unit_test(test_diagnostics_destroy_n1),
                cmocka_unit_test(test_diagnostics_data_destroy_n1),
index dd0e96a..5c31661 100644 (file)
 
 #include "test_diagnostics.h"
 
-static void test_diagnostics_get_client_id_n1(void **state) {
+static void test_diagnostics_get_client_id_n1(void **state)
+{
        (void) state;
        char *client_id;
 
        assert_int_equal(diagnostics_get_client_id(NULL, &client_id), DIAGNOSTICS_ERROR_INVALID_PARAMETER);
 }
 
-static void test_diagnostics_get_client_id_n2(void **state) {
+static void test_diagnostics_get_client_id_n2(void **state)
+{
        (void) state;
        struct _diagnostics_ctx_s *ctx = build_ctx_crash();
 
@@ -44,7 +46,8 @@ static void test_diagnostics_get_client_id_n2(void **state) {
        destroy_ctx(ctx);
 }
 
-static void test_diagnostics_get_client_id_p1(void **state) {
+static void test_diagnostics_get_client_id_p1(void **state)
+{
        (void) state;
        diagnostics_ctx_h ctx = build_ctx_crash();
        char *client_id;
@@ -56,7 +59,8 @@ static void test_diagnostics_get_client_id_p1(void **state) {
        destroy_ctx(ctx);
 }
 
-int main(void) {
+int main(void)
+{
        const struct CMUnitTest tests[] = {
                cmocka_unit_test(test_diagnostics_get_client_id_n1),
                cmocka_unit_test(test_diagnostics_get_client_id_n2),
index f1a0a6f..adf775b 100644 (file)
@@ -30,7 +30,8 @@
 
 #include "test_diagnostics.h"
 
-static void test_diagnostics_get_data_n1(void **state) {
+static void test_diagnostics_get_data_n1(void **state)
+{
        (void) state;
        diagnostics_data_h data;
        const char *params[] = {"cs_full"};
@@ -38,7 +39,8 @@ static void test_diagnostics_get_data_n1(void **state) {
        assert_int_equal(diagnostics_get_data(NULL, params, 1, (void**)&data), DIAGNOSTICS_ERROR_INVALID_PARAMETER);
 }
 
-static void test_diagnostics_get_data_n2(void **state) {
+static void test_diagnostics_get_data_n2(void **state)
+{
        (void) state;
        diagnostics_ctx_h br_ptr = build_ctx_crash();
        diagnostics_data_h data;
@@ -49,7 +51,8 @@ static void test_diagnostics_get_data_n2(void **state) {
        destroy_ctx(br_ptr);
 }
 
-static void test_diagnostics_get_data_n3(void **state) {
+static void test_diagnostics_get_data_n3(void **state)
+{
        (void) state;
        diagnostics_ctx_h br_ptr = build_ctx_crash();
        const char *params[] = {"cs_full"};
@@ -59,7 +62,8 @@ static void test_diagnostics_get_data_n3(void **state) {
        destroy_ctx(br_ptr);
 }
 
-static void test_diagnostics_get_data_p1(void **state) {
+static void test_diagnostics_get_data_p1(void **state)
+{
        (void) state;
        struct _diagnostics_ctx_s *ctx = build_ctx_crash();
        struct _diagnostics_data_s *data = NULL;
@@ -76,7 +80,8 @@ static void test_diagnostics_get_data_p1(void **state) {
        destroy_ctx(ctx);
 }
 
-int main(void) {
+int main(void)
+{
        const struct CMUnitTest tests[] = {
                cmocka_unit_test(test_diagnostics_get_data_n1),
                cmocka_unit_test(test_diagnostics_get_data_n2),
index 7baa12c..8422c2c 100644 (file)
@@ -31,7 +31,8 @@
 #include "test_diagnostics.h"
 #include "test_diagnostics_add_function_defs.h"
 
-static void test_diagnostics_get_report_path_n1(void **state) {
+static void test_diagnostics_get_report_path_n1(void **state)
+{
        (void) state;
        const char *path;
        size_t len;
@@ -39,7 +40,8 @@ static void test_diagnostics_get_report_path_n1(void **state) {
        assert_int_equal(get_report_path(NULL, &path, &len), DIAGNOSTICS_ERROR_INVALID_PARAMETER);
 }
 
-static void test_diagnostics_get_report_path_n2(void **state) {
+static void test_diagnostics_get_report_path_n2(void **state)
+{
        (void) state;
        diagnostics_ctx_h br_ptr = build_ctx_crash();
        size_t len;
@@ -49,7 +51,8 @@ static void test_diagnostics_get_report_path_n2(void **state) {
        destroy_ctx(br_ptr);
 }
 
-static void test_diagnostics_get_report_path_n3(void **state) {
+static void test_diagnostics_get_report_path_n3(void **state)
+{
        (void) state;
        diagnostics_ctx_h ctx = build_ctx_crash();
        ((struct _diagnostics_ctx_s *)ctx)->signal_type = SIG_TYPE_CRASH + 10;
@@ -61,7 +64,8 @@ static void test_diagnostics_get_report_path_n3(void **state) {
        destroy_ctx(ctx);
 }
 
-static void test_diagnostics_get_report_path_p1(void **state) {
+static void test_diagnostics_get_report_path_p1(void **state)
+{
        (void) state;
        diagnostics_ctx_h ctx = build_ctx_crash();
        const char *path;
@@ -73,7 +77,8 @@ static void test_diagnostics_get_report_path_p1(void **state) {
        destroy_ctx(ctx);
 }
 
-int main(void) {
+int main(void)
+{
        const struct CMUnitTest tests[] = {
                cmocka_unit_test(test_diagnostics_get_report_path_n1),
                cmocka_unit_test(test_diagnostics_get_report_path_n2),
index cb175cc..af04f61 100644 (file)
@@ -30,7 +30,8 @@
 
 #include "test_diagnostics.h"
 
-static void test_diagnostics_request_client_data_n1(void **state) {
+static void test_diagnostics_request_client_data_n1(void **state)
+{
        (void) state;
        int params_size = 3;
        const char *params[] = {"a", "b", "c"};
@@ -39,7 +40,8 @@ static void test_diagnostics_request_client_data_n1(void **state) {
        assert_int_equal(diagnostics_request_client_data(NULL, params, params_size, (void**)&data), DIAGNOSTICS_ERROR_INVALID_PARAMETER);
 }
 
-static void test_diagnostics_request_client_data_n2(void **state) {
+static void test_diagnostics_request_client_data_n2(void **state)
+{
        (void) state;
        const char *client_id = "";
        int params_size = -1;
@@ -49,7 +51,8 @@ static void test_diagnostics_request_client_data_n2(void **state) {
        assert_int_equal(diagnostics_request_client_data(client_id, params, params_size, (void**)&data), DIAGNOSTICS_ERROR_INVALID_PARAMETER);
 }
 
-static void test_diagnostics_request_client_data_n3(void **state) {
+static void test_diagnostics_request_client_data_n3(void **state)
+{
        (void) state;
        const char *client_id = "";
        int params_size = 0;
@@ -60,7 +63,8 @@ static void test_diagnostics_request_client_data_n3(void **state) {
        assert_int_equal(diagnostics_request_client_data(client_id, NULL, params_size, (void**)&data), DIAGNOSTICS_ERROR_IO_ERROR);
 }
 
-static void test_diagnostics_request_client_data_n4(void **state) {
+static void test_diagnostics_request_client_data_n4(void **state)
+{
        (void) state;
        const char *client_id = "";
        int params_size = 3;
@@ -69,7 +73,8 @@ static void test_diagnostics_request_client_data_n4(void **state) {
        assert_int_equal(diagnostics_request_client_data(client_id, params, params_size, NULL), DIAGNOSTICS_ERROR_INVALID_PARAMETER);
 }
 
-static void test_diagnostics_request_client_data_n5(void **state) {
+static void test_diagnostics_request_client_data_n5(void **state)
+{
        (void) state;
        const char *client_id = "";
        int params_size = 3;
@@ -84,7 +89,8 @@ static void test_diagnostics_request_client_data_n5(void **state) {
        assert_null(data);
 }
 
-static void test_diagnostics_request_client_data_p1(void **state) {
+static void test_diagnostics_request_client_data_p1(void **state)
+{
        (void) state;
        const char *client_id = "";
        int params_size = 3;
@@ -100,7 +106,8 @@ static void test_diagnostics_request_client_data_p1(void **state) {
        assert_int_equal(data->fd, 1);
 }
 
-int main(void) {
+int main(void)
+{
        const struct CMUnitTest tests[] = {
                cmocka_unit_test(test_diagnostics_request_client_data_n1),
                cmocka_unit_test(test_diagnostics_request_client_data_n2),
index af2d70c..b9da4a4 100644 (file)
@@ -37,12 +37,14 @@ void callback(void *ctx, void *user_data)
        (void)user_data;
 }
 
-static void test_diagnostics_set_notification_cb_n1(void **state) {
+static void test_diagnostics_set_notification_cb_n1(void **state)
+{
        (void) state;
        assert_int_equal(diagnostics_set_notification_cb(NULL, NULL), DIAGNOSTICS_ERROR_INVALID_PARAMETER);
 }
 
-static void test_diagnostics_set_notification_cb_p1(void **state) {
+static void test_diagnostics_set_notification_cb_p1(void **state)
+{
        (void) state;
 
        will_return(__wrap_dbus_subscribe, DIAGNOSTICS_ERROR_NONE);
@@ -54,7 +56,8 @@ static void test_diagnostics_set_notification_cb_p1(void **state) {
        cb_info.cb = NULL;
 }
 
-static void test_diagnostics_set_notification_cb_p2(void **state) {
+static void test_diagnostics_set_notification_cb_p2(void **state)
+{
        (void) state;
 
        will_return(__wrap_dbus_subscribe, DIAGNOSTICS_ERROR_NONE);
@@ -63,7 +66,8 @@ static void test_diagnostics_set_notification_cb_p2(void **state) {
        assert_int_equal(diagnostics_set_notification_cb(callback, NULL), DIAGNOSTICS_ERROR_RESOURCE_BUSY);
 }
 
-int main(void) {
+int main(void)
+{
        const struct CMUnitTest tests[] = {
                cmocka_unit_test(test_diagnostics_set_notification_cb_n1),
                cmocka_unit_test(test_diagnostics_set_notification_cb_p1),
index f6f588c..18d6bd1 100644 (file)
@@ -45,7 +45,8 @@ void signal_callback(void *_ctx, void *user_data)
        assert_null(ctx->signal->parameters);
 }
 
-static void test_diagnostics_signal_handler_p1(void **state) {
+static void test_diagnostics_signal_handler_p1(void **state)
+{
        (void) state;
        const gchar *sender_name = g_strdup("sender");
        const gchar *object_path = g_strdup("object path");
@@ -53,7 +54,7 @@ static void test_diagnostics_signal_handler_p1(void **state) {
        const gchar *signal_name = g_strdup("signal name");
        char *t = "abc";
        gboolean en = FALSE;
-       GVariant *parameters = g_variant_new_parsed ("{'title': <%s>, 'enabled': <%b>}", t, en);
+       GVariant *parameters = g_variant_new_parsed("{'title': <%s>, 'enabled': <%b>}", t, en);
        cb_info.cb = signal_callback;
 
        signal_handler(NULL, sender_name, object_path, interface_name, signal_name, parameters, NULL);
@@ -65,7 +66,8 @@ static void test_diagnostics_signal_handler_p1(void **state) {
        g_variant_unref(parameters);
 }
 
-int main(void) {
+int main(void)
+{
        const struct CMUnitTest tests[] = {
                cmocka_unit_test(test_diagnostics_signal_handler_p1),
        };