Skip to content
This repository has been archived by the owner on Jan 7, 2019. It is now read-only.

Commit

Permalink
[tests] Fixes and improves the release tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Jun 28, 2017
2 parents 611e3af + 008bfda commit f2ac1a0
Show file tree
Hide file tree
Showing 30 changed files with 120 additions and 24 deletions.
6 changes: 6 additions & 0 deletions src/SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@ else:
template = template)

sources = [runner] + files.sources

# build xpcc_build_info.hpp file
env.BuildInfoHeader()

# build xpcc_git_info.hpp file
env.GitInfoHeader()

# build the program
program = env.Program(target = 'executable',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ using Led3 = xpcc::GpioInverted<GpioOutputF3>;
using Button = xpcc::GpioUnused;
using Leds = xpcc::SoftwareGpioPort< Led3, Led2, Led1, Led0 >;

// Create an IODeviceWrapper around the Uart Peripheral we want to use
using LoggerDevice = xpcc::IODeviceWrapper< Uart1, xpcc::IOBuffer::BlockIfFull >;

inline void
initialize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@

#include "al_avreb_can.hpp"

xpcc::IODeviceWrapper< Uart1, xpcc::IOBuffer::BlockIfFull > serialDevice;
Board::LoggerDevice serialDevice;
xpcc::IOStream serialStream(serialDevice);
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ using LedD13 = D13;

using Leds = xpcc::SoftwareGpioPort< LedD13 >;

// Create an IODeviceWrapper around the Uart Peripheral we want to use
using LoggerDevice = xpcc::IODeviceWrapper< Uart0, xpcc::IOBuffer::BlockIfFull >;

inline void
initialize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "arduino_uno.hpp"

// Create an IODeviceWrapper around the Uart Peripheral we want to use
xpcc::IODeviceWrapper< Uart0, xpcc::IOBuffer::BlockIfFull > loggerDevice;
Board::LoggerDevice loggerDevice;

// Set all four logger streams to use the UART
xpcc::IOStream serialStream(loggerDevice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "nucleo_f031k6.hpp"

// Create an IODeviceWrapper around the Uart Peripheral we want to use
xpcc::IODeviceWrapper< Board::stlink::Uart, xpcc::IOBuffer::BlockIfFull > loggerDevice;
Board::LoggerDevice loggerDevice;

// Set all four logger streams to use the UART
xpcc::log::Logger xpcc::log::debug(loggerDevice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ using Tx = GpioOutputA2;
using Uart = Usart1;
}

// Create an IODeviceWrapper around the Uart Peripheral we want to use
using LoggerDevice = xpcc::IODeviceWrapper< stlink::Uart, xpcc::IOBuffer::BlockIfFull >;


inline void
initialize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "nucleo_f103rb.hpp"

// Create an IODeviceWrapper around the Uart Peripheral we want to use
xpcc::IODeviceWrapper< Board::stlink::Uart, xpcc::IOBuffer::BlockIfFull > loggerDevice;
Board::LoggerDevice loggerDevice;

// Set all four logger streams to use the UART
xpcc::log::Logger xpcc::log::debug(loggerDevice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ using Tx = GpioOutputA2;
using Uart = Usart2;
}

// Create an IODeviceWrapper around the Uart Peripheral we want to use
using LoggerDevice = xpcc::IODeviceWrapper< stlink::Uart, xpcc::IOBuffer::BlockIfFull >;


inline void
initialize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "nucleo_f303k8.hpp"

// Create an IODeviceWrapper around the Uart Peripheral we want to use
xpcc::IODeviceWrapper< Board::stlink::Uart, xpcc::IOBuffer::BlockIfFull > loggerDevice;
Board::LoggerDevice loggerDevice;

// Set all four logger streams to use the UART
xpcc::log::Logger xpcc::log::debug(loggerDevice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ using Tx = GpioOutputA2;
using Uart = Usart2;
}

// Create an IODeviceWrapper around the Uart Peripheral we want to use
using LoggerDevice = xpcc::IODeviceWrapper< stlink::Uart, xpcc::IOBuffer::BlockIfFull >;


inline void
initialize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "nucleo_f401re.hpp"

// Create an IODeviceWrapper around the Uart Peripheral we want to use
xpcc::IODeviceWrapper< Board::stlink::Uart, xpcc::IOBuffer::BlockIfFull > loggerDevice;
Board::LoggerDevice loggerDevice;

// Set all four logger streams to use the UART
xpcc::log::Logger xpcc::log::debug(loggerDevice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ using Tx = GpioOutputA2;
using Uart = Usart2;
}

// Create an IODeviceWrapper around the Uart Peripheral we want to use
using LoggerDevice = xpcc::IODeviceWrapper< stlink::Uart, xpcc::IOBuffer::BlockIfFull >;


inline void
initialize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "nucleo_f411re.hpp"

// Create an IODeviceWrapper around the Uart Peripheral we want to use
xpcc::IODeviceWrapper< Board::stlink::Uart, xpcc::IOBuffer::BlockIfFull > loggerDevice;
Board::LoggerDevice loggerDevice;

// Set all four logger streams to use the UART
xpcc::log::Logger xpcc::log::debug(loggerDevice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ using Tx = GpioOutputA2;
using Uart = Usart2;
}

// Create an IODeviceWrapper around the Uart Peripheral we want to use
using LoggerDevice = xpcc::IODeviceWrapper< stlink::Uart, xpcc::IOBuffer::BlockIfFull >;


inline void
initialize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "nucleo_f429zi.hpp"

// Create an IODeviceWrapper around the Uart Peripheral we want to use
xpcc::IODeviceWrapper< Board::stlink::Uart, xpcc::IOBuffer::BlockIfFull > loggerDevice;
Board::LoggerDevice loggerDevice;

// Set all four logger streams to use the UART
xpcc::log::Logger xpcc::log::debug(loggerDevice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@ using Rx = GpioInputD9;
using Uart = Usart3;
}

// Create an IODeviceWrapper around the Uart Peripheral we want to use
using LoggerDevice = xpcc::IODeviceWrapper< stlink::Uart, xpcc::IOBuffer::BlockIfFull >;


inline void
initialize()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "nucleo_l476rg.hpp"

// Create an IODeviceWrapper around the Uart Peripheral we want to use
xpcc::IODeviceWrapper< Board::stlink::Uart, xpcc::IOBuffer::BlockIfFull > loggerDevice;
Board::LoggerDevice loggerDevice;

// Set all four logger streams to use the UART
xpcc::log::Logger xpcc::log::debug(loggerDevice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ using Rx = GpioInputA3;
using Uart = Usart2;
}

// Create an IODeviceWrapper around the Uart Peripheral we want to use
using LoggerDevice = xpcc::IODeviceWrapper< stlink::Uart, xpcc::IOBuffer::BlockIfFull >;

inline void
initialize()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <xpcc/utils/bit_constants.hpp>

// Create an IODeviceWrapper around the Uart Peripheral we want to use
xpcc::IODeviceWrapper< Board::stlink::Uart, xpcc::IOBuffer::BlockIfFull > loggerDevice;
Board::LoggerDevice loggerDevice;

// Set all four logger streams to use the UART
xpcc::log::Logger xpcc::log::debug(loggerDevice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,9 @@ using Rx = GpioInputB11; // STLK_TX [STLINK V2-1_U2_TX]: USART3_RX
using Uart = Usart3;
}

// Create an IODeviceWrapper around the Uart Peripheral we want to use
using LoggerDevice = xpcc::IODeviceWrapper< stlink::Uart, xpcc::IOBuffer::BlockIfFull >;

inline void
initializeTouchscreen()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "stm32f746g_discovery.hpp"

// Create an IODeviceWrapper around the Uart Peripheral we want to use
xpcc::IODeviceWrapper< Board::stlink::Uart, xpcc::IOBuffer::BlockIfFull > loggerDevice;
Board::LoggerDevice loggerDevice;

// Set all four logger streams to use the UART
xpcc::log::Logger xpcc::log::debug(loggerDevice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ using Rx = GpioInputB7;
using Uart = Usart1;
}

// Create an IODeviceWrapper around the Uart Peripheral we want to use
using LoggerDevice = xpcc::IODeviceWrapper< stlink::Uart, xpcc::IOBuffer::BlockIfFull >;

inline void
initialize()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "stm32f769i_discovery.hpp"

// Create an IODeviceWrapper around the Uart Peripheral we want to use
xpcc::IODeviceWrapper< Board::stlink::Uart, xpcc::IOBuffer::BlockIfFull > loggerDevice;
Board::LoggerDevice loggerDevice;

// Set all four logger streams to use the UART
xpcc::log::Logger xpcc::log::debug(loggerDevice);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ using Rx = GpioInputA10;
using Uart = Usart1;
}

// Create an IODeviceWrapper around the Uart Peripheral we want to use
using LoggerDevice = xpcc::IODeviceWrapper< stlink::Uart, xpcc::IOBuffer::BlockIfFull >;

// Onboard MicroSD card slot
namespace usd
{
Expand Down
12 changes: 6 additions & 6 deletions src/xpcc/driver/pressure/bmp085_data_impl_double.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ DataDouble::calculateCalibratedTemperature()
double c4 = ::pow(10, -3) * ::pow(2, -15) * calibration.ac4;
double b1 = ::pow(160, 2) * ::pow(2, -30) * calibration.b1;

c5 = (::pow(2, -15) / 160) * calibration.ac5;
c5 = (::pow(2, -15) / 160.0) * double(calibration.ac5);
c6 = calibration.ac6;
mc = (::pow(2, 11) / ::pow(160, 2)) * calibration.mc;
mc = (::pow(2, 11) / ::pow(160, 2)) * double(calibration.mc);
md = calibration.md / 160.0;
x0 = calibration.ac1;
x1 = double(160.0) * ::pow(2, -13) * calibration.ac2;
x2 = ::pow(160, 2) * ::pow(2, -25) * calibration.b2;
x1 = double(160.0) * ::pow(2, -13) * double(calibration.ac2);
x2 = ::pow(160, 2) * ::pow(2, -25) * double(calibration.b2);
y00 = c4 * ::pow(2, 15);
y11 = c4 * c3;
y2 = c4 * b1;
Expand Down Expand Up @@ -93,8 +93,8 @@ DataDouble::calculateCalibratedPressure()
calculateCalibratedTemperature();

double s = calibratedTemperatureDouble - double(25.0);
double x = (x2 * pow(s, 2)) + (x1 * s) + x0;
double y = (y2 * pow(s, 2)) + (y11 * s) + y00;
double x = (x2 * s * s) + ( x1 * s) + x0;
double y = (y2 * s * s) + (y11 * s) + y00;
double z = (pu - x) / y;

XPCC_LOG_DEBUG.printf("s = %9.5f\n", s);
Expand Down
12 changes: 8 additions & 4 deletions src/xpcc/driver/pressure/test/bmp085_test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include <xpcc/driver/pressure/bmp085.hpp>
#include <xpcc/debug/logger/logger.hpp>

#include <algorithm> // for std::max

#include "bmp085_test.hpp"

#undef XPCC_LOG_LEVEL
Expand Down Expand Up @@ -133,10 +135,11 @@ Bmp085Test::testConversion()

// Check pressure conversion at 10 different temperatures
uint16_t adc_temp_span = adc_temp_max[jj] - adc_temp_min[jj];
uint16_t adc_temp_inc = std::max(adc_temp_span / 10U, 1U);

for (uint16_t adc_temp = adc_temp_min[jj];
adc_temp < adc_temp_max[jj];
adc_temp += adc_temp_span/10)
adc_temp += adc_temp_inc)
{
data.raw[0] = adc_temp >> 8;
data.raw[1] = adc_temp & 0xff;
Expand All @@ -152,9 +155,10 @@ Bmp085Test::testConversion()
XPCC_LOG_DEBUG.printf("adc_temp = %04x, T = %f\n", adc_temp, temp);

uint16_t adc_press_span = adc_press_max[jj] - adc_press_min[jj];
uint16_t adc_press_inc = std::max(adc_press_span / 10U, 1U);
for (uint16_t adc_press = adc_press_min[jj];
adc_press < adc_press_max[jj];
adc_press += adc_press_span/10)
adc_press += adc_press_inc)
{
data.raw[2] = adc_press >> 8;
data.raw[3] = adc_press & 0xff;
Expand Down Expand Up @@ -189,7 +193,7 @@ Bmp085Test::testConversion()
XPCC_LOG_DEBUG.printf(" max = %d\n", max_error);
XPCC_LOG_DEBUG.printf(" sum = %d\n", total_error);

TEST_ASSERT_TRUE(total_error <= 1541);
TEST_ASSERT_TRUE(max_error <= 71);
TEST_ASSERT_EQUALS_RANGE(total_error, 0, 1541);
TEST_ASSERT_EQUALS_RANGE(max_error, 0, 71);
}
}
3 changes: 3 additions & 0 deletions src/xpcc/io/test/io_stream_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,8 @@ IoStreamTest::testPrintf1()
void
IoStreamTest::testPrintf2()
{
#ifdef XPCC__OS_HOSTED
// Only run on hosted because glibc needs so many flash and RAM may crash.
// Compare xpcc's formatter with glibc's formatter

float ff_testvector[] = {
Expand Down Expand Up @@ -515,6 +517,7 @@ IoStreamTest::testPrintf2()
}
}
}
#endif
}

int myFunc1(void) { return -1; };
Expand Down
2 changes: 1 addition & 1 deletion src/xpcc/processing/resumable/test/resumable_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,7 @@ ResumableTest::testReturnVoidClass()
auto result = thread.resumable();
TEST_ASSERT_EQUALS(result.getState(), xpcc::rf::Stop);
TEST_ASSERT_EQUALS(result.getResult(), xpcc::rf::Stop);
TEST_ASSERT_TRUE(sizeof(result) == 1);
TEST_ASSERT_EQUALS(sizeof(result), sizeof(uint_fast8_t));

// this now returns the state
auto result2 = RF_CALL_BLOCKING(thread.resumable());
Expand Down
Loading

0 comments on commit f2ac1a0

Please sign in to comment.