tests: move cpp tests to subsys/cpp
Wrongly places under application_development. We have a CPP subsystem, so move them under tests/subsys/cpp for consistency. Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
parent
a1829cf235
commit
174afccced
8 changed files with 0 additions and 0 deletions
|
@ -1,8 +0,0 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.13.1)
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(cpp)
|
||||
|
||||
FILE(GLOB app_sources src/*.cpp)
|
||||
target_sources(app PRIVATE ${app_sources})
|
|
@ -1,5 +0,0 @@
|
|||
CONFIG_CPLUSPLUS=y
|
||||
CONFIG_NET_BUF=y
|
||||
CONFIG_ZTEST=y
|
||||
CONFIG_ZTEST_STACKSIZE=2048
|
||||
CONFIG_MINIMAL_LIBC_MALLOC_ARENA_SIZE=128
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2018 Google LLC.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/*
|
||||
* This is mainly a parse test that verifies that Zephyr header files
|
||||
* compile in C++ mode.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <zephyr/types.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <init.h>
|
||||
#include <device.h>
|
||||
#include <kernel.h>
|
||||
#include <net/buf.h>
|
||||
#include <sys/byteorder.h>
|
||||
#include <sys/crc.h>
|
||||
#include <sys/crc.h>
|
||||
|
||||
#include <drivers/gpio.h>
|
||||
#include <drivers/led_strip.h>
|
||||
#include <drivers/spi.h>
|
||||
#include <drivers/uart.h>
|
||||
#include <usb/usb_device.h>
|
||||
#include <usb/class/usb_hid.h>
|
||||
#include <drivers/watchdog.h>
|
||||
|
||||
#include <ztest.h>
|
||||
|
||||
class foo_class {
|
||||
public:
|
||||
foo_class(int foo) : foo(foo) {}
|
||||
int get_foo() const { return foo;}
|
||||
private:
|
||||
int foo;
|
||||
};
|
||||
|
||||
struct foo {
|
||||
int v1;
|
||||
};
|
||||
/* Check that BUILD_ASSERT compiles. */
|
||||
BUILD_ASSERT(sizeof(foo) == sizeof(int));
|
||||
|
||||
static struct foo foos[5];
|
||||
/* Check that ARRAY_SIZE compiles. */
|
||||
BUILD_ASSERT(ARRAY_SIZE(foos) == 5, "expected 5 elements");
|
||||
|
||||
/* Check that SYS_INIT() compiles. */
|
||||
static int test_init(const struct device *dev)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYS_INIT(test_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);
|
||||
|
||||
|
||||
static void test_new_delete(void)
|
||||
{
|
||||
foo_class *test_foo = new foo_class(10);
|
||||
zassert_equal(test_foo->get_foo(), 10, NULL);
|
||||
delete test_foo;
|
||||
}
|
||||
|
||||
void test_main(void)
|
||||
{
|
||||
ztest_test_suite(cpp_tests,
|
||||
ztest_unit_test(test_new_delete)
|
||||
);
|
||||
|
||||
ztest_run_test_suite(cpp_tests);
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
tests:
|
||||
application_development.cpp.main:
|
||||
integration_platforms:
|
||||
- mps2_an385
|
||||
platform_exclude: qemu_x86_coverage
|
||||
tags: cpp
|
|
@ -1,8 +0,0 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.13.1)
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(cpp)
|
||||
|
||||
FILE(GLOB app_sources src/*.cpp)
|
||||
target_sources(app PRIVATE ${app_sources})
|
|
@ -1,6 +0,0 @@
|
|||
CONFIG_NEWLIB_LIBC=y
|
||||
CONFIG_CPLUSPLUS=y
|
||||
CONFIG_LIB_CPLUSPLUS=y
|
||||
CONFIG_STD_CPP17=y
|
||||
CONFIG_ZTEST=y
|
||||
CONFIG_ZTEST_STACKSIZE=2048
|
|
@ -1,108 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2019 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <array>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <ztest.h>
|
||||
|
||||
BUILD_ASSERT(__cplusplus == 201703);
|
||||
|
||||
std::array<int, 4> array = {1, 2, 3, 4};
|
||||
std::vector<int> vector;
|
||||
|
||||
static void test_array(void)
|
||||
{
|
||||
zassert_equal(array.size(), 4, "unexpected size");
|
||||
zassert_equal(array[0], 1, "array[0] wrong");
|
||||
zassert_equal(array[3], 4, "array[3] wrong");
|
||||
|
||||
std::array<uint8_t, 2> local = {1, 2};
|
||||
zassert_equal(local.size(), 2, "unexpected size");
|
||||
zassert_equal(local[0], 1, "local[0] wrong");
|
||||
zassert_equal(local[1], 2, "local[1] wrong");
|
||||
}
|
||||
|
||||
static void test_vector(void)
|
||||
{
|
||||
zassert_equal(vector.size(), 0, "vector init nonzero");
|
||||
for (auto v : array) {
|
||||
vector.push_back(v);
|
||||
}
|
||||
zassert_equal(vector.size(), array.size(), "vector store failed");
|
||||
}
|
||||
|
||||
struct make_unique_data {
|
||||
static int ctors;
|
||||
static int dtors;
|
||||
int inst;
|
||||
|
||||
make_unique_data () :
|
||||
inst{++ctors}
|
||||
{ }
|
||||
|
||||
~make_unique_data ()
|
||||
{
|
||||
++dtors;
|
||||
}
|
||||
};
|
||||
int make_unique_data::ctors;
|
||||
int make_unique_data::dtors;
|
||||
|
||||
static void test_make_unique(void)
|
||||
{
|
||||
zassert_equal(make_unique_data::ctors, 0, "ctor count not initialized");
|
||||
zassert_equal(make_unique_data::dtors, 0, "dtor count not initialized");
|
||||
auto d = std::make_unique<make_unique_data>();
|
||||
zassert_true(static_cast<bool>(d), "allocation failed");
|
||||
zassert_equal(make_unique_data::ctors, 1, "ctr update failed");
|
||||
zassert_equal(d->inst, 1, "instance init failed");
|
||||
zassert_equal(make_unique_data::dtors, 0, "dtor count not zero");
|
||||
d.reset();
|
||||
zassert_false(d, "release failed");
|
||||
zassert_equal(make_unique_data::dtors, 1, "dtor count not incremented");
|
||||
}
|
||||
|
||||
#if defined(CONFIG_EXCEPTIONS)
|
||||
static void throw_exception(void)
|
||||
{
|
||||
throw 42;
|
||||
}
|
||||
|
||||
static void test_exception(void)
|
||||
{
|
||||
try
|
||||
{
|
||||
throw_exception();
|
||||
}
|
||||
catch (int i)
|
||||
{
|
||||
zassert_equal(i, 42, "Incorrect exception value");
|
||||
return;
|
||||
}
|
||||
|
||||
zassert_unreachable("Missing exception catch");
|
||||
}
|
||||
#else
|
||||
|
||||
static void test_exception(void)
|
||||
{
|
||||
ztest_test_skip();
|
||||
}
|
||||
#endif
|
||||
|
||||
void test_main(void)
|
||||
{
|
||||
TC_PRINT("version %u\n", (uint32_t)__cplusplus);
|
||||
ztest_test_suite(libcxx_tests,
|
||||
ztest_unit_test(test_array),
|
||||
ztest_unit_test(test_vector),
|
||||
ztest_unit_test(test_make_unique),
|
||||
ztest_unit_test(test_exception)
|
||||
);
|
||||
ztest_run_test_suite(libcxx_tests);
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
common:
|
||||
filter: TOOLCHAIN_HAS_NEWLIB == 1
|
||||
integration_platforms:
|
||||
- mps2_an385
|
||||
tests:
|
||||
application_development.cpp.libcxx:
|
||||
platform_exclude: qemu_x86_coverage
|
||||
toolchain_exclude: xcc
|
||||
min_flash: 54
|
||||
tags: cpp
|
||||
application_development.cpp.libcxx.exceptions:
|
||||
platform_exclude: qemu_x86_coverage
|
||||
toolchain_exclude: xcc
|
||||
min_flash: 54
|
||||
tags: cpp
|
||||
timeout: 5
|
||||
extra_configs:
|
||||
- CONFIG_EXCEPTIONS=y
|
Loading…
Add table
Add a link
Reference in a new issue