summaryrefslogtreecommitdiff
path: root/zephyr/test/uart_printf
diff options
context:
space:
mode:
Diffstat (limited to 'zephyr/test/uart_printf')
-rw-r--r--zephyr/test/uart_printf/CMakeLists.txt20
-rw-r--r--zephyr/test/uart_printf/include/common.h12
-rw-r--r--zephyr/test/uart_printf/include/printf.h23
-rw-r--r--zephyr/test/uart_printf/include/uart.h28
-rw-r--r--zephyr/test/uart_printf/prj.conf9
-rw-r--r--zephyr/test/uart_printf/src/fakes.cc36
-rw-r--r--zephyr/test/uart_printf/src/main.cc101
-rw-r--r--zephyr/test/uart_printf/testcase.yaml8
8 files changed, 0 insertions, 237 deletions
diff --git a/zephyr/test/uart_printf/CMakeLists.txt b/zephyr/test/uart_printf/CMakeLists.txt
deleted file mode 100644
index 8844bfb7be..0000000000
--- a/zephyr/test/uart_printf/CMakeLists.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-cmake_minimum_required(VERSION 3.20.0)
-
-find_package(Zephyr COMPONENTS unittest REQUIRED HINTS $ENV{ZEPHYR_BASE})
-project(uart_printf)
-
-target_sources(testbinary
- PRIVATE
- ../../../common/uart_printf.c
- src/fakes.cc
- src/main.cc
-)
-
-target_include_directories(testbinary
- PRIVATE
- include
-)
diff --git a/zephyr/test/uart_printf/include/common.h b/zephyr/test/uart_printf/include/common.h
deleted file mode 100644
index 79af9594b3..0000000000
--- a/zephyr/test/uart_printf/include/common.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef ZEPHYR_TEST_UART_PRINTF_INCLUDE_COMMON_H_
-#define ZEPHYR_TEST_UART_PRINTF_INCLUDE_COMMON_H_
-
-#define EC_SUCCESS 0
-#define EC_ERROR_OVERFLOW -1
-
-#endif /* ZEPHYR_TEST_UART_PRINTF_INCLUDE_COMMON_H_ */
diff --git a/zephyr/test/uart_printf/include/printf.h b/zephyr/test/uart_printf/include/printf.h
deleted file mode 100644
index b6fcf6337d..0000000000
--- a/zephyr/test/uart_printf/include/printf.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef ZEPHYR_TEST_UART_PRINTF_INCLUDE_PRINTF_H_
-#define ZEPHYR_TEST_UART_PRINTF_INCLUDE_PRINTF_H_
-
-#include <zephyr/fff.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef int (*vfnprintf_addchar_t)(void *, int);
-DECLARE_FAKE_VALUE_FUNC(int, vfnprintf, vfnprintf_addchar_t, void *,
- const char *, va_list);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ZEPHYR_TEST_UART_PRINTF_INCLUDE_PRINTF_H_ */
diff --git a/zephyr/test/uart_printf/include/uart.h b/zephyr/test/uart_printf/include/uart.h
deleted file mode 100644
index 51fd42a17e..0000000000
--- a/zephyr/test/uart_printf/include/uart.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#ifndef ZEPHYR_TEST_UART_PRINTF_INCLUDE_UART_H_
-#define ZEPHYR_TEST_UART_PRINTF_INCLUDE_UART_H_
-
-#include <zephyr/fff.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-int uart_putc(int c);
-int uart_puts(const char *outstr);
-int uart_put(const char *out, int len);
-int uart_put_raw(const char *out, int len);
-int uart_printf(const char *format, ...);
-
-DECLARE_FAKE_VALUE_FUNC(int, uart_tx_char_raw, void *, int);
-DECLARE_FAKE_VOID_FUNC(uart_tx_start);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ZEPHYR_TEST_UART_PRINTF_INCLUDE_UART_H_ */
diff --git a/zephyr/test/uart_printf/prj.conf b/zephyr/test/uart_printf/prj.conf
deleted file mode 100644
index 744afcce87..0000000000
--- a/zephyr/test/uart_printf/prj.conf
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-CONFIG_ZTEST=y
-CONFIG_ZTEST_NEW_API=y
-CONFIG_CPLUSPLUS=y
-CONFIG_STD_CPP20=y
-CONFIG_LIB_CPLUSPLUS=y
diff --git a/zephyr/test/uart_printf/src/fakes.cc b/zephyr/test/uart_printf/src/fakes.cc
deleted file mode 100644
index 0bb5fea1eb..0000000000
--- a/zephyr/test/uart_printf/src/fakes.cc
+++ /dev/null
@@ -1,36 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <zephyr/fff.h>
-#include <zephyr/ztest.h>
-
-#include "printf.h"
-#include "uart.h"
-
-DEFINE_FFF_GLOBALS;
-
-/* printf.h */
-DEFINE_FAKE_VALUE_FUNC(int, vfnprintf, vfnprintf_addchar_t, void *,
- const char *, va_list);
-
-/* uart.h */
-DEFINE_FAKE_VALUE_FUNC(int, uart_tx_char_raw, void *, int);
-DEFINE_FAKE_VOID_FUNC(uart_tx_start);
-
-static void fake_reset_rule_before(const struct ztest_unit_test *test,
- void *data)
-{
- ARG_UNUSED(test);
- ARG_UNUSED(data);
-
- /* printf.h */
- RESET_FAKE(vfnprintf);
-
- /* uart.h */
- RESET_FAKE(uart_tx_char_raw);
- RESET_FAKE(uart_tx_start);
-}
-
-ZTEST_RULE(fake_reset, fake_reset_rule_before, nullptr);
diff --git a/zephyr/test/uart_printf/src/main.cc b/zephyr/test/uart_printf/src/main.cc
deleted file mode 100644
index 9feb6a7ae9..0000000000
--- a/zephyr/test/uart_printf/src/main.cc
+++ /dev/null
@@ -1,101 +0,0 @@
-/* Copyright 2022 The ChromiumOS Authors
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file.
- */
-
-#include <cstring>
-#include <string>
-
-#include <zephyr/ztest.h>
-
-#include "common.h"
-#include "printf.h"
-#include "uart.h"
-
-ZTEST_SUITE(uart_printf, nullptr, nullptr, nullptr, nullptr, nullptr);
-
-ZTEST(uart_printf, test_uart_putc)
-{
- int return_vals[] = { 0, -1 };
-
- SET_RETURN_SEQ(uart_tx_char_raw, return_vals, 2);
-
- zassert_ok(uart_putc(5));
- zassert_equal(EC_ERROR_OVERFLOW, uart_putc(5));
-}
-
-ZTEST(uart_printf, test_uart_put_success)
-{
- const std::string test_string = "test string";
- std::string output_string;
-
- /* Print the whole string */
- zassert_equal(test_string.size(),
- static_cast<size_t>(uart_put(test_string.c_str(),
- test_string.size())));
- zassert_equal(test_string.size(), uart_tx_char_raw_fake.call_count);
-
- /* Copy the history so it's easier to assert */
- for (size_t i = 0; i < test_string.size(); ++i) {
- output_string += uart_tx_char_raw_fake.arg1_history[i];
- }
-
- /* Verify that the string was passed to uart_tx_char_raw() */
- zassert_equal(test_string, output_string);
-}
-
-ZTEST(uart_printf, test_uart_put_fail_tx)
-{
- const char test_string[] = "\n";
-
- uart_tx_char_raw_fake.return_val = -1;
-
- /* Try printing the newline */
- zassert_equal(0, uart_put(test_string, 1));
- zassert_equal(1, uart_tx_char_raw_fake.call_count);
- zassert_equal('\r', uart_tx_char_raw_fake.arg1_val);
-}
-
-ZTEST(uart_printf, test_uart_puts_fail_tx)
-{
- const char test_string[] = "\n\0";
-
- uart_tx_char_raw_fake.return_val = -1;
-
- /* Try printing the newline */
- zassert_equal(EC_ERROR_OVERFLOW, uart_puts(test_string));
- zassert_equal(1, uart_tx_char_raw_fake.call_count);
- zassert_equal('\r', uart_tx_char_raw_fake.arg1_val);
-}
-
-ZTEST(uart_printf, test_uart_put_raw_fail_tx)
-{
- const char test_string[] = "\n";
-
- uart_tx_char_raw_fake.return_val = -1;
-
- /* Try printing the newline */
- zassert_equal(0, uart_put_raw(test_string, 1));
- zassert_equal(1, uart_tx_char_raw_fake.call_count);
- zassert_equal('\n', uart_tx_char_raw_fake.arg1_val);
-}
-
-static int vfnprintf_custom_fake_expect_int_arg;
-static int vfnprintf_custom_fake(vfnprintf_addchar_t, void *, const char *,
- va_list alist)
-{
- zassert_equal(vfnprintf_custom_fake_expect_int_arg, va_arg(alist, int));
- return 0;
-}
-ZTEST(uart_printf, test_uart_printf)
-{
- const char test_format[] = "d=%d";
-
- vfnprintf_custom_fake_expect_int_arg = 5;
- vfnprintf_fake.custom_fake = vfnprintf_custom_fake;
-
- zassert_ok(
- uart_printf(test_format, vfnprintf_custom_fake_expect_int_arg));
- zassert_equal(1, vfnprintf_fake.call_count);
- zassert_equal(test_format, vfnprintf_fake.arg2_val);
-}
diff --git a/zephyr/test/uart_printf/testcase.yaml b/zephyr/test/uart_printf/testcase.yaml
deleted file mode 100644
index 0315abab6f..0000000000
--- a/zephyr/test/uart_printf/testcase.yaml
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2022 The ChromiumOS Authors
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-tests:
- uart.printf:
- tags: uart
- type: unit