mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/Tasty.git
synced 2025-06-10 02:26:00 +00:00
Updated test cases to work for TACOS rework
This commit is contained in:
parent
b6c929d316
commit
5feca7778f
@ -19,12 +19,10 @@
|
|||||||
#define STA_ASSERT_FORCE
|
#define STA_ASSERT_FORCE
|
||||||
#define STA_DEBUGGING_ENABLED
|
#define STA_DEBUGGING_ENABLED
|
||||||
|
|
||||||
// Settings for the rtos-utils
|
|
||||||
#define STA_RTOS_SYSTEM_EVENTS_ENABLE
|
|
||||||
|
|
||||||
// Use the default configs for TACOS
|
// Use the default configs for TACOS
|
||||||
#include <sta/tacos/configs/default.hpp>
|
#include <sta/tacos/configs/default.hpp>
|
||||||
|
|
||||||
|
#define STA_TACOS_WATCHDOG_ENABLED
|
||||||
#define STA_TACOS_WATCHDOG_FREQUENCY 1000
|
#define STA_TACOS_WATCHDOG_FREQUENCY 1000
|
||||||
#define STA_TACOS_NUM_STATES 8
|
#define STA_TACOS_NUM_STATES 8
|
||||||
|
|
||||||
|
@ -10,6 +10,11 @@ namespace sta
|
|||||||
{
|
{
|
||||||
namespace tasty
|
namespace tasty
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @brief Initialize Tasty for the test case.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
void test_init();
|
||||||
/**
|
/**
|
||||||
* @brief Print a test result via serial.
|
* @brief Print a test result via serial.
|
||||||
*
|
*
|
||||||
@ -28,6 +33,12 @@ namespace sta
|
|||||||
} // namespace sta
|
} // namespace sta
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Initialize Tasty for the test case.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define STA_TASTY_INIT() ( (void)( sta::tasty::test_init() ) )
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Assert statement for automatic testing using tasty. Sends the test result to the host via serial.
|
* @brief Assert statement for automatic testing using tasty. Sends the test result to the host via serial.
|
||||||
*
|
*
|
||||||
@ -43,4 +54,4 @@ namespace sta
|
|||||||
|
|
||||||
#endif // STA_DEBUGGING_ENABLED
|
#endif // STA_DEBUGGING_ENABLED
|
||||||
|
|
||||||
#endif // STA_TASTY_UTILS_HPP
|
#endif // STA_TASTY_UTILS_HPP
|
||||||
|
2
run.py
2
run.py
@ -45,7 +45,7 @@ for case in os.listdir(path):
|
|||||||
# Store the results for each file and line combination in a dict.
|
# Store the results for each file and line combination in a dict.
|
||||||
results = dict()
|
results = dict()
|
||||||
|
|
||||||
with serial.Serial('COM4', baudrate=115200) as ser:
|
with serial.Serial('COM5', baudrate=115200) as ser:
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
output = ser.readline().decode()
|
output = ser.readline().decode()
|
||||||
|
@ -22,22 +22,24 @@ namespace sta
|
|||||||
|
|
||||||
void func() override
|
void func() override
|
||||||
{
|
{
|
||||||
|
STA_TASTY_INIT();
|
||||||
|
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 0);
|
STA_TASTY_ASSERT(tacos::getState() == 0);
|
||||||
|
|
||||||
// Transitioning from 0 to 1 should work correclty.
|
// Transitioning from 0 to 1 should work correctly.
|
||||||
tacos::setState(0, 1);
|
tacos::requestState(0, 1);
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 1);
|
STA_TASTY_ASSERT(tacos::getState() == 1);
|
||||||
|
|
||||||
// Transitioning from 0 to 5 should fail because we are in state 1.
|
// Transitioning from 0 to 5 should fail because we are in state 1.
|
||||||
tacos::setState(0, 5);
|
tacos::requestState(0, 5);
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 1);
|
STA_TASTY_ASSERT(tacos::getState() == 1);
|
||||||
|
|
||||||
// Transitioning from 7 to 0 should fail aswell
|
// Transitioning from 7 to 0 should fail aswell
|
||||||
tacos::setState(7, 0);
|
tacos::requestState(7, 0);
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 1);
|
STA_TASTY_ASSERT(tacos::getState() == 1);
|
||||||
|
|
||||||
// Transitioning from 4 to 5 should also fail.
|
// Transitioning from 4 to 5 should also fail.
|
||||||
tacos::setState(5, 4);
|
tacos::requestState(5, 4);
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 1);
|
STA_TASTY_ASSERT(tacos::getState() == 1);
|
||||||
|
|
||||||
STA_TASTY_TERMINATE();
|
STA_TASTY_TERMINATE();
|
||||||
|
@ -22,6 +22,8 @@ namespace sta
|
|||||||
|
|
||||||
void func() override
|
void func() override
|
||||||
{
|
{
|
||||||
|
STA_TASTY_INIT();
|
||||||
|
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 0);
|
STA_TASTY_ASSERT(tacos::getState() == 0);
|
||||||
|
|
||||||
// Schedule a state transition in 100 ticks.
|
// Schedule a state transition in 100 ticks.
|
||||||
@ -35,7 +37,7 @@ namespace sta
|
|||||||
// ... and still not
|
// ... and still not
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 0);
|
STA_TASTY_ASSERT(tacos::getState() == 0);
|
||||||
|
|
||||||
this->sleep(48);
|
this->sleep(40);
|
||||||
|
|
||||||
// ... and still not
|
// ... and still not
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 0);
|
STA_TASTY_ASSERT(tacos::getState() == 0);
|
||||||
|
@ -22,34 +22,36 @@ namespace sta
|
|||||||
|
|
||||||
void func() override
|
void func() override
|
||||||
{
|
{
|
||||||
|
STA_TASTY_INIT();
|
||||||
|
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 0);
|
STA_TASTY_ASSERT(tacos::getState() == 0);
|
||||||
|
|
||||||
// Trigger a state transition with lockout of 100 ticks.
|
// Trigger a state transition with lockout of 100 ticks.
|
||||||
tacos::setState(0, 1, 100);
|
tacos::requestState(0, 1, 100);
|
||||||
|
|
||||||
// The state transition should have been executed correctly.
|
// The state transition should have been executed correctly.
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 1);
|
STA_TASTY_ASSERT(tacos::getState() == 1);
|
||||||
|
|
||||||
// This state transition should get blocked.
|
// This state transition should get blocked.
|
||||||
tacos::setState(1, 3);
|
tacos::requestState(1, 3);
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 1);
|
STA_TASTY_ASSERT(tacos::getState() == 1);
|
||||||
|
|
||||||
this->sleep(50);
|
this->sleep(50);
|
||||||
|
|
||||||
// This state transition should get blocked.
|
// This state transition should get blocked.
|
||||||
tacos::setState(1, 4);
|
tacos::requestState(1, 4);
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 1);
|
STA_TASTY_ASSERT(tacos::getState() == 1);
|
||||||
|
|
||||||
this->sleep(48);
|
this->sleep(44);
|
||||||
|
|
||||||
// This state transition should get blocked.
|
// This state transition should get blocked.
|
||||||
tacos::setState(1, 2);
|
tacos::requestState(1, 2);
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 0);
|
STA_TASTY_ASSERT(tacos::getState() == 1);
|
||||||
|
|
||||||
this->sleep(3);
|
this->sleep(10);
|
||||||
|
|
||||||
// This state transition should get executed correctly.
|
// This state transition should get executed correctly.
|
||||||
tacos::setState(1, 7);
|
tacos::requestState(1, 7);
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 7);
|
STA_TASTY_ASSERT(tacos::getState() == 7);
|
||||||
|
|
||||||
STA_TASTY_TERMINATE();
|
STA_TASTY_TERMINATE();
|
||||||
|
@ -22,10 +22,12 @@ namespace sta
|
|||||||
|
|
||||||
void func() override
|
void func() override
|
||||||
{
|
{
|
||||||
|
STA_TASTY_INIT();
|
||||||
|
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 0);
|
STA_TASTY_ASSERT(tacos::getState() == 0);
|
||||||
|
|
||||||
// Trigger a state transition with lockout of 100 ticks.
|
// Trigger a state transition with lockout of 100 ticks.
|
||||||
tacos::setState(0, 1, 100);
|
tacos::requestState(0, 1, 100);
|
||||||
|
|
||||||
// Schedule a state transition to be executed after 50 ticks.
|
// Schedule a state transition to be executed after 50 ticks.
|
||||||
tacos::setStateTimed(1, 2, 50);
|
tacos::setStateTimed(1, 2, 50);
|
||||||
@ -33,16 +35,16 @@ namespace sta
|
|||||||
// This should have no effect.
|
// This should have no effect.
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 1);
|
STA_TASTY_ASSERT(tacos::getState() == 1);
|
||||||
|
|
||||||
// Wait for 50 ticks.
|
// Wait for 60 ticks.
|
||||||
this->sleep(50);
|
this->sleep(60);
|
||||||
|
|
||||||
// The state transition should have been blocked by the lockout timer
|
// The state transition should have been blocked by the lockout timer
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 1);
|
STA_TASTY_ASSERT(tacos::getState() == 1);
|
||||||
|
|
||||||
// Schedule a state transition to be executed in 51 ticks.
|
// Schedule a state transition to be executed in 41 ticks.
|
||||||
tacos::setStateTimed(1, 2, 51);
|
tacos::setStateTimed(1, 2, 41);
|
||||||
|
|
||||||
this->sleep(51);
|
this->sleep(50);
|
||||||
|
|
||||||
// This state transition should get through.
|
// This state transition should get through.
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 2);
|
STA_TASTY_ASSERT(tacos::getState() == 2);
|
||||||
|
@ -22,6 +22,8 @@ namespace sta
|
|||||||
|
|
||||||
void func() override
|
void func() override
|
||||||
{
|
{
|
||||||
|
STA_TASTY_INIT();
|
||||||
|
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 0);
|
STA_TASTY_ASSERT(tacos::getState() == 0);
|
||||||
|
|
||||||
// Schedule a state transition in 50 ticks.
|
// Schedule a state transition in 50 ticks.
|
||||||
@ -30,7 +32,7 @@ namespace sta
|
|||||||
this->sleep(10);
|
this->sleep(10);
|
||||||
|
|
||||||
// Force a state transition now. This should override the timed transition.
|
// Force a state transition now. This should override the timed transition.
|
||||||
tacos::setState(0, 2);
|
tacos::requestState(0, 2);
|
||||||
STA_TASTY_ASSERT(tacos::getState() == 2);
|
STA_TASTY_ASSERT(tacos::getState() == 2);
|
||||||
|
|
||||||
this->sleep(41);
|
this->sleep(41);
|
||||||
|
@ -72,6 +72,8 @@ namespace sta
|
|||||||
|
|
||||||
void onTastyInit()
|
void onTastyInit()
|
||||||
{
|
{
|
||||||
|
STA_TASTY_INIT();
|
||||||
|
|
||||||
std::shared_ptr<Victim> victim_ptr = tacos::addThread<Victim>({0});
|
std::shared_ptr<Victim> victim_ptr = tacos::addThread<Victim>({0});
|
||||||
tacos::addThread<ViciousMurderer>({0}, victim_ptr);
|
tacos::addThread<ViciousMurderer>({0}, victim_ptr);
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,8 @@ namespace sta
|
|||||||
|
|
||||||
void onTastyInit()
|
void onTastyInit()
|
||||||
{
|
{
|
||||||
|
STA_TASTY_INIT();
|
||||||
|
|
||||||
tacos::addThread<Dummy>({0});
|
tacos::addThread<Dummy>({0});
|
||||||
tacos::addThread<Observer>({0});
|
tacos::addThread<Observer>({0});
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,8 @@ namespace sta
|
|||||||
|
|
||||||
void onTastyInit()
|
void onTastyInit()
|
||||||
{
|
{
|
||||||
|
STA_TASTY_INIT();
|
||||||
|
|
||||||
mutexA = new RtosMutex("MutA");
|
mutexA = new RtosMutex("MutA");
|
||||||
mutexB = new RtosMutex("MutB");
|
mutexB = new RtosMutex("MutB");
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ namespace sta
|
|||||||
|
|
||||||
this->sleep(20);
|
this->sleep(20);
|
||||||
|
|
||||||
tacos::setState(0, 1);
|
tacos::requestState(0, 1);
|
||||||
|
|
||||||
this->sleep(5);
|
this->sleep(5);
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ namespace sta
|
|||||||
STA_TASTY_ASSERT(thread_A->getStatus() == tacos::ThreadStatus::STOPPED);
|
STA_TASTY_ASSERT(thread_A->getStatus() == tacos::ThreadStatus::STOPPED);
|
||||||
STA_TASTY_ASSERT(sta::rtos::getNumAllocs() == mallocs + 2);
|
STA_TASTY_ASSERT(sta::rtos::getNumAllocs() == mallocs + 2);
|
||||||
|
|
||||||
tacos::setState(1, 0);
|
tacos::requestState(1, 0);
|
||||||
|
|
||||||
this->sleep(5);
|
this->sleep(5);
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ namespace sta
|
|||||||
STA_TASTY_ASSERT(thread_B->getStatus() == tacos::ThreadStatus::STOPPED);
|
STA_TASTY_ASSERT(thread_B->getStatus() == tacos::ThreadStatus::STOPPED);
|
||||||
STA_TASTY_ASSERT(sta::rtos::getNumAllocs() == mallocs + 2);
|
STA_TASTY_ASSERT(sta::rtos::getNumAllocs() == mallocs + 2);
|
||||||
|
|
||||||
tacos::setState(0, 1);
|
tacos::requestState(0, 1);
|
||||||
|
|
||||||
STA_TASTY_ASSERT(!thread_A->isRunning());
|
STA_TASTY_ASSERT(!thread_A->isRunning());
|
||||||
STA_TASTY_ASSERT(thread_B->isRunning());
|
STA_TASTY_ASSERT(thread_B->isRunning());
|
||||||
@ -104,6 +104,8 @@ namespace sta
|
|||||||
|
|
||||||
void onTastyInit()
|
void onTastyInit()
|
||||||
{
|
{
|
||||||
|
STA_TASTY_INIT();
|
||||||
|
|
||||||
thread_A = tacos::addThread<ThreadA>({0});
|
thread_A = tacos::addThread<ThreadA>({0});
|
||||||
thread_B = tacos::addThread<ThreadB>({1});
|
thread_B = tacos::addThread<ThreadB>({1});
|
||||||
tacos::addThread<Observer>({0, 1});
|
tacos::addThread<Observer>({0, 1});
|
||||||
|
@ -16,14 +16,12 @@ namespace sta
|
|||||||
{
|
{
|
||||||
STA_WEAK
|
STA_WEAK
|
||||||
void onTastyInit()
|
void onTastyInit()
|
||||||
{
|
{}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace tacos
|
namespace tacos
|
||||||
{
|
{
|
||||||
void onManagerInit()
|
void startup()
|
||||||
{
|
{
|
||||||
tasty::onTastyInit();
|
tasty::onTastyInit();
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,17 @@
|
|||||||
#ifdef STA_DEBUGGING_ENABLED
|
#ifdef STA_DEBUGGING_ENABLED
|
||||||
|
|
||||||
#include <sta/debug/debug.hpp>
|
#include <sta/debug/debug.hpp>
|
||||||
|
#include <sta/devices/stm32/delay.hpp>
|
||||||
|
|
||||||
namespace sta
|
namespace sta
|
||||||
{
|
{
|
||||||
namespace tasty
|
namespace tasty
|
||||||
{
|
{
|
||||||
|
void test_init()
|
||||||
|
{
|
||||||
|
sta::delayMs(10);
|
||||||
|
}
|
||||||
|
|
||||||
void test_case(const char * file, uint32_t line, bool rslt)
|
void test_case(const char * file, uint32_t line, bool rslt)
|
||||||
{
|
{
|
||||||
STA_DEBUG_PRINTF("[%s|%d|%d]", file, line, rslt);
|
STA_DEBUG_PRINTF("[%s|%d|%d]", file, line, rslt);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user