1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-17 02:52:12 +01:00

Fix broken unit tests

This commit is contained in:
Oleg Semyonov 2013-05-03 15:14:29 +03:00
parent ee1a149888
commit 137ddbf73a
9 changed files with 72 additions and 58 deletions

View File

@ -261,9 +261,9 @@ fw_$(1)_%: uavobjects_flight
$(V1) $(MKDIR) -p $(BUILD_DIR)/fw_$(1)/dep
$(V1) cd $(ROOT_DIR)/flight/targets/boards/$(1)/firmware && \
$$(MAKE) -r --no-print-directory \
BUILD_TYPE=fw \
BOARD_NAME=$(1) \
BOARD_SHORT_NAME=$(2) \
BUILD_TYPE=fw \
TOPDIR=$(ROOT_DIR)/flight/targets/boards/$(1)/firmware \
OUTDIR=$(BUILD_DIR)/fw_$(1) \
TARGET=fw_$(1) \
@ -288,9 +288,9 @@ bl_$(1)_%:
$(V1) $(MKDIR) -p $(BUILD_DIR)/bl_$(1)/dep
$(V1) cd $(ROOT_DIR)/flight/targets/boards/$(1)/bootloader && \
$$(MAKE) -r --no-print-directory \
BUILD_TYPE=bl \
BOARD_NAME=$(1) \
BOARD_SHORT_NAME=$(2) \
BUILD_TYPE=bl \
TOPDIR=$(ROOT_DIR)/flight/targets/boards/$(1)/bootloader \
OUTDIR=$(BUILD_DIR)/bl_$(1) \
TARGET=bl_$(1) \
@ -326,9 +326,9 @@ bu_$(1)_%: bl_$(1)_bino
$(V1) $(MKDIR) -p $(BUILD_DIR)/bu_$(1)/dep
$(V1) cd $(ROOT_DIR)/flight/targets/common/bootloader_updater && \
$$(MAKE) -r --no-print-directory \
BUILD_TYPE=bu \
BOARD_NAME=$(1) \
BOARD_SHORT_NAME=$(2) \
BUILD_TYPE=bu \
TOPDIR=$(ROOT_DIR)/flight/targets/common/bootloader_updater \
OUTDIR=$(BUILD_DIR)/bu_$(1) \
TARGET=bu_$(1) \
@ -350,9 +350,9 @@ ef_$(1)_%: bl_$(1)_bin fw_$(1)_opfw
$(V1) $(MKDIR) -p $(BUILD_DIR)/ef_$(1)
$(V1) cd $(ROOT_DIR)/flight/targets/common/entire_flash && \
$$(MAKE) -r --no-print-directory \
BUILD_TYPE=ef \
BOARD_NAME=$(1) \
BOARD_SHORT_NAME=$(2) \
BUILD_TYPE=ef \
DFU_CMD="$(DFUUTIL_DIR)/bin/dfu-util" \
TOPDIR=$(ROOT_DIR)/flight/targets/common/entire_flash \
OUTDIR=$(BUILD_DIR)/ef_$(1) \
@ -656,20 +656,9 @@ ut_$(1)_%: $$(UT_OUT_DIR)
$(V1) cd $(ROOT_DIR)/flight/tests/$(1) && \
$$(MAKE) -r --no-print-directory \
BUILD_TYPE=ut \
BOARD_SHORT_NAME=$(1) \
TCHAIN_PREFIX="" \
REMOVE_CMD="$(RM)" \
\
TARGET=$(1) \
TOPDIR=$(ROOT_DIR)/flight/tests/$(1) \
OUTDIR="$(UT_OUT_DIR)/$(1)" \
\
PIOS=$(PIOS) \
OPUAVOBJ=$(OPUAVOBJ) \
OPUAVTALK=$(OPUAVTALK) \
FLIGHTLIB=$(FLIGHTLIB) \
\
GTEST_DIR=$(GTEST_DIR) \
\
TARGET=$(1) \
$$*
.PHONY: ut_$(1)_clean

View File

@ -387,12 +387,15 @@ static int32_t PIOS_Flash_Jedec_EraseChip(uintptr_t flash_id)
while (PIOS_Flash_Jedec_Busy(flash_dev) != 0) {
#if defined(FLASH_FREERTOS)
vTaskDelay(1);
if ((i++) % 100 == 0)
if ((i++) % 100 == 0) {
#else
if ((i++) % 10000 == 0)
if ((i++) % 10000 == 0) {
#endif
#ifdef PIOS_LED_HEARTBEAT
PIOS_LED_Toggle(PIOS_LED_HEARTBEAT);
#endif
}
}

View File

@ -193,7 +193,9 @@ static int32_t logfs_erase_all_arenas()
uint16_t num_arenas = logfs.cfg->total_fs_size / logfs.cfg->arena_size;
for (uint16_t arena = 0; arena < num_arenas; arena++) {
PIOS_LED_Toggle(PIOS_LED_HEARTBEAT);
#ifdef PIOS_LED_HEARTBEAT
PIOS_LED_Toggle(PIOS_LED_HEARTBEAT);
#endif
if (logfs_erase_arena(arena) != 0)
return -1;
}

View File

@ -1,6 +1,7 @@
###############################################################################
# @file Makefile
# @author PhoenixPilot, http://github.com/PhoenixPilot, Copyright (C) 2012
# Copyright (c) 2013, The OpenPilot Team, http://www.openpilot.org
# @addtogroup
# @{
# @addtogroup
@ -23,21 +24,17 @@
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
WHEREAMI := $(dir $(lastword $(MAKEFILE_LIST)))
TOP := $(realpath $(WHEREAMI)/../../../)
include $(TOP)/make/firmware-defs.mk
ifndef OPENPILOT_IS_COOL
$(error Top level Makefile must be used to build this target)
endif
include $(ROOT_DIR)/make/firmware-defs.mk
EXTRAINCDIRS += $(TOPDIR)
EXTRAINCDIRS += $(PIOS)/inc
CFLAGS += -O0
CFLAGS += -Wall -Werror
CFLAGS += -g
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -I.
SRC += $(PIOS)/common/pios_flashfs_logfs.c
CFLAGS += "-DFLASH_IMAGE_FILE=\"$(OUTDIR)/theflash.bin\""
CONLYFLAGS += -std=gnu99
SRC := $(PIOS)/common/pios_flashfs_logfs.c
include $(TOP)/make/unittest.mk
include $(ROOT_DIR)/make/unittest.mk

View File

@ -1,5 +1,9 @@
#ifndef OPENPILOT_H
#define OPENPILOT_H
#include <stdbool.h>
#define PIOS_Assert(x) if (!(x)) { while (1) ; }
#define PIOS_DEBUG_Assert(x) PIOS_Assert(x)
#endif /* OPENPILOT_H */

View File

@ -1,4 +1,12 @@
#if defined(PIOS_INCLUDE_FLASH)
#ifndef PIOS_H
#define PIOS_H
/* PIOS board specific feature selection */
#include "pios_config.h"
#ifdef PIOS_INCLUDE_FLASH
#include <pios_flash.h>
#include <pios_flashfs.h>
#endif
#endif /* PIOS_H */

View File

@ -1 +1,7 @@
#ifndef PIOS_CONFIG_H
#define PIOS_CONFIG_H
/* Enable/Disable PiOS modules */
#define PIOS_INCLUDE_FLASH
#endif /* PIOS_CONFIG_H */

View File

@ -544,6 +544,8 @@ doxygen_version:
$(eval $(call TOOL_INSTALL_TEMPLATE,gtest,$(GTEST_DIR),$(GTEST_URL),$(notdir $(GTEST_URL))))
export GTEST_DIR
.PHONY: gtest_version
gtest_version:
-$(V1) $(SED) -n "s/^PACKAGE_STRING='\(.*\)'/\1/p" < $(GTEST_DIR)/configure

View File

@ -1,6 +1,7 @@
###############################################################################
# @file unittest.mk
# @author PhoenixPilot, http://github.com/PhoenixPilot, Copyright (C) 2012
# Copyright (c) 2013, The OpenPilot Team, http://www.openpilot.org
# @addtogroup
# @{
# @addtogroup
@ -23,40 +24,42 @@
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Flags passed to the preprocessor.
CPPFLAGS += -I$(GTEST_DIR)/include
# Flags passed to the C++ compiler.
CXXFLAGS += -g -Wall -Wextra
# Google Test needs the pthread library
LDFLAGS += -lpthread
#################################
#
# Template to build the user test
#
#################################
# Need to disable THUMB mode for unit tests
# Use native toolchain and disable THUMB mode for unit tests
override ARM_SDK_PREFIX :=
override THUMB :=
EXTRAINCDIRS += .
ALLSRC := $(SRC) $(wildcard ./*.c)
ALLCPPSRC := $(wildcard ./*.cpp) $(GTEST_DIR)/src/gtest_main.cc
ALLSRCBASE := $(notdir $(basename $(ALLSRC) $(ALLCPPSRC)))
ALLOBJ := $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE)))
# Unit test source files
ALLSRC := $(SRC) $(wildcard ./*.c)
ALLCPPSRC := $(wildcard ./*.cpp) $(GTEST_DIR)/src/gtest_main.cc
ALLSRCBASE := $(notdir $(basename $(ALLSRC) $(ALLCPPSRC)))
ALLOBJ := $(addprefix $(OUTDIR)/, $(addsuffix .o, $(ALLSRCBASE)))
$(foreach src,$(ALLSRC),$(eval $(call COMPILE_C_TEMPLATE,$(src))))
$(foreach src,$(ALLCPPSRC),$(eval $(call COMPILE_CXX_TEMPLATE,$(src))))
# Specific extensions to CPPFLAGS only for the google test library
$(OUTDIR)/gtest-all.o : CPPFLAGS += -I$(GTEST_DIR)
$(eval $(call COMPILE_CXX_TEMPLATE, $(GTEST_DIR)/src/gtest-all.cc))
$(OUTDIR)/gtest-all.o: CPPFLAGS += -I$(GTEST_DIR)
$(eval $(call COMPILE_CXX_TEMPLATE, $(GTEST_DIR)/src/gtest-all.cc))
$(eval $(call LINK_CXX_TEMPLATE,$(OUTDIR)/$(TARGET).elf,$(ALLOBJ) $(OUTDIR)/gtest-all.o))
# Flags passed to the preprocessor
CPPFLAGS += -I$(GTEST_DIR)/include
# Flags passed to the C++ compiler
CXXFLAGS += -g -Wall -Wextra
# Flags passed to the C compiler
CONLYFLAGS += -std=gnu99
# Common compiler flags
CFLAGS += -O0 -g
CFLAGS += -Wall -Werror
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
# Google Test needs the pthread library
LDFLAGS += -lpthread
.PHONY: elf
elf: $(OUTDIR)/$(TARGET).elf