build_component_harness

Macro build_component_harness 

Source
macro_rules! build_component_harness {
    (
        $(#[$meta:meta])*
        $vis:vis harness $harness:ident <$item:ident> {
            component: $component_field:ident : $component_ty:ty,
            $($sections:tt)*
        }
    ) => { ... };
    (
        @normalize
        [$($meta:tt)*]
        [$vis:vis]
        [$harness:ident]
        [$($struct_head:tt)+]
        [$($impl_head:tt)+]
        [$($step_generics_decl:tt)*]
        [$expected_ident:ident]
        [$expected_ty:ty]
        [$($step_where:tt)*]
        [$item_ty:ty]
        [$component_field:ident : $component_ty:ty]
        [$($rx_ports:tt)*]
        [$($tx_ports:tt)*]
        [$($rx_port_arrays:tt)*]
        [$($tx_port_arrays:tt)*]
        rx ports: { $($rx_section:tt)* }, $($rest:tt)*
    ) => { ... };
    (
        @normalize
        [$($meta:tt)*]
        [$vis:vis]
        [$harness:ident]
        [$($struct_head:tt)+]
        [$($impl_head:tt)+]
        [$($step_generics_decl:tt)*]
        [$expected_ident:ident]
        [$expected_ty:ty]
        [$($step_where:tt)*]
        [$item_ty:ty]
        [$component_field:ident : $component_ty:ty]
        [$($rx_ports:tt)*]
        [$($tx_ports:tt)*]
        [$($rx_port_arrays:tt)*]
        [$($tx_port_arrays:tt)*]
        rx ports: { $($rx_section:tt)* }
    ) => { ... };
    (
        @normalize
        [$($meta:tt)*]
        [$vis:vis]
        [$harness:ident]
        [$($struct_head:tt)+]
        [$($impl_head:tt)+]
        [$($step_generics_decl:tt)*]
        [$expected_ident:ident]
        [$expected_ty:ty]
        [$($step_where:tt)*]
        [$item_ty:ty]
        [$component_field:ident : $component_ty:ty]
        [$($rx_ports:tt)*]
        [$($tx_ports:tt)*]
        [$($rx_port_arrays:tt)*]
        [$($tx_port_arrays:tt)*]
        tx ports: { $($tx_section:tt)* }, $($rest:tt)*
    ) => { ... };
    (
        @normalize
        [$($meta:tt)*]
        [$vis:vis]
        [$harness:ident]
        [$($struct_head:tt)+]
        [$($impl_head:tt)+]
        [$($step_generics_decl:tt)*]
        [$expected_ident:ident]
        [$expected_ty:ty]
        [$($step_where:tt)*]
        [$item_ty:ty]
        [$component_field:ident : $component_ty:ty]
        [$($rx_ports:tt)*]
        [$($tx_ports:tt)*]
        [$($rx_port_arrays:tt)*]
        [$($tx_port_arrays:tt)*]
        tx ports: { $($tx_section:tt)* }
    ) => { ... };
    (
        @normalize
        [$($meta:tt)*]
        [$vis:vis]
        [$harness:ident]
        [$($struct_head:tt)+]
        [$($impl_head:tt)+]
        [$($step_generics_decl:tt)*]
        [$expected_ident:ident]
        [$expected_ty:ty]
        [$($step_where:tt)*]
        [$item_ty:ty]
        [$component_field:ident : $component_ty:ty]
        [$($rx_ports:tt)*]
        [$($tx_ports:tt)*]
        [$($rx_port_arrays:tt)*]
        [$($tx_port_arrays:tt)*]
        rx port arrays: { $($rx_array_section:tt)* }, $($rest:tt)*
    ) => { ... };
    (
        @normalize
        [$($meta:tt)*]
        [$vis:vis]
        [$harness:ident]
        [$($struct_head:tt)+]
        [$($impl_head:tt)+]
        [$($step_generics_decl:tt)*]
        [$expected_ident:ident]
        [$expected_ty:ty]
        [$($step_where:tt)*]
        [$item_ty:ty]
        [$component_field:ident : $component_ty:ty]
        [$($rx_ports:tt)*]
        [$($tx_ports:tt)*]
        [$($rx_port_arrays:tt)*]
        [$($tx_port_arrays:tt)*]
        rx port arrays: { $($rx_array_section:tt)* }
    ) => { ... };
    (
        @normalize
        [$($meta:tt)*]
        [$vis:vis]
        [$harness:ident]
        [$($struct_head:tt)+]
        [$($impl_head:tt)+]
        [$($step_generics_decl:tt)*]
        [$expected_ident:ident]
        [$expected_ty:ty]
        [$($step_where:tt)*]
        [$item_ty:ty]
        [$component_field:ident : $component_ty:ty]
        [$($rx_ports:tt)*]
        [$($tx_ports:tt)*]
        [$($rx_port_arrays:tt)*]
        [$($tx_port_arrays:tt)*]
        tx port arrays: { $($tx_array_section:tt)* }, $($rest:tt)*
    ) => { ... };
    (
        @normalize
        [$($meta:tt)*]
        [$vis:vis]
        [$harness:ident]
        [$($struct_head:tt)+]
        [$($impl_head:tt)+]
        [$($step_generics_decl:tt)*]
        [$expected_ident:ident]
        [$expected_ty:ty]
        [$($step_where:tt)*]
        [$item_ty:ty]
        [$component_field:ident : $component_ty:ty]
        [$($rx_ports:tt)*]
        [$($tx_ports:tt)*]
        [$($rx_port_arrays:tt)*]
        [$($tx_port_arrays:tt)*]
        tx port arrays: { $($tx_array_section:tt)* }
    ) => { ... };
    (
        @normalize
        [$($meta:tt)*]
        [$vis:vis]
        [$harness:ident]
        [$($struct_head:tt)+]
        [$($impl_head:tt)+]
        [$($step_generics_decl:tt)*]
        [$expected_ident:ident]
        [$expected_ty:ty]
        [$($step_where:tt)*]
        [$item_ty:ty]
        [$component_field:ident : $component_ty:ty]
        [$($rx_ports:tt)*]
        [$($tx_ports:tt)*]
        [$($rx_port_arrays:tt)*]
        [$($tx_port_arrays:tt)*]
    ) => { ... };
    (
        @impl_inferred
        [$($meta:tt)*]
        [$vis:vis]
        [$harness:ident]
        [$($struct_head:tt)+]
        [$($impl_head:tt)+]
        [$($step_generics_decl:tt)*]
        [$expected_ident:ident]
        [$expected_ty:ty]
        [$($step_where:tt)*]
        [$item_ty:ty]
        [$component_field:ident : $component_ty:ty]
        rx ports: {
            $(
                $rx_variant:ident <$rx_ty:ty> => $rx_field:ident
            ),* $(,)?
        },
        tx ports: {
            $(
                $tx_variant:ident <$tx_ty:ty> => $tx_field:ident
            ),* $(,)?
        },
        rx port arrays: {
            $(
                $rx_array_variant:ident <$rx_array_ty:ty> => $rx_array_field:ident {
                    count: $rx_array_count:ident
                }
            ),* $(,)?
        },
        tx port arrays: {
            $(
                $tx_array_variant:ident <$tx_array_ty:ty> => $tx_array_field:ident {
                    count: $tx_array_count:ident
                }
            ),* $(,)?
        } $(,)?
    ) => { ... };
    (
        @impl_model
        [$(#[$meta:meta])*]
        [$vis:vis]
        [$harness:ident]
        [$item:ident]
        [$default_expected:ty]
        [$access_memory:path]
        [$component_field:ident : $component_ty:ty]
        rx ports: { $($rx_variant:ident <$rx_ty:ty> => $rx_field:ident),* $(,)? },
        tx ports: { $($tx_variant:ident <$tx_ty:ty> => $tx_field:ident),* $(,)? },
        rx port arrays: {
            $($rx_array_variant:ident <$rx_array_ty:ty> => $rx_array_field:ident {
                count: $rx_array_count:ident
            }),* $(,)?
        },
        tx port arrays: {
            $($tx_array_variant:ident <$tx_array_ty:ty> => $tx_array_field:ident {
                count: $tx_array_count:ident
            }),* $(,)?
        } $(,)?
    ) => { ... };
    (
        @impl
        [$(#[$meta:meta])*]
        [$vis:vis]
        [$harness:ident]
        [$($struct_head:tt)+]
        [$($impl_head:tt)+]
        [$($step_generics_decl:tt)*]
        [$expected_ident:ident]
        [$expected_ty:ty]
        [$($step_where:tt)*]
        [$item_ty:ty]
        [$component_field:ident : $component_ty:ty]
        rx ports: {
            $(
                $rx_variant:ident <$rx_ty:ty> => $rx_field:ident {
                    port: { $($rx_method:tt)+ }
                }
            ),* $(,)?
        },
        tx ports: {
            $(
                $tx_variant:ident <$tx_ty:ty, $tx_expected_ty:ty> => $tx_field:ident {
                    connect: { $($tx_method:tt)+ }
                }
            ),* $(,)?
        },
        rx port arrays: {
            $(
                $rx_array_variant:ident <$rx_array_ty:ty> => $rx_array_field:ident {
                    port: { $($rx_array_method:tt)+ },
                    count: $rx_array_count:ident
                }
            ),* $(,)?
        },
        tx port arrays: {
            $(
                $tx_array_variant:ident <$tx_array_ty:ty, $tx_array_expected_ty:ty> => $tx_array_field:ident {
                    connect: { $($tx_array_method:tt)+ },
                    count: $tx_array_count:ident
                }
            ),* $(,)?
        } $(,)?
    ) => { ... };
}
Expand description

Build a simulation test harness around a component.

This macro generates the harness struct, local Port/Step enums, helper macros, fixed step execution, stateful step generators, and recursive sequence/parallel step driving for a component testbench.

See the crate-level Testing documentation for the intended usage pattern, generated API, and examples.