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
5dbaeaed
authored
Feb 02, 2015
by
Tobias Fuchs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
containers_cpp: fixed cpplint warnings
parent
3ab938a6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
32 deletions
+35
-32
containers_cpp/test/main.cc
+8
-8
containers_cpp/test/queue_test-inl.h
+18
-16
containers_cpp/test/queue_test.h
+9
-8
No files found.
containers_cpp/test/main.cc
View file @
5dbaeaed
...
...
@@ -24,6 +24,14 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <embb/containers/lock_free_tree_value_pool.h>
#include <embb/containers/wait_free_array_value_pool.h>
#include <embb/containers/wait_free_spsc_queue.h>
#include <embb/containers/object_pool.h>
#include <embb/containers/lock_free_stack.h>
#include <embb/containers/lock_free_mpmc_queue.h>
#include <embb/base/c/memory_allocation.h>
#include <partest/partest.h>
#include <embb/base/thread.h>
...
...
@@ -32,14 +40,6 @@
#include "./stack_test.h"
#include "./hazard_pointer_test.h"
#include "./object_pool_test.h"
#include <embb/containers/lock_free_tree_value_pool.h>
#include <embb/containers/wait_free_array_value_pool.h>
#include <embb/containers/wait_free_spsc_queue.h>
#include <embb/containers/object_pool.h>
#include <embb/containers/lock_free_stack.h>
#include <embb/containers/lock_free_mpmc_queue.h>
#include <embb/base/c/memory_allocation.h>
#define COMMA ,
...
...
containers_cpp/test/queue_test-inl.h
View file @
5dbaeaed
...
...
@@ -45,7 +45,7 @@ QueueTest<Queue_t, MultipleProducers, MultipleConsumers>::QueueTest() :
next_producer_id
(
0
),
next_consumer_id
(
0
),
n_producer_elements
(
static_cast
<
int
>
(
partest
::
TestSuite
::
GetDefaultNumIterations
()
*
static_cast
<
int
>
(
partest
::
TestSuite
::
GetDefaultNumIterations
()
*
MIN_ENQ_ELEMENTS
))
{
CreateUnit
(
"QueueTestSingleThreadEnqueueDequeue"
).
Pre
(
&
QueueTest
::
QueueTestSingleThreadEnqueueDequeue_Pre
,
this
).
...
...
@@ -105,10 +105,11 @@ template<typename Queue_t, bool MultipleProducers, bool MultipleConsumers>
void
QueueTest
<
Queue_t
,
MultipleProducers
,
MultipleConsumers
>::
QueueTestOrderMPMC_Post
()
{
delete
queue
;
// Tally for all elements enqueued by all producers,
// initialized with all 0:
// Tally for all elements enqueued by all producers,
// initialized with all 0:
::
std
::
vector
<
unsigned
char
>
total_tally
;
size_t
n_elements_total
=
static_cast
<
size_t
>
(
n_producers
*
n_producer_elements
);
size_t
n_elements_total
=
static_cast
<
size_t
>
(
n_producers
*
n_producer_elements
);
for
(
size_t
i
=
0
;
i
<
n_elements_total
/
8
;
++
i
)
{
total_tally
.
push_back
(
0
);
}
...
...
@@ -118,10 +119,10 @@ QueueTestOrderMPMC_Post() {
total_tally
[
e
]
|=
consumers
[
c
].
Tally
()[
e
];
}
}
// Test if all elements have been dequeued by any
// consumer.
// Test if all elements have been dequeued by any
// consumer.
// To avoid static cast warning:
for
(
size_t
t
=
0
;
for
(
size_t
t
=
0
;
t
<
static_cast
<
size_t
>
(
n_producers
*
n_producer_elements
/
8
);
++
t
)
{
PT_ASSERT_EQ_MSG
(
total_tally
[
t
],
0xff
,
...
...
@@ -146,13 +147,13 @@ QueueTestOrderMPMC_ConsumerThreadMethod() {
template
<
typename
Queue_t
,
bool
MultipleProducers
,
bool
MultipleConsumers
>
void
QueueTest
<
Queue_t
,
MultipleProducers
,
MultipleConsumers
>::
Producer
::
Run
()
{
// Enqueue pairs of (producer id, counter):
// Enqueue pairs of (producer id, counter):
for
(
int
i
=
0
;
i
<
n_producer_elements
;
++
i
)
{
while
(
!
q
->
TryEnqueue
(
element_t
(
producer_id
,
i
)))
{
embb
::
base
::
Thread
::
CurrentYield
();
}
}
// Enqueue -1 as terminator element of this producer:
// Enqueue -1 as terminator element of this producer:
while
(
!
q
->
TryEnqueue
(
element_t
(
producer_id
,
-
1
)))
{
embb
::
base
::
Thread
::
CurrentYield
();
}
...
...
@@ -161,14 +162,14 @@ Run() {
template
<
typename
Queue_t
,
bool
MultipleProducers
,
bool
MultipleConsumers
>
QueueTest
<
Queue_t
,
MultipleProducers
,
MultipleConsumers
>::
Consumer
::
Consumer
(
Queue_t
*
const
queue
,
int
numProducers
,
int
numProducerElements
)
:
q
(
queue
),
q
(
queue
),
n_producers
(
numProducers
),
n_producer_elements
(
numProducerElements
)
{
for
(
int
p_id
=
0
;
p_id
<
n_producers
;
++
p_id
)
{
// Initialize last value dequeued from producers with
// below-minimum value:
sequence_number
.
push_back
(
-
1
);
// Initialize element tally for producer with all 0,
// Initialize element tally for producer with all 0,
// 8 flags / char:
for
(
int
i
=
0
;
i
<
n_producer_elements
/
8
;
++
i
)
{
consumer_tally
.
push_back
(
0
);
...
...
@@ -193,9 +194,9 @@ Run() {
producerId
=
element
.
first
;
// Assert on dequeued element:
PT_ASSERT_LT_MSG
(
producerId
,
static_cast
<
size_t
>
(
n_producers
),
"Invalid producer id in dequeue"
);
"Invalid producer id in dequeue"
);
PT_ASSERT_LT_MSG
(
sequence_number
[
producerId
],
element
.
second
,
"Invalid element sequence"
);
"Invalid element sequence"
);
// Store last value received from the element's producer:
sequence_number
[
producerId
]
=
element
.
second
;
const
size_t
pos
((
producerId
*
n_producer_elements
)
+
...
...
@@ -298,8 +299,9 @@ void QueueTest<Queue_t, MultipleProducers, MultipleConsumers>::
QueueTestSingleThreadEnqueueDequeue_Post
()
{
delete
queue
;
}
}
// namespace test
}
// namespace containers
}
// namespace embb
}
// namespace test
}
// namespace containers
}
// namespace embb
#endif // CONTAINERS_CPP_TEST_QUEUE_TEST_INL_H_
containers_cpp/test/queue_test.h
View file @
5dbaeaed
...
...
@@ -27,10 +27,10 @@
#ifndef CONTAINERS_CPP_TEST_QUEUE_TEST_H_
#define CONTAINERS_CPP_TEST_QUEUE_TEST_H_
#include <vector>
#include <utility>
#include <partest/partest.h>
#include <embb/base/duration.h>
#include <vector>
#include <utility>
namespace
embb
{
namespace
containers
{
...
...
@@ -41,6 +41,7 @@ template<typename Queue_t,
class
QueueTest
:
public
partest
::
TestCase
{
public
:
typedef
::
std
::
pair
<
size_t
,
int
>
element_t
;
private
:
/// Minimum number of elements enqueued by every producer
/// in MP/MC unit test. Must be a multiple of 8.
...
...
@@ -69,8 +70,8 @@ class QueueTest : public partest::TestCase {
int
n_producer_elements
;
public
:
Producer
(
Queue_t
*
const
queue
,
size_t
id
,
int
numProducerElements
)
:
q
(
queue
),
producer_id
(
id
),
q
(
queue
),
producer_id
(
id
),
n_producer_elements
(
numProducerElements
)
{}
void
Run
();
};
...
...
@@ -108,13 +109,13 @@ class QueueTest : public partest::TestCase {
void
QueueTestSingleThreadEnqueueDequeue_Pre
();
void
QueueTestSingleThreadEnqueueDequeue_Post
();
void
QueueTestSingleThreadEnqueueDequeue_ThreadMethod
();
public
:
QueueTest
();
};
}
// namespace test
}
// namespace containers
}
// namespace embb
}
// namespace test
}
// namespace containers
}
// namespace embb
#include "./queue_test-inl.h"
...
...
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