mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/Tasty.git
synced 2025-06-11 19:15:59 +00:00
First proof of concept for automatic testing
This commit is contained in:
parent
d8b4258b20
commit
9dc48e1271
@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
#ifndef STA_TASTY_CONFIG_HPP
|
#ifndef STA_TASTY_CONFIG_HPP
|
||||||
#define STA_TASTY_CONFIG_HPP
|
#define STA_TASTY_CONFIG_HPP
|
||||||
|
|
||||||
#define TASTY_CASE_5
|
#define TASTY_CASE_7
|
||||||
|
|
||||||
#endif // STA_TASTY_CONFIG_HPP
|
#endif // STA_TASTY_CONFIG_HPP
|
||||||
|
64
run.py
Normal file
64
run.py
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
import serial
|
||||||
|
import subprocess
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from termcolor import colored
|
||||||
|
|
||||||
|
|
||||||
|
# Just the content we want to paste into the config.hpp file.
|
||||||
|
cfg_template = """
|
||||||
|
#ifndef STA_TASTY_CONFIG_HPP
|
||||||
|
#define STA_TASTY_CONFIG_HPP
|
||||||
|
|
||||||
|
#define TASTY_CASE_{}
|
||||||
|
|
||||||
|
#endif // STA_TASTY_CONFIG_HPP
|
||||||
|
"""
|
||||||
|
|
||||||
|
path = 'Tasty/src/cases/'
|
||||||
|
|
||||||
|
|
||||||
|
for case in os.listdir(path):
|
||||||
|
# Find the number of the test case.
|
||||||
|
match = re.match('case([0-9])+\.cpp', case)
|
||||||
|
number = match.group(1)
|
||||||
|
|
||||||
|
with open('Tasty/include/sta/tasty/config.hpp', 'w') as f:
|
||||||
|
f.write(cfg_template.format(number))
|
||||||
|
|
||||||
|
# Build the new project and upload it to the STM32.
|
||||||
|
subprocess.call(f'Tasty/flash.bat {case}', stdout=sys.stdout)
|
||||||
|
|
||||||
|
print(colored(f'Running case { number }...', 'blue'))
|
||||||
|
|
||||||
|
# Store the results for each file and line combination in a dict.
|
||||||
|
results = dict()
|
||||||
|
|
||||||
|
with serial.Serial('COM4', baudrate=115200) as ser:
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
output = ser.readline().decode()
|
||||||
|
except:
|
||||||
|
continue
|
||||||
|
|
||||||
|
# '[T]' is used to decode the end of a test case.
|
||||||
|
if '[T]' in output:
|
||||||
|
break
|
||||||
|
|
||||||
|
# Try to extract the test results from the serial output.
|
||||||
|
match = re.match('\[(.*?)\|([0-9]+)\|(0|1)\]', output)
|
||||||
|
|
||||||
|
if match is not None:
|
||||||
|
file, line, result = match.group(1), match.group(2), match.group(3)
|
||||||
|
|
||||||
|
# Update the result for the file and line by logical ANDing it with the new result.
|
||||||
|
results[(file, line)] = results.get((file, line), True) and int(result) == 1
|
||||||
|
|
||||||
|
# Print the test results.
|
||||||
|
for (file, line), result in results.items():
|
||||||
|
if result:
|
||||||
|
print(file + ', line ' + line + '\t' + colored('[PASSED]' , 'green'))
|
||||||
|
else:
|
||||||
|
print(file + ', line ' + line + '\t' + colored('[FAILED]' , 'red'))
|
@ -11,7 +11,7 @@ namespace sta
|
|||||||
{
|
{
|
||||||
namespace tasty
|
namespace tasty
|
||||||
{
|
{
|
||||||
class DummyThread
|
class DummyThread : public tacos::TacosThread
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
/* data */
|
/* data */
|
||||||
@ -51,4 +51,4 @@ namespace sta
|
|||||||
} // namespace tasty
|
} // namespace tasty
|
||||||
} // namespace sta
|
} // namespace sta
|
||||||
|
|
||||||
#endif // TASTY_CASE_1
|
#endif // TASTY_CASE_1
|
||||||
|
@ -11,7 +11,7 @@ namespace sta
|
|||||||
{
|
{
|
||||||
namespace tasty
|
namespace tasty
|
||||||
{
|
{
|
||||||
class DummyThread
|
class DummyThread : public tacos::TacosThread
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
/* data */
|
/* data */
|
||||||
@ -56,4 +56,4 @@ namespace sta
|
|||||||
} // namespace tasty
|
} // namespace tasty
|
||||||
} // namespace sta
|
} // namespace sta
|
||||||
|
|
||||||
#endif // TASTY_CASE_2
|
#endif // TASTY_CASE_2
|
||||||
|
@ -11,7 +11,7 @@ namespace sta
|
|||||||
{
|
{
|
||||||
namespace tasty
|
namespace tasty
|
||||||
{
|
{
|
||||||
class DummyThread
|
class DummyThread : public tacos::TacosThread
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
/* data */
|
/* data */
|
||||||
@ -63,4 +63,4 @@ namespace sta
|
|||||||
} // namespace tasty
|
} // namespace tasty
|
||||||
} // namespace sta
|
} // namespace sta
|
||||||
|
|
||||||
#endif // TASTY_CASE_3
|
#endif // TASTY_CASE_3
|
||||||
|
@ -11,7 +11,7 @@ namespace sta
|
|||||||
{
|
{
|
||||||
namespace tasty
|
namespace tasty
|
||||||
{
|
{
|
||||||
class DummyThread
|
class DummyThread : public tacos::TacosThread
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
/* data */
|
/* data */
|
||||||
@ -58,4 +58,4 @@ namespace sta
|
|||||||
} // namespace tasty
|
} // namespace tasty
|
||||||
} // namespace sta
|
} // namespace sta
|
||||||
|
|
||||||
#endif // TASTY_CASE_4
|
#endif // TASTY_CASE_4
|
||||||
|
@ -11,7 +11,7 @@ namespace sta
|
|||||||
{
|
{
|
||||||
namespace tasty
|
namespace tasty
|
||||||
{
|
{
|
||||||
class DummyThread
|
class DummyThread : public tacos::TacosThread
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
/* data */
|
/* data */
|
||||||
@ -49,4 +49,4 @@ namespace sta
|
|||||||
} // namespace tasty
|
} // namespace tasty
|
||||||
} // namespace sta
|
} // namespace sta
|
||||||
|
|
||||||
#endif // TASTY_CASE_5
|
#endif // TASTY_CASE_5
|
||||||
|
Loading…
x
Reference in New Issue
Block a user