Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
59f0a0d3
Commit
59f0a0d3
authored
Dec 09, 2014
by
Don Gagne
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1089 from DonLakeFlyer/UTLogFiles
Delete any temp log file before each unit test case
parents
fc1228be
fbf8ebb0
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
9 deletions
+41
-9
QGCApplication.cc
src/QGCApplication.cc
+11
-8
MAVLinkProtocol.cc
src/comm/MAVLinkProtocol.cc
+12
-0
MAVLinkProtocol.h
src/comm/MAVLinkProtocol.h
+3
-0
MavlinkLogTest.cc
src/qgcunittest/MavlinkLogTest.cc
+11
-1
MavlinkLogTest.h
src/qgcunittest/MavlinkLogTest.h
+1
-0
UnitTest.cc
src/qgcunittest/UnitTest.cc
+3
-0
No files found.
src/QGCApplication.cc
View file @
59f0a0d3
...
...
@@ -97,14 +97,17 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) :
// First thing we want to do is set up the qtlogging.ini file. If it doesn't already exist we copy
// it to the correct location. This way default debug builds will have logging turned off.
static
const
char
*
qtProjectDir
=
"QtProject"
;
static
const
char
*
qtLoggingFile
=
"qtlogging.ini"
;
bool
loggingDirectoryOk
=
false
;
QDir
iniFileLocation
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
GenericConfigLocation
));
if
(
!
iniFileLocation
.
cd
(
"QtProjects"
))
{
if
(
!
iniFileLocation
.
mkdir
(
"QtProjects"
))
{
qDebug
()
<<
"Unable to create qtlogging.ini directory"
<<
iniFileLocation
.
filePath
(
"QtProjects"
);
if
(
!
iniFileLocation
.
cd
(
qtProjectDir
))
{
if
(
!
iniFileLocation
.
mkdir
(
qtProjectDir
))
{
qDebug
()
<<
"Unable to create qtlogging.ini directory"
<<
iniFileLocation
.
filePath
(
qtProjectDir
);
}
else
{
if
(
!
iniFileLocation
.
cd
(
"QtProjects"
))
{
qDebug
()
<<
"Unable to access qtlogging.ini directory"
<<
iniFileLocation
.
filePath
(
"QtProjects"
);;
if
(
!
iniFileLocation
.
cd
(
qtProjectDir
))
{
qDebug
()
<<
"Unable to access qtlogging.ini directory"
<<
iniFileLocation
.
filePath
(
qtProjectDir
);;
}
loggingDirectoryOk
=
true
;
}
...
...
@@ -114,9 +117,9 @@ QGCApplication::QGCApplication(int &argc, char* argv[], bool unitTesting) :
if
(
loggingDirectoryOk
)
{
qDebug
()
<<
iniFileLocation
;
if
(
!
iniFileLocation
.
exists
(
"qtlogging.ini"
))
{
if
(
!
QFile
::
copy
(
":QLoggingCategory/qtlogging.ini"
,
iniFileLocation
.
filePath
(
"qtlogging.ini"
)))
{
qDebug
()
<<
"Unable to copy
qtlogging.ini
to"
<<
iniFileLocation
;
if
(
!
iniFileLocation
.
exists
(
qtLoggingFile
))
{
if
(
!
QFile
::
copy
(
":QLoggingCategory/qtlogging.ini"
,
iniFileLocation
.
filePath
(
qtLoggingFile
)))
{
qDebug
()
<<
"Unable to copy
"
<<
QString
(
qtLoggingFile
)
<<
"
to"
<<
iniFileLocation
;
}
}
}
...
...
src/comm/MAVLinkProtocol.cc
View file @
59f0a0d3
...
...
@@ -757,3 +757,15 @@ void MAVLinkProtocol::suspendLogForReplay(bool suspend)
_logSuspendReplay
=
suspend
;
}
void
MAVLinkProtocol
::
deleteTempLogFiles
(
void
)
{
QDir
tempDir
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
TempLocation
));
QString
filter
(
QString
(
"*.%1"
).
arg
(
_logFileExtension
));
QFileInfoList
fileInfoList
=
tempDir
.
entryInfoList
(
QStringList
(
filter
),
QDir
::
Files
);
foreach
(
const
QFileInfo
fileInfo
,
fileInfoList
)
{
QFile
::
remove
(
fileInfo
.
filePath
());
}
}
src/comm/MAVLinkProtocol.h
View file @
59f0a0d3
...
...
@@ -199,6 +199,9 @@ public slots:
/// and not called directly in order to synchronize with the bytesReady signal
/// which may be ahead of it in the signal queue.
void
suspendLogForReplay
(
bool
suspend
);
/// @brief Deletes any log files which are in the temp directory
static
void
deleteTempLogFiles
(
void
);
protected:
// Override from QObject
...
...
src/qgcunittest/MavlinkLogTest.cc
View file @
59f0a0d3
...
...
@@ -125,7 +125,7 @@ void MavlinkLogTest::_bootLogDetectionSave_test(void)
void
MavlinkLogTest
::
_bootLogDetectionZeroLength_test
(
void
)
{
// Create a fake e
e
mpty mavlink log
// Create a fake empty mavlink log
_createTempLogFile
(
true
);
// Zero length log files should not generate any additional UI pop-ups. It should just be deleted silently.
...
...
@@ -170,3 +170,13 @@ void MavlinkLogTest::_connectLog_test(void)
QTest
::
qWait
(
1000
);
// Need to allow signals to move between threads to shutdown MainWindow
}
void
MavlinkLogTest
::
_deleteTempLogFiles_test
(
void
)
{
// Verify that the MAVLinkProtocol::deleteTempLogFiles api works correctly
_createTempLogFile
(
false
);
MAVLinkProtocol
::
deleteTempLogFiles
();
QDir
tmpDir
(
QStandardPaths
::
writableLocation
(
QStandardPaths
::
TempLocation
));
QStringList
logFiles
(
tmpDir
.
entryList
(
QStringList
(
QString
(
"*.%1"
).
arg
(
_logFileExtension
)),
QDir
::
Files
));
QCOMPARE
(
logFiles
.
count
(),
0
);
}
src/qgcunittest/MavlinkLogTest.h
View file @
59f0a0d3
...
...
@@ -46,6 +46,7 @@ private slots:
void
_bootLogDetectionSave_test
(
void
);
void
_bootLogDetectionZeroLength_test
(
void
);
void
_connectLog_test
(
void
);
void
_deleteTempLogFiles_test
(
void
);
private:
void
_createTempLogFile
(
bool
zeroLength
);
...
...
src/qgcunittest/UnitTest.cc
View file @
59f0a0d3
...
...
@@ -28,6 +28,7 @@
#include "UnitTest.h"
#include "QGCApplication.h"
#include "MAVLinkProtocol.h"
bool
UnitTest
::
_messageBoxRespondedTo
=
false
;
bool
UnitTest
::
_badResponseButton
=
false
;
...
...
@@ -115,6 +116,8 @@ void UnitTest::init(void)
// Each test gets a clean global state
qgcApp
()
->
destroySingletonsForUnitTest
();
qgcApp
()
->
createSingletonsForUnitTest
();
MAVLinkProtocol
::
deleteTempLogFiles
();
}
/// @brief Called after each test.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment