1
0
Fork 0
mirror of https://github.com/opentx/opentx.git synced 2025-07-17 13:25:20 +03:00

First conversion non regression test (X9D+)

This commit is contained in:
Bertrand Songis 2019-05-07 23:35:12 +02:00
parent 45dacf246d
commit 684b02d093
6 changed files with 65 additions and 7 deletions

View file

@ -363,7 +363,7 @@ enum PotsWarnMode {
#define RESERVE_RANGE_FOR_GVARS 10
// even we do not spend space in EEPROM for 10 GVARS, we reserve the space inside the range of values, like offset, weight, etc.
#define MAX_GVARS 9
#define MAX_GVARS 9
enum SwitchSources {
SWSRC_NONE = 0,

View file

@ -283,15 +283,17 @@ uint16_t RlcFile::readRlc(uint8_t *buf, uint16_t i_len)
memclear(&buf[i], ln);
i += ln;
m_zeroes -= ln;
if (m_zeroes) break;
if (m_zeroes)
break;
ln = min<uint16_t>(m_bRlc, i_len-i);
uint8_t lr = read(&buf[i], ln);
i += 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);
@ -299,7 +301,7 @@ uint16_t RlcFile::readRlc(uint8_t *buf, uint16_t i_len)
m_zeroes =(m_bRlc>>4) & 0x7;
m_bRlc = m_bRlc & 0x0f;
}
else if(m_bRlc&0x40) {
else if (m_bRlc&0x40) {
m_zeroes = m_bRlc & 0x3f;
m_bRlc = 0;
}

View 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

Binary file not shown.

View file

@ -35,6 +35,9 @@ extern uint16_t anaInValues[NUM_STICKS+NUM_POTS+NUM_SLIDERS];
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)
#define RADIO_RESET() \
g_eeGeneral.switchConfig = 0x00007bff

View file

@ -26,8 +26,6 @@
#define SWAP_DEFINED
#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)
{