Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
FORMUS3IC_LAS3
/
embb
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
68d10aa4
authored
May 27, 2015
by
Christian Kern
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/development' into embb449_mtapi_id_pool_invalid_id
parents
025ef7c9
cefb02cd
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
4 deletions
+26
-4
base_c/src/condition_variable.c
+2
-2
base_c/test/condition_var_test.cc
+1
-1
base_c/test/time_test.cc
+17
-0
base_c/test/time_test.h
+6
-1
No files found.
base_c/src/condition_variable.c
View file @
68d10aa4
...
@@ -83,8 +83,8 @@ int embb_condition_wait_until(embb_condition_t* condition_var,
...
@@ -83,8 +83,8 @@ int embb_condition_wait_until(embb_condition_t* condition_var,
embb_time_t
now
;
embb_time_t
now
;
embb_time_now
(
&
now
);
embb_time_now
(
&
now
);
/* Check if absolute timepoint (in milliseconds) still is in the future */
/* Check if absolute timepoint (in milliseconds) still is in the future */
if
(
time
->
seconds
*
1000
+
time
->
nanoseconds
/
1000000
if
(
(
time
->
seconds
*
1000
+
time
->
nanoseconds
/
1000000
)
-
now
.
seconds
*
1000
-
now
.
nanoseconds
/
1000000
>
0
)
{
>
(
now
.
seconds
*
1000
+
now
.
nanoseconds
/
1000000
)
)
{
/* Convert to (unsigned type) milliseconds and round up */
/* Convert to (unsigned type) milliseconds and round up */
DWORD
time_diff
=
(
DWORD
)
(
DWORD
time_diff
=
(
DWORD
)
(
time
->
seconds
*
1000
+
time
->
nanoseconds
/
1000000
time
->
seconds
*
1000
+
time
->
nanoseconds
/
1000000
...
...
base_c/test/condition_var_test.cc
View file @
68d10aa4
...
@@ -105,7 +105,7 @@ void ConditionVarTest::TestTimedWaitTimeouts() {
...
@@ -105,7 +105,7 @@ void ConditionVarTest::TestTimedWaitTimeouts() {
embb_time_t
time
;
embb_time_t
time
;
embb_duration_t
duration
=
EMBB_DURATION_INIT
;
embb_duration_t
duration
=
EMBB_DURATION_INIT
;
// Wait for
now
tests already passed time point
// Wait for
"now"
tests already passed time point
embb_time_now
(
&
time
);
embb_time_now
(
&
time
);
embb_mutex_lock
(
&
mutex
);
embb_mutex_lock
(
&
mutex
);
int
status
=
embb_condition_wait_until
(
&
cond
,
&
mutex
,
&
time
);
int
status
=
embb_condition_wait_until
(
&
cond
,
&
mutex
,
&
time
);
...
...
base_c/test/time_test.cc
View file @
68d10aa4
...
@@ -36,6 +36,9 @@ namespace test {
...
@@ -36,6 +36,9 @@ namespace test {
TimeTest
::
TimeTest
()
{
TimeTest
::
TimeTest
()
{
CreateUnit
(
"Time in duration"
).
Add
(
&
TimeTest
::
TestTimeInDuration
,
this
);
CreateUnit
(
"Time in duration"
).
Add
(
&
TimeTest
::
TestTimeInDuration
,
this
);
CreateUnit
(
"Monotonicity"
).
Add
(
&
TimeTest
::
TestMonotonicity
,
this
,
1
,
partest
::
TestSuite
::
GetDefaultNumIterations
()
*
10
);
}
}
void
TimeTest
::
TestTimeInDuration
()
{
void
TimeTest
::
TestTimeInDuration
()
{
...
@@ -48,6 +51,20 @@ void TimeTest::TestTimeInDuration() {
...
@@ -48,6 +51,20 @@ void TimeTest::TestTimeInDuration() {
PT_EXPECT_EQ
(
status
,
EMBB_SUCCESS
);
PT_EXPECT_EQ
(
status
,
EMBB_SUCCESS
);
}
}
void
TimeTest
::
TestMonotonicity
()
{
embb_time_t
first
;
embb_time_t
second
;
int
status1
=
embb_time_in
(
&
first
,
embb_duration_zero
());
int
status2
=
embb_time_in
(
&
second
,
embb_duration_zero
());
PT_EXPECT_EQ
(
status1
,
EMBB_SUCCESS
);
PT_EXPECT_EQ
(
status2
,
EMBB_SUCCESS
);
unsigned
long
long
first_abs
=
first
.
seconds
*
1000
+
first
.
nanoseconds
/
1000000
;
unsigned
long
long
second_abs
=
second
.
seconds
*
1000
+
second
.
nanoseconds
/
1000000
;
PT_EXPECT_GE
(
second_abs
,
first_abs
);
}
}
// namespace test
}
// namespace test
}
// namespace base
}
// namespace base
}
// namespace embb
}
// namespace embb
base_c/test/time_test.h
View file @
68d10aa4
...
@@ -42,9 +42,14 @@ class TimeTest : public partest::TestCase {
...
@@ -42,9 +42,14 @@ class TimeTest : public partest::TestCase {
private
:
private
:
/**
/**
* Tests time
in
duration method.
* Tests time
-in-
duration method.
*/
*/
void
TestTimeInDuration
();
void
TestTimeInDuration
();
/**
* Tests that succeedingly taken times are monotonously increasing.
*/
void
TestMonotonicity
();
};
};
}
// namespace test
}
// namespace 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