STAR
Cal STAR — firmware, DAQ server, and engine design
Loading...
Searching...
No Matches
test_idle.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "idle.h"
Include dependency graph for test_idle.c:

Go to the source code of this file.

Classes

struct  fake_t

Macros

#define CHECK(condition)

Functions

static uint32_t counts_for_mv (uint32_t mv)
static void note (fake_t *f, unsigned what)
static self_test_battery_t fake_battery (void *context, uint32_t now_ms, uint32_t budget_ms)
static bool fake_usb (void *context)
static self_test_reply_t fake_send (void *context, const idle_heartbeat_t *hb, uint32_t budget_ms)
static idle_command_t fake_poll (void *context)
static idle_config_t config (void)
static void set_mv (fake_t *f, uint32_t mv)
static void setup (idle_t *idle, fake_t *f, uint32_t now)
static void push_command (fake_t *f, idle_command_t cmd)
static void test_conversion (void)
static void test_init_rejects_bad_input (void)
static void test_wake_before_enter_is_error (void)
static void test_first_wake_sends_heartbeat (void)
static void test_sixty_seconds_gives_six_heartbeats (void)
static void test_battery_read_before_transmit (void)
static void test_thresholds (void)
static void test_hysteresis (void)
static void test_usb_is_never_battery_health (void)
static void test_invalid_battery_still_sends (void)
static void test_send_failure_counted_and_sleep_continues (void)
static void test_arm_requested_without_heartbeat (void)
static void test_disarm_stays_idle (void)
static void test_disarm_then_arm_in_one_wake (void)
static void test_command_drain_is_bounded (void)
static void test_radio_wake_does_not_delay_heartbeat (void)
static void test_early_lsi_wake_within_tolerance (void)
static void test_long_gap_sends_one_heartbeat (void)
static void test_clock_and_sequence_wraparound (void)
static void test_failure_count_saturates (void)
int main (void)

Variables

static const idle_port_t port = {fake_battery, fake_usb, fake_send, fake_poll}

Macro Definition Documentation

◆ CHECK

Function Documentation

◆ config()

idle_config_t config ( void )
static

Definition at line 80 of file test_idle.c.

Referenced by setup(), test_init_rejects_bad_input(), and test_wake_before_enter_is_error().

◆ counts_for_mv()

uint32_t counts_for_mv ( uint32_t mv)
static

Definition at line 16 of file test_idle.c.

Referenced by set_mv().

◆ fake_battery()

self_test_battery_t fake_battery ( void * context,
uint32_t now_ms,
uint32_t budget_ms )
static

Definition at line 42 of file test_idle.c.

References b, fake_t::battery, fake_t::battery_calls, CHECK, fake_t::expected_budget, and note().

◆ fake_poll()

idle_command_t fake_poll ( void * context)
static

◆ fake_send()

self_test_reply_t fake_send ( void * context,
const idle_heartbeat_t * hb,
uint32_t budget_ms )
static

◆ fake_usb()

bool fake_usb ( void * context)
static

Definition at line 53 of file test_idle.c.

References note(), and fake_t::usb.

◆ main()

◆ note()

void note ( fake_t * f,
unsigned what )
static

Definition at line 36 of file test_idle.c.

References fake_t::order, and fake_t::order_count.

Referenced by fake_battery(), fake_send(), and fake_usb().

◆ push_command()

◆ set_mv()

void set_mv ( fake_t * f,
uint32_t mv )
static

◆ setup()

void setup ( idle_t * idle,
fake_t * f,
uint32_t now )
static

◆ test_arm_requested_without_heartbeat()

void test_arm_requested_without_heartbeat ( void )
static

◆ test_battery_read_before_transmit()

void test_battery_read_before_transmit ( void )
static

Definition at line 202 of file test_idle.c.

References CHECK, idle, idle_on_wake(), fake_t::order, fake_t::order_count, and setup().

Referenced by main().

◆ test_clock_and_sequence_wraparound()

void test_clock_and_sequence_wraparound ( void )
static

Definition at line 439 of file test_idle.c.

References CHECK, idle, idle_on_wake(), r, fake_t::send_calls, fake_t::sent, idle_heartbeat_t::sequence, and setup().

Referenced by main().

◆ test_command_drain_is_bounded()

void test_command_drain_is_bounded ( void )
static

◆ test_conversion()

void test_conversion ( void )
static

Definition at line 112 of file test_idle.c.

References CHECK, and idle_counts_to_mv().

Referenced by main().

◆ test_disarm_stays_idle()

void test_disarm_stays_idle ( void )
static

Definition at line 363 of file test_idle.c.

References CHECK, idle, IDLE_CMD_DISARM, IDLE_EVENT_SLEEP, idle_on_wake(), push_command(), r, and setup().

Referenced by main().

◆ test_disarm_then_arm_in_one_wake()

void test_disarm_then_arm_in_one_wake ( void )
static

Definition at line 374 of file test_idle.c.

References CHECK, idle, IDLE_CMD_ARM, IDLE_CMD_DISARM, IDLE_EVENT_ARM_REQUESTED, idle_on_wake(), push_command(), and setup().

Referenced by main().

◆ test_early_lsi_wake_within_tolerance()

void test_early_lsi_wake_within_tolerance ( void )
static

Definition at line 413 of file test_idle.c.

References CHECK, idle, idle_on_wake(), r, and setup().

Referenced by main().

◆ test_failure_count_saturates()

void test_failure_count_saturates ( void )
static

◆ test_first_wake_sends_heartbeat()

◆ test_hysteresis()

void test_hysteresis ( void )
static

◆ test_init_rejects_bad_input()

◆ test_invalid_battery_still_sends()

◆ test_long_gap_sends_one_heartbeat()

void test_long_gap_sends_one_heartbeat ( void )
static

Definition at line 428 of file test_idle.c.

References CHECK, idle, idle_on_wake(), r, fake_t::send_calls, and setup().

Referenced by main().

◆ test_radio_wake_does_not_delay_heartbeat()

void test_radio_wake_does_not_delay_heartbeat ( void )
static

Definition at line 397 of file test_idle.c.

References fake_t::battery_calls, CHECK, idle, idle_on_wake(), r, fake_t::send_calls, and setup().

Referenced by main().

◆ test_send_failure_counted_and_sleep_continues()

◆ test_sixty_seconds_gives_six_heartbeats()

void test_sixty_seconds_gives_six_heartbeats ( void )
static

◆ test_thresholds()

◆ test_usb_is_never_battery_health()

void test_usb_is_never_battery_health ( void )
static

◆ test_wake_before_enter_is_error()

void test_wake_before_enter_is_error ( void )
static

Variable Documentation

◆ port

Definition at line 78 of file test_idle.c.