Port unit tests to Zephyr build system

This commit is contained in:
Martin Jäger
2021-10-05 14:59:39 +02:00
parent 456fcf86a4
commit c54d8ebe05
38 changed files with 392 additions and 426 deletions
-2
View File
@@ -8,10 +8,8 @@
#include <zephyr.h>
#ifndef UNIT_TEST
#include <logging/log.h>
LOG_MODULE_REGISTER(bat_charger, CONFIG_BAT_LOG_LEVEL);
#endif
#include <math.h> // for fabs function
#include <stdio.h>
+2 -4
View File
@@ -8,10 +8,8 @@
#include <zephyr.h>
#ifndef UNIT_TEST
#include <logging/log.h>
LOG_MODULE_REGISTER(daq, CONFIG_DAQ_LOG_LEVEL);
#endif
#include <math.h> // log for thermistor calculation
#include <assert.h>
@@ -364,9 +362,9 @@ void daq_set_hv_limit(float hv_overvoltage)
}
#endif
#if defined(UNIT_TEST)
#if !defined(CONFIG_SOC_FAMILY_STM32)
#include "../test/daq_stub.h"
#include "daq_stub.h"
void prepare_adc_readings(AdcValues values)
{
+10 -3
View File
@@ -9,12 +9,13 @@
#include <zephyr.h>
#include <soc.h>
#ifndef UNIT_TEST
#include <drivers/hwinfo.h>
#include <stm32_ll_utils.h>
#include <sys/crc.h>
#include <logging/log.h>
LOG_MODULE_REGISTER(data_objects, CONFIG_DATA_OBJECTS_LOG_LEVEL);
#ifdef CONFIG_SOC_FAMILY_STM32
#include <stm32_ll_utils.h>
#endif
#include <stdio.h>
@@ -37,9 +38,15 @@ const char metadata_url[] =
const char device_type[] = DT_PROP(DT_PATH(pcb), type);
const char hardware_version[] = DT_PROP(DT_PATH(pcb), version_str);
const char firmware_version[] = FIRMWARE_VERSION_ID;
char device_id[9];
#ifdef CONFIG_SOC_FAMILY_STM32
uint32_t flash_size = LL_GetFlashSize();
uint32_t flash_page_size = FLASH_PAGE_SIZE;
char device_id[9];
#else
uint32_t flash_size = 128;
uint32_t flash_page_size = 0x800;
#endif
static char auth_password[11];
+1 -1
View File
@@ -15,7 +15,7 @@
#include <stdio.h>
#ifndef UNIT_TEST
#ifdef CONFIG_SOC_FAMILY_STM32
#include <device.h>
#include <logging/log.h>
-2
View File
@@ -8,13 +8,11 @@
#include <zephyr.h>
#ifndef UNIT_TEST
#include <device.h>
#include <drivers/gpio.h>
#include <logging/log.h>
LOG_MODULE_REGISTER(dcdc, CONFIG_DCDC_LOG_LEVEL);
#endif
#include <math.h> // for fabs function
#include <stdlib.h> // for min/max function
+2 -2
View File
@@ -13,7 +13,7 @@
#include "mcu.h"
#include "setup.h"
#ifndef UNIT_TEST
#ifdef CONFIG_SOC_FAMILY_STM32
#include <soc.h>
#include <pinmux/pinmux_stm32.h>
#include <stm32_ll_bus.h>
@@ -44,7 +44,7 @@ static uint16_t clamp_ccr(uint16_t ccr_target)
}
}
#ifndef UNIT_TEST
#ifdef CONFIG_SOC_FAMILY_STM32
static const struct soc_gpio_pinctrl tim_pinctrl[] = ST_STM32_DT_INST_PINCTRL(0, 0);
+1 -1
View File
@@ -30,7 +30,7 @@ extern "C" {
*/
static inline uint32_t uptime()
{
#ifdef __ZEPHYR__
#ifndef UNIT_TEST
return k_uptime_get() / 1000;
#else
return time(NULL);
-2
View File
@@ -7,10 +7,8 @@
#include "leds.h"
#include <zephyr.h>
#ifndef UNIT_TEST
#include <drivers/gpio.h>
#include <task_wdt/task_wdt.h>
#endif
#include "hardware.h"
+2 -2
View File
@@ -6,7 +6,7 @@
#include "load.h"
#ifndef UNIT_TEST
#ifdef CONFIG_SOC_FAMILY_STM32
#include <zephyr.h>
#include <device.h>
@@ -229,7 +229,7 @@ bool pgood_check()
#endif
}
#else // UNIT_TEST
#else // CONFIG_SOC_FAMILY_STM32
void load_out_init() {;}
void usb_out_init() {;}
+1 -1
View File
@@ -44,7 +44,7 @@
#define TSENSE_CAL2 (*((uint16_t *)0x1FFF75CA))
#define TSENSE_CAL1_VALUE 30.0 // temperature of first calibration point
#define TSENSE_CAL2_VALUE 110.0 // temperature of second calibration point
#elif defined(UNIT_TEST)
#elif !defined(CONFIG_SOC_FAMILY_STM32)
#define VREFINT_CAL (4096 * 1.224 / 3.0) // VREFINT @3.0V/25°C
#define VREFINT_VALUE 3000 // mV
#define TSENSE_CAL1 (4096.0 * (670 - 161) / 3300) // datasheet: slope 1.61 mV/°C
-2
View File
@@ -8,10 +8,8 @@
#include <zephyr.h>
#ifndef UNIT_TEST
#include <logging/log.h>
LOG_MODULE_REGISTER(pwm_switch, CONFIG_PWM_LOG_LEVEL);
#endif
#include <stdio.h>
#include <time.h>