1. Repeated test name approved. 2. Overal timeout for UART receiving data done. All works
This commit is contained in:
@@ -50,5 +50,5 @@
|
||||
}
|
||||
},
|
||||
|
||||
"timeout_msec": 27000
|
||||
"timeout_msec": 35000
|
||||
}
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
"test_randomDataTest_100_110.json",
|
||||
"test_endurance_50_60_marchFTE_5.json",
|
||||
"test_abort.json",
|
||||
"#test_start_March_FTE_all_targ0_repeat2.json",
|
||||
"#test_abort.json"
|
||||
"test_start_March_FTE_all_targ0_repeat2.json",
|
||||
"test_abort.json"
|
||||
],
|
||||
|
||||
"abort": [
|
||||
|
||||
@@ -43,12 +43,23 @@ bool UART::send(const QByteArray& data, QString &err)
|
||||
|
||||
QByteArray UART::receive(int timeoutMs)
|
||||
{
|
||||
// overall timeout for all received chunks from UART
|
||||
QByteArray result;
|
||||
QElapsedTimer timer;
|
||||
timer.start();
|
||||
|
||||
while (serial.waitForReadyRead(timeoutMs))
|
||||
while(timer.elapsed() < timeoutMs)
|
||||
{
|
||||
int remain = timeoutMs - timer.elapsed();
|
||||
|
||||
if (remain <= 0) break;
|
||||
|
||||
if (serial.waitForReadyRead(remain))
|
||||
{
|
||||
result += serial.readAll();
|
||||
}
|
||||
else { break; }
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -3,10 +3,25 @@
|
||||
|
||||
extern TestOptions g_options;
|
||||
|
||||
std::vector<QString> getJsonTests()
|
||||
QString prepareTestName(QString name)
|
||||
{
|
||||
// replace invalid symbols into "_"
|
||||
name.replace(QRegularExpression("[^a-zA-Z0-9_]"), "_");
|
||||
|
||||
// prepend T is digit first
|
||||
if (!name.isEmpty() && name[0].isDigit()) { name.prepend("T_"); }
|
||||
|
||||
// protection from empty name:
|
||||
if (name.isEmpty()) { name = "unnamed"; }
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
std::vector<TestCaseParam> getJsonTests()
|
||||
{
|
||||
QStringList list;
|
||||
std::vector<QString> result;
|
||||
std::vector<TestCaseParam> result;
|
||||
QMap<QString, int> counters;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -26,10 +41,25 @@ std::vector<QString> getJsonTests()
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
for (const auto& s : list)
|
||||
for (const QString &path : list)
|
||||
{
|
||||
result.push_back(s);
|
||||
QFile f(path);
|
||||
|
||||
QString testName = "unknown";
|
||||
|
||||
if (f.open(QIODevice::ReadOnly))
|
||||
{
|
||||
QJsonObject obj = QJsonDocument::fromJson(f.readAll()).object();
|
||||
testName = obj["meta"].toObject()["name"].toString();
|
||||
}
|
||||
|
||||
int index = counters[testName]++;
|
||||
|
||||
TestCaseParam p;
|
||||
p.path = path;
|
||||
p.name = prepareTestName(QString("%1_%2").arg(testName).arg(index));
|
||||
|
||||
result.push_back(p);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -39,15 +69,10 @@ std::vector<QString> getJsonTests()
|
||||
INSTANTIATE_TEST_SUITE_P(
|
||||
JsonTestSuite,
|
||||
UARTFixture,
|
||||
::testing::ValuesIn(
|
||||
getJsonTests()
|
||||
),
|
||||
[](const testing::TestParamInfo<QString>& info)
|
||||
::testing::ValuesIn(getJsonTests()),
|
||||
[](const testing::TestParamInfo<TestCaseParam>& info)
|
||||
{
|
||||
QFileInfo fi(info.param);
|
||||
|
||||
return fi.baseName()
|
||||
.toStdString();
|
||||
return info.param.name.toStdString();
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
UART UARTFixture::uart;
|
||||
comSettings_t UARTFixture::comPortSettings;
|
||||
Stats_t UARTFixture::stats;
|
||||
path_t UARTFixture::path;
|
||||
QString UARTFixture::logFile;
|
||||
|
||||
@@ -12,12 +13,9 @@ int UARTFixture::extract_struct_from_elf(QString structTypeName)
|
||||
|
||||
QStringList arguments;
|
||||
arguments << path.elf_parser
|
||||
<< "-f"
|
||||
<< path.MK_elf_file
|
||||
<< "-t"
|
||||
<< structTypeName
|
||||
<< "-o"
|
||||
<< path.iar_json_out;
|
||||
<< "-f" << path.MK_elf_file
|
||||
<< "-t" << structTypeName
|
||||
<< "-o" << path.iar_json_out;
|
||||
|
||||
process.start(program, arguments);
|
||||
|
||||
@@ -52,12 +50,9 @@ int UARTFixture::convert_map_file()
|
||||
|
||||
QStringList arguments;
|
||||
arguments << path.map_parser
|
||||
<< "-f"
|
||||
<< path.MK_map_file
|
||||
<< "-s"
|
||||
<< "ENTRY LIST"
|
||||
<< "-o"
|
||||
<< path.iar_json_out;
|
||||
<< "-f" << path.MK_map_file
|
||||
<< "-s" << "ENTRY LIST"
|
||||
<< "-o" << path.iar_json_out;
|
||||
|
||||
process.start(program, arguments);
|
||||
|
||||
@@ -153,6 +148,7 @@ int UARTFixture::readConfig()
|
||||
void UARTFixture::SetUpTestSuite()
|
||||
{
|
||||
Logger::setupLog();
|
||||
memset(&stats, 0, sizeof(stats));
|
||||
|
||||
int fail = UARTFixture::readConfig();
|
||||
if (fail == true) { return; }
|
||||
@@ -184,6 +180,7 @@ void UARTFixture::TearDownTestSuite()
|
||||
|
||||
QString curTime1 = QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss");
|
||||
QString htmlFile = path.stand_report_html_path;
|
||||
Logger::appendSummary(logFile, stats.total, stats.passed, stats.failed);
|
||||
HtmlReport::generate(logFile, htmlFile, curTime1);
|
||||
}
|
||||
|
||||
@@ -195,7 +192,8 @@ extern TestOptions g_options;
|
||||
|
||||
TEST_P(UARTFixture, JsonCase)
|
||||
{
|
||||
QString caseFile = GetParam();
|
||||
TestCaseParam param = GetParam();
|
||||
QString caseFile = param.path;
|
||||
runCase(caseFile);
|
||||
}
|
||||
|
||||
@@ -207,7 +205,6 @@ void UARTFixture::runCase(
|
||||
QString err;
|
||||
QString error;
|
||||
|
||||
|
||||
QFile caseFileJson(caseFile);
|
||||
// ASSERT_TRUE(caseFileJson.open(QIODevice::ReadOnly));
|
||||
if (!caseFileJson.open(QIODevice::ReadOnly))
|
||||
@@ -260,6 +257,9 @@ void UARTFixture::runCase(
|
||||
|
||||
Logger::saveTestLog(logFile, handler, cfg, passed, error);
|
||||
|
||||
stats.total++;
|
||||
if (passed) stats.passed++;
|
||||
else stats.failed++;
|
||||
EXPECT_TRUE(passed);
|
||||
|
||||
if (g_options.delayMs > 0)
|
||||
|
||||
@@ -7,11 +7,25 @@
|
||||
#include "../core/test_stats.h"
|
||||
#include <json_processor.h>
|
||||
|
||||
struct TestCaseParam
|
||||
{
|
||||
QString path;
|
||||
QString name;
|
||||
};
|
||||
|
||||
struct Stats_t
|
||||
{
|
||||
uint16_t total;
|
||||
uint16_t passed;
|
||||
uint16_t failed;
|
||||
};
|
||||
|
||||
class UARTFixture :
|
||||
public ::testing::TestWithParam<QString>
|
||||
public ::testing::TestWithParam<TestCaseParam>
|
||||
{
|
||||
protected:
|
||||
static UART uart;
|
||||
static Stats_t stats;
|
||||
static comSettings_t comPortSettings;
|
||||
static path_t path;
|
||||
static QString logFile;
|
||||
|
||||
Reference in New Issue
Block a user