Skip to content

Commit

Permalink
Merge pull request #31 from Glamhoth/ros-108/design-inspection-tests
Browse files Browse the repository at this point in the history
ROS#108 - Design & Inspection tests
  • Loading branch information
Glamhoth authored Aug 16, 2023
2 parents 520d8e5 + 9d7ecdb commit 7289cac
Show file tree
Hide file tree
Showing 20 changed files with 205 additions and 39 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
Cargo.lock
target/

docs/
docs-test/

# editor files
!.vscode/*.md
!.vscode/*.svd
Expand Down
12 changes: 8 additions & 4 deletions src/boolean_condition/boolean_condition_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,10 @@ mod tests {

use crate::boolean_condition::BooleanConditionStorage;

/// @SRS{ROS-FUN-RTOS-1070}
/// @SRS{ROS-FUN-RTOS-1080}
#[cfg_attr(not(doc), test)]
fn evaluate_or_set_true() {
fn req_evaluate_or_set_true() {
static CONDITION_X_STORAGE: BooleanConditionStorage = BooleanConditionStorage::new();
unsafe {
CONDITION_X_STORAGE
Expand All @@ -162,9 +163,10 @@ mod tests {
assert!(condition_set.evaluate());
}

/// @SRS{ROS-FUN-RTOS-1070}
/// @SRS{ROS-FUN-RTOS-1080}
#[cfg_attr(not(doc), test)]
fn evaluate_or_set_false() {
fn req_evaluate_or_set_false() {
static CONDITION_X_STORAGE: BooleanConditionStorage = BooleanConditionStorage::new();
unsafe {
CONDITION_X_STORAGE
Expand All @@ -189,9 +191,10 @@ mod tests {
assert!(!condition_set.evaluate());
}

/// @SRS{ROS-FUN-RTOS-1070}
/// @SRS{ROS-FUN-RTOS-1090}
#[cfg_attr(not(doc), test)]
fn evaluate_and_set_true() {
fn req_evaluate_and_set_true() {
static CONDITION_X_STORAGE: BooleanConditionStorage = BooleanConditionStorage::new();
unsafe {
CONDITION_X_STORAGE
Expand All @@ -216,9 +219,10 @@ mod tests {
assert!(condition_set.evaluate());
}

/// @SRS{ROS-FUN-RTOS-1070}
/// @SRS{ROS-FUN-RTOS-1090}
#[cfg_attr(not(doc), test)]
fn evaluate_and_set_false() {
fn req_evaluate_and_set_false() {
static CONDITION_X_STORAGE: BooleanConditionStorage = BooleanConditionStorage::new();
unsafe {
CONDITION_X_STORAGE
Expand Down
8 changes: 4 additions & 4 deletions src/tasklet/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ impl<const N: usize> MockConditionSet<N> {
}
}

/// @SRS{ROS-FUN-RTOS-50}
/// @SRS{ROS-FUN-RTOS-60}
/// @SRS{ROS-FUN-RTOS-70}
/// @SRS{ROS-FUN-RTOS-80}
/// @SRS{ROS-FUN-RTOS-050}
/// @SRS{ROS-FUN-RTOS-060}
/// @SRS{ROS-FUN-RTOS-070}
/// @SRS{ROS-FUN-RTOS-080}
#[cfg_attr(not(doc), test)]
fn req_tasklet_execution_state() {
static mut MOCK_DATA_PROVIDER: MockDataProvider = MockDataProvider::new();
Expand Down
28 changes: 22 additions & 6 deletions testbins/test-boolean-condition/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use aerugo::{

struct TaskAContext {
queue_handle: MessageQueueHandle<u8, 10>,
enable_condition_handle: BooleanConditionHandle,
done_condition_handle: BooleanConditionHandle,
}

struct TaskBContext {
Expand All @@ -14,12 +16,17 @@ struct TaskBContext {
done_condition_handle: BooleanConditionHandle,
}

#[derive(Default)]
struct TaskCContext {}
struct TaskCContext {
enable_condition_handle: BooleanConditionHandle,
done_condition_handle: BooleanConditionHandle,
}

#[allow(clippy::needless_pass_by_ref_mut)]
fn task_a(_: (), context: &mut TaskAContext, _: &dyn RuntimeApi) {
log!("TaskA");
let enable_status = context.enable_condition_handle.get_value();
let done_status = context.done_condition_handle.get_value();

log!("TaskA: {}, {}", enable_status, done_status);

context
.queue_handle
Expand All @@ -40,8 +47,11 @@ fn task_b(data: u8, context: &mut TaskBContext, _: &dyn RuntimeApi) {
}

#[allow(clippy::needless_pass_by_ref_mut)]
fn task_c(data: bool, _: &mut TaskCContext, _: &dyn RuntimeApi) {
log!("TaskC");
fn task_c(data: bool, context: &mut TaskCContext, _: &dyn RuntimeApi) {
let enable_status = context.enable_condition_handle.get_value();
let done_status = context.done_condition_handle.get_value();

log!("TaskC: {}, {}", enable_status, done_status);

if data {
std::process::exit(0)
Expand Down Expand Up @@ -97,12 +107,18 @@ fn main() -> ! {

let task_a_context = TaskAContext {
queue_handle: queue_x_handle,
enable_condition_handle,
done_condition_handle,
};
let task_b_context = TaskBContext {
counter: 0,
enable_condition_handle,
done_condition_handle,
};
let task_c_context = TaskCContext {
enable_condition_handle,
done_condition_handle,
};

AERUGO
.create_tasklet_with_context(task_a_config, task_a, task_a_context, &TASK_A_STORAGE)
Expand All @@ -111,7 +127,7 @@ fn main() -> ! {
.create_tasklet_with_context(task_b_config, task_b, task_b_context, &TASK_B_STORAGE)
.expect("Unable to create TaskB");
AERUGO
.create_tasklet(task_c_config, task_c, &TASK_C_STORAGE)
.create_tasklet_with_context(task_c_config, task_c, task_c_context, &TASK_C_STORAGE)
.expect("Unable to create TaskC");

let task_a_handle = TASK_A_STORAGE
Expand Down
113 changes: 113 additions & 0 deletions tests/requirements/design.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/// @SRS{ROS-BSP-010}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_ros_provide_rtos() {}

/// @SRS{ROS-FUN-RTOS-020}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_tasklet_persistent_context_data() {}

/// @SRS{ROS-FUN-RTOS-030}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_tasklet_user_data_safe_access() {}

/// @SRS{ROS-FUN-RTOS-040}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_safe_access_to_shared_data() {}

/// @SRS{ROS-FUN-BSP-WDT-010}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_ros_provide_driver_wdt() {}

/// @SRS{ROS-FUN-BSP-NVIC-010}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_ros_provide_driver_nvic() {}

/// @SRS{ROS-FUN-BSP-SCB-010}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_ros_provide_driver_scb() {}

/// @SRS{ROS-FUN-BSP-SYST-010}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_ros_provide_driver_syst() {}

/// @SRS{ROS-FUN-BSP-PMC-010}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_ros_provide_driver_pcm() {}

/// @SRS{ROS-FUN-BSP-UART-010}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_ros_provide_driver_uart() {}

/// @SRS{ROS-FUN-BSP-PIO-010}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_ros_provide_driver_pio() {}

/// @SRS{ROS-FUN-BSP-SPI-010}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_ros_provide_driver_spi() {}

/// @SRS{ROS-FUN-BSP-TIC-010}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_ros_provide_driver_tic() {}

/// @SRS{ROS-FUN-BSP-XDMAC-010}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_ros_provide_driver_xdmac() {}

/// @SRS{ROS-FUN-BSP-FPU-010}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_ros_provide_driver_fpu() {}

/// @SRS{ROS-RES-010}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_bsp_target_samv71() {}

/// @SRS{ROS-DES-010}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_bsp_implemented_in_rust() {}

/// @SRS{ROS-DES-020}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_ros_implemented_in_rust() {}

/// @SRS{ROS-POR-010}
///
/// Design Analysis is described in N7S-ROS-SVSR-001, chapter 6.2.
#[cfg_attr(not(doc), test)]
fn des_ros_partitioned_into_platform_specific_and_agnostic_code() {}
17 changes: 17 additions & 0 deletions tests/requirements/inspection.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/// @SRS{ROS-GEN-010}
///
/// Inspection is described in N7S-ROS-SVSR-001, chapter 7.2.
#[cfg_attr(not(doc), test)]
fn insp_english_documentation() {}

/// @SRS{ROS-DES-030}
///
/// Inspection is described in N7S-ROS-SVSR-001, chapter 7.2.
#[cfg_attr(not(doc), test)]
fn insp_create_appliction_without_dynamic_allocations() {}

/// @SRS{ROS-DES-040}
///
/// Inspection is described in N7S-ROS-SVSR-001, chapter 7.2.
#[cfg_attr(not(doc), test)]
fn insp_evaluate_async_construct() {}
13 changes: 3 additions & 10 deletions tests/requirements/mod.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
mod test_basic_execution;
mod test_boolean_condition;
mod test_event_cancellation;
mod test_event_clear_queue;
mod test_events;
mod test_hal_timer;
mod test_hal_watchdog;
mod test_message_queue;
mod test_tasklet_priority;
mod test_tasklet_priority_multiple_queues;
mod design;
mod inspection;
mod test;
10 changes: 10 additions & 0 deletions tests/requirements/test/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mod test_basic_execution;
mod test_boolean_condition;
mod test_event_cancellation;
mod test_event_clear_queue;
mod test_events;
mod test_hal_timer;
mod test_hal_watchdog;
mod test_message_queue;
mod test_tasklet_priority;
mod test_tasklet_priority_multiple_queues;
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use assert_cmd::Command;
use test_binary::build_test_binary;

/// @SRS{ROS-FUN-RTOS-10}
/// @SRS{ROS-FUN-RTOS-010}
/// @SRS{ROS-FUN-RTOS-110}
/// @SRS{ROS-FUN-RTOS-130}
#[cfg_attr(not(doc), test)]
fn req_test_basic_execution() {
let test_bin_path =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
use assert_cmd::Command;
use test_binary::build_test_binary;

/// @SRS{ROS-FUN-RTOS-10}
/// @SRS{ROS-FUN-RTOS-010}
/// @SRS{ROS-FUN-RTOS-130}
/// @SRS{ROS-FUN-RTOS-1010}
/// @SRS{ROS-FUN-RTOS-1020}
/// @SRS{ROS-FUN-RTOS-1030}
/// @SRS{ROS-FUN-RTOS-1060}
/// @SRS{ROS-FUN-RTOS-1090}
Expand All @@ -18,13 +20,13 @@ fn req_test_boolean_condition() {
.success()
.code(0)
.stdout(
r#"TaskA
r#"TaskA: true, false
TaskB: 1
TaskA
TaskA: true, false
TaskB: 1
TaskA
TaskA: true, false
TaskB: 1
TaskC
TaskC: false, true
"#,
);
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use assert_cmd::Command;
use test_binary::build_test_binary;

/// @SRS{ROS-FUN-RTOS-10}
/// @SRS{ROS-FUN-RTOS-010}
/// @SRS{ROS-FUN-RTOS-130}
/// @SRS{ROS-FUN-RTOS-3010}
/// @SRS{ROS-FUN-RTOS-3020}
/// @SRS{ROS-FUN-RTOS-3050}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use assert_cmd::Command;
use test_binary::build_test_binary;

/// @SRS{ROS-FUN-RTOS-10}
/// @SRS{ROS-FUN-RTOS-010}
/// @SRS{ROS-FUN-RTOS-130}
/// @SRS{ROS-FUN-RTOS-3010}
/// @SRS{ROS-FUN-RTOS-3020}
/// @SRS{ROS-FUN-RTOS-3050}
/// @SRS{ROS-FUN-RTOS-3060}
/// @SRS{ROS-FUN-RTOS-3070}
/// @SRS[ROS-FUN-RTOS-3080]
/// @SRS{ROS-FUN-RTOS-3090}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use assert_cmd::Command;
use test_binary::build_test_binary;

/// @SRS{ROS-FUN-RTOS-10}
/// @SRS{ROS-FUN-RTOS-010}
/// @SRS{ROS-FUN-RTOS-130}
/// @SRS{ROS-FUN-RTOS-3010}
/// @SRS{ROS-FUN-RTOS-3020}
/// @SRS{ROS-FUN-RTOS-3070}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
use assert_cmd::Command;
use test_binary::build_test_binary;

/// @SRS{ROS-FUN-RTOS-10}
/// @SRS{ROS-FUN-RTOS-010}
/// @SRS{ROS-FUN-RTOS-130}
/// @SRS{ROS-FUN-RTOS-2010}
/// @SRS{ROS-FUN-RTOS-2020}
/// @SRS{ROS-FUN-RTOS-2030}
/// @SRS{ROS-FUN-RTOS-2060}
/// @SRS{ROS-FUN-RTOS-2070}
#[cfg_attr(not(doc), test)]
fn req_test_message_queue() {
let test_bin_path =
Expand Down
Loading

0 comments on commit 7289cac

Please sign in to comment.