Exclude some lines for coverage measurement 15/234315/1
authorHwankyu Jhun <h.jhun@samsung.com>
Mon, 25 May 2020 10:47:32 +0000 (19:47 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Mon, 25 May 2020 10:59:10 +0000 (19:59 +0900)
Change-Id: Ie9d73a23772ea8a80491d529af57efb538eb7e37
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/ac-internal.cc
src/fdbroker-internal.cc
src/fdbroker-internal.h
src/parcel-internal.cc
src/proxy-internal.cc
src/rpc-port-parcel.cc
src/rpc-port.cc
src/stub-internal.cc

index 2e97a9a..860190a 100644 (file)
@@ -99,9 +99,11 @@ int AccessController::Check(GDBusConnection* connection, const char* sender,
   return ret;
 }
 
+// LCOV_EXCL_START
 int AccessController::SetCache(const std::string& sender) {
   return -1;
 }
+// LCOV_EXCL_STOP
 
 AccessController::Cynara::Cynara()
     : cynara_(nullptr, cynara_finish), client_(nullptr, std::free),
@@ -109,7 +111,7 @@ AccessController::Cynara::Cynara()
   cynara* cynara_inst = nullptr;
 
   if (cynara_initialize(&cynara_inst, NULL) != CYNARA_API_SUCCESS) {
-    LOGE("cynara_initialize() is failed");
+    LOGE("cynara_initialize() is failed");  // LCOV_EXL_LINE
   } else {
     cynara_.reset(cynara_inst);
   }
@@ -123,8 +125,8 @@ int AccessController::Cynara::FetchCredsFromDBus(GDBusConnection* connection,
   int ret = cynara_creds_gdbus_get_user(connection, sender, USER_METHOD_DEFAULT,
                                     &user);
   if (ret != CYNARA_API_SUCCESS) {
-    LOGE("cynara_creds_gdbus_get_user() is failed : %d", ret);
-    return -1;
+    LOGE("cynara_creds_gdbus_get_user() is failed : %d", ret);  // LCOV_EXCL_LINE
+    return -1;  // LCOV_EXCL_LINE
   }
   user_.reset(user);
 
@@ -132,8 +134,8 @@ int AccessController::Cynara::FetchCredsFromDBus(GDBusConnection* connection,
   ret = cynara_creds_gdbus_get_client(connection, sender, CLIENT_METHOD_DEFAULT,
                                       &client);
   if (ret != CYNARA_API_SUCCESS) {
-    LOGE("cynara_creds_gdbus_get_client() is failed : %d", ret);
-    return -1;
+    LOGE("cynara_creds_gdbus_get_client() is failed : %d", ret);  // LCOV_EXCL_LINE
+    return -1;  // LCOV_EXCL_LINE
   }
   client_.reset(client);
 
index 647a39d..98b09e7 100644 (file)
@@ -54,10 +54,12 @@ FdBroker::DBusConnectionManager& FdBroker::DBusConnectionManager::GetInst() {
   return dm;
 }
 
+// LCOV_EXCL_START
 void FdBroker::DBusConnectionManager::Dispose() {
   if (!disposed_)
     Fini();
 }
+// LCOV_EXCL_STOP
 
 GDBusConnection* FdBroker::DBusConnectionManager::GetConnection() {
   return gdbus_conn_;
@@ -73,12 +75,14 @@ void FdBroker::DBusConnectionManager::Init() {
 
   gdbus_conn_ = g_bus_get_sync(G_BUS_TYPE_SESSION, NULL, &error);
   if (gdbus_conn_ == nullptr) {
+    // LCOV_EXCL_START
     if (error != nullptr) {
       LOGE("Failed to get dbus [%s]", error->message);
       g_error_free(error);
     }
 
     return;
+    // LCOV_EXCL_STOP
   }
 
   disposed_ = false;
@@ -93,12 +97,15 @@ void FdBroker::DBusConnectionManager::Fini() {
   disposed_ = true;
 }
 
+// LCOV_EXCL_START
 FdBroker::DBusMock& FdBroker::DBusMock::GetInst() {
   static DBusMock mock;
 
   return mock;
 }
+// LCOV_EXCL_STOP
 
+// LCOV_EXCL_START
 int FdBroker::DBusMock::Send(const std::string& sender,
                              const std::string& port, int fds[2]) {
   if (port == "wrong_port")
@@ -109,7 +116,9 @@ int FdBroker::DBusMock::Send(const std::string& sender,
   ports_[port]->OnFdReceived(sender, fds);
   return 0;
 }
+// LCOV_EXCL_STOP
 
+// LCOV_EXCL_START
 int FdBroker::DBusMock::AddListener(const std::string& port,
                                     FdBroker::IEventListener* listener) {
   if (ports_.find(port) != ports_.end())
@@ -118,17 +127,22 @@ int FdBroker::DBusMock::AddListener(const std::string& port,
   ports_[port] = listener;
   return 0;
 }
+// LCOV_EXCL_STOP
 
+// LCOV_EXCL_START
 int FdBroker::DBusMock::Watch(FdBroker::IEventWatcher* watcher,
                               const std::string& target_appid,
                               const std::string& port_name) {
   watcher->OnPortAppeared(target_appid, port_name);
   return 0;
 }
+// LCOV_EXCL_STOP
 
+// LCOV_EXCL_START
 void FdBroker::DBusMock::Dispose() {
   ports_.clear();
 }
+// LCOV_EXCL_STOP
 
 FdBroker::SocketPair::SocketPair(bool mock)
     : mock_(mock) {
@@ -146,13 +160,13 @@ FdBroker::SocketPair::~SocketPair() {
 int FdBroker::SocketPair::Request(const std::string& target_appid,
                                   const std::string& port_name) {
   if (mock_) {
-    return socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, socks_);
+    return socketpair(AF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0, socks_);  // LCOV_EXCL_LINE
   }
 
   if (aul_rpc_port_create_socket_pair(target_appid.c_str(),
       port_name.c_str(), &socks_) != AUL_R_OK) {
-    LOGE("error create socket pair");
-    return -1;
+    LOGE("error create socket pair");  // LCOV_EXCL_LINE
+    return -1;  // LCOV_EXCL_LINE
   }
 
   return 0;
@@ -184,9 +198,9 @@ int FdBroker::FdList::Add(int fd) {
   close(fd);
 
   if (err != NULL) {
-    LOGE("g_unix_fd_list_append [%s]", err->message);
-    g_error_free(err);
-    return -1;
+    LOGE("g_unix_fd_list_append [%s]", err->message);  // LCOV_EXCL_LINE
+    g_error_free(err);  // LCOV_EXCL_LINE
+    return -1;  // LCOV_EXCL_LINE
   }
 
   return 0;
@@ -223,7 +237,7 @@ void FdBroker::Cancel() {
   }
 
   if (mock_) {
-    DBusMock::GetInst().Dispose();
+    DBusMock::GetInst().Dispose();  // LCOV_EXCL_LINE
   }
 }
 
@@ -253,8 +267,8 @@ int FdBroker::Send(const std::string& target_appid,
 
   if (!mock_ && aul_app_get_appid_bypid(getpid(),
        sender_appid, sizeof(sender_appid)) < 0) {
-    LOGE("Can't get appid");
-    return -1;
+    LOGE("Can't get appid");  // LCOV_EXCL_LINE
+    return -1;  // LCOV_EXCL_LINE
   }
 
   if (main_sock_pair.Request(target_appid, port_name) != 0)
@@ -263,6 +277,7 @@ int FdBroker::Send(const std::string& target_appid,
     return -1;
 
   if (mock_) {
+    // LCOV_EXCL_START
     int send_fds[2];
     send_fds[0] = main_sock_pair.Detach(SocketPair::RECEIVER);
     send_fds[1] = delegate_sock_pair.Detach(SocketPair::RECEIVER);
@@ -274,6 +289,7 @@ int FdBroker::Send(const std::string& target_appid,
     (*fds)[1] = delegate_sock_pair.Detach(SocketPair::SENDER);
     watcher_->OnPortConnected(watch_appid_, watch_port_name_);
     return (*fds)[0];
+    // LCOV_EXCL_STOP
   }
 
   if (fd_list.Add(main_sock_pair.Detach(SocketPair::RECEIVER)) != 0)
@@ -285,20 +301,20 @@ int FdBroker::Send(const std::string& target_appid,
                                        RPC_PORT_OBJECT_PATH,
                                        interface_name.c_str(), "send_message");
   if (!msg) {
-    LOGE("Can't allocate new method call");
-    return -1;
+    LOGE("Can't allocate new method call");  // LCOV_EXCL_LINE
+    return -1;  // LCOV_EXCL_LINE
   }
 
   if (cancellable_) {
-    g_cancellable_cancel(cancellable_);
-    g_object_unref(cancellable_);
+    g_cancellable_cancel(cancellable_);  // LCOV_EXCL_LINE
+    g_object_unref(cancellable_);  // LCOV_EXCL_LINE
   }
 
   cancellable_ = g_cancellable_new();
   if (!cancellable_) {
-    LOGE("Failed to create GCancellable");
-    g_object_unref(msg);
-    return -1;
+    LOGE("Failed to create GCancellable");  // LCOV_EXCL_LINE
+    g_object_unref(msg);  // LCOV_EXCL_LINE
+    return -1;  // LCOV_EXCL_LINE
   }
 
   g_dbus_message_set_unix_fd_list(msg, fd_list.GetRaw());
@@ -314,6 +330,7 @@ int FdBroker::Send(const std::string& target_appid,
   return (*fds)[0];
 }
 
+// LCOV_EXCL_START
 int FdBroker::SendSync(const std::string& target_appid,
                        const std::string& port_name,
                        int (*fds)[2]) {
@@ -449,6 +466,7 @@ int FdBroker::SendSync(const std::string& target_appid,
 
   return (*fds)[0];
 }
+// LCOV_EXCL_STOP
 
 void FdBroker::ReceiveMessage(const char* sender_appid,
                               GDBusMethodInvocation* invocation) {
@@ -461,12 +479,12 @@ void FdBroker::ReceiveMessage(const char* sender_appid,
   fd_list = g_dbus_message_get_unix_fd_list(msg);
 
   if (fd_list == nullptr)
-    return;
+    return;  // LCOV_EXCL_LINE
 
   returned_fds = g_unix_fd_list_steal_fds(fd_list, &fd_len);
   if (returned_fds == nullptr || fd_len != 2) {
-    LOGE("fail to get fds. fd_len(%d)", fd_len);
-    return;
+    LOGE("fail to get fds. fd_len(%d)", fd_len);  // LCOV_EXCL_LINE
+    return;  // LCOV_EXCL_LINE
   }
 
   listener_->OnFdReceived(sender_appid, returned_fds);
@@ -518,21 +536,21 @@ int FdBroker::GetOwnerId(const std::string& interface_name) {
       &error);
 
   if (error) {
-    LOGE("RequestName fail : %s", error->message);
-    g_error_free(error);
-    return -1;
+    LOGE("RequestName fail : %s", error->message);  // LCOV_EXCL_LINE
+    g_error_free(error);  // LCOV_EXCL_LINE
+    return -1;  // LCOV_EXCL_LINE
   }
 
   if (result == nullptr) {
-    LOGE("fail to get name NULL");
-    return -1;
+    LOGE("fail to get name NULL");  // LCOV_EXCL_LINE
+    return -1;  // LCOV_EXCL_LINE
   }
 
   g_variant_get(result, "(u)", &owner_id);
   if (owner_id == 0) {
-    LOGE("Acquiring the own name is failed");
-    g_variant_unref(result);
-    return -1;
+    LOGE("Acquiring the own name is failed");  // LCOV_EXCL_LINE
+    g_variant_unref(result);  // LCOV_EXCL_LINE
+    return -1;  // LCOV_EXCL_LINE
   }
 
   LOGD("Acquiring the own name : %d", owner_id);
@@ -552,8 +570,8 @@ int FdBroker::GetSenderPid(GDBusConnection *connection, const gchar *sender) {
       "/org/freedesktop/DBus", "org.freedesktop.DBus",
       "GetConnectionUnixProcessID");
   if (!msg) {
-    LOGE("Can't allocate new method call");
-    goto out;
+    LOGE("Can't allocate new method call");  // LCOV_EXCL_LINE
+    goto out;  // LCOV_EXCL_LINE
   }
 
   g_dbus_message_set_body(msg, g_variant_new("(s)", sender));
@@ -561,11 +579,13 @@ int FdBroker::GetSenderPid(GDBusConnection *connection, const gchar *sender) {
       G_DBUS_SEND_MESSAGE_FLAGS_NONE, -1, NULL, NULL, &err);
 
   if (!reply) {
+    // LCOV_EXCL_START
     if (err != NULL) {
       LOGE("Failed to get pid [%s]", err->message);
       g_error_free(err);
     }
     goto out;
+    // LCOV_EXCL_STOP
   }
 
   body = g_dbus_message_get_body(reply);
@@ -636,29 +656,31 @@ int FdBroker::RegisterDbusInterface(const std::string& port_name) {
 
 int FdBroker::Listen(IEventListener* ev, const std::string& port_name) {
   if (listener_ != nullptr) {
-    LOGE("listener_ is not NULL");
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+    LOGE("listener_ is not NULL");  // LCOV_EXCL_LINE
+    return RPC_PORT_ERROR_INVALID_PARAMETER;  // LCOV_EXCL_LINE
   }
 
   if (ev == nullptr) {
-    LOGE("ev is NULL");
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+    LOGE("ev is NULL");  // LCOV_EXCL_LINE
+    return RPC_PORT_ERROR_INVALID_PARAMETER;  // LCOV_EXCL_LINE
   }
 
   if (mock_) {
+    // LCOV_EXCL_START
     int ret = DBusMock::GetInst().AddListener(port_name, ev);
 
     if (ret < 0)
       return ret;
 
     return RPC_PORT_ERROR_NONE;
+    // LCOV_EXCL_STOP
   }
 
   int ret = RegisterDbusInterface(port_name);
 
   if (ret != 0) {
-    LOGE("Failed to register dbus interface");
-    return RPC_PORT_ERROR_IO_ERROR;
+    LOGE("Failed to register dbus interface");  // LCOV_EXCL_LINE
+    return RPC_PORT_ERROR_IO_ERROR;  // LCOV_EXCL_LINE
   }
 
   listener_ = ev;
@@ -678,15 +700,15 @@ void FdBroker::OnNameAppeared(GDBusConnection *connection,
   char owner_appid[255] = { 0, };
 
   if (aul_app_get_appid_bypid(pid, owner_appid, sizeof(owner_appid)) < 0) {
-    LOGE("aul_app_get_appid_bypid failed %d", pid);
-    broker->watcher_->OnPortRejected(owner_appid);
-    return;
+    LOGE("aul_app_get_appid_bypid failed %d", pid);  // LCOV_EXCL_LINE
+    broker->watcher_->OnPortRejected(owner_appid);  // LCOV_EXCL_LINE
+    return;  // LCOV_EXCL_LINE
   }
 
   if (broker->watch_appid_ != owner_appid) {
-    LOGE("invalid appid %s", owner_appid);
-    broker->watcher_->OnPortRejected(owner_appid);
-    return;
+    LOGE("invalid appid %s", owner_appid);  // LCOV_EXCL_LINE
+    broker->watcher_->OnPortRejected(owner_appid);  // LCOV_EXCL_LINE
+    return;  // LCOV_EXCL_LINE
   }
 
   broker->watcher_->OnPortAppeared(broker->watch_appid_,
@@ -715,19 +737,23 @@ int FdBroker::Watch(IEventWatcher* ev, const std::string& target_appid,
   watch_port_name_ = port_name;
 
   if (mock_) {
+    // LCOV_EXCL_START
     ret = DBusMock::GetInst().Watch(ev, target_appid, port_name);
     if (ret < 0)
       return -1;
 
     return 0;
+    // LCOV_EXCL_STOP
   }
 
   std::string interface_name = GetInterfaceName(target_appid, port_name);
 
   if (watcher_id_ > 0) {
+    // LCOV_EXCL_START
     g_bus_unwatch_name(watcher_id_);
     LOGD("Retry to watch name. stub %s:%s",
         target_appid.c_str(), port_name.c_str());
+    // LCOV_EXCL_STOP
   }
 
   watcher_id_ = g_bus_watch_name_on_connection(
@@ -739,9 +765,9 @@ int FdBroker::Watch(IEventWatcher* ev, const std::string& target_appid,
       this,
       NULL);
   if (watcher_id_ == 0) {
-    LOGE("Failed to watch connection(%s)", interface_name.c_str());
-    watcher_ = nullptr;
-    return -1;
+    LOGE("Failed to watch connection(%s)", interface_name.c_str());  // LCOV_EXCL_LINE
+    watcher_ = nullptr;  // LCOV_EXCL_LINE
+    return -1;  // LCOV_EXCL_LINE
   }
 
   return 0;
@@ -753,12 +779,14 @@ int FdBroker::Prepare(const std::string& target_appid,
     int ret = aul_rpc_port_prepare_stub(target_appid.c_str(),
         port_name.c_str());
     if (ret != AUL_R_OK) {
+      // LCOV_EXCL_START
       LOGE("Failed to prepare stub %s:%s [ret : %d]",
           target_appid.c_str(), port_name.c_str(), ret);
       if (ret == AUL_R_EILLACC)
         return -EILLEGALACCESS;
 
       return ret;
+      // LCOV_EXCL_STOP
     }
   }
 
@@ -781,12 +809,13 @@ void FdBroker::OnResultReceived(GObject* source_object,
 
   FdBroker* broker = static_cast<FdBroker*>(user_data);
   if (broker == nullptr) {
-      LOGW("Null broker");
-      return;
+      LOGW("Null broker");  // LCOV_EXCL_LINE
+      return;  // LCOV_EXCL_LINE
   }
   IEventWatcher* watcher = broker->watcher_;
 
   if (err) {
+    // LCOV_EXCL_START
     watcher->OnPortDisconnected(broker->watch_appid_, broker->watch_port_name_,
         true);
     g_error_free(err);
@@ -797,19 +826,22 @@ void FdBroker::OnResultReceived(GObject* source_object,
       broker->cancellable_ = nullptr;
     }
     return;
+    // LCOV_EXCL_STOP
   }
 
   if (reply == nullptr) {
-    LOGW("Null reply");
-    return;
+    LOGW("Null reply");  // LCOV_EXCL_LINE
+    return;  // LCOV_EXCL_LINE
   }
 
   GVariant* reply_body = g_dbus_message_get_body(reply);
   if (reply_body == nullptr) {
+    // LCOV_EXCL_START
     LOGE("g_dbus_message_get_body() is failed");
     watcher->OnPortDisconnected(broker->watch_appid_, broker->watch_port_name_);
     g_object_unref(reply);
     return;
+    // LCOV_EXCL_STOP
   }
 
   int ret;
index a248736..0e5e325 100644 (file)
@@ -107,8 +107,8 @@ class FdBroker {
     void Dispose();
 
    private:
-    DBusMock() = default;
-    ~DBusMock() = default;
+    DBusMock() = default;  // LCOV_EXCL_LINE
+    ~DBusMock() = default;  // LCOV_EXCL_LINE
 
    private:
     std::map<std::string, FdBroker::IEventListener*> ports_;
index 54f2d99..319b921 100644 (file)
@@ -151,18 +151,24 @@ void Parcel::Read(unsigned char* buf, unsigned int size) {
   reader_ += size;
 }
 
+// LCOV_EXCL_START
 void Parcel::ResetReader() {
   reader_ = 0;
 }
+// LCOV_EXCL_STOP
 
+// LCOV_EXCL_START
 void Parcel::Clear() {
   data_.clear();
   reader_ = 0;
 }
+// LCOV_EXCL_STOP
 
+// LCOV_EXCL_START
 void Parcel::Reset(const unsigned char* buf, unsigned int size) {
   Clear();
   Write(buf, size);
 }
+// LCOV_EXCL_STOP
 
 }  // namespace rpc_port
index fa6f3ed..3d45bc2 100644 (file)
@@ -41,8 +41,8 @@ Proxy::Proxy(bool mock)
 Proxy::~Proxy() {
   LOGD("Proxy::~Proxy");
   if (conn_timer_) {
-    g_source_remove(conn_timer_);
-    conn_timer_ = 0;
+    g_source_remove(conn_timer_);  // LCOV_EXCL_LINE
+    conn_timer_ = 0;  // LCOV_EXCL_LINE
   }
 }
 
@@ -126,6 +126,7 @@ void Proxy::OnPortAppeared(const std::string& appid,
   fds_[1] = 0;
   int r = fd_broker_.Send(appid, port_name, &fds_);
   if (r <= 0) {
+    // LCOV_EXCL_START
     IEventListener* listener = listener_;
     listener_ = nullptr;
     if (r == -EILLEGALACCESS)
@@ -133,6 +134,7 @@ void Proxy::OnPortAppeared(const std::string& appid,
     else
       listener->OnDisconnected(appid);
     return;
+    // LCOV_EXCL_STOP
   }
 
   LOGW("[__OnPortAppeared__] fds[0]: %d, fds[1]: %d", fds_[0], fds_[1]);
@@ -149,8 +151,8 @@ void Proxy::OnPortConnected(const std::string& appid,
   LOGW("[__OnPortConnected__] endpoint(%s), port_name(%s)",
       appid.c_str(), port_name.c_str());
   if (!listener_) {
-    LOGW("listener is null");
-    return;
+    LOGW("listener is null");  // LCOV_EXCL_LINE
+    return;  // LCOV_EXCL_LINE
   }
 
   main_port_.reset(new ProxyPort(this, fds_[0], appid, false));
@@ -158,6 +160,7 @@ void Proxy::OnPortConnected(const std::string& appid,
   listener_->OnConnected(appid, main_port_.get());
 }
 
+// LCOV_EXCL_START
 void Proxy::OnPortDisconnected(const std::string& appid,
                                const std::string& port_name, bool cancel) {
   LOGW("[__OnPortDisconnected__] endporint(%s), port_name(%s)",
@@ -177,6 +180,7 @@ void Proxy::OnPortDisconnected(const std::string& appid,
   listener_ = nullptr;
   listener->OnDisconnected(appid);
 }
+// LCOV_EXCL_STOP
 
 int Proxy::Connect(std::string appid, std::string port_name,
                    IEventListener* ev) {
@@ -184,8 +188,8 @@ int Proxy::Connect(std::string appid, std::string port_name,
     return RPC_PORT_ERROR_INVALID_PARAMETER;
 
   if (listener_ != nullptr) {
-    LOGD("Already connected");
-    return RPC_PORT_ERROR_INVALID_PARAMETER;
+    LOGD("Already connected");  // LCOV_EXCL_LINE
+    return RPC_PORT_ERROR_INVALID_PARAMETER;  // LCOV_EXCL_LINE
   }
 
   listener_ = ev;
@@ -193,22 +197,25 @@ int Proxy::Connect(std::string appid, std::string port_name,
   port_name_ = std::move(port_name);
 
   if (conn_timer_)
-    g_source_remove(conn_timer_);
+    g_source_remove(conn_timer_);  // LCOV_EXCL_LINE
   conn_timer_ = g_timeout_add(10 * 1000, DbusNameTimeout, this);
 
   int r = fd_broker_.Watch(this, target_appid_, port_name_);
   if (r < 0) {
+    // LCOV_EXCL_START
     g_source_remove(conn_timer_);
     listener_ = nullptr;
     if (r == -EILLEGALACCESS)
       return RPC_PORT_ERROR_PERMISSION_DENIED;
 
     return RPC_PORT_ERROR_IO_ERROR;
+    // LCOV_EXCL_STOP
   }
 
   return RPC_PORT_ERROR_NONE;
 }
 
+// LCOV_EXCL_START
 int Proxy::ConnectSync(std::string appid, std::string port_name,
                        IEventListener* ev) {
   if (ev == nullptr)
@@ -249,7 +256,9 @@ int Proxy::ConnectSync(std::string appid, std::string port_name,
 
   return RPC_PORT_ERROR_NONE;
 }
+// LCOV_EXCL_STOP
 
+// LCOV_EXCL_START
 gboolean Proxy::DbusNameTimeout(gpointer user_data) {
   Proxy* obj = static_cast<Proxy*>(user_data);
 
@@ -264,6 +273,7 @@ gboolean Proxy::DbusNameTimeout(gpointer user_data) {
 
   return G_SOURCE_REMOVE;
 }
+// LCOV_EXCL_STOP
 
 Proxy::ProxyPort::ProxyPort(Proxy* parent, int fd, const std::string& id,
     bool receive) : Port(fd, id), parent_(parent) {
@@ -287,18 +297,20 @@ int Proxy::ProxyPort::Watch(bool receive) {
 
   gioc_ = g_io_channel_unix_new(fd);
   if (!gioc_) {
-    LOGE("Error is %s", strerror_r(errno, buf, sizeof(buf)));
-    return -1;
+    LOGE("Error is %s", strerror_r(errno, buf, sizeof(buf)));  // LCOV_EXCL_LINE
+    return -1;  // LCOV_EXCL_LINE
   }
 
   disconn_src_ = g_io_add_watch(gioc_,
       (GIOCondition)(G_IO_ERR | G_IO_HUP | G_IO_NVAL),
       Proxy::OnSocketDisconnected, parent_);
   if (disconn_src_ == 0) {
+    // LCOV_EXCL_START
     LOGE("Failed to add watch on socket");
     g_io_channel_unref(gioc_);
     gioc_ = nullptr;
     return -1;
+    // LCOV_EXCL_STOP
   }
 
   if (!receive)
@@ -308,12 +320,14 @@ int Proxy::ProxyPort::Watch(bool receive) {
       (GIOCondition)(G_IO_IN),
       Proxy::OnDataReceived, parent_);
   if (src_ == 0) {
+    // LCOV_EXCL_START
     LOGE("Failed to add watch on socket");
     g_source_remove(disconn_src_);
     disconn_src_ = 0;
     g_io_channel_unref(gioc_);
     gioc_ = nullptr;
     return -1;
+    // LCOV_EXCL_STOP
   }
 
   return 0;
index f906779..13b7cc2 100644 (file)
@@ -59,8 +59,8 @@ RPC_API int rpc_port_parcel_create_from_port(rpc_port_parcel_h* h,
     buf = new unsigned char[len];
     ret = rpc_port_read(port, buf, len);
     if (ret != 0) {
-      delete[] buf;
-      return ret;
+      delete[] buf; // LCOV_EXCL_LINE
+      return ret;  // LCOV_EXCL_LINE
     }
   }
 
@@ -377,6 +377,7 @@ RPC_API int rpc_port_parcel_burst_write(rpc_port_parcel_h h,
   return RPC_PORT_ERROR_NONE;
 }
 
+// LCOV_EXCL_START
 RPC_API int rpc_port_parcel_reset_reader(rpc_port_parcel_h h) {
   if (h == nullptr)
     return RPC_PORT_ERROR_INVALID_PARAMETER;
@@ -387,7 +388,9 @@ RPC_API int rpc_port_parcel_reset_reader(rpc_port_parcel_h h) {
 
   return RPC_PORT_ERROR_NONE;
 }
+// LCOV_EXCL_STOP
 
+// LCOV_EXCL_START
 RPC_API int rpc_port_parcel_to_array(rpc_port_parcel_h h, void **array,
     unsigned int *size) {
   if (h == nullptr || !array || !size)
@@ -406,7 +409,9 @@ RPC_API int rpc_port_parcel_to_array(rpc_port_parcel_h h, void **array,
 
   return RPC_PORT_ERROR_NONE;
 }
+// LCOV_EXCL_STOP
 
+// LCOV_EXCL_START
 RPC_API int rpc_port_parcel_from_array(rpc_port_parcel_h h, const void *array,
     unsigned int size) {
   if (h == nullptr || !array || size == 0)
@@ -417,4 +422,5 @@ RPC_API int rpc_port_parcel_from_array(rpc_port_parcel_h h, const void *array,
   p->Reset(reinterpret_cast<const unsigned char*>(array), size);
 
   return RPC_PORT_ERROR_NONE;
-}
\ No newline at end of file
+}
+// LCOV_EXCL_STOP
index 0b00a1f..932b0a3 100644 (file)
@@ -205,12 +205,14 @@ RPC_API int rpc_port_proxy_create(rpc_port_proxy_h* h) {
   return RPC_PORT_ERROR_NONE;
 }
 
+// LCOV_EXCL_START
 RPC_API int rpc_port_proxy_create_mockup(rpc_port_proxy_h* h) {
   auto p = new ::ProxyExt(true);
 
   *h = p;
   return 0;
 }
+// LCOV_EXL_STOP
 
 RPC_API int rpc_port_proxy_destroy(rpc_port_proxy_h h) {
   if (h == nullptr)
@@ -233,6 +235,7 @@ RPC_API int rpc_port_proxy_connect(rpc_port_proxy_h h, const char* appid,
   return p->Connect(appid, port, p);
 }
 
+// LCOV_EXCL_START
 RPC_API int rpc_port_proxy_connect_sync(rpc_port_proxy_h h, const char* appid,
     const char* port) {
   if (h == nullptr || appid == nullptr || port == nullptr)
@@ -243,6 +246,7 @@ RPC_API int rpc_port_proxy_connect_sync(rpc_port_proxy_h h, const char* appid,
 
   return p->ConnectSync(appid, port, p);
 }
+// LCOV_EXCL_STOP
 
 RPC_API int rpc_port_proxy_add_connected_event_cb(rpc_port_proxy_h h,
     rpc_port_proxy_connected_event_cb cb, void *user_data) {
@@ -329,6 +333,7 @@ RPC_API int rpc_port_stub_create(rpc_port_stub_h* h, const char* port_name) {
   return RPC_PORT_ERROR_NONE;
 }
 
+// LCOV_EXCL_START
 RPC_API int rpc_port_stub_create_mockup(rpc_port_stub_h* h,
                                         const char* port_name) {
   if (h == nullptr || port_name == nullptr)
@@ -339,6 +344,7 @@ RPC_API int rpc_port_stub_create_mockup(rpc_port_stub_h* h,
   *h = p;
   return 0;
 }
+//LCOV_EXCL_STOP
 
 RPC_API int rpc_port_stub_destroy(rpc_port_stub_h h) {
   if (h == nullptr)
index 2630364..8b0476a 100644 (file)
@@ -78,7 +78,7 @@ std::shared_ptr<Port> Stub::FindDelegatePort(
     }
   }
 
-  return {};
+  return {};  // LCOV_EXCL_LINE
 }
 
 void Stub::RemoveAcceptedPorts(std::string instance) {
@@ -107,7 +107,7 @@ gboolean Stub::OnDataReceived(GIOChannel *gio, GIOCondition cond,
         stub->RemoveAcceptedPorts(p->GetInstance());
 
         if (aul_rpc_port_notify_rpc_finished() != AUL_R_OK)
-          LOGW("Failed to notify rpc finished");
+          LOGW("Failed to notify rpc finished");  // LCOV_EXCL_LINE
 
         return FALSE;
       }
@@ -121,7 +121,7 @@ gboolean Stub::OnDataReceived(GIOChannel *gio, GIOCondition cond,
         stub->RemoveAcceptedPorts(p->GetInstance());
 
         if (aul_rpc_port_notify_rpc_finished() != AUL_R_OK)
-          LOGW("Failed to notify rpc finished");
+          LOGW("Failed to notify rpc finished");  // LCOV_EXCL_LINE
 
         return FALSE;
       }
@@ -143,7 +143,7 @@ gboolean Stub::OnSocketDisconnected(GIOChannel *gio, GIOCondition cond,
     if (p->GetFd() == fd) {
       stub->listener_->OnDisconnected(p->GetId(), p->GetInstance());
       if (aul_rpc_port_notify_rpc_finished() != AUL_R_OK)
-        LOGW("Failed to notify rpc finished");
+        LOGW("Failed to notify rpc finished");  // LCOV_EXCL_LINE
       stub->RemoveAcceptedPorts(p->GetInstance());
       break;
     }
@@ -197,18 +197,22 @@ int Stub::AcceptedPort::Watch(bool receive) {
 
   gioc_ = g_io_channel_unix_new(fd);
   if (!gioc_) {
+    // LCOV_EXCL_START
     LOGE("Error is %s", strerror_r(errno, buf, sizeof(buf)));
     return -1;
+    // LCOV_EXCL_STOP
   }
 
   disconn_src_ = g_io_add_watch(gioc_,
                                 (GIOCondition)(G_IO_ERR | G_IO_HUP | G_IO_NVAL),
                                 Stub::OnSocketDisconnected, parent_);
   if (disconn_src_ == 0) {
+    // LCOV_EXCL_START
     LOGE("fail to add watch on socket");
     g_io_channel_unref(gioc_);
     gioc_ = nullptr;
     return -1;
+    // LCOV_EXCL_STOP
   }
 
   if (!receive)
@@ -218,12 +222,14 @@ int Stub::AcceptedPort::Watch(bool receive) {
                         (GIOCondition)(G_IO_IN),
                         Stub::OnDataReceived, parent_);
   if (src_ == 0) {
+    // LCOV_EXCL_START
     LOGE("fail to add watch on socket");
     g_source_remove(disconn_src_);
     disconn_src_ = 0;
     g_io_channel_unref(gioc_);
     gioc_ = nullptr;
     return -1;
+    // LCOV_EXCL_STOP
   }
 
   return 0;