Add tests for new drain and flush functions in UART api 00/287200/3
authorAntoni Adaszkiewicz <a.adaszkiewi@samsung.com>
Tue, 24 Jan 2023 16:29:47 +0000 (17:29 +0100)
committerAntoni Adaszkiewicz <a.adaszkiewi@samsung.com>
Mon, 13 Feb 2023 13:33:11 +0000 (14:33 +0100)
Change-Id: I7ec9d9b0893f1628c96e23c41b7119f3e01bd51b

test/include/test_peripheral_uart.h
test/peripheral-io-test.c
test/src/test_peripheral_uart.c

index 89e2b33..389b8d2 100644 (file)
@@ -78,5 +78,9 @@ int test_peripheral_io_uart_peripheral_uart_read_n2(void);
 int test_peripheral_io_uart_peripheral_uart_write_p(void);
 int test_peripheral_io_uart_peripheral_uart_write_n1(void);
 int test_peripheral_io_uart_peripheral_uart_write_n2(void);
+int test_peripheral_io_uart_peripheral_uart_flush_p(void);
+int test_peripheral_io_uart_peripheral_uart_flush_n(void);
+int test_peripheral_io_uart_peripheral_uart_drain_p(void);
+int test_peripheral_io_uart_peripheral_uart_drain_n(void);
 
 #endif /* __TEST_PERIPHERAL_UART_H__ */
\ No newline at end of file
index 420445a..65dacb3 100644 (file)
@@ -484,6 +484,14 @@ static void __test_peripheral_uart_run()
        __error_check(ret, "test_peripheral_io_uart_peripheral_uart_write_n1");
        ret = test_peripheral_io_uart_peripheral_uart_write_n2();
        __error_check(ret, "test_peripheral_io_uart_peripheral_uart_write_n2");
+       ret = test_peripheral_io_uart_peripheral_uart_flush_p();
+       __error_check(ret, "test_peripheral_io_uart_peripheral_uart_flush_p");
+       ret = test_peripheral_io_uart_peripheral_uart_flush_n();
+       __error_check(ret, "test_peripheral_io_uart_peripheral_uart_flush_n");
+       ret = test_peripheral_io_uart_peripheral_uart_drain_p();
+       __error_check(ret, "test_peripheral_io_uart_peripheral_uart_drain_p");
+       ret = test_peripheral_io_uart_peripheral_uart_drain_n();
+       __error_check(ret, "test_peripheral_io_uart_peripheral_uart_drain_n");
        __test_performance_for_function("open/close", test_peripheral_io_uart_peripheral_uart_open_p);
 }
 
index 0c7db85..c813fec 100644 (file)
@@ -1695,3 +1695,101 @@ int test_peripheral_io_uart_peripheral_uart_write_n2(void)
 
        return PERIPHERAL_ERROR_NONE;
 }
+
+int test_peripheral_io_uart_peripheral_uart_flush_p(void)
+{
+       int ret = PERIPHERAL_ERROR_NONE;
+
+       peripheral_uart_h uart_h = NULL;
+
+       if (g_feature == false) {
+               ret = peripheral_uart_flush(uart_h);
+               if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED)
+                       return ret;
+
+       } else {
+               ret = peripheral_uart_open(port, &uart_h);
+               if (ret != PERIPHERAL_ERROR_NONE)
+                       return ret;
+
+               ret = peripheral_uart_flush(uart_h);
+               if (ret != PERIPHERAL_ERROR_NONE && ret != PERIPHERAL_ERROR_TRY_AGAIN) {
+                       peripheral_uart_close(uart_h);
+                       return ret;
+               }
+
+               ret = peripheral_uart_close(uart_h);
+               if (ret != PERIPHERAL_ERROR_NONE)
+                       return ret;
+       }
+
+       return PERIPHERAL_ERROR_NONE;
+}
+
+int test_peripheral_io_uart_peripheral_uart_flush_n(void)
+{
+       int ret = PERIPHERAL_ERROR_NONE;
+
+       if (g_feature == false) {
+               ret = peripheral_uart_flush(NULL);
+               if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED)
+                       return ret;
+
+       } else {
+               ret = peripheral_uart_flush(NULL);
+               if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) {
+                       return ret;
+               }
+       }
+
+       return PERIPHERAL_ERROR_NONE;
+}
+
+int test_peripheral_io_uart_peripheral_uart_drain_p(void)
+{
+       int ret = PERIPHERAL_ERROR_NONE;
+
+       peripheral_uart_h uart_h = NULL;
+
+       if (g_feature == false) {
+               ret = peripheral_uart_drain(uart_h);
+               if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED)
+                       return ret;
+
+       } else {
+               ret = peripheral_uart_open(port, &uart_h);
+               if (ret != PERIPHERAL_ERROR_NONE)
+                       return ret;
+
+               ret = peripheral_uart_drain(uart_h);
+               if (ret != PERIPHERAL_ERROR_NONE && ret != PERIPHERAL_ERROR_TRY_AGAIN) {
+                       peripheral_uart_close(uart_h);
+                       return ret;
+               }
+
+               ret = peripheral_uart_close(uart_h);
+               if (ret != PERIPHERAL_ERROR_NONE)
+                       return ret;
+       }
+
+       return PERIPHERAL_ERROR_NONE;
+}
+
+int test_peripheral_io_uart_peripheral_uart_drain_n(void)
+{
+       int ret = PERIPHERAL_ERROR_NONE;
+
+       if (g_feature == false) {
+               ret = peripheral_uart_drain(NULL);
+               if (ret != PERIPHERAL_ERROR_NOT_SUPPORTED)
+                       return ret;
+
+       } else {
+               ret = peripheral_uart_drain(NULL);
+               if (ret != PERIPHERAL_ERROR_INVALID_PARAMETER) {
+                       return ret;
+               }
+       }
+
+       return PERIPHERAL_ERROR_NONE;
+}