Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
ECSS Services
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AcubeSat-OBC
ECSS Services
Commits
6dc4eaff
Unverified
Commit
6dc4eaff
authored
5 years ago
by
Grigoris Pavlakis
Browse files
Options
Downloads
Patches
Plain Diff
Improve tests
parent
d770dae8
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Services/ParameterService.cpp
+1
-2
1 addition, 2 deletions
src/Services/ParameterService.cpp
test/Services/ParameterService.cpp
+41
-31
41 additions, 31 deletions
test/Services/ParameterService.cpp
with
42 additions
and
33 deletions
src/Services/ParameterService.cpp
+
1
−
2
View file @
6dc4eaff
...
...
@@ -35,8 +35,7 @@ void ParameterService::reportParameterIds(Message& paramIds) {
ErrorHandler
::
AcceptanceErrorType
::
UnacceptableMessage
);
uint16_t
numOfIds
=
paramIds
.
readUint16
();
// number of parameter IDs carried in the message
// uint16_t numOfValidIds = 0; // number of IDs that are actually included in the list
// reqParam.skipBytes(2); // skip the first 16 bits where the number of valid IDs will be included
reqParam
.
appendUint16
(
numOfValidIds
(
paramIds
));
// include the number of valid IDs
for
(
uint16_t
i
=
0
;
i
<
numOfIds
;
i
++
)
{
...
...
This diff is collapsed.
Click to expand it.
test/Services/ParameterService.cpp
+
41
−
31
View file @
6dc4eaff
...
...
@@ -16,63 +16,73 @@ void foo(ValueType* bar) { // sample function
*/
TEST_CASE
(
"Parameter Service - General"
)
{
SECTION
(
"Parameter Setup"
)
{
pserv
.
addNewParameter
(
3
,
14
);
// this one has ID 0
pserv
.
addNewParameter
(
1
,
7
,
12
);
// this one has 1
pserv
.
addNewParameter
(
4
,
12
,
3
,
nullptr
);
// this one has 2
pserv
.
addNewParameter
(
12
,
3
,
6
,
&
foo
);
// this one has 3
pserv
.
addNewParameter
(
15
,
7
,
3
,
&
foo
);
//and this one 4
}
SECTION
(
"Addition to full map"
)
{
CHECK
(
pserv
.
addNewParameter
(
15
,
5
,
4
));
pserv
.
addNewParameter
(
3
,
14
);
// this one has ID 1
pserv
.
addNewParameter
(
1
,
7
,
12
);
// this one has 2
pserv
.
addNewParameter
(
4
,
12
,
3
,
nullptr
);
// this one has 3
pserv
.
addNewParameter
(
12
,
3
,
6
,
&
foo
);
// this one has 4
pserv
.
addNewParameter
(
15
,
7
,
3
,
&
foo
);
//and this one 5
REQUIRE_FALSE
(
pserv
.
addNewParameter
(
15
,
5
,
4
));
// addNewParameter should return false
Services
.
reset
();
// reset all services
}
// SECTION("Addition of already existing parameter") {
//
// }
}
TEST_CASE
(
"Parameter Report Subservice"
)
{
// SECTION("Empty parameter report") {
//
// }
SECTION
(
"Faulty Instruction Handling Test"
)
{
Message
request
(
20
,
1
,
Message
::
TC
,
1
);
Message
report
(
20
,
2
,
Message
::
TM
,
1
);
SECTION
(
"Faulty instruction handling"
)
{
pserv
.
addNewParameter
(
3
,
14
);
// ID 1
pserv
.
addNewParameter
(
1
,
7
,
12
);
// ID 2
pserv
.
addNewParameter
(
4
,
12
,
3
,
nullptr
);
// ID 3
Message
request
(
20
,
1
,
Message
::
TC
,
1
);
request
.
appendUint16
(
2
);
// number of requested IDs
request
.
appendUint16
(
65535
);
//
faulty
ID in this context
request
.
appendUint16
(
65535
);
//
invalid
ID in this context
request
.
appendUint16
(
1
);
// valid
MessageParser
::
execute
(
request
);
Message
report
=
ServiceTests
::
get
(
1
);
CHECK
(((
ServiceTests
::
get
(
0
).
messageType
==
4
)
&&
(
ServiceTests
::
get
(
0
).
serviceType
==
1
)));
CHECK
(
ServiceTests
::
get
(
0
).
messageType
==
4
);
CHECK
(
ServiceTests
::
get
(
0
).
serviceType
==
1
);
// check for an ST[1,4] message caused by the faulty ID
CHECK
((
ServiceTests
::
thrownError
(
ErrorHandler
::
ExecutionStartErrorType
::
UnknownExecutionStartError
)));
// check for the thrown UnknownExecutionStartError
CHECK
(((
ServiceTests
::
get
(
1
).
messageType
==
2
)
&&
(
ServiceTests
::
get
(
1
).
serviceType
==
20
)));
CHECK
(
report
.
messageType
==
2
);
CHECK
(
report
.
serviceType
==
20
);
// check for an ST[20,2] message (the one that contains the settings)
ServiceTests
::
reset
();
}
CHECK
(
report
.
readUint16
()
==
1
);
// only one parameter shall be contained
CHECK
(
report
.
readUint16
()
==
1
);
// check for parameter ID
CHECK
(
report
.
readUint32
()
==
12
);
// check for value (defined when adding parameters)
ServiceTests
::
reset
();
// clear all errors
Services
.
reset
();
// reset the services
}
// **WARNING**
// TODO: Update this test (and all tests in general) to use the error handler's output when
// checking for assertions.
SECTION
(
"Wrong Message Type Handling Test"
)
{
Message
falseRequest
(
15
,
3
,
Message
::
TM
,
1
);
// a totally wrong message
Message
falseRequest
(
62
,
3
,
Message
::
TM
,
1
);
// a totally wrong message
MessageParser
::
execute
(
falseRequest
);
Message
errorNotif
=
ServiceTests
::
get
(
0
);
CHECK
(
errorNotif
.
messageType
==
4
);
// check for proper failed start of
// execution notification
CHECK
(
errorNotif
.
serviceType
==
1
);
Message
response
=
ServiceTests
::
get
(
1
);
CHECK
(
response
.
messageType
==
2
);
CHECK
(
response
.
serviceType
==
20
);
CHECK
(
response
.
packetType
==
Message
::
TM
);
CHECK
(
response
.
readPosition
==
0
);
// if empty, this should't change from 0
CHECK
(
ServiceTests
::
thrownError
(
ErrorHandler
::
InternalErrorType
::
OtherMessageType
));
ServiceTests
::
reset
();
Services
.
reset
();
}
}
TEST_CASE
(
"Parameter Setting Subservice"
)
{
//SECTION("Passing of null-pointer as update function on construction")
SECTION
(
"Faulty Instruction Handling Test"
)
{
Message
setRequest
(
20
,
3
,
Message
::
TC
,
1
);
Message
reportRequest
(
20
,
1
,
Message
::
TC
,
1
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment