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
304681a7
Unverified
Commit
304681a7
authored
6 years ago
by
Dimitrios Stoupis
Browse files
Options
Downloads
Patches
Plain Diff
Added sections for all the required tests
parent
7a6a877d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/Services/TimeBasedSchedulingService.cpp
+83
-31
83 additions, 31 deletions
test/Services/TimeBasedSchedulingService.cpp
with
83 additions
and
31 deletions
test/Services/TimeBasedSchedulingService.cpp
+
83
−
31
View file @
304681a7
...
@@ -7,12 +7,15 @@
...
@@ -7,12 +7,15 @@
namespace
unit_test
{
namespace
unit_test
{
struct
Tester
{
struct
Tester
{
TimeBasedSchedulingService
gen
;
TimeBasedSchedulingService
gen
;
static
bool
executionFunctionStatus
(
TimeBasedSchedulingService
tmService
)
{
static
bool
executionFunctionStatus
(
TimeBasedSchedulingService
tmService
)
{
return
tmService
.
executionFunctionStatus
;
return
tmService
.
executionFunctionStatus
;
}
}
static
uint8_t
currentNumberOfActivities
(
TimeBasedSchedulingService
tmService
)
{
static
uint8_t
currentNumberOfActivities
(
TimeBasedSchedulingService
tmService
)
{
return
tmService
.
currentNumberOfActivities
;
return
tmService
.
currentNumberOfActivities
;
}
}
static
auto
scheduledActivities
(
TimeBasedSchedulingService
tmService
)
{
static
auto
scheduledActivities
(
TimeBasedSchedulingService
tmService
)
{
return
tmService
.
scheduledActivities
;
return
tmService
.
scheduledActivities
;
}
}
...
@@ -40,44 +43,93 @@ TEST_CASE("TC[11,2]", "[service][st11]") {
...
@@ -40,44 +43,93 @@ TEST_CASE("TC[11,2]", "[service][st11]") {
CHECK
(
not
unit_test
::
Tester
::
executionFunctionStatus
(
timeSchedulingService
));
CHECK
(
not
unit_test
::
Tester
::
executionFunctionStatus
(
timeSchedulingService
));
}
}
TEST_CASE
(
"TC[11,4]"
,
"[service][st11]"
)
{
TEST_CASE
(
"ST[11] Integrated test"
,
"[service][st11]"
)
{
Message
receivedMessage
(
11
,
4
,
Message
::
TC
,
1
),
#define NUMBER_OF_INSTRUCTIONS 4 // The number of total instructions in the packet
testMessage1
(
6
,
5
,
Message
::
TC
,
4
),
testMessage2
(
4
,
5
,
Message
::
TC
,
6
),
testMessage3
(
3
,
2
,
Message
::
TC
,
7
);
Message
testMessage1
(
6
,
5
,
Message
::
TC
,
4
),
testMessage2
(
4
,
5
,
Message
::
TC
,
6
),
testMessage3
(
3
,
2
,
Message
::
TC
,
7
),
testMessage4
(
12
,
23
,
Message
::
TC
,
5
);
MessageParser
msgParser
;
MessageParser
msgParser
;
TimeBasedSchedulingService
timeBasedSchedulingService
;
SECTION
(
"TC[11,4] Activity insertion"
)
{
Message
receivedMessage
(
11
,
4
,
Message
::
TC
,
1
);
receivedMessage
.
appendUint16
(
NUMBER_OF_INSTRUCTIONS
);
// Test activity 1
testMessage1
.
appendUint16
(
4253
);
// Append dummy data
receivedMessage
.
appendUint32
(
1556435
);
// todo: Append actual time
receivedMessage
.
appendString
(
msgParser
.
convertTCToStr
(
testMessage1
));
// Test activity 2
testMessage2
.
appendUint16
(
45667
);
// Append dummy data
receivedMessage
.
appendUint32
(
1957232
);
// todo: Append actual time
receivedMessage
.
appendString
(
msgParser
.
convertTCToStr
(
testMessage2
));
// Test activity 3
testMessage3
.
appendUint16
(
456
);
// Append dummy data
receivedMessage
.
appendUint32
(
1726435
);
// todo: Append actual time
receivedMessage
.
appendString
(
msgParser
.
convertTCToStr
(
testMessage3
));
// Test activity 4
testMessage4
.
appendUint16
(
934
);
// Append dummy data
receivedMessage
.
appendUint32
(
17248435
);
// todo: Append actual time
receivedMessage
.
appendString
(
msgParser
.
convertTCToStr
(
testMessage4
));
// Insert activities in the schedule. They have to be inserted sorted
timeBasedSchedulingService
.
insertActivities
(
receivedMessage
);
auto
scheduledActivities
=
unit_test
::
Tester
::
scheduledActivities
(
timeBasedSchedulingService
);
CHECK
(
scheduledActivities
.
size
()
==
4
);
REQUIRE
(
scheduledActivities
.
at
(
0
).
requestReleaseTime
==
1556435
);
REQUIRE
(
scheduledActivities
.
at
(
1
).
requestReleaseTime
==
1726435
);
REQUIRE
(
scheduledActivities
.
at
(
2
).
requestReleaseTime
==
1957232
);
REQUIRE
(
scheduledActivities
.
at
(
3
).
requestReleaseTime
==
17248435
);
REQUIRE
(
scheduledActivities
.
at
(
0
).
request
==
testMessage1
);
REQUIRE
(
scheduledActivities
.
at
(
1
).
request
==
testMessage3
);
REQUIRE
(
scheduledActivities
.
at
(
2
).
request
==
testMessage2
);
REQUIRE
(
scheduledActivities
.
at
(
3
).
request
==
testMessage4
);
}
receivedMessage
.
appendUint16
(
3
);
// Number od instructions
SECTION
(
"TC[11,5] Activity deletion by ID"
)
{
Message
receivedMessage
(
11
,
5
,
Message
::
TC
,
1
);
receivedMessage
.
appendUint16
(
NUMBER_OF_INSTRUCTIONS
);
// Test activity 1
//timeBasedSchedulingService.detailReporActivitiesByID();
testMessage1
.
appendUint16
(
4253
);
// todo: Append dummy data
}
receivedMessage
.
appendUint32
(
1556435
);
// todo: Append actual time
receivedMessage
.
appendString
(
msgParser
.
convertTCToStr
(
testMessage1
));
// Test activity 2
SECTION
(
"TC[11,7] Time shift activities by ID"
)
{
testMessage2
.
appendUint16
(
45667
);
// todo: Append dummy data
Message
receivedMessage
(
11
,
7
,
Message
::
TC
,
1
);
receivedMessage
.
appendUint32
(
1
);
// todo: Append actual time
receivedMessage
.
appendUint16
(
NUMBER_OF_INSTRUCTIONS
);
receivedMessage
.
appendString
(
msgParser
.
convertTCToStr
(
testMessage2
));
// Test activity 3
//timeBasedSchedulingService.detailReporActivitiesByID();
testMessage3
.
appendUint16
(
456
);
// todo: Append dummy data
}
receivedMessage
.
appendUint32
(
1726435
);
// todo: Append actual time
receivedMessage
.
appendString
(
msgParser
.
convertTCToStr
(
testMessage3
));
SECTION
(
"TC[11,9] Detail report scheduled activities by ID"
)
{
Message
receivedMessage
(
11
,
9
,
Message
::
TC
,
1
);
receivedMessage
.
appendUint16
(
NUMBER_OF_INSTRUCTIONS
);
TimeBasedSchedulingService
timeBasedSchedulingService
;
//timeBasedSchedulingService.detailReporActivitiesByID();
timeBasedSchedulingService
.
insertActivities
(
receivedMessage
);
}
auto
scheduledActivities
=
unit_test
::
Tester
::
scheduledActivities
(
timeBasedSchedulingService
);
SECTION
(
"TC[11,12] Summary report scheduled activities by ID"
)
{
CHECK
(
scheduledActivities
.
size
()
==
2
);
// Two will be inserted (Second is invalid)
Message
receivedMessage
(
11
,
12
,
Message
::
TC
,
1
);
REQUIRE
(
scheduledActivities
.
at
(
0
).
requestReleaseTime
==
1556435
);
receivedMessage
.
appendUint16
(
NUMBER_OF_INSTRUCTIONS
);
REQUIRE
(
scheduledActivities
.
at
(
1
).
requestReleaseTime
==
1726435
);
//CHECK(memcmp(&scheduledActivities.at(0).request, &testMessage2, sizeof(Message)));
//timeBasedSchedulingService.detailReporActivitiesByID();
std
::
cout
<<
scheduledActivities
.
at
(
0
).
request
.
data
<<
" "
<<
testMessage1
.
data
<<
std
::
endl
;
}
if
(
scheduledActivities
.
at
(
0
).
request
==
testMessage1
)
{
std
::
cout
<<
"Message are the same!!"
<<
std
::
endl
;
SECTION
(
"TC[11,15] Time shift all scheduled activities"
)
{
Message
receivedMessage
(
11
,
15
,
Message
::
TC
,
1
);
receivedMessage
.
appendUint16
(
NUMBER_OF_INSTRUCTIONS
);
//timeBasedSchedulingService.detailReporActivitiesByID();
}
SECTION
(
"TC[11,16] Detail report all scheduled activities"
)
{
Message
receivedMessage
(
11
,
16
,
Message
::
TC
,
1
);
receivedMessage
.
appendUint16
(
NUMBER_OF_INSTRUCTIONS
);
//timeBasedSchedulingService.detailReporActivitiesByID();
}
}
//CHECK(scheduledActivities.at(0).request == testMessage1);
//REQUIRE(scheduledActivities.at(2).requestReleaseTime == 1556435);
//REQUIRE(scheduledActivities.at(0).requestID.applicationID == 45);
}
}
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