Skip to content

Commit

Permalink
Merge pull request #207 from Denzo77/master
Browse files Browse the repository at this point in the history
stubs for unit testing
  • Loading branch information
Denzo77 authored Jul 24, 2018
2 parents f2daaa6 + 6775a4b commit ca2ba56
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 4 deletions.
7 changes: 6 additions & 1 deletion content/OTRadioLink/utility/OTV0P2BASE_Entropy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,12 @@ void seedPRNGs()
DEBUG_SERIAL_PRINTLN();
#endif
}

#else
// Stub for integration tests
uint8_t getSecureRandomByte(const bool)
{
return (0);
}
#endif // ARDUINO_ARCH_AVR


Expand Down
3 changes: 2 additions & 1 deletion content/OTRadioLink/utility/OTV0P2BASE_PowerManagement.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,8 @@ void power_intermittent_peripherals_disable();
// Stub for unit testing
// RAII style wrapper around functions that power/disable UART peripheral.
// WARNING! EXPERIMENTAL!
template <uint16_t>
// Added dummy value to allow compilation.
template <uint16_t = 0>
class RAII_EnableSerial final
{
public:
Expand Down
6 changes: 6 additions & 0 deletions content/OTRadioLink/utility/OTV0P2BASE_RTC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ void persistRTC() // TODO Work out emulated EEPROM on EFR32
}
}
}
#else
// Stub for integration tests
void persistRTC() {}
#endif // ARDUINO_ARCH_AVR

#ifdef ARDUINO_ARCH_AVR
Expand Down Expand Up @@ -171,6 +174,9 @@ bool restoreRTC() // TODO Work out emulated EEPROM on EFR32

return(true);
}
#else
// Stub for integration tests
bool restoreRTC() { return(false); }
#endif // ARDUINO_ARCH_AVR

// Get minutes since midnight local time [0,1439].
Expand Down
5 changes: 4 additions & 1 deletion content/OTRadioLink/utility/OTV0P2BASE_Security.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,10 @@ int8_t getNextMatchingNodeID(const uint8_t _index, const uint8_t *prefix, const
// No match has been found.
return(-1);
}

#else
// Stub for integration tests
bool ensureIDCreated() { return (true); }
bool ensureIDCreated(const bool) { return (true); }
#endif // ARDUINO_ARCH_AVR


Expand Down
1 change: 1 addition & 0 deletions content/OTRadioLink/utility/OTV0P2BASE_SensorSHT21.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class DummyHumiditySensor final
constexpr static bool isRHHigh() { return(false); } // Unknown, so always false.
constexpr static bool isRHHighWithHyst() { return(false); } // Unknown, so always false.
constexpr static uint8_t get() { return(0); }
constexpr static uint8_t read() { return(0); }
};
// Previous name as used in V0p2_Main.
typedef DummyHumiditySensor DummyHumiditySensorSHT21;
Expand Down
8 changes: 8 additions & 0 deletions content/OTRadioLink/utility/OTV0P2BASE_SensorTemperaturePot.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,14 @@ class SensorTemperaturePotMock final : public SensorTemperaturePotBase
// Returns the existing value: use set() to set a new one.
// Simplistically updates other flags and outputs based on current value.
uint8_t read() override { return(get()); }

// Set WARM/FROST and BAKE start/cancel callbacks.
// If not NULL, are called when the pot is adjusted appropriately.
// Typically at most one of these callbacks would be made on any appropriate pot adjustment.
// void setWFBCallbacks(void (*warmModeCallback_)(bool), void (*bakeStartCallback_)(bool))
// { warmModeCallback = warmModeCallback_; bakeStartCallback = bakeStartCallback_; }
void setWFBCallbacks(void (*)(bool), void (*)(bool)) {}

};

#ifdef ARDUINO_ARCH_AVR
Expand Down
5 changes: 4 additions & 1 deletion content/OTRadioLink/utility/OTV0P2BASE_Sleep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,10 @@ uint_fast8_t clockJitterEntropyByte()
wdt_disable(); // Ensure no spurious WDT wakeup pending.
return(result);
}

#else
// Stubs for integration tests
void nap(const int_fast8_t) {}
bool nap(const int_fast8_t, bool) { return(false); }
#endif // ARDUINO_ARCH_AVR

#if defined(EFR32FG1P133F256GM48) && defined(V0P2BASE_SYSTICK_EMULATED_SUBCYCLE)
Expand Down

0 comments on commit ca2ba56

Please sign in to comment.