mirror of
https://github.com/opentx/opentx.git
synced 2025-07-18 22:05:10 +03:00
First conversion non regression test (X9D+)
This commit is contained in:
parent
45dacf246d
commit
684b02d093
6 changed files with 65 additions and 7 deletions
|
@ -283,7 +283,8 @@ uint16_t RlcFile::readRlc(uint8_t *buf, uint16_t i_len)
|
||||||
memclear(&buf[i], ln);
|
memclear(&buf[i], ln);
|
||||||
i += ln;
|
i += ln;
|
||||||
m_zeroes -= ln;
|
m_zeroes -= ln;
|
||||||
if (m_zeroes) break;
|
if (m_zeroes)
|
||||||
|
break;
|
||||||
|
|
||||||
ln = min<uint16_t>(m_bRlc, i_len-i);
|
ln = min<uint16_t>(m_bRlc, i_len-i);
|
||||||
uint8_t lr = read(&buf[i], ln);
|
uint8_t lr = read(&buf[i], ln);
|
||||||
|
@ -291,7 +292,8 @@ uint16_t RlcFile::readRlc(uint8_t *buf, uint16_t i_len)
|
||||||
m_bRlc -= lr;
|
m_bRlc -= lr;
|
||||||
if (m_bRlc) break;
|
if (m_bRlc) break;
|
||||||
|
|
||||||
if (read(&m_bRlc, 1) !=1) break; // read how many bytes to read
|
if (read(&m_bRlc, 1) != 1)
|
||||||
|
break; // read how many bytes to read
|
||||||
|
|
||||||
assert(m_bRlc & 0x7f);
|
assert(m_bRlc & 0x7f);
|
||||||
|
|
||||||
|
|
55
radio/src/tests/conversions.cpp
Normal file
55
radio/src/tests/conversions.cpp
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
/*
|
||||||
|
* Copyright (C) OpenTX
|
||||||
|
*
|
||||||
|
* Based on code named
|
||||||
|
* th9x - http://code.google.com/p/th9x
|
||||||
|
* er9x - http://code.google.com/p/er9x
|
||||||
|
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||||
|
*
|
||||||
|
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License version 2 as
|
||||||
|
* published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "gtests.h"
|
||||||
|
#include "storage/conversions/conversions.h"
|
||||||
|
#include "location.h"
|
||||||
|
|
||||||
|
void loadEEPROMFile(const char * filename)
|
||||||
|
{
|
||||||
|
FILE * f = fopen(filename, "rb");
|
||||||
|
assert(fread(eeprom, 1, EEPROM_SIZE, f) == EEPROM_SIZE);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if defined(PCBX9DP)
|
||||||
|
TEST(Eeprom, ConversionX9DPFrom22)
|
||||||
|
{
|
||||||
|
loadEEPROMFile(TESTS_PATH "/tests/eeprom_22_x9d+.bin");
|
||||||
|
|
||||||
|
eepromOpen();
|
||||||
|
convertModelData(0, 218);
|
||||||
|
eeLoadModel(0);
|
||||||
|
|
||||||
|
EXPECT_ZSTREQ("Test", g_model.header.name);
|
||||||
|
EXPECT_EQ(TMRMODE_COUNT - 1 + SWSRC_SA0, g_model.timers[0].mode);
|
||||||
|
EXPECT_EQ(80, g_model.mixData[0].weight);
|
||||||
|
EXPECT_EQ(-100, g_model.limitData[0].max);
|
||||||
|
EXPECT_EQ(80, g_model.expoData[0].weight);
|
||||||
|
EXPECT_EQ(SWASH_TYPE_120X, g_model.swashR.type);
|
||||||
|
EXPECT_EQ(10, g_model.flightModeData[0].gvars[0]);
|
||||||
|
EXPECT_ZSTREQ("Tes", g_model.gvars[0].name);
|
||||||
|
EXPECT_EQ(MODULE_TYPE_R9M, g_model.moduleData[EXTERNAL_MODULE].type);
|
||||||
|
EXPECT_EQ(MODULE_SUBTYPE_R9M_FCC, g_model.moduleData[EXTERNAL_MODULE].subType);
|
||||||
|
EXPECT_ZSTREQ("Thr", g_model.inputNames[0]);
|
||||||
|
EXPECT_ZSTREQ("Tes", g_model.telemetrySensors[0].label);
|
||||||
|
EXPECT_EQ(10, g_model.telemetrySensors[0].id);
|
||||||
|
EXPECT_EQ(10, g_model.telemetrySensors[0].frskyInstance.physID);
|
||||||
|
}
|
||||||
|
#endif
|
BIN
radio/src/tests/eeprom_22_x9d+.bin
Normal file
BIN
radio/src/tests/eeprom_22_x9d+.bin
Normal file
Binary file not shown.
|
@ -35,6 +35,9 @@ extern uint16_t anaInValues[NUM_STICKS+NUM_POTS+NUM_SLIDERS];
|
||||||
|
|
||||||
void doMixerCalculations();
|
void doMixerCalculations();
|
||||||
|
|
||||||
|
extern const char * zchar2string(const char * zstring, int size);
|
||||||
|
#define EXPECT_ZSTREQ(c_string, z_string) EXPECT_STREQ(c_string, zchar2string(z_string, sizeof(z_string)))
|
||||||
|
|
||||||
#if defined(PCBTARANIS) || defined(PCBHORUS)
|
#if defined(PCBTARANIS) || defined(PCBHORUS)
|
||||||
#define RADIO_RESET() \
|
#define RADIO_RESET() \
|
||||||
g_eeGeneral.switchConfig = 0x00007bff
|
g_eeGeneral.switchConfig = 0x00007bff
|
||||||
|
|
|
@ -26,8 +26,6 @@
|
||||||
#define SWAP_DEFINED
|
#define SWAP_DEFINED
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
|
|
||||||
extern const char * zchar2string(const char * zstring, int size);
|
|
||||||
#define EXPECT_ZSTREQ(c_string, z_string) EXPECT_STREQ(c_string, zchar2string(z_string, sizeof(z_string)))
|
|
||||||
|
|
||||||
::testing::AssertionResult __luaExecStr(const char * str)
|
::testing::AssertionResult __luaExecStr(const char * str)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue