Move the board profile tests into the native Unity suite

The board tests ran through tools/test-board-profile.sh with their own stubs, assert() and a script that copied nine method bodies out of Transceiver.cpp, so they were outside pio test -e native and the coverage report.

Pure decisions now live in units the native env builds: BoardProfile::usesPin is constexpr, RadioReadiness decides register validity, the receive-state outcome (ready, retry or unavailable, with one try today) and whether a queued job may transmit, and ShadeGpioGuard decides whether a shade's outputs touch a board pad. Transceiver and ShadeGpio call them with identical behaviour. New Unity suites cover the generic and LILYGO profiles (reserved pads, startup order, radio bring-up) and the readiness unit; the old harness, its script, CI step and stubs are deleted.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
R. Sid Shaytay 2026-11-14 18:46:33 -08:00
parent 2b3d556729
commit 28af01195a
No known key found for this signature in database
27 changed files with 595 additions and 517 deletions

View file

@ -10,12 +10,64 @@
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <type_traits>
typedef uint8_t byte;
// Fixed so anything formatted from it is deterministic.
inline unsigned long millis() { return 0; }
// Starts at 0 and only moves when a test calls delay() or sets it, so anything
// formatted from it is deterministic.
inline unsigned long stubMillis = 0;
inline unsigned long millis() { return stubMillis; }
inline void delay(unsigned long ms) { stubMillis += ms; }
// A fake GPIO bank for board code. Every pin call is also logged in order
// so tests can check the startup sequence, not only the final levels.
constexpr int LOW = 0;
constexpr int HIGH = 1;
constexpr int INPUT = 0x01;
constexpr int OUTPUT = 0x03;
struct StubGpioEvent {
enum Kind : char { Mode = 'M', Level = 'L', Write = 'W', SpiBegin = 'B', SpiEnd = 'E' };
Kind kind;
uint8_t pin;
int value;
};
inline std::vector<StubGpioEvent> stubGpioLog;
inline int stubPinLevel[64] = {};
inline int stubPinMode[64] = {};
inline int stubPinReadOverride[64] = {}; // -1 for none, set by stubGpioReset()
inline void stubGpioReset() {
stubGpioLog.clear();
for(int i = 0; i < 64; i++) { stubPinLevel[i] = 0; stubPinMode[i] = 0; stubPinReadOverride[i] = -1; }
stubMillis = 0;
}
// The ESP-IDF call that sets the output latch whatever the pin mode is.
inline void stubSetLatch(uint8_t pin, int level) {
stubPinLevel[pin] = level;
stubGpioLog.push_back({StubGpioEvent::Level, pin, level});
}
inline void pinMode(uint8_t pin, uint8_t mode) {
stubPinMode[pin] = mode;
stubGpioLog.push_back({StubGpioEvent::Mode, pin, mode});
}
// Arduino 3 only accepts writes once pinMode has made the pin an output.
inline void digitalWrite(uint8_t pin, uint8_t level) {
if(stubPinMode[pin] != OUTPUT) return;
stubPinLevel[pin] = level;
stubGpioLog.push_back({StubGpioEvent::Write, pin, level});
}
inline int digitalRead(uint8_t pin) {
return stubPinReadOverride[pin] >= 0 ? stubPinReadOverride[pin] : stubPinLevel[pin];
}
// Serial output is discarded.
struct StubSerial {
template <typename... Args> void printf(const char *, Args...) {}
void println(const char *) {}
};
inline StubSerial Serial;
// Tests that measure time set this.
inline unsigned long stubMicros = 0;
inline unsigned long micros() { return stubMicros; }

19
test/stubs/SPI.h Normal file
View file

@ -0,0 +1,19 @@
// Arduino SPI stand-in for the native test env: remembers whether the bus is
// up and logs begin/end in order with the pin calls (see Arduino.h).
#pragma once
#include <Arduino.h>
struct StubSPI {
bool active = false;
unsigned int begins = 0;
unsigned int ends = 0;
int8_t sck = -1, miso = -1, mosi = -1, cs = -1;
void begin(int8_t s, int8_t mi, int8_t mo, int8_t c) {
active = true; begins++; sck = s; miso = mi; mosi = mo; cs = c;
stubGpioLog.push_back({StubGpioEvent::SpiBegin, 0, 0});
}
void end() {
active = false; ends++;
stubGpioLog.push_back({StubGpioEvent::SpiEnd, 0, 0});
}
};
inline StubSPI SPI;

8
test/stubs/driver/gpio.h Normal file
View file

@ -0,0 +1,8 @@
// ESP-IDF gpio_set_level stand-in for the native test env; see Arduino.h.
#pragma once
#include <Arduino.h>
using gpio_num_t = int;
inline int gpio_set_level(gpio_num_t pin, uint32_t level) {
stubSetLatch(static_cast<uint8_t>(pin), static_cast<int>(level));
return 0;
}

View file

@ -0,0 +1,47 @@
// A generic board: the profile reserves nothing and does nothing.
#include <unity.h>
#include "BoardProfile.cpp"
#include "ShadeGpioGuard.h"
void setUp() {
stubGpioReset();
SPI = StubSPI();
}
void tearDown() {}
static void test_there_is_no_integrated_radio() {
TEST_ASSERT_FALSE(BoardProfile::integratedRadio);
}
static void test_no_pad_is_reserved() {
for(unsigned pin = 0; pin < 256; pin++) TEST_ASSERT_FALSE(BoardProfile::usesPin((uint8_t)pin));
}
static void test_begin_leaves_the_hardware_alone() {
BoardProfile::begin();
TEST_ASSERT_EQUAL_UINT(0, stubGpioLog.size());
TEST_ASSERT_FALSE(SPI.active);
TEST_ASSERT_EQUAL_UINT(0, SPI.begins);
}
static void test_any_frequency_is_accepted_without_touching_the_bus() {
TEST_ASSERT_TRUE(BoardProfile::prepareRadio(868.0f));
TEST_ASSERT_TRUE(BoardProfile::prepareRadio(433.42f));
TEST_ASSERT_EQUAL_UINT(0, stubGpioLog.size());
TEST_ASSERT_EQUAL_UINT(0, SPI.begins);
TEST_ASSERT_EQUAL_UINT(0, SPI.ends);
}
static void test_shade_outputs_may_use_any_pad() {
for(unsigned pin = 0; pin < 256; pin++) {
const uint8_t p = (uint8_t)pin;
TEST_ASSERT_FALSE(shadeOutputsUseBoardPins(radio_proto::GP_Relay, p, p, p));
TEST_ASSERT_FALSE(shadeOutputsUseBoardPins(radio_proto::GP_Remote, p, p, p));
}
}
int main(int, char **) {
UNITY_BEGIN();
RUN_TEST(test_there_is_no_integrated_radio);
RUN_TEST(test_no_pad_is_reserved);
RUN_TEST(test_begin_leaves_the_hardware_alone);
RUN_TEST(test_any_frequency_is_accepted_without_touching_the_bus);
RUN_TEST(test_shade_outputs_may_use_any_pad);
return UNITY_END();
}

View file

@ -0,0 +1,221 @@
// The LILYGO T-Embed CC1101 profile: which pads the board owns, the hardware
// startup order and the radio bring-up. BoardProfile.cpp is included so it
// is built for this board whatever the env's flags are.
#include <unity.h>
#include <cmath>
#define ESPSOMFY_LILYGO_T_EMBED_CC1101 1
#define CONFIG_IDF_TARGET_ESP32S3 1
#include "BoardProfile.cpp"
#include "ShadeGpioGuard.h"
using E = StubGpioEvent;
static const uint8_t RESERVED[] = {3, 9, 10, 11, 12, 13, 15, 21, 38, 41, 43, 44, 47, 48};
void setUp() {
// begin() runs once per boot, so what it set up stays between tests.
int modes[64];
memcpy(modes, stubPinMode, sizeof(modes));
stubGpioReset();
memcpy(stubPinMode, modes, sizeof(modes));
SPI = StubSPI();
}
void tearDown() {}
static unsigned countEvents(E::Kind kind, uint8_t pin, int value) {
unsigned n = 0;
for(const auto &e : stubGpioLog) if(e.kind == kind && e.pin == pin && e.value == value) n++;
return n;
}
static int firstEvent(E::Kind kind, uint8_t pin) {
for(size_t i = 0; i < stubGpioLog.size(); i++)
if(stubGpioLog[i].kind == kind && stubGpioLog[i].pin == pin) return (int)i;
return -1;
}
// --- reserved pads ---
static void test_profile_has_an_integrated_radio() {
TEST_ASSERT_TRUE(BoardProfile::integratedRadio);
}
static void test_the_wiring_is_the_lilygo_one() {
TEST_ASSERT_EQUAL(15, BoardProfile::power);
TEST_ASSERT_EQUAL(11, BoardProfile::sck);
TEST_ASSERT_EQUAL(9, BoardProfile::mosi);
TEST_ASSERT_EQUAL(10, BoardProfile::miso);
TEST_ASSERT_EQUAL(12, BoardProfile::cs);
TEST_ASSERT_EQUAL(3, BoardProfile::tx);
TEST_ASSERT_EQUAL(38, BoardProfile::rx);
}
static void test_every_board_pad_is_reserved() {
for(uint8_t pin : RESERVED) TEST_ASSERT_TRUE_MESSAGE(BoardProfile::usesPin(pin), "pad not reserved");
}
static void test_usb_and_flash_pads_are_reserved() {
TEST_ASSERT_TRUE(BoardProfile::usesPin(19));
TEST_ASSERT_TRUE(BoardProfile::usesPin(20));
for(uint8_t pin = 26; pin <= 37; pin++) TEST_ASSERT_TRUE(BoardProfile::usesPin(pin));
}
static void test_other_pads_are_free() {
TEST_ASSERT_FALSE(BoardProfile::usesPin(0));
TEST_ASSERT_FALSE(BoardProfile::usesPin(16));
TEST_ASSERT_FALSE(BoardProfile::usesPin(18));
TEST_ASSERT_FALSE(BoardProfile::usesPin(25));
TEST_ASSERT_FALSE(BoardProfile::usesPin(39));
TEST_ASSERT_FALSE(BoardProfile::usesPin(46));
TEST_ASSERT_FALSE(BoardProfile::usesPin(255));
}
// --- shade outputs on board pads (a backup may carry another board's pins) ---
static void test_a_relay_output_on_any_board_pad_is_refused() {
for(uint8_t pin = 0; pin < 64; pin++) {
if(!BoardProfile::usesPin(pin)) continue;
TEST_ASSERT_TRUE(shadeOutputsUseBoardPins(radio_proto::GP_Relay, pin, 17, 18));
TEST_ASSERT_TRUE(shadeOutputsUseBoardPins(radio_proto::GP_Relay, 16, pin, 18));
TEST_ASSERT_TRUE(shadeOutputsUseBoardPins(radio_proto::GP_Remote, pin, 17, 18));
TEST_ASSERT_TRUE(shadeOutputsUseBoardPins(radio_proto::GP_Remote, 16, pin, 18));
TEST_ASSERT_TRUE(shadeOutputsUseBoardPins(radio_proto::GP_Remote, 16, 17, pin));
}
}
static void test_a_relay_has_no_my_output() {
for(uint8_t pin = 0; pin < 64; pin++)
if(BoardProfile::usesPin(pin))
TEST_ASSERT_FALSE(shadeOutputsUseBoardPins(radio_proto::GP_Relay, 16, 17, pin));
}
static void test_free_pads_are_allowed() {
TEST_ASSERT_FALSE(shadeOutputsUseBoardPins(radio_proto::GP_Relay, 16, 17, 18));
TEST_ASSERT_FALSE(shadeOutputsUseBoardPins(radio_proto::GP_Remote, 16, 17, 18));
}
static void test_radio_shades_have_no_gpio_outputs() {
TEST_ASSERT_FALSE(shadeOutputsUseBoardPins(radio_proto::RTS, 3, 9, 10));
TEST_ASSERT_FALSE(shadeOutputsUseBoardPins(radio_proto::RTW, 3, 9, 10));
TEST_ASSERT_FALSE(shadeOutputsUseBoardPins(radio_proto::RTV, 3, 9, 10));
}
// --- startup order; this runs first as begin() only acts once ---
static void test_begin_deselects_every_slave_before_the_power_rail() {
BoardProfile::begin();
const int power = firstEvent(E::Level, BoardProfile::power);
TEST_ASSERT_TRUE(power >= 0);
TEST_ASSERT_EQUAL_UINT(1, countEvents(E::Level, BoardProfile::power, HIGH));
// Nothing happens after the rail comes up except settling.
TEST_ASSERT_EQUAL((int)stubGpioLog.size() - 2, power); // then its own pinMode
TEST_ASSERT_EQUAL(E::Mode, stubGpioLog.back().kind);
TEST_ASSERT_EQUAL(BoardProfile::power, stubGpioLog.back().pin);
const uint8_t high[] = {BoardProfile::cs, BoardProfile::sdCS, BoardProfile::displayCS,
BoardProfile::nrfCS, BoardProfile::sw1, BoardProfile::sw0};
const uint8_t low[] = {BoardProfile::nrfCE, BoardProfile::backlight};
for(uint8_t pin : high) {
TEST_ASSERT_TRUE(firstEvent(E::Level, pin) < power);
TEST_ASSERT_EQUAL_UINT(1, countEvents(E::Level, pin, HIGH));
TEST_ASSERT_EQUAL(OUTPUT, stubPinMode[pin]);
}
for(uint8_t pin : low) {
TEST_ASSERT_TRUE(firstEvent(E::Level, pin) < power);
TEST_ASSERT_EQUAL_UINT(1, countEvents(E::Level, pin, LOW));
TEST_ASSERT_EQUAL(OUTPUT, stubPinMode[pin]);
}
TEST_ASSERT_EQUAL(OUTPUT, stubPinMode[BoardProfile::power]);
TEST_ASSERT_EQUAL(10, (int)stubMillis); // rail settling
// Each pin's safe level is latched before it is made an output.
for(const auto &e : stubGpioLog) {
if(e.kind != E::Mode) continue;
TEST_ASSERT_EQUAL(OUTPUT, e.value);
int latch = -1, mode = -1;
for(size_t i = 0; i < stubGpioLog.size(); i++) {
if(stubGpioLog[i].pin != e.pin) continue;
if(stubGpioLog[i].kind == E::Level && latch < 0) latch = (int)i;
if(stubGpioLog[i].kind == E::Mode && mode < 0) mode = (int)i;
}
TEST_ASSERT_TRUE_MESSAGE(latch >= 0 && latch < mode, "pin became an output before its level was latched");
}
// The shared SPI pads are left alone until the radio is prepared.
for(uint8_t pin : {BoardProfile::sck, BoardProfile::mosi, BoardProfile::miso})
TEST_ASSERT_EQUAL(-1, firstEvent(E::Mode, pin));
TEST_ASSERT_FALSE(SPI.active);
}
static void test_a_second_begin_does_nothing() {
// begin() ran in the previous test; starting again changes nothing.
stubGpioLog.clear();
BoardProfile::begin();
TEST_ASSERT_EQUAL_UINT(0, stubGpioLog.size());
}
// --- radio bring-up ---
static void test_prepare_releases_spi_before_it_probes_the_pads() {
TEST_ASSERT_TRUE(BoardProfile::prepareRadio(433.42f));
const int end = firstEvent(E::SpiEnd, 0);
TEST_ASSERT_TRUE(end >= 0);
for(uint8_t pin : {BoardProfile::sck, BoardProfile::mosi, BoardProfile::miso})
TEST_ASSERT_TRUE(firstEvent(E::Mode, pin) > end);
TEST_ASSERT_EQUAL(INPUT, stubPinMode[BoardProfile::miso]);
TEST_ASSERT_EQUAL(OUTPUT, stubPinMode[BoardProfile::mosi]);
TEST_ASSERT_EQUAL(OUTPUT, stubPinMode[BoardProfile::sck]);
TEST_ASSERT_EQUAL(HIGH, stubPinLevel[BoardProfile::cs]); // released after the probe
TEST_ASSERT_TRUE(SPI.active);
TEST_ASSERT_EQUAL_UINT(1, SPI.begins);
TEST_ASSERT_EQUAL(11, SPI.sck);
TEST_ASSERT_EQUAL(10, SPI.miso);
TEST_ASSERT_EQUAL(9, SPI.mosi);
TEST_ASSERT_EQUAL(12, SPI.cs);
}
static void test_prepare_can_run_again_on_a_running_bus() {
TEST_ASSERT_TRUE(BoardProfile::prepareRadio(433.42f));
TEST_ASSERT_TRUE(BoardProfile::prepareRadio(433.42f));
TEST_ASSERT_EQUAL_UINT(2, SPI.begins);
TEST_ASSERT_EQUAL_UINT(2, SPI.ends);
TEST_ASSERT_TRUE(SPI.active);
}
static void test_prepare_refuses_a_frequency_outside_the_433_band() {
TEST_ASSERT_FALSE(BoardProfile::prepareRadio(868.0f));
TEST_ASSERT_FALSE(BoardProfile::prepareRadio(386.9f));
TEST_ASSERT_FALSE(BoardProfile::prepareRadio(464.1f));
TEST_ASSERT_FALSE(BoardProfile::prepareRadio(0.0f));
TEST_ASSERT_FALSE(BoardProfile::prepareRadio(NAN));
TEST_ASSERT_TRUE(BoardProfile::prepareRadio(387.0f));
TEST_ASSERT_TRUE(BoardProfile::prepareRadio(464.0f));
}
static void test_a_rejected_frequency_leaves_the_bus_alone() {
BoardProfile::prepareRadio(868.0f);
TEST_ASSERT_EQUAL_UINT(0, stubGpioLog.size());
TEST_ASSERT_EQUAL_UINT(0, SPI.begins);
}
static void test_prepare_fails_fast_when_the_radio_holds_miso_high() {
stubPinReadOverride[BoardProfile::miso] = HIGH;
TEST_ASSERT_FALSE(BoardProfile::prepareRadio(433.42f));
TEST_ASSERT_TRUE(stubMillis <= 25); // not a hang inside the radio driver
TEST_ASSERT_EQUAL(HIGH, stubPinLevel[BoardProfile::cs]);
TEST_ASSERT_FALSE(SPI.active);
TEST_ASSERT_EQUAL_UINT(0, SPI.begins);
}
static void test_a_retry_after_a_fault_does_not_power_cycle_the_board() {
stubPinReadOverride[BoardProfile::miso] = HIGH;
TEST_ASSERT_FALSE(BoardProfile::prepareRadio(433.42f));
stubPinReadOverride[BoardProfile::miso] = -1;
TEST_ASSERT_TRUE(BoardProfile::prepareRadio(433.42f));
TEST_ASSERT_EQUAL_UINT(0, countEvents(E::Level, BoardProfile::power, HIGH));
TEST_ASSERT_EQUAL_UINT(0, countEvents(E::Level, BoardProfile::power, LOW));
}
int main(int, char **) {
UNITY_BEGIN();
RUN_TEST(test_begin_deselects_every_slave_before_the_power_rail);
RUN_TEST(test_a_second_begin_does_nothing);
RUN_TEST(test_profile_has_an_integrated_radio);
RUN_TEST(test_the_wiring_is_the_lilygo_one);
RUN_TEST(test_every_board_pad_is_reserved);
RUN_TEST(test_usb_and_flash_pads_are_reserved);
RUN_TEST(test_other_pads_are_free);
RUN_TEST(test_a_relay_output_on_any_board_pad_is_refused);
RUN_TEST(test_a_relay_has_no_my_output);
RUN_TEST(test_free_pads_are_allowed);
RUN_TEST(test_radio_shades_have_no_gpio_outputs);
RUN_TEST(test_prepare_releases_spi_before_it_probes_the_pads);
RUN_TEST(test_prepare_can_run_again_on_a_running_bus);
RUN_TEST(test_prepare_refuses_a_frequency_outside_the_433_band);
RUN_TEST(test_a_rejected_frequency_leaves_the_bus_alone);
RUN_TEST(test_prepare_fails_fast_when_the_radio_holds_miso_high);
RUN_TEST(test_a_retry_after_a_fault_does_not_power_cycle_the_board);
return UNITY_END();
}

View file

@ -0,0 +1,129 @@
#include <unity.h>
#include <cmath>
#include "RadioReadiness.h"
void setUp() {}
void tearDown() {}
// What a healthy CC1101 reports when set up for 433.42 MHz async OOK.
static radio_readings_t healthy() {
radio_readings_t r;
r.partnum = 0;
r.version = 0x14;
r.iocfg0 = 0x0D;
r.iocfg2 = 0x0D;
r.pktctrl0 = 0x32;
r.mdmcfg2 = 0x3C;
r.freqWord = 0x10AB85;
return r;
}
static const float MHZ = 433.42f;
static void test_frequency_word_converts_to_mhz() {
TEST_ASSERT_FLOAT_WITHIN(0.01f, 433.42f, radioFrequencyMHz(0x10AB85));
TEST_ASSERT_EQUAL_FLOAT(0.0f, radioFrequencyMHz(0));
}
static void test_a_healthy_radio_is_ready() {
TEST_ASSERT_TRUE(radioRegistersReady(healthy(), MHZ));
}
static void test_a_part_that_is_not_a_cc1101_is_refused() {
radio_readings_t r = healthy();
r.partnum = 1;
TEST_ASSERT_FALSE(radioRegistersReady(r, MHZ));
r.partnum = 0xFF;
TEST_ASSERT_FALSE(radioRegistersReady(r, MHZ));
}
static void test_no_chip_answering_is_refused() {
radio_readings_t r = healthy();
r.version = 0;
TEST_ASSERT_FALSE(radioRegistersReady(r, MHZ));
r.version = 0xFF;
TEST_ASSERT_FALSE(radioRegistersReady(r, MHZ));
}
static void test_gdo_pins_must_carry_the_async_data() {
radio_readings_t r = healthy();
r.iocfg0 = 0;
TEST_ASSERT_FALSE(radioRegistersReady(r, MHZ));
r = healthy();
r.iocfg2 = 0;
TEST_ASSERT_FALSE(radioRegistersReady(r, MHZ));
}
static void test_packet_format_and_modulation_must_be_set() {
radio_readings_t r = healthy();
r.pktctrl0 = 0;
TEST_ASSERT_FALSE(radioRegistersReady(r, MHZ));
r = healthy();
r.pktctrl0 = 0x10; // only part of the async format bits
TEST_ASSERT_FALSE(radioRegistersReady(r, MHZ));
r = healthy();
r.mdmcfg2 = 0;
TEST_ASSERT_FALSE(radioRegistersReady(r, MHZ));
r = healthy();
r.mdmcfg2 = 0x0C; // 2-FSK instead of OOK
TEST_ASSERT_FALSE(radioRegistersReady(r, MHZ));
}
static void test_unrelated_register_bits_are_ignored() {
radio_readings_t r = healthy();
r.pktctrl0 = 0x3F;
r.mdmcfg2 = 0xBF;
TEST_ASSERT_TRUE(radioRegistersReady(r, MHZ));
}
static void test_the_frequency_readback_must_match_the_request() {
radio_readings_t r = healthy();
r.freqWord = 0;
TEST_ASSERT_FALSE(radioRegistersReady(r, MHZ));
r.freqWord = 0x10AB85 + 100; // 0.04 MHz away
TEST_ASSERT_FALSE(radioRegistersReady(r, MHZ));
TEST_ASSERT_FALSE(radioRegistersReady(healthy(), 433.92f));
TEST_ASSERT_FALSE(radioRegistersReady(healthy(), NAN));
}
static void test_rx_state_ready() {
TEST_ASSERT_EQUAL(rx_outcome_t::ready, radioRxOutcome(RADIO_MARCSTATE_RX, 0, 1));
TEST_ASSERT_EQUAL(rx_outcome_t::ready, radioRxOutcome(0xED, 0, 1)); // upper bits are not state
}
static void test_a_radio_not_in_rx_is_unavailable_with_one_try() {
TEST_ASSERT_EQUAL(rx_outcome_t::unavailable, radioRxOutcome(0x00, 0, 1));
TEST_ASSERT_EQUAL(rx_outcome_t::unavailable, radioRxOutcome(0x01, 0, 1)); // IDLE
TEST_ASSERT_EQUAL(rx_outcome_t::unavailable, radioRxOutcome(0x11, 0, 1)); // RXFIFO_OVERFLOW
}
static void test_a_radio_not_in_rx_may_retry_while_tries_are_left() {
TEST_ASSERT_EQUAL(rx_outcome_t::retry, radioRxOutcome(0x01, 0, 2));
TEST_ASSERT_EQUAL(rx_outcome_t::unavailable, radioRxOutcome(0x01, 1, 2));
TEST_ASSERT_EQUAL(rx_outcome_t::ready, radioRxOutcome(RADIO_MARCSTATE_RX, 1, 2));
}
static void test_zero_tries_never_retry() {
TEST_ASSERT_EQUAL(rx_outcome_t::unavailable, radioRxOutcome(0x01, 0, 0));
}
static void test_the_firmware_makes_one_try_for_now() {
TEST_ASSERT_EQUAL(1, RADIO_RX_ATTEMPTS);
}
static void test_a_generic_radio_may_always_queue_and_send() {
TEST_ASSERT_TRUE(radioMayTransmit(false, false));
TEST_ASSERT_TRUE(radioMayTransmit(false, true));
}
static void test_the_integrated_radio_transmits_only_when_ready() {
TEST_ASSERT_TRUE(radioMayTransmit(true, true));
TEST_ASSERT_FALSE(radioMayTransmit(true, false));
}
int main(int, char **) {
UNITY_BEGIN();
RUN_TEST(test_frequency_word_converts_to_mhz);
RUN_TEST(test_a_healthy_radio_is_ready);
RUN_TEST(test_a_part_that_is_not_a_cc1101_is_refused);
RUN_TEST(test_no_chip_answering_is_refused);
RUN_TEST(test_gdo_pins_must_carry_the_async_data);
RUN_TEST(test_packet_format_and_modulation_must_be_set);
RUN_TEST(test_unrelated_register_bits_are_ignored);
RUN_TEST(test_the_frequency_readback_must_match_the_request);
RUN_TEST(test_rx_state_ready);
RUN_TEST(test_a_radio_not_in_rx_is_unavailable_with_one_try);
RUN_TEST(test_a_radio_not_in_rx_may_retry_while_tries_are_left);
RUN_TEST(test_zero_tries_never_retry);
RUN_TEST(test_the_firmware_makes_one_try_for_now);
RUN_TEST(test_a_generic_radio_may_always_queue_and_send);
RUN_TEST(test_the_integrated_radio_transmits_only_when_ready);
return UNITY_END();
}