Skip to content

Commit 9ebcb0b

Browse files
committed
tests: add test skeleton project
Documentation from nathanj's pull request #12.
1 parent 6800d65 commit 9ebcb0b

File tree

8 files changed

+50
-0
lines changed

8 files changed

+50
-0
lines changed

README.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,23 @@ Sample Output
139139
0x0000035d (0x86a9)
140140
Fatal fault in thread 0x00400060! Aborting.
141141
142+
Testing
143+
*******
144+
145+
The Zephyr test runner can be used:
146+
147+
.. code-block:: console
148+
149+
$ZEPHYR_BASE/scripts/sanitycheck --testcase-root tests -p native_posix -N
150+
151+
Or you can build and run the test manually:
152+
153+
.. code-block:: console
154+
155+
cd tests/rust
156+
mkdir -p build-posix && cd build-posix
157+
cmake -GNinja -DBOARD=native_posix ..
158+
ninja run
142159
143160
Supported Architectures
144161
***********************

tests/rust/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.13.1)
4+
get_filename_component(ZEPHYR_RUST ${CMAKE_CURRENT_SOURCE_DIR}/../.. ABSOLUTE)
5+
list(APPEND ZEPHYR_MODULES ${ZEPHYR_RUST})
6+
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
7+
project(rust)
8+
target_sources(app PRIVATE ./src/main.c)

tests/rust/Cargo.lock

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/rust/Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "app"
3+
version = "0.1.0"
4+
authors = ["Tyler Hall <[email protected]>"]
5+
edition = "2018"
6+
7+
[dependencies]

tests/rust/prj.conf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_RUST=y
2+
CONFIG_ZTEST=y

tests/rust/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#[no_mangle]
2+
pub extern "C" fn test_main() {
3+
println!("Hello, world!");
4+
}

tests/rust/src/main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// Empty

tests/rust/testcase.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
common:
2+
arch_whitelist: x86 arm posix
3+
tests:
4+
rust.main:
5+
tags: rust

0 commit comments

Comments
 (0)