-utc_eet_connection_close.c
-utc_eet_connection_empty.c
-utc_eet_connection_new.c
-utc_eet_connection_node_send.c
-utc_eet_connection_received.c
-utc_eet_connection_send.c
+utc_eet_connection.c
-utc_eet_connection_close.c
-utc_eet_connection_empty.c
-utc_eet_connection_new.c
-utc_eet_connection_node_send.c
-utc_eet_connection_received.c
-utc_eet_connection_send.c
+utc_eet_connection.c
-utc_eet_connection_close.c
-utc_eet_connection_empty.c
-utc_eet_connection_new.c
-utc_eet_connection_node_send.c
-utc_eet_connection_received.c
-utc_eet_connection_send.c
+utc_eet_connection.c
-utc_eet_connection_close.c
-#utc_eet_connection_empty.c
-utc_eet_connection_new.c
-utc_eet_connection_node_send.c
-utc_eet_connection_received.c
-#utc_eet_connection_send.c
+utc_eet_connection.c
--- /dev/null
+#include <check.h>
+#include <Eet.h>
+#include <netinet/in.h>
+#include "../utc_eet_utils.h"
+
+Eina_Bool called = EINA_FALSE;
+Eina_Bool called_w = EINA_FALSE;
+Eet_Data_Descriptor *edd = NULL;
+
+/**
+ * @addtogroup eet
+ * @{
+ * @defgroup eet_connection
+ *
+ *
+ * @precondition
+ * @step 1 eet initialized successfully through eet_init()
+ * @step 2 Call utils_create_eet_data_descriptor to create initialized Eet_Data_Descriptor
+ */
+static void
+setup(void)
+{
+ printf(" ============ Startup ============ \n");
+ eet_init();
+
+ edd = utils_eet_create_data_descriptor();
+}
+
+static void
+teardown(void)
+{
+ printf(" ============ Cleanup ============ \n");
+ eet_data_descriptor_free(edd);
+ eet_shutdown();
+}
+
+Eina_Bool Read_Cb(const void *eet_data, size_t size, void *user_data)
+{
+ called = EINA_TRUE;
+ return EINA_TRUE;
+}
+
+Eina_Bool Write_Cb(const void *data, size_t size, void *user_data)
+{
+ called_w = EINA_TRUE;
+ return EINA_TRUE;
+}
+
+/**
+ * @addtogroup eet_connection
+ * @{
+ * @defgroup eet_connection_pack_p
+ * @li eet_connection_new()
+ * @li eet_connection_close()
+ * @li eet_connection_node_send()
+ * @li eet_connection_send()
+ * @li eet_connection_received()
+ * @li eet_connection_empty()
+ * @{
+ * @objective Positive test 01 case checking if the functions works correctly and without errors.
+ *
+ * @procedure
+ * @step 1 Create new connection with NULL as an user_data argument.
+ * @step 2 Create new connection with valid arguments by call eet_connection_new().
+ * @step 3 Call eet_connection_node_send(), try send eet_node object.
+ * @step 4 Call eet_connection_send() with data and check returned value.
+ * @step 5 Call eet_connection_received().
+ * @step 6 Call eet_connection_empty().
+ * @step 7 Call eet_connection_close().
+ *
+ * @passcondition Function doesn't cause segmentation fault and returned value is not NULL.
+ * @}
+ * @}
+ */
+START_TEST(utc_eet_connection_pack_p)
+{
+ int value = 2;
+ Eina_Bool on_going = EINA_FALSE;
+ Eet_Connection *conn;
+ Eet_Connection *conn2;
+ Eet_Node *node;
+ Example_Struct1 st1 = {0};
+ int data[2] = { htonl(0x4270ACE1), 0 };
+ int size = sizeof data;
+
+ conn2 = eet_connection_new(Read_Cb, Write_Cb, &value);
+ if (conn2 == NULL)
+ {
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. function returned %d..", __FILE__, __LINE__, value);
+ }
+ if (eet_connection_close(conn2, &on_going) != &value)
+ {
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ else if (on_going == EINA_TRUE)
+ {
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+
+ conn = eet_connection_new(Read_Cb, Write_Cb, NULL);
+ if (conn == NULL)
+ {
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+
+ int number = eet_connection_received(conn, &data, size);
+ eet_connection_close(conn, NULL);
+ if (number != 0 || !called)
+ {
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. function returned %d..", __FILE__, __LINE__, number);
+ }
+
+ conn = eet_connection_new(Read_Cb, Write_Cb, NULL);
+ if (conn == NULL)
+ {
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ node = eet_node_char_new("name", 0x20);
+ if (!node)
+ {
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed, Eet_Node is not created..", __FILE__, __LINE__);
+ }
+ else if (eet_connection_node_send(conn, node, NULL) != EINA_TRUE || !called)
+ {
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ else if (eet_connection_node_send(conn, node, "abc128") != EINA_TRUE || !called_w)
+ {
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ eet_connection_close(conn, NULL);
+ eet_node_del(node);
+ called_w = EINA_FALSE;
+
+ conn = eet_connection_new(Read_Cb, Write_Cb, NULL);
+ if (conn == NULL)
+ {
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ if (eet_connection_send(conn, edd, &st1, NULL) != EINA_TRUE || !called_w)
+ {
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+ called_w = EINA_FALSE;
+ if (eet_connection_send(conn, edd, &st1, "abc128") != EINA_TRUE || !called_w)
+ {
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+
+ if (!eet_connection_empty(conn))
+ {
+ /*TODO Write test case that will check if is some data pending inside*/
+ ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
+ }
+
+ eet_connection_close(conn, NULL);
+
+ printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
+}
+END_TEST
+
+/**
+ *@}
+ */
+Suite *
+test_suite(void)
+{
+ Suite *suite = suite_create("utc_eet_connection");
+
+ TCase *tcase = tcase_create("TCase");
+ tcase_set_timeout(tcase, 30);
+ tcase_add_checked_fixture(tcase, setup, teardown);
+ tcase_add_test(tcase, utc_eet_connection_pack_p);
+
+ suite_add_tcase(suite, tcase);
+
+ return suite;
+}
+
+int
+main()
+{
+ int number_failed;
+
+ Suite *suite = test_suite();
+ SRunner *srunner = srunner_create(suite);
+ srunner_set_log(srunner, "utc_eet_connection.log");
+ srunner_set_xml(srunner, "utc_eet_connection.xml");
+ srunner_run_all(srunner, CK_NORMAL);
+ number_failed = srunner_ntests_failed(srunner);
+ srunner_free(srunner);
+
+ return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
+}
+++ /dev/null
-#include <check.h>
-#include <Eet.h>
-#include "../../utc_negative_unitest.h"
-
-/**
- * @addtogroup eet_connection
- * @{
- * @defgroup eet_connection_close eet_connection_close()
- *
- *
- * @precondition
- * @step 1 eet initialized successfully through eet_init()
- */
-
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eet_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eet_shutdown();
-}
-
-Eina_Bool Read_Cb(const void *eet_data, size_t size, void *user_data)
-{
- return EINA_TRUE;
-}
-
-Eina_Bool Write_Cb(const void *data, size_t size, void *user_data)
-{
- return EINA_TRUE;
-}
-
-/**
- * @addtogroup eet_connection_close
- * @{
- * @objective Positive test case checks:
- * @li function doesn't return NULL;
- * @li returned pointer points to the same data that were passed to connection when it was being created.
- * @li there are no incomplete data packets are in the connection.
- *
- * @n Input Data:
- * @li valid connection
- * @li pointer to Eina_Bool variable to be set if a partial packet wasn't completed
- *
- * @procedure
- * @step 1 Create a new connection and pass to it pointer to some data.
- * @step 2 Close this connection.
- * @step 3 Check if passed (step 1) and returned (step 2) pointers point to the same value.
- * @step 4 Check on_going out parameter - it should be set to EINA_FALSE still no data
- * were transferred via the connection.
- *
- * @passcondition
- * @li Pointers to data passed to connection when it was being created and data returned by
- * eet_connection_close are the same.
- * @li on_going parameter is set to EINA_FALSE.
- * @}
- */
-START_TEST(utc_eet_connection_close_p)
-{
- Eina_Bool on_going = EINA_FALSE;
- int data = 123456;
- Eet_Connection *conn = eet_connection_new(Read_Cb, Write_Cb, &data);
-
- if (!conn)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed, Eet_Connection is not created..", __FILE__, __LINE__);
- }
- else if (eet_connection_close(conn, &on_going) != &data)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed, pointers aren't the same..", __FILE__, __LINE__);
- }
- else if (on_going == EINA_TRUE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed, on_going equals EINA_TRUE..", __FILE__, __LINE__);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- }
-}
-END_TEST
-
-/**
- * @addtogroup eet_connection_close
- * @{
- * @objective Negative test case checks:
- * @li function doesn't cause segmentation fault with NULL instead of
- * valid connection or on_going parameter;
- * @li function returns NULL if any parameter is NULL.
- *
- * @n Input_Data:
- * @li NULL instead of valid connection and pointer to on_going (EINA_BOOL) variable
- * @li valid connection and NULL instead of on_going (EINA_BOOL) variable
- *
- * @procedure
- * @step 1 Create eet_connection object with NULL as user_data parameter instead of valid context handler pointer.
- * @step 2 Call function with NULL instead of connection and check returned value.
- * @step 3 Call function with NULL instead of on_going.
- *
- * @passcondition Function doesn't cause segmentation fault and returns NULL pointer.
- * @}
- */
-START_TEST(utc_eet_connection_close_n)
-{
- Eina_Bool on_going = EINA_FALSE;
- int data = 123456;
-
- Eet_Connection* conn = eet_connection_new(Read_Cb, Write_Cb, &data);
-
- if (!conn)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed, Eet_Connection is not created..", __FILE__, __LINE__);
- }
-
- CREATE_CHECKED_ARGS_ARRAY(1, 0)
- UNITEST_FUNC_NEG_CA_RET(NULL, eet_connection_close, conn, &on_going)
-
- if (result_of_testing == TEST_FAIL || on_going == EINA_TRUE)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- }
-
- eet_connection_close(conn, NULL);
-
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eet_connection_close");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eet_connection_close_p);
- tcase_add_test(tcase, utc_eet_connection_close_n);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eet_connection_close.log");
- srunner_set_xml(srunner, "utc_eet_connection_close.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eet.h>
-#include "../../utc_negative_unitest.h"
-
-/**
- * @addtogroup eet_connection
- * @{
- * @defgroup eet_connection_empty eet_connection_empty()
- *
- * @precondition
- * @step 1 eet initialized successfully through eet_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eet_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eet_shutdown();
-}
-
-Eina_Bool Read_Cb(const void *eet_data, size_t size, void *user_data)
-{
- return EINA_TRUE;
-}
-
-Eina_Bool Write_Cb(const void *data, size_t size, void *user_data)
-{
- return EINA_TRUE;
-}
-
-/**
- * @addtogroup eet_connection_empty
- * @{
- * @objective Positive test case checks if data pass through connetion not in pending state.
- *
- * @n Input Data:
- * @li Valid Eet_Connetion
- *
- * @procedure
- * @step 1 Create new connection with NULL as an user_data argument.
- * @step 2 Call target function
- *
- * @passcondition Function doesn't cause segmentation fault and returns EINA_FALSE.
- * @}
- */
-START_TEST(utc_eet_connection_empty_p)
-{
- int data[2] = { htonl(0x4270ACE1), 0 };
- int size = sizeof data;
-
- Eet_Connection *conn = eet_connection_new(Read_Cb, Write_Cb, NULL);
-
- if (conn == NULL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Connection wasn't created..", __FILE__, __LINE__);
- }
- else if (eet_connection_received(conn, &data, size))
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Data wasn't send..", __FILE__, __LINE__);
- }
- else if (!eet_connection_empty(conn))
- {
- /*TODO Write test case that will check if is some data pending inside*/
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- }
- eet_connection_close(conn, NULL);
-}
-END_TEST
-
-/**
- * @addtogroup eet_connection_empty
- * @{
- * @objective Negative test case checks if function doesn't cause segmentation and returns EINA_FALSE
- * if it is called with NULL as connection arguments.
- *
- * @ Input Data:
- * @li NULL as Eet_Connection
- *
- * @procedure
- * @step 1 Call function and pass (in turn) NULL instead of argument.
- *
- * @passcondition Function doesn't cause segmentation fault and return EINA_FALSE.
- * @}
- */
-START_TEST(utc_eet_connection_empty_n)
-{
-
- if (UNITEST_FUNC_NEG_RET(EINA_TRUE, eet_connection_empty, NULL) == TEST_FAIL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- }
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eet_connection_empty");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eet_connection_empty_p);
- tcase_add_test(tcase, utc_eet_connection_empty_n);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eet_connection_empty.log");
- srunner_set_xml(srunner, "utc_eet_connection_empty.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eet.h>
-#include "../../utc_negative_unitest.h"
-
-/**
- * @addtogroup eet_connection
- * @{
- * @defgroup eet_connection_new eet_connection_new()
- *
- *
- * @precondition
- * @step 1 eet initialized successfully through eet_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eet_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eet_shutdown();
-}
-
-Eina_Bool Read_Cb(const void *eet_data, size_t size, void *user_data)
-{
- return EINA_TRUE;
-}
-
-Eina_Bool Write_Cb(const void *data, size_t size, void *user_data)
-{
- return EINA_TRUE;
-}
-
-/**
- * @addtogroup eet_connection_new
- * @{
- * @objective Positive test case 1 checks if function creates new connection correctly
- * with NULL instead of user_data argument.
- *
- * @n Input Data:
- * @li callback to call when one Eet_Data packet has been fully assembled;
- * @li callback to call when one Eet_Data packet is ready to be send over the wire;
- * @li NULL instead of user_data (context handler).
- *
- * @procedure
- * @step 1 Create new connection with NULL as an user_data argument.
- *
- * @passcondition Function doesn't cause segmentation fault and returned value is not NULL.
- * @}
- */
-START_TEST(utc_eet_connection_new_p_1)
-{
- Eet_Connection *conn = eet_connection_new(Read_Cb, Write_Cb, NULL);
-
- if (conn == NULL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
- eet_connection_close(conn, NULL);
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-
-/**
- * @addtogroup eet_connection_new
- * @{
- * @objective Positive test case 2 checks if function creates new connection with valid arguments correctly.
- * @n Input Data:
- * @li callback to call when one Eet_Data packet has been fully assembled;
- * @li callback to call when one Eet_Data packet is ready to be send over the wire;
- * @li Pointer to local integer variable (provided to both callbacks to be used as a context handler).
- *
- * @procedure
- * @step 1 Create new connection with valid arguments.
- *
- * @passcondition Function doesn't return NULL.
- * @}
- */
-START_TEST(utc_eet_connection_new_p_2)
-{
- int value = 2;
-
- Eet_Connection *conn = eet_connection_new(Read_Cb, Write_Cb, &value);
-
- if (conn == NULL)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
- eet_connection_close(conn, NULL);
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-
-/**
- * @addtogroup eet_connection_new
- * @{
- * @objective Negative test case checks if function doesn't cause segmentation fault and
- * doesn't create connection if it is called with NULL as eet_read_cb or eet_write_cb arguments.
- *
- * @ Input Data:
- * @li callback to call when one Eet_Data packet has been fully assembled;
- * @li callback to call when one Eet_Data packet is ready to be send over the wire;
- * @li NULL instead of user_data (context handler).
- *
- * @procedure
- * @step 1 Call function 2 times and pass (in turn) NULL instead of callbacks
- * eet_read_cb and eet_write_cb.
- *
- * @passcondition Function doesn't cause segmentation fault and doesn't create connection.
- * @}
- */
-START_TEST(utc_eet_connection_new_n)
-{
-
- CREATE_CHECKED_ARGS_ARRAY(1, 1, 0);
- UNITEST_FUNC_NEG_CA_RET(NULL, eet_connection_new, Read_Cb, Write_Cb, NULL);
-
- if (result_of_testing == TEST_FAIL)
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- else
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eet_connection_new");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eet_connection_new_p_1);
- tcase_add_test(tcase, utc_eet_connection_new_p_2);
- tcase_add_test(tcase, utc_eet_connection_new_n);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eet_connection_new.log");
- srunner_set_xml(srunner, "utc_eet_connection_new.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eet.h>
-#include "../../utc_negative_unitest.h"
-
-Eina_Bool called = EINA_FALSE;
-
-/**
- * @addtogroup eet_connection
- * @{
- * @defgroup eet_connection_node_send eet_connection_node_send()
- *
- *
- * @precondition
- * @step 1 eet initialized successfully through eet_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eet_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eet_shutdown();
-}
-
-Eina_Bool Read_Cb(const void *eet_data, size_t size, void *user_data)
-{
- return EINA_TRUE;
-}
-
-Eina_Bool Write_Cb(const void *data, size_t size, void *user_data)
-{
- called = EINA_TRUE;
- return EINA_TRUE;
-}
-
-/**
- * @addtogroup eet_connection_node_send
- * @{
- * @objective Positive test case 1 checks if function correctly sends eet_node object
- * if it is called with valid arguments but with NULL instead of cipher_key. Also function shouldn't
- * cause segmentation fault.
- *
- * @n Input Data:
- * @li valid Eet_Connection;
- * @li pointer to data that should be sent (Eet_Node structure);
- * @li NULL instead of cipher_key.
- *
- * @procedure
- * @step 1 Create new connection
- * @step 2 Create eet_node object
- * @step 3 Call function, try send eet_node object
- * @step 4 Close connection
- *
- * @passcondition Function doesn't cause segmentation fault, returns EINA_TRUE and callback Write_Cb was called.
- * @}
- */
-START_TEST(utc_eet_connection_node_send_p_1)
-{
- Eet_Connection *conn = eet_connection_new(Read_Cb, Write_Cb, NULL);
- Eet_Node *node = eet_node_char_new("name", 0x20);
-
- if (!conn)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed, Eet_Connection is not created..", __FILE__, __LINE__);
- }
- else if (!node)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed, Eet_Node is not created..", __FILE__, __LINE__);
- }
- else if (eet_connection_node_send(conn, node, NULL) != EINA_TRUE || !called)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- }
- eet_node_del(node);
- eet_connection_close(conn, NULL);
- called = EINA_FALSE;
-}
-END_TEST
-
-/**
- * @addtogroup eet_connection_node_send
- * @{
- * @objective Positive test case 2 checks if function correctly sends eet_node object
- * if it is called with all arguments.
- *
- * @n Input Data:
- * @li valid Eet_Connection;
- * @li pointer to data that should be sent (Eet_Node structure);
- * @li "abc128" string as cipher_key.
- *
- * @procedure
- * @step 1 Create new connection
- * @step 2 Create eet_node object
- * @step 3 Call function, try send eet_node object
- * @step 4 Close connection
- *
- * @passcondition Function returns EINA_TRUE and callback Write_Cb was called.
- * @}
- */
-START_TEST(utc_eet_connection_node_send_p_2)
-{
- char *cipher_key = "abc128";
- Eet_Connection *conn = eet_connection_new(Read_Cb, Write_Cb, NULL);
- Eet_Node *node = eet_node_char_new("name", 0x20);
-
- if (!conn)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed, Eet_Connection is not created..", __FILE__, __LINE__);
- }
- else if (!node)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed, Eet_Node is not created..", __FILE__, __LINE__);
- }
- else if (eet_connection_node_send(conn, node, cipher_key) != EINA_TRUE || !called)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- }
- eet_node_del(node);
- eet_connection_close(conn, NULL);
- called = EINA_FALSE;
-}
-END_TEST
-
-/**
- * @addtogroup eet_connection_node_send
- * @{
- * @objective Negative test case checks if function doesn't cause segmentation fault
- * and returns EINA_FALSE if it is called with NULL instead of some arguments.
- *
- * @n Input Data:
- * @li valid Eet_Connection;
- * @li pointer to data that should be sent (Eet_Node structure);
- * @li NULL instead of cipher_key.
- *
- * @procedure
- * @step 1 Create new connection
- * @step 2 Create eet_node object
- * @step 3 Call function 2 times and pass (in turn) NULL instead of connection and node
- * @step 4 Close connection
- *
- * @passcondition Function doesn't cause segmentation fault, returns EINA_FALSE and callback Write_Cb wasn't called.
- * @}
- */
-START_TEST(utc_eet_connection_node_send_n)
-{
- Eet_Connection *conn = eet_connection_new(Read_Cb, Write_Cb, NULL);
- Eet_Node *node = eet_node_char_new("name", 0x20);
-
- if (!conn)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed, Eet_Connection is not created..", __FILE__, __LINE__);
- }
- else if (!node)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed, Eet_Node is not created..", __FILE__, __LINE__);
- }
- else
- {
- CREATE_CHECKED_ARGS_ARRAY(1, 1, 0);
- UNITEST_FUNC_NEG_CA_RET(EINA_FALSE, eet_connection_node_send, conn, node, NULL);
-
- if (result_of_testing == TEST_FAIL || called)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- }
- }
- eet_node_del(node);
- eet_connection_close(conn, NULL);
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eet_connection_node_send");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eet_connection_node_send_p_1);
- tcase_add_test(tcase, utc_eet_connection_node_send_p_2);
- tcase_add_test(tcase, utc_eet_connection_node_send_n);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eet_connection_node_send.log");
- srunner_set_xml(srunner, "utc_eet_connection_node_send.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eet.h>
-#include <netinet/in.h>
-#include "../../utc_negative_unitest.h"
-
-#define MAGIC_EET_DATA_PACKET 0x4270ACE1
-
-Eina_Bool called = EINA_FALSE;
-
-/**
- * @addtogroup eet_connection
- * @{
- * @defgroup eet_connection_received eet_connection_received()
- *
- * @precondition
- * @step 1 eet initialized successfully through eet_init()
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eet_init();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eet_shutdown();
-}
-
-Eina_Bool Read_Cb(const void *eet_data, size_t size, void *user_data)
-{
- called = EINA_TRUE;
- return EINA_TRUE;
-}
-
-Eina_Bool Write_Cb(const void *data, size_t size, void *user_data)
-{
- return EINA_TRUE;
-}
-
-/**
- * @addtogroup eet_connection_received
- * @{
- * @objective Positive test case checks if function returns proper value if it
- * is called with valid arguments.
- *
- * @n Input Data:
- * @li valid Eet_Connection;
- * @li pointer to raw data packet - array from 2 integers, first from them must have value
- * 0x4270ACE1, converted to network byte order (via htonl function);
- * @li size of raw data packet.
- *
- * @procedure
- * @step 1 Prepare packet data
- * @step 2 Create new connection
- * @step 3 Call the function with valid arguments
- * @step 4 Close connection
- *
- * @passcondition Function returns 0 and callback Read_Cb was called.
- * @}
- */
-START_TEST(utc_eet_connection_received_p)
-{
- int data[2] = { htonl(0x4270ACE1), 0 };
- int size = sizeof data;
- Eet_Connection *conn = eet_connection_new(Read_Cb, Write_Cb, NULL);
-
- if (!conn)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed, Eet_Connection is not created..", __FILE__, __LINE__);
- }
- int number = eet_connection_received(conn, &data, size);
- eet_connection_close(conn, NULL);
-
- if (number != 0 || !called)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. function returned %d..", __FILE__, __LINE__, number);
- }
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- called = EINA_FALSE;
-}
-END_TEST
-
-/**
- * @addtogroup eet_connection_received
- * @{
- * @objective Negative test case 1 checks if function doesn't cause segmentation fault
- * and returns expected value if it is called with NULL instead of some arguments.
- *
- * @n Input Data:
- * @li valid Eet_Connection;
- * @li pointer to raw data packet (integer value 12345);
- * @li sizeof(int)*2 - minimal size of raw data packet.
- *
- * @procedure
- * @step 1 Create new connection
- * @step 2 Call function 2 times and pass (in turn) NULL instead of connection
- * and pointer to raw data packet
- *
- * @passcondition Function doesn't cause segmentation fault and returned value
- * is equal to passed packet size (here: sizeof(int)*2) and callback Read_Cb wasn't called.
- * @}
- */
-START_TEST(utc_eet_connection_received_n_1)
-{
- int data = 123456;
- int size = sizeof(int)*2;
- Eet_Connection *conn = eet_connection_new(Read_Cb, Write_Cb, NULL);
-
- if (!conn)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed, Eet_Connection is not created..", __FILE__, __LINE__);
- }
-
- CREATE_CHECKED_ARGS_ARRAY(1, 1, 0);
- UNITEST_FUNC_NEG_CA_RET(size, eet_connection_received, conn, &data, (size_t)size);
-
- if (result_of_testing == TEST_FAIL || called)
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- else
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-
- eet_connection_close(conn, NULL);
- called = EINA_FALSE;
-}
-END_TEST
-
-/**
- * @addtogroup eet_connection_received
- * @{
- * @objective Negative test case 2 checks if function doesn't cause segmentation fault
- * and returns expected value if it is called with wrong 'size' arguments.
- * @n Input Data:
- * @li valid Eet_Connection;
- * @li pointer to raw data packet (integer value 12345);
- * @li sizeof(int)*10 - wrong size of raw data packet.
- *
- * @procedure
- * @step 1 Create new connection
- * @step 2 Call function and pass wrong size value
- *
- * @passcondition Function doesn't cause segmentation fault and returns value not equal 0 (it means
- * error occurred) and callback Read_Cb wasn't called.
- * @}
- */
-START_TEST(utc_eet_connection_received_n_2)
-{
- int data = 123456;
- int size = sizeof(int)*10;
- Eet_Connection *conn = eet_connection_new(Read_Cb, Write_Cb, NULL);
-
- if (!conn)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed, Eet_Connection is not created..", __FILE__, __LINE__);
- }
-
- if (!eet_connection_received(conn, &data, size) || called)
- {
- eet_connection_close(conn, NULL);
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed.. function returned 0", __FILE__, __LINE__);
- }
- eet_connection_close(conn, NULL);
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eet_connection_received");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eet_connection_received_p);
- tcase_add_test(tcase, utc_eet_connection_received_n_1);
- tcase_add_test(tcase, utc_eet_connection_received_n_2);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eet_connection_received.log");
- srunner_set_xml(srunner, "utc_eet_connection_received.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}
+++ /dev/null
-#include <check.h>
-#include <Eet.h>
-#include "../../utc_negative_unitest.h"
-#include "../utc_eet_utils.h"
-
-Eina_Bool called = EINA_FALSE;
-Eet_Data_Descriptor *edd = NULL;
-
-/**
- * @addtogroup eet_connection
- * @{
- * @defgroup eet_connection_send eet_connection_send()
- *
- *
- * @precondition
- * @step 1 eet initialized successfully through eet_init()
- * @step 2 Call utils_create_eet_data_descriptor to create initialized Eet_Data_Descriptor
- */
-static void
-setup(void)
-{
- printf(" ============ Startup ============ \n");
- eet_init();
-
- edd = utils_eet_create_data_descriptor();
-}
-
-static void
-teardown(void)
-{
- printf(" ============ Cleanup ============ \n");
- eet_data_descriptor_free(edd);
- eet_shutdown();
-}
-
-Eina_Bool Read_Cb (const void *eet_data, size_t size, void *user_data)
-{
- return EINA_TRUE;
-}
-
-Eina_Bool Write_Cb (const void *data, size_t size, void *user_data)
-{
- called = EINA_TRUE;
- return EINA_TRUE;
-}
-
-/**
- * @addtogroup eet_connection_send
- * @{
- * @objective Positive test case 1 checks if function returns Eina_True if it is called
- * with valid arguments but with NULL instead of cipher_key. Also function shouldn't
- * cause segmentation fault.
- *
- * @n Input Data:
- * @li valid Eet_Connection;
- * @li data descriptor with info about data type for sending;
- * @li pointer to data for sending;
- * @li NULL instead of cipher_key.
- *
- * @procedure
- * @step 1 Create connection
- * @step 2 Send data and check returned value
- * @step 3 Close connection
- *
- * @passcondition Function doesn't cause segmentation fault and returns EINA_TRUE
- * @}
- */
-START_TEST(utc_eet_connection_send_p_1)
-{
- if (!edd)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
- Example_Struct1 data = {0};
- Eet_Connection *conn = eet_connection_new(Read_Cb, Write_Cb, NULL);
-
- if (!conn)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed, Eet_Connection is not created..", __FILE__, __LINE__);
- }
- else if (eet_connection_send(conn, edd, &data, NULL) != EINA_TRUE || !called)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- called = EINA_FALSE;
- }
- eet_connection_close(conn, NULL);
-}
-END_TEST
-
-/**
- * @addtogroup eet_connection_send
- * @{
- * @objective Positive test case 2 checks if function returns Eina_True
- * if it is called with valid arguments.
- *
- * @n Input Data:
- * @li valid Eet_Connection;
- * @li data descriptor with info about data type for sending;
- * @li pointer to data for sending;
- * @li "abc128" string as a cipher_key.
- *
- * @procedure
- * @step 1 Create connection
- * @step 2 Send data and check returned value
- * @step 3 Close connection
- *
- * @passcondition Function returns EINA_TRUE
- * @}
- */
-START_TEST(utc_eet_connection_send_p_2)
-{
- if (!edd)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
- Example_Struct1 data = {0};
- char *cipher_key = "abc128";
- Eet_Connection *conn = eet_connection_new(Read_Cb, Write_Cb, NULL);
-
- if (!conn)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed, Eet_Connection is not created..", __FILE__, __LINE__);
- }
- else if (eet_connection_send(conn, edd, &data, cipher_key) != EINA_TRUE || !called)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- called = EINA_FALSE;
- }
- eet_connection_close(conn, NULL);
-}
-END_TEST
-
-/**
- * @addtogroup eet_connection_send
- * @{
- * @objective Negative test case checks if function doesn't cause segmentation fault
- * and returns EINA_FALSE if it is called with NULL instead of some arguments.
- *
- * @n Input Data:
- * @li valid Eet_Connection;
- * @li data descriptor with info about data type for sending;
- * @li pointer to data for sending;
- * @li NULL instead of cipher_key.
- *
- * @procedure
- * @step 1 Create connection
- * @step 2 Call function 3 times and pass (in turn) NULL instead of connection,
- * data descriptor and data to be sent
- *
- * @passcondition Function doesn't cause segmentation fault end returns EINA_FALSE.
- * @}
- */
-START_TEST(utc_eet_connection_send_n)
-{
- if (!edd)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
- Example_Struct1 data = {0};
- Eet_Connection *conn = eet_connection_new(Read_Cb, Write_Cb, NULL);
-
- if (!conn)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed, Eet_Connection is not created..", __FILE__, __LINE__);
- }
-
- CREATE_CHECKED_ARGS_ARRAY(1, 1, 1, 0);
- UNITEST_FUNC_NEG_CA_RET(EINA_FALSE, eet_connection_send, conn, edd, &data, NULL);
-
- if (result_of_testing == TEST_FAIL || called)
- {
- ck_abort_msg("[TEST_FAIL]:: %s[%d] : Test has failed..", __FILE__, __LINE__);
- }
- else
- {
- printf("[TEST_PASS]:: %s[%d] : Test has passed..\n", __FILE__, __LINE__);
- }
-
- eet_connection_close(conn, NULL);
-}
-END_TEST
-/**
- *@}
- */
-Suite *
-test_suite(void)
-{
- Suite *suite = suite_create("utc_eet_connection_send");
-
- TCase *tcase = tcase_create("TCase");
- tcase_set_timeout(tcase, 30);
- tcase_add_checked_fixture(tcase, setup, teardown);
- tcase_add_test(tcase, utc_eet_connection_send_p_1);
- tcase_add_test(tcase, utc_eet_connection_send_p_2);
- tcase_add_test(tcase, utc_eet_connection_send_n);
- suite_add_tcase(suite, tcase);
-
- return suite;
-}
-
-int
-main()
-{
- int number_failed;
-
- Suite *suite = test_suite();
- SRunner *srunner = srunner_create(suite);
- srunner_set_log(srunner, "utc_eet_connection_send.log");
- srunner_set_xml(srunner, "utc_eet_connection_send.xml");
- srunner_run_all(srunner, CK_NORMAL);
- number_failed = srunner_ntests_failed(srunner);
- srunner_free(srunner);
-
- return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
-}