Index: denali.pro =================================================================== diff -u -rb9c5b0b3afc3b34d4980ecc4f023f498f80dafbc -re02b2d465b145702dc41965b2e7da154857eea75 --- denali.pro (.../denali.pro) (revision b9c5b0b3afc3b34d4980ecc4f023f498f80dafbc) +++ denali.pro (.../denali.pro) (revision e02b2d465b145702dc41965b2e7da154857eea75) @@ -132,6 +132,18 @@ unittests/tst_logging.cpp } +tst_utilities { + message(Building with QtTest test case utilities) + QT += testlib + DEFINES += UNIT_TEST \ + TEST_CLASS_INCLUDE=\\\"unittests/tst_utilities.h\\\" \ + TEST_CLASS_NAME=tst_utilities + HEADERS += \ + unittests/tst_utilities.h + SOURCES += \ + unittests/tst_utilities.cpp +} + # Additional import path used to resolve QML modules in Qt Creator's code model QML_IMPORT_PATH = Index: denali.pro.user =================================================================== diff -u -rb9c5b0b3afc3b34d4980ecc4f023f498f80dafbc -re02b2d465b145702dc41965b2e7da154857eea75 --- denali.pro.user (.../denali.pro.user) (revision b9c5b0b3afc3b34d4980ecc4f023f498f80dafbc) +++ denali.pro.user (.../denali.pro.user) (revision e02b2d465b145702dc41965b2e7da154857eea75) @@ -1,6 +1,6 @@ - + EnvironmentId @@ -352,7 +352,7 @@ 1 false - + 1 1 3768 false true @@ -732,7 +732,101 @@ 2 true - 5 + + /home/denali/Project/tmp/build/unittest/tst_utilities + + + true + qmake + + QtProjectManager.QMakeBuildStep + true + CONFIG+=tst_utilities CONFIG+=CodeCoverage + false + true + true + + + true + Make + + Qt4ProjectManager.MakeStep + + false + LINK=csg++ AR=csar CXX=csg++ CC=csgcc -j4 + + false + + + true + + %{buildDir}/denali + %{buildDir} + Custom Process Step + + ProjectExplorer.ProcessStep + + + true + -m denali.csmes -t UnitTests denali.csexe + cmcsexeimport + %{buildDir} + Custom Process Step + + ProjectExplorer.ProcessStep + + + true + --csmes=denali.csmes --html=Coverage/index + cmreport + %{buildDir} + Custom Process Step + + ProjectExplorer.ProcessStep + + + true + --csmes=denali.csmes --csv-excel=Coverage/coverage.csv + cmreport + %{buildDir} + Custom Process Step + + ProjectExplorer.ProcessStep + + 6 + Build + + ProjectExplorer.BuildSteps.Build + + + + true + Make + + Qt4ProjectManager.MakeStep + + true + clean + + false + + 1 + Clean + + ProjectExplorer.BuildSteps.Clean + + 2 + false + + PATH=/opt/SquishCoco/bin:/opt/SquishCoco/wrapper/bin:/opt/Qt5.12.5/5.12.5/gcc_64/bin:/usr/bin:/home/denali/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin + + Test + tst_utilities + Qt4ProjectManager.Qt4BuildConfiguration + 2 + true + + 6 0 Index: sources/applicationcontroller.cpp =================================================================== diff -u -rb9c5b0b3afc3b34d4980ecc4f023f498f80dafbc -re02b2d465b145702dc41965b2e7da154857eea75 --- sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision b9c5b0b3afc3b34d4980ecc4f023f498f80dafbc) +++ sources/applicationcontroller.cpp (.../applicationcontroller.cpp) (revision e02b2d465b145702dc41965b2e7da154857eea75) @@ -81,7 +81,6 @@ */ void ApplicationController::initConnections() { - connect(&_MainTimer , SIGNAL( didTimeout()), this , SLOT(onMainTimerTimeout())); Index: sources/storage/filehandler.cpp =================================================================== diff -u -rb9c5b0b3afc3b34d4980ecc4f023f498f80dafbc -re02b2d465b145702dc41965b2e7da154857eea75 --- sources/storage/filehandler.cpp (.../filehandler.cpp) (revision b9c5b0b3afc3b34d4980ecc4f023f498f80dafbc) +++ sources/storage/filehandler.cpp (.../filehandler.cpp) (revision e02b2d465b145702dc41965b2e7da154857eea75) @@ -85,6 +85,12 @@ QString cp = "cp"; QStringList arguments; arguments << "-r" << vSource << vDestination; - return QProcess::execute(cp, arguments); + int result = QProcess::execute(cp, arguments); + + cp = "sync;sync;sync;"; + arguments.clear(); + QProcess::execute(cp, arguments); + + return result; } Index: sources/utility/types.h =================================================================== diff -u -rfeb3423b373dc2a2c4267ef9fcb4d924d738423d -re02b2d465b145702dc41965b2e7da154857eea75 --- sources/utility/types.h (.../types.h) (revision feb3423b373dc2a2c4267ef9fcb4d924d738423d) +++ sources/utility/types.h (.../types.h) (revision e02b2d465b145702dc41965b2e7da154857eea75) @@ -19,6 +19,7 @@ #include // Project #include "format.h" +#include "logger.h" class Types { public: @@ -97,12 +98,13 @@ bool Types::getValue(const QByteArray &vData, int &vIndex, T &vValue) { int end = vIndex + sizeof(T); if (vData.length() < end) { - qDebug() << QString("Not enough data from position %1 to the length of %2 to get data of type '%3' in buffer %4") + LOG_ERROR(QString("Not enough data from position %1 to the length of %2 to get data of type '%3' in buffer %4") .arg(vIndex) .arg(sizeof(T)) .arg(typeid(T).name()) .arg(Format::toHexString(vData)) - ; + ); + return false; } int i = 0; while (vIndex < end) { Index: unittests/tst_canbus.cpp =================================================================== diff -u -rb9c5b0b3afc3b34d4980ecc4f023f498f80dafbc -re02b2d465b145702dc41965b2e7da154857eea75 --- unittests/tst_canbus.cpp (.../tst_canbus.cpp) (revision b9c5b0b3afc3b34d4980ecc4f023f498f80dafbc) +++ unittests/tst_canbus.cpp (.../tst_canbus.cpp) (revision e02b2d465b145702dc41965b2e7da154857eea75) @@ -82,6 +82,12 @@ }); } +void tst_canbus::tst_FrameInterface_ReInit() +{ + QVERIFY( ! _FrameInterface .init() ); // Coverage + QVERIFY( ! _MessageDispatcher .init() ); // Coverage +} + void tst_canbus::tst_FrameInterface_ActionTransmit_KeepAlive() { _expected = "A5.07.00.00.E3.00.00.00"; Index: unittests/tst_canbus.h =================================================================== diff -u -rb9c5b0b3afc3b34d4980ecc4f023f498f80dafbc -re02b2d465b145702dc41965b2e7da154857eea75 --- unittests/tst_canbus.h (.../tst_canbus.h) (revision b9c5b0b3afc3b34d4980ecc4f023f498f80dafbc) +++ unittests/tst_canbus.h (.../tst_canbus.h) (revision e02b2d465b145702dc41965b2e7da154857eea75) @@ -39,6 +39,8 @@ void tst_FrameInterface_Init(); + void tst_FrameInterface_ReInit(); + void tst_FrameInterface_ActionTransmit_KeepAlive(); void tst_FrameInterface_TransmitFrame_LongerData(); void tst_FrameInterface_ActionTransmit_PowerOff_Accepted(); Index: unittests/tst_utilities.cpp =================================================================== diff -u --- unittests/tst_utilities.cpp (revision 0) +++ unittests/tst_utilities.cpp (revision e02b2d465b145702dc41965b2e7da154857eea75) @@ -0,0 +1,51 @@ +/*! + * + * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, + * IN PART OR IN WHOLE, + * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * file tst_utilities.cpp + * date 01/08/2020 + * author Behrouz NematiPour + * + */ +#include "tst_utilities.h" + +// Qt + +// Project +#include "types.h" + +tst_utilities::tst_utilities(QObject *parent) : QObject(parent) { } + +// void tst_utilities::initTestCase_data() +// { +// } + +//void tst_utilities::initTestCase() +//{ +//} + +// void tst_utilities::init() +// { +// } + +//void tst_utilities::cleanup() +//{ +//} + +//void tst_utilities::cleanupTestCase() +//{ +//} + +void tst_utilities::getValue_len() +{ + Types::S32 vFlowSetPoint; + int index = 0; + QByteArray data; + data += 0xFF; + QVERIFY( ! Types::getValue<>( data, index, vFlowSetPoint ) ); +} + Index: unittests/tst_utilities.h =================================================================== diff -u --- unittests/tst_utilities.h (revision 0) +++ unittests/tst_utilities.h (revision e02b2d465b145702dc41965b2e7da154857eea75) @@ -0,0 +1,50 @@ +/*! + * + * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. + * copyright + * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, + * IN PART OR IN WHOLE, + * WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. + * + * file tst_utilities.h + * date 01/08/2019 + * author Behrouz NematiPour + * + */ +#pragma once + +#include +#include + +class tst_utilities : public QObject +{ + Q_OBJECT + + bool _emited = false ; + QByteArray _expected {} ; + QVariantList _data {} ; + int _action = -1 ; + +public: + explicit tst_utilities(QObject *parent = nullptr); + +private slots: + + // void initTestCase_data(); + + // will be called before the first test function is executed. + // void initTestCase(); + + // will be called before each test function is executed. + // void init(); + + // will be called after every test function. + // void cleanup(); + + // will be called after the last test function was executed. + // void cleanupTestCase(); + + void getValue_len(); + +}; +