mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/Tasty.git
synced 2025-09-28 15:57:33 +00:00
Added first test case for watchdog
This commit is contained in:
@@ -2,6 +2,6 @@
|
|||||||
#ifndef STA_TASTY_CONFIG_HPP
|
#ifndef STA_TASTY_CONFIG_HPP
|
||||||
#define STA_TASTY_CONFIG_HPP
|
#define STA_TASTY_CONFIG_HPP
|
||||||
|
|
||||||
#define TASTY_CASE_6
|
#define TASTY_CASE_7
|
||||||
|
|
||||||
#endif // STA_TASTY_CONFIG_HPP
|
#endif // STA_TASTY_CONFIG_HPP
|
||||||
|
@@ -41,9 +41,6 @@ namespace sta
|
|||||||
STA_TASTY_ASSERT(tacos::getState() == 1);
|
STA_TASTY_ASSERT(tacos::getState() == 1);
|
||||||
|
|
||||||
STA_TASTY_TERMINATE();
|
STA_TASTY_TERMINATE();
|
||||||
|
|
||||||
|
|
||||||
this->sleep(1000000);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
83
src/cases/case7.cpp
Normal file
83
src/cases/case7.cpp
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* case7.cpp
|
||||||
|
*
|
||||||
|
* Created on: Jan 24, 2024
|
||||||
|
* Author: Dario
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <sta/tasty/config.hpp>
|
||||||
|
#ifdef TASTY_CASE_7
|
||||||
|
|
||||||
|
#include <sta/tacos.hpp>
|
||||||
|
#include <sta/tasty/utils.hpp>
|
||||||
|
#include <sta/tacos/watchdog.hpp>
|
||||||
|
|
||||||
|
namespace sta
|
||||||
|
{
|
||||||
|
namespace tasty
|
||||||
|
{
|
||||||
|
static uint8_t alive_flag = 0;
|
||||||
|
|
||||||
|
class Dummy : public tacos::TacosThread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Dummy()
|
||||||
|
: tacos::TacosThread{"Dummy", osPriorityNormal}
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void init() override
|
||||||
|
{
|
||||||
|
alive_flag = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void func() override
|
||||||
|
{
|
||||||
|
this->sleep(100);
|
||||||
|
|
||||||
|
// Thread is stuck in infinite loop
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
osThreadYield();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class Observer : public tacos::TacosThread
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Observer()
|
||||||
|
: tacos::TacosThread{"Observer", osPriorityNormal}
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void func() override
|
||||||
|
{
|
||||||
|
this->sleep(10);
|
||||||
|
STA_TASTY_ASSERT(alive_flag == 1);
|
||||||
|
|
||||||
|
this->sleep(110);
|
||||||
|
alive_flag = 0;
|
||||||
|
|
||||||
|
// After at most 1000 ticks, the watchdog should have revived the thread.
|
||||||
|
this->sleep(2000);
|
||||||
|
STA_TASTY_ASSERT(alive_flag == 1);
|
||||||
|
STA_TASTY_ASSERT(tacos::Watchdog::instance()->getNumRestarts() == 1);
|
||||||
|
|
||||||
|
STA_TASTY_TERMINATE();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void onTastyInit()
|
||||||
|
{
|
||||||
|
tacos::addThread<Dummy>({0});
|
||||||
|
tacos::addThread<Observer>({0});
|
||||||
|
}
|
||||||
|
} // namespace tasty
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // TASTY_CASE_7
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user