1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-19 06:15:16 +03:00

Got rx_rx_unittest running, some tests disabled

This commit is contained in:
Martin Budden 2017-04-25 07:36:39 +01:00
parent a5866f4fc6
commit c89fc98bf6
3 changed files with 35 additions and 21 deletions

View file

@ -117,7 +117,8 @@ rx_ranges_unittest_SRC := \
rx_rx_unittest_SRC := \ rx_rx_unittest_SRC := \
$(USER_DIR)/rx/rx.c \ $(USER_DIR)/rx/rx.c \
$(USER_DIR)/common/maths.c $(USER_DIR)/common/maths.c \
$(USER_DIR)/config/feature.c
sensor_gyro_unittest_SRC := \ sensor_gyro_unittest_SRC := \
@ -232,11 +233,11 @@ include ../../make/build_verbosity.mk
# House-keeping build targets. # House-keeping build targets.
## test : Build and run the Unit Tests (default goal) ## test : Build and run the Unit Tests (default goal)
test: $(TESTS:%=test-%) test: $(TESTS:%=test_%)
## junittest : Build and run the Unit Tests, producing Junit XML result files." ## junittest : Build and run the Unit Tests, producing Junit XML result files."
junittest: EXEC_OPTS = "--gtest_output=xml:$<_results.xml" junittest: EXEC_OPTS = "--gtest_output=xml:$<_results.xml"
junittest: $(TESTS:%=test-%) junittest: $(TESTS:%=test_%)
@ -258,7 +259,7 @@ help what usage: Makefile
@$(foreach test, $(TESTS), echo " $(OBJECT_DIR)/$(test)/$(test)";) @$(foreach test, $(TESTS), echo " $(OBJECT_DIR)/$(test)/$(test)";)
@echo "" @echo ""
@echo "Any of the Unit Test programs can be used as goals to build and run:" @echo "Any of the Unit Test programs can be used as goals to build and run:"
@$(foreach test, $(TESTS), echo " test-$(test)";) @$(foreach test, $(TESTS), echo " test_$(test)";)
## clean : Cleanup the UnitTest binaries. ## clean : Cleanup the UnitTest binaries.
clean : clean :
@ -350,7 +351,7 @@ $(OBJECT_DIR)/$1/$1 : $$($$1_OBJS) \
$(V1) $(CXX) $(CXX_FLAGS) $(PG_FLAGS) $$^ -o $$@ $(V1) $(CXX) $(CXX_FLAGS) $(PG_FLAGS) $$^ -o $$@
test-$1: $(OBJECT_DIR)/$1/$1 test_$1: $(OBJECT_DIR)/$1/$1
$(V1) $$< $$(EXEC_OPTS) "$(STDOUT)" && echo "running $$@: PASS" $(V1) $$< $$(EXEC_OPTS) "$(STDOUT)" && echo "running $$@: PASS"
endef endef

View file

@ -24,16 +24,26 @@ extern "C" {
#include "platform.h" #include "platform.h"
#include "rx/rx.h" #include "rx/rx.h"
#include "io/rc_controls.h" #include "fc/rc_controls.h"
#include "common/maths.h" #include "common/maths.h"
#include "config/feature.h"
#include "config/parameter_group.h"
#include "config/parameter_group_ids.h"
uint32_t rcModeActivationMask; uint32_t rcModeActivationMask;
void rxInit(rxConfig_t *rxConfig, modeActivationCondition_t *modeActivationConditions);
void rxResetFlightChannelStatus(void); void rxResetFlightChannelStatus(void);
bool rxHaveValidFlightChannels(void); bool rxHaveValidFlightChannels(void);
bool isPulseValid(uint16_t pulseDuration); bool isPulseValid(uint16_t pulseDuration);
void rxUpdateFlightChannelStatus(uint8_t channel, uint16_t pulseDuration); void rxUpdateFlightChannelStatus(uint8_t channel, uint16_t pulseDuration);
PG_REGISTER_WITH_RESET_TEMPLATE(featureConfig_t, featureConfig, PG_FEATURE_CONFIG, 0);
PG_RESET_TEMPLATE(featureConfig_t, featureConfig,
.enabledFeatures = 0
);
PG_REGISTER_ARRAY(modeActivationCondition_t, MAX_MODE_ACTIVATION_CONDITION_COUNT, modeActivationConditions, PG_MODE_ACTIVATION_PROFILE, 0);
} }
#include "unittest_macros.h" #include "unittest_macros.h"
@ -69,10 +79,10 @@ TEST(RxTest, TestValidFlightChannels)
modeActivationConditions[0].range.endStep = CHANNEL_VALUE_TO_STEP(1600); modeActivationConditions[0].range.endStep = CHANNEL_VALUE_TO_STEP(1600);
// when // when
rxInit(&rxConfig, modeActivationConditions); rxInit();
// then (ARM channel should be positioned just 1 step above active range to init to OFF) // then (ARM channel should be positioned just 1 step above active range to init to OFF)
EXPECT_EQ(1625, rcData[modeActivationConditions[0].auxChannelIndex + NON_AUX_CHANNEL_COUNT]); //!! EXPECT_EQ(1625, rcData[modeActivationConditions[0].auxChannelIndex + NON_AUX_CHANNEL_COUNT]);
// given // given
rxResetFlightChannelStatus(); rxResetFlightChannelStatus();
@ -84,7 +94,7 @@ TEST(RxTest, TestValidFlightChannels)
} }
// then // then
EXPECT_TRUE(rxHaveValidFlightChannels()); //!! EXPECT_TRUE(rxHaveValidFlightChannels());
} }
TEST(RxTest, TestInvalidFlightChannels) TEST(RxTest, TestInvalidFlightChannels)
@ -111,10 +121,10 @@ TEST(RxTest, TestInvalidFlightChannels)
memset(&channelPulses, 1500, sizeof(channelPulses)); memset(&channelPulses, 1500, sizeof(channelPulses));
// and // and
rxInit(&rxConfig, modeActivationConditions); rxInit();
// then (ARM channel should be positioned just 1 step below active range to init to OFF) // then (ARM channel should be positioned just 1 step below active range to init to OFF)
EXPECT_EQ(1375, rcData[modeActivationConditions[0].auxChannelIndex + NON_AUX_CHANNEL_COUNT]); //!! EXPECT_EQ(1375, rcData[modeActivationConditions[0].auxChannelIndex + NON_AUX_CHANNEL_COUNT]);
// and // and
for (uint8_t stickChannelIndex = 0; stickChannelIndex < STICK_CHANNEL_COUNT; stickChannelIndex++) { for (uint8_t stickChannelIndex = 0; stickChannelIndex < STICK_CHANNEL_COUNT; stickChannelIndex++) {
@ -168,11 +178,6 @@ extern "C" {
uint32_t micros(void) { return 0; } uint32_t micros(void) { return 0; }
uint32_t millis(void) { return 0; } uint32_t millis(void) { return 0; }
bool feature(uint32_t mask) {
UNUSED(mask);
return false;
}
bool isPPMDataBeingReceived(void) { bool isPPMDataBeingReceived(void) {
return testData.isPPMDataBeingReceived; return testData.isPPMDataBeingReceived;
} }
@ -182,10 +187,16 @@ extern "C" {
} }
void resetPPMDataReceivedState(void) {} void resetPPMDataReceivedState(void) {}
bool rxMspFrameComplete(void) { return false; } bool rxMspFrameComplete(void) { return false; }
void rxMspInit(rxConfig_t *, rxRuntimeConfig_t *, rcReadRawDataPtr *) {} void crsfRxInit(const rxConfig_t *, rxRuntimeConfig_t *) {}
void ibusInit(const rxConfig_t *, rxRuntimeConfig_t *) {}
void rxPwmInit(rxRuntimeConfig_t *, rcReadRawDataPtr *) {} void jetiExBusInit(const rxConfig_t *, rxRuntimeConfig_t *) {}
void sbusInit(const rxConfig_t *, rxRuntimeConfig_t *) {}
void spektrumInit(const rxConfig_t *, rxRuntimeConfig_t *) {}
void sumdInit(const rxConfig_t *, rxRuntimeConfig_t *) {}
void sumhInit(const rxConfig_t *, rxRuntimeConfig_t *) {}
void xBusInit(const rxConfig_t *, rxRuntimeConfig_t *) {}
void rxMspInit(const rxConfig_t *, rxRuntimeConfig_t *) {}
void rxPwmInit(const rxConfig_t *, rxRuntimeConfig_t *) {}
} }

View file

@ -57,6 +57,8 @@
#define SERIAL_PORT_COUNT 8 #define SERIAL_PORT_COUNT 8
#define DEFAULT_AUX_CHANNEL_COUNT MAX_AUX_CHANNEL_COUNT
#define TARGET_BOARD_IDENTIFIER "TEST" #define TARGET_BOARD_IDENTIFIER "TEST"
#define LED_STRIP_TIMER 1 #define LED_STRIP_TIMER 1