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_randomDataTest_100_110.json",
|
||||||
"test_endurance_50_60_marchFTE_5.json",
|
"test_endurance_50_60_marchFTE_5.json",
|
||||||
"test_abort.json",
|
"test_abort.json",
|
||||||
"#test_start_March_FTE_all_targ0_repeat2.json",
|
"test_start_March_FTE_all_targ0_repeat2.json",
|
||||||
"#test_abort.json"
|
"test_abort.json"
|
||||||
],
|
],
|
||||||
|
|
||||||
"abort": [
|
"abort": [
|
||||||
|
|||||||
@@ -43,12 +43,23 @@ bool UART::send(const QByteArray& data, QString &err)
|
|||||||
|
|
||||||
QByteArray UART::receive(int timeoutMs)
|
QByteArray UART::receive(int timeoutMs)
|
||||||
{
|
{
|
||||||
|
// overall timeout for all received chunks from UART
|
||||||
QByteArray result;
|
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();
|
result += serial.readAll();
|
||||||
}
|
}
|
||||||
|
else { break; }
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,10 +3,25 @@
|
|||||||
|
|
||||||
extern TestOptions g_options;
|
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;
|
QStringList list;
|
||||||
std::vector<QString> result;
|
std::vector<TestCaseParam> result;
|
||||||
|
QMap<QString, int> counters;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -26,10 +41,25 @@ std::vector<QString> getJsonTests()
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const QString &path : list)
|
||||||
for (const auto& s : 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;
|
return result;
|
||||||
@@ -39,15 +69,10 @@ std::vector<QString> getJsonTests()
|
|||||||
INSTANTIATE_TEST_SUITE_P(
|
INSTANTIATE_TEST_SUITE_P(
|
||||||
JsonTestSuite,
|
JsonTestSuite,
|
||||||
UARTFixture,
|
UARTFixture,
|
||||||
::testing::ValuesIn(
|
::testing::ValuesIn(getJsonTests()),
|
||||||
getJsonTests()
|
[](const testing::TestParamInfo<TestCaseParam>& info)
|
||||||
),
|
|
||||||
[](const testing::TestParamInfo<QString>& info)
|
|
||||||
{
|
{
|
||||||
QFileInfo fi(info.param);
|
return info.param.name.toStdString();
|
||||||
|
|
||||||
return fi.baseName()
|
|
||||||
.toStdString();
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
UART UARTFixture::uart;
|
UART UARTFixture::uart;
|
||||||
comSettings_t UARTFixture::comPortSettings;
|
comSettings_t UARTFixture::comPortSettings;
|
||||||
|
Stats_t UARTFixture::stats;
|
||||||
path_t UARTFixture::path;
|
path_t UARTFixture::path;
|
||||||
QString UARTFixture::logFile;
|
QString UARTFixture::logFile;
|
||||||
|
|
||||||
@@ -12,12 +13,9 @@ int UARTFixture::extract_struct_from_elf(QString structTypeName)
|
|||||||
|
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments << path.elf_parser
|
arguments << path.elf_parser
|
||||||
<< "-f"
|
<< "-f" << path.MK_elf_file
|
||||||
<< path.MK_elf_file
|
<< "-t" << structTypeName
|
||||||
<< "-t"
|
<< "-o" << path.iar_json_out;
|
||||||
<< structTypeName
|
|
||||||
<< "-o"
|
|
||||||
<< path.iar_json_out;
|
|
||||||
|
|
||||||
process.start(program, arguments);
|
process.start(program, arguments);
|
||||||
|
|
||||||
@@ -52,12 +50,9 @@ int UARTFixture::convert_map_file()
|
|||||||
|
|
||||||
QStringList arguments;
|
QStringList arguments;
|
||||||
arguments << path.map_parser
|
arguments << path.map_parser
|
||||||
<< "-f"
|
<< "-f" << path.MK_map_file
|
||||||
<< path.MK_map_file
|
<< "-s" << "ENTRY LIST"
|
||||||
<< "-s"
|
<< "-o" << path.iar_json_out;
|
||||||
<< "ENTRY LIST"
|
|
||||||
<< "-o"
|
|
||||||
<< path.iar_json_out;
|
|
||||||
|
|
||||||
process.start(program, arguments);
|
process.start(program, arguments);
|
||||||
|
|
||||||
@@ -153,6 +148,7 @@ int UARTFixture::readConfig()
|
|||||||
void UARTFixture::SetUpTestSuite()
|
void UARTFixture::SetUpTestSuite()
|
||||||
{
|
{
|
||||||
Logger::setupLog();
|
Logger::setupLog();
|
||||||
|
memset(&stats, 0, sizeof(stats));
|
||||||
|
|
||||||
int fail = UARTFixture::readConfig();
|
int fail = UARTFixture::readConfig();
|
||||||
if (fail == true) { return; }
|
if (fail == true) { return; }
|
||||||
@@ -184,6 +180,7 @@ void UARTFixture::TearDownTestSuite()
|
|||||||
|
|
||||||
QString curTime1 = QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss");
|
QString curTime1 = QDateTime::currentDateTime().toString("dd.MM.yyyy hh:mm:ss");
|
||||||
QString htmlFile = path.stand_report_html_path;
|
QString htmlFile = path.stand_report_html_path;
|
||||||
|
Logger::appendSummary(logFile, stats.total, stats.passed, stats.failed);
|
||||||
HtmlReport::generate(logFile, htmlFile, curTime1);
|
HtmlReport::generate(logFile, htmlFile, curTime1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -195,7 +192,8 @@ extern TestOptions g_options;
|
|||||||
|
|
||||||
TEST_P(UARTFixture, JsonCase)
|
TEST_P(UARTFixture, JsonCase)
|
||||||
{
|
{
|
||||||
QString caseFile = GetParam();
|
TestCaseParam param = GetParam();
|
||||||
|
QString caseFile = param.path;
|
||||||
runCase(caseFile);
|
runCase(caseFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +205,6 @@ void UARTFixture::runCase(
|
|||||||
QString err;
|
QString err;
|
||||||
QString error;
|
QString error;
|
||||||
|
|
||||||
|
|
||||||
QFile caseFileJson(caseFile);
|
QFile caseFileJson(caseFile);
|
||||||
// ASSERT_TRUE(caseFileJson.open(QIODevice::ReadOnly));
|
// ASSERT_TRUE(caseFileJson.open(QIODevice::ReadOnly));
|
||||||
if (!caseFileJson.open(QIODevice::ReadOnly))
|
if (!caseFileJson.open(QIODevice::ReadOnly))
|
||||||
@@ -260,6 +257,9 @@ void UARTFixture::runCase(
|
|||||||
|
|
||||||
Logger::saveTestLog(logFile, handler, cfg, passed, error);
|
Logger::saveTestLog(logFile, handler, cfg, passed, error);
|
||||||
|
|
||||||
|
stats.total++;
|
||||||
|
if (passed) stats.passed++;
|
||||||
|
else stats.failed++;
|
||||||
EXPECT_TRUE(passed);
|
EXPECT_TRUE(passed);
|
||||||
|
|
||||||
if (g_options.delayMs > 0)
|
if (g_options.delayMs > 0)
|
||||||
|
|||||||
@@ -7,11 +7,25 @@
|
|||||||
#include "../core/test_stats.h"
|
#include "../core/test_stats.h"
|
||||||
#include <json_processor.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 :
|
class UARTFixture :
|
||||||
public ::testing::TestWithParam<QString>
|
public ::testing::TestWithParam<TestCaseParam>
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
static UART uart;
|
static UART uart;
|
||||||
|
static Stats_t stats;
|
||||||
static comSettings_t comPortSettings;
|
static comSettings_t comPortSettings;
|
||||||
static path_t path;
|
static path_t path;
|
||||||
static QString logFile;
|
static QString logFile;
|
||||||
|
|||||||
Reference in New Issue
Block a user