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