utest: fix protex issue 15/164315/2
authorRoman Marchenko <r.marchenko@samsung.com>
Mon, 18 Dec 2017 11:23:44 +0000 (13:23 +0200)
committerRoman Marchenko <r.marchenko@samsung.com>
Mon, 18 Dec 2017 12:03:16 +0000 (14:03 +0200)
Change-Id: I8c2e93345ba14375853ac7f001deb211df2744df

utests/src/ut_main.cpp
utests/src/ut_tdm_client.cpp
utests/src/ut_tdm_hwc_window.cpp

index 8d0544a..6443f33 100644 (file)
 
 int main(int argc, char **argv)
 {
-       ::testing::InitGoogleTest(&argc, argv);
-       ::testing::FLAGS_gtest_death_test_style = "fast";
+       try {
+               ::testing::InitGoogleTest(&argc, argv);
+               ::testing::FLAGS_gtest_death_test_style = "fast";
+       } catch ( ... ) {
+               std::cout << "error while trying to init google tests.\n";
+               exit(EXIT_FAILURE);
+       }
        return RUN_ALL_TESTS();
 }
index 3c88875..ba4bb07 100644 (file)
@@ -105,7 +105,7 @@ tdm_client_test_prepare dont_use_it;
 class TDMClientTest : public ::testing::Test
 {
 protected:
-       TDMClientTest() : error(TDM_ERROR_NONE), server_pid(0), cl_serv_lock_fd(-1),
+       TDMClientTest() : error(TDM_ERROR_NONE), server_pid(0),
                dsp(nullptr), output(nullptr), layer(nullptr), buffer(nullptr), is_server_stopped(false)
        {
                set_env_vars();
@@ -237,14 +237,25 @@ private:
 
        void send_request(int req)
        {
-               send(socks_pair.client_socket, &req, sizeof req, 0);
+               int count;
+
+               count = send(socks_pair.client_socket, &req, sizeof req, 0);
+
+               if (count != sizeof req)
+                       std::cout << "error while trying to send request to socks_pair.client_socket.\n";
        }
 
        void handle_client_request()
        {
                int req;
+               int count;
 
-               recv(socks_pair.server_socket, &req, sizeof req, 0);
+               count = recv(socks_pair.server_socket, &req, sizeof req, 0);
+
+               if (count != sizeof req) {
+                       std::cout << "error while trying to reserve data from socks_pair.server_socket.\n";
+                       return;
+               }
 
                switch(req)
                {
@@ -472,6 +483,11 @@ void TDMClientTest::init_tdm(void)
        for (int i = 0; i < outputs_cnt; i++)
        {
                output = tdm_display_get_output(dsp, i, nullptr);
+               if (output == NULL) {
+                       std::cout << "tdm_display_get_output faild, server's gonna be stopped.\n";
+                       deinit_tdm();
+                       exit(EXIT_FAILURE);
+               }
                tdm_output_get_output_type(output, &tdm_output_type);
 
                /* we're not interesting about other outputs */
index 2b62c0e..13b7cc2 100644 (file)
@@ -330,7 +330,7 @@ TEST_F(TDMOutputHwc, DISABLED_SetClientTargetBufferSuccessfulSetBuff)
 
 TEST_F(TDMOutputHwc, DISABLED_SetClientTargetBufferSuccessfulResetBuff)
 {
-       tdm_hwc_region damage;
+       tdm_hwc_region damage = {.num_rects = 0, .rects = NULL};
 
        for (int i = 0; i < output_count; i++) {
                if (IsHwcEnable(i)) {