Add handling of test-mode.

This commit is contained in:
Gerhard Hoffmann 2023-07-06 14:23:04 +02:00
parent f2556412d8
commit 17eaa7858f

View File

@ -83,6 +83,7 @@ Update::Update(hwinf *hw,
QString update_ctrl_file,
QString workingDir,
bool maintenanceMode,
bool testMode,
QObject *parent,
char const *serialInterface,
char const *baudrate)
@ -94,37 +95,43 @@ Update::Update(hwinf *hw,
, m_update_ctrl_file_copy(update_ctrl_file + ".copy")
, m_workingDir(workingDir)
, m_maintenanceMode(maintenanceMode)
, m_testMode(testMode)
, m_init(true) {
// make sure the files are empty
if (m_update_ctrl_file.exists()) {
if (m_update_ctrl_file.open(QIODevice::ReadWrite |
QIODevice::Truncate |
QIODevice::Text)) {
m_update_ctrl_file.close();
if (!m_testMode) {
// make sure the files are empty
if (m_update_ctrl_file.exists()) {
if (m_update_ctrl_file.open(QIODevice::ReadWrite |
QIODevice::Truncate |
QIODevice::Text)) {
m_update_ctrl_file.close();
}
} else {
qCritical() << "Update-file" << m_update_ctrl_file.fileName()
<< "does not exist";
m_init = false;
}
} else {
qCritical() << "Update-file" << m_update_ctrl_file.fileName()
<< "does not exist";
m_init = false;
}
if (m_update_ctrl_file_copy.exists()) {
if (m_update_ctrl_file_copy.open(QIODevice::ReadWrite |
QIODevice::Truncate |
QIODevice::Text)) {
m_update_ctrl_file_copy.close();
if (m_update_ctrl_file_copy.exists()) {
if (m_update_ctrl_file_copy.open(QIODevice::ReadWrite |
QIODevice::Truncate |
QIODevice::Text)) {
m_update_ctrl_file_copy.close();
}
} else {
qCritical() << "Update-file-copy" << m_update_ctrl_file_copy.fileName()
<< "does not exist";
m_init = false;
}
} else {
qCritical() << "Update-file-copy" << m_update_ctrl_file_copy.fileName()
<< "does not exist";
m_init = false;
}
// execute update_psa-script
if (m_init) {
if ((m_init = execUpdateScript()) == false) {
qCritical() << "UPDATE_SCRIPT FAILED";
} else {
if (!m_testMode) {
if ((m_init = execUpdateScript()) == false) {
qCritical() << "UPDATE_SCRIPT FAILED";
}
}
if (m_init) {
if (!m_update_ctrl_file.open(QIODevice::ReadWrite | QIODevice::Text)) {
qCritical() << "CAN NOT OPEN" << m_update_ctrl_file.fileName();
m_init = false;