Skip to content

Commit b454733

Browse files
committed
Automating testing of C libraries.
1 parent 6698578 commit b454733

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+12106
-338
lines changed

Makefile

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
SWIFTNAV_ROOT := $(shell pwd)
66
MAKEFLAGS += SWIFTNAV_ROOT=$(SWIFTNAV_ROOT)
77
SBP_SPEC_DIR := $(SWIFTNAV_ROOT)/spec/yaml/swiftnav/sbp/
8+
SBP_TESTS_SPEC_DIR := $(SWIFTNAV_ROOT)/spec/tests/yaml/
89
SBP_GEN_BIN := python sbpg/generator.py
910
export PYTHONPATH := .
1011

@@ -48,15 +49,21 @@ c:
4849
-o $(SWIFTNAV_ROOT)/c/include/libsbp \
4950
-r $(SBP_MAJOR_VERSION).$(SBP_MINOR_VERSION) \
5051
--c
52+
rm -f $(SWIFTNAV_ROOT)/c/test/auto_check*.c
53+
cd $(SWIFTNAV_ROOT)/generator; \
54+
$(SBP_GEN_BIN) -i $(SBP_TESTS_SPEC_DIR) \
55+
-o $(SWIFTNAV_ROOT)/c/test \
56+
-r $(SBP_MAJOR_VERSION).$(SBP_MINOR_VERSION) \
57+
--test-c
5158
@echo
5259
@echo "Finished. Please check $(SWIFTNAV_ROOT)/c/include/libsbp."
5360

5461
deps:
5562
@echo
5663
@echo "Installing dependencies..."
5764
@echo
58-
cd $(SWIFTNAV_ROOT)/generator; \
59-
pip install --user -r requirements.txt
65+
cd $(SWIFTNAV_ROOT)/generator; pip install --user -r requirements.txt
66+
cd $(SWIFTNAV_ROOT); npm install
6067
@echo
6168
@echo "Finished!"
6269

@@ -170,7 +177,7 @@ test-c: c
170177
cd $(SWIFTNAV_ROOT)/c; \
171178
mkdir -p build/ && cd build/; \
172179
cmake ../; \
173-
make test
180+
make
174181

175182
test-java: java
176183
@echo

c/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ On Debian-based systems (including Ubuntu 12.10 or later) you can get
1212
them with:
1313

1414
```shell
15-
sudo apt-get install build-essential pkg-config cmake
15+
sudo apt-get install build-essential pkg-config cmake doxygen check
16+
```
17+
18+
On Mac:
19+
20+
```shell
21+
brew install check cmake pkg-config doxygen
1622
```
1723

1824
On other systems, you can obtain CMake from your operating system

c/example/example.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ void setup_port()
5151
}
5252
}
5353

54-
void hearbeat_callback(u16 sender_id, u8 len, u8 msg[], void *context)
54+
void heartbeat_callback(u16 sender_id, u8 len, u8 msg[], void *context)
5555
{
5656
(void)sender_id, (void)len, (void)msg, (void)context;
5757
fprintf(stdout, "%s\n", __FUNCTION__);
@@ -117,7 +117,7 @@ int main(int argc, char **argv)
117117

118118
sbp_state_init(&s);
119119

120-
sbp_register_callback(&s, SBP_MSG_HEARTBEAT, &hearbeat_callback, NULL,
120+
sbp_register_callback(&s, SBP_MSG_HEARTBEAT, &heartbeat_callback, NULL,
121121
&heartbeat_callback_node);
122122

123123
while(1) {

c/src/sbp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "libsbp/edc.h"
1414
#include "libsbp/sbp.h"
15+
#include <stdio.h>
1516

1617
#define SBP_PREAMBLE 0x55
1718

c/test/CMakeLists.txt

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,8 @@ else (CMAKE_CROSSCOMPILING)
1717

1818
include_directories("${PROJECT_SOURCE_DIR}/include/libsbp")
1919

20-
add_executable(test_libsbp
21-
check_acquisition.c
22-
check_bootload.c
23-
check_edc.c
24-
check_file_io.c
25-
check_flash.c
26-
check_main.c
27-
check_navigation.c
28-
check_observation.c
29-
check_piksi.c
30-
check_sbp.c
31-
check_settings.c
32-
check_system.c
33-
check_tracking.c
34-
)
20+
FILE(GLOB generated_c_sources auto*.c)
21+
add_executable(test_libsbp check_main.c check_edc.c check_sbp.c ${generated_c_sources})
3522

3623
target_link_libraries(test_libsbp ${TEST_LIBS})
3724
add_custom_command(

0 commit comments

Comments
 (0)