obu-firmware builds against vanetza-idf from microbu-esp32c5/external, but that tree was gitignored, so a clone of this repository could not build the firmware it ships. It is now committed here as ordinary files in its own folder, microbu-esp32c5/: the colleague's commit cf4b99f plus the V2X2MAP bridge's signature verification (--trust) used on the bench. Nothing is fetched from or pushed to the colleague's repository; this repository and its remotes carry everything. The folder's own .gitignore keeps build output, downloaded components and private key material out, as it did there; the committed file set is identical to that repository's tracked files. The ESP32-C5 is still flashed from obu-firmware/, which only takes vanetza-idf from microbu-esp32c5/, so the two stay separate folders. FLASHING.md says how to take a newer version of the colleague's tree (copy it over the folder, rebuild, test, commit).
62 lines
1.8 KiB
C++
62 lines
1.8 KiB
C++
#include <gtest/gtest.h>
|
|
#include <vanetza/common/clock.hpp>
|
|
#include <vanetza/common/manual_runtime.hpp>
|
|
#include <vanetza/dcc/fully_meshed_state_machine.hpp>
|
|
#include <vanetza/dcc/state_machine_budget.hpp>
|
|
|
|
using namespace vanetza::dcc;
|
|
using vanetza::ManualRuntime;
|
|
using std::chrono::milliseconds;
|
|
|
|
static const vanetza::Clock::duration immediately = milliseconds(0);
|
|
|
|
class StateMachineBudgetTest : public ::testing::Test
|
|
{
|
|
protected:
|
|
StateMachineBudgetTest() :
|
|
runtime(vanetza::Clock::time_point { std::chrono::seconds(4711) }),
|
|
budget(fsm, runtime) {}
|
|
|
|
ManualRuntime runtime;
|
|
FullyMeshedStateMachine fsm;
|
|
StateMachineBudget budget;
|
|
};
|
|
|
|
TEST_F(StateMachineBudgetTest, relaxed)
|
|
{
|
|
Relaxed relaxed;
|
|
const auto relaxed_tx_interval = relaxed.transmission_interval();
|
|
ASSERT_EQ(relaxed_tx_interval, fsm.transmission_interval());
|
|
|
|
EXPECT_EQ(immediately, budget.delay());
|
|
budget.notify();
|
|
EXPECT_EQ(relaxed_tx_interval, budget.delay());
|
|
|
|
runtime.trigger(relaxed_tx_interval - milliseconds(10));
|
|
EXPECT_EQ(milliseconds(10), budget.delay());
|
|
|
|
runtime.trigger(milliseconds(20));
|
|
EXPECT_EQ(immediately, budget.delay());
|
|
}
|
|
|
|
TEST_F(StateMachineBudgetTest, restrictive)
|
|
{
|
|
Restrictive restrictive;
|
|
const auto restrictive_tx_interval = restrictive.transmission_interval();
|
|
|
|
// put FSM into restrictive state
|
|
for (unsigned i = 0; i < 10; ++i) {
|
|
fsm.update(ChannelLoad(0.6));
|
|
}
|
|
ASSERT_STREQ("Restrictive", fsm.state().name());
|
|
|
|
EXPECT_EQ(immediately, budget.delay());
|
|
budget.notify();
|
|
EXPECT_EQ(restrictive_tx_interval, budget.delay());
|
|
|
|
runtime.trigger(restrictive_tx_interval / 2);
|
|
EXPECT_EQ(restrictive_tx_interval / 2, budget.delay());
|
|
runtime.trigger(restrictive_tx_interval / 2);
|
|
EXPECT_EQ(immediately, budget.delay());
|
|
}
|