mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-06-01 04:46:51 +08:00
[test] improve module tests (#3517)
Co-authored-by: Fabien-B <Fabien-B@github.com>.
This commit is contained in:
@@ -34,5 +34,8 @@
|
|||||||
<!-- Load DSDL generated files-->
|
<!-- Load DSDL generated files-->
|
||||||
<include name="$(PAPARAZZI_HOME)/var/include/DSDLcode/include"/>
|
<include name="$(PAPARAZZI_HOME)/var/include/DSDLcode/include"/>
|
||||||
<file name="uavcan.equipment.air_data.RawAirData.c" dir="$(PAPARAZZI_HOME)/var/include/DSDLcode/src"/>
|
<file name="uavcan.equipment.air_data.RawAirData.c" dir="$(PAPARAZZI_HOME)/var/include/DSDLcode/src"/>
|
||||||
|
<test>
|
||||||
|
<include name="$(PAPARAZZI_HOME)/sw/ext/dronecan/libcanard"/>
|
||||||
|
</test>
|
||||||
</makefile>
|
</makefile>
|
||||||
</module>
|
</module>
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <canard.h>
|
||||||
|
|
||||||
|
struct uavcan_iface_t;
|
||||||
|
|
||||||
|
typedef struct {} uavcan_event;
|
||||||
|
|
||||||
|
|
||||||
|
typedef void (*uavcan_callback)(struct uavcan_iface_t *iface, CanardRxTransfer *transfer);
|
||||||
|
|
||||||
|
void uavcan_init(void);
|
||||||
|
void uavcan_bind(uint16_t data_type_id, uint64_t data_type_signature, uavcan_event *ev, uavcan_callback cb);
|
||||||
|
void uavcan_broadcast(struct uavcan_iface_t *iface, uint64_t data_type_signature, uint16_t data_type_id,
|
||||||
|
uint8_t priority, const void *payload, uint16_t payload_len);
|
||||||
@@ -48,15 +48,15 @@ OTHER_PARAMS: List[str] = [
|
|||||||
|
|
||||||
|
|
||||||
class Test:
|
class Test:
|
||||||
def __init__(self, tst, files, files_arch, test_name, test_id):
|
def __init__(self, tst, files, files_arch, includes, test_name, test_id):
|
||||||
self.configure_regex = re.compile(r"(\$\([a-zA-Z_][a-zA-Z_0-9]*\))")
|
self.configure_regex = re.compile(r"(\$\([a-zA-Z_][a-zA-Z_0-9]*\))")
|
||||||
self.files = files # type: List[str]
|
self.files = files # type: List[str]
|
||||||
self.files_arch = files_arch # type: List[str]
|
self.files_arch = files_arch # type: List[str]
|
||||||
|
self.includes = includes # type: List[str]
|
||||||
self.firmware = None # type: Optional[str]
|
self.firmware = None # type: Optional[str]
|
||||||
self.archs = [] # type: List[str]
|
self.archs = [] # type: List[str]
|
||||||
self.defines = [] # type: List[Tuple[str,str, str]]
|
self.defines = [] # type: List[Tuple[str,str, str]]
|
||||||
self.configures = {} # type: Dict[str:str]
|
self.configures = {} # type: Dict[str:str]
|
||||||
self.includes = [] # type: List[str]
|
|
||||||
self.shells = [] # type: List[str]
|
self.shells = [] # type: List[str]
|
||||||
self.test_name = test_name
|
self.test_name = test_name
|
||||||
self.test_id = test_id
|
self.test_id = test_id
|
||||||
@@ -108,6 +108,10 @@ class Test:
|
|||||||
for m in re.findall(self.configure_regex, string):
|
for m in re.findall(self.configure_regex, string):
|
||||||
if m[2:-1] in self.configures.keys():
|
if m[2:-1] in self.configures.keys():
|
||||||
string = string.replace(m, self.configures[m[2:-1]])
|
string = string.replace(m, self.configures[m[2:-1]])
|
||||||
|
else:
|
||||||
|
env_val = getenv(m[2:-1])
|
||||||
|
if env_val is not None:
|
||||||
|
string = string.replace(m, env_val)
|
||||||
return string
|
return string
|
||||||
self.files = map(substitute, self.files)
|
self.files = map(substitute, self.files)
|
||||||
self.files_arch = map(substitute, self.files_arch)
|
self.files_arch = map(substitute, self.files_arch)
|
||||||
@@ -141,7 +145,8 @@ class Test:
|
|||||||
for file in self.files:
|
for file in self.files:
|
||||||
# build with the "test" arch.
|
# build with the "test" arch.
|
||||||
arch_include = f"-I../../tests/modules/test_arch"
|
arch_include = f"-I../../tests/modules/test_arch"
|
||||||
cmd_args = [gcc] + GCC_PARAMS + [file] + OTHER_PARAMS + module_id + defines + includes + [arch_include] + shells
|
arch_modules_include = f"-I../../tests/modules/test_arch/modules"
|
||||||
|
cmd_args = [gcc] + GCC_PARAMS + [file] + OTHER_PARAMS + module_id + defines + includes + [arch_include, arch_modules_include] + shells
|
||||||
cmds.append(cmd_args)
|
cmds.append(cmd_args)
|
||||||
|
|
||||||
for file in self.files_arch:
|
for file in self.files_arch:
|
||||||
@@ -212,8 +217,9 @@ class Module:
|
|||||||
for mkf in mod_elt.findall("makefile"):
|
for mkf in mod_elt.findall("makefile"):
|
||||||
files = self.get_files(mkf)
|
files = self.get_files(mkf)
|
||||||
files_arch = self.get_files_arch(mkf)
|
files_arch = self.get_files_arch(mkf)
|
||||||
|
includes = self.get_includes(mkf)
|
||||||
for i, tst in enumerate(mkf.findall("test")):
|
for i, tst in enumerate(mkf.findall("test")):
|
||||||
test = Test(tst, files, files_arch, f"{self.name}", i)
|
test = Test(tst, files, files_arch, includes, f"{self.name}", i)
|
||||||
self.tests.append(test)
|
self.tests.append(test)
|
||||||
|
|
||||||
def get_files(self, mkf):
|
def get_files(self, mkf):
|
||||||
@@ -247,6 +253,14 @@ class Module:
|
|||||||
files.append(file_path)
|
files.append(file_path)
|
||||||
return files
|
return files
|
||||||
|
|
||||||
|
def get_includes(self, mkf):
|
||||||
|
includes = []
|
||||||
|
for include in mkf.findall("include"):
|
||||||
|
name = include.attrib["name"]
|
||||||
|
includes.append(name)
|
||||||
|
return includes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_modules():
|
def get_modules():
|
||||||
files = os.listdir(PPRZ_HOME+"/conf/modules")
|
files = os.listdir(PPRZ_HOME+"/conf/modules")
|
||||||
|
|||||||
Reference in New Issue
Block a user