summaryrefslogtreecommitdiff
path: root/src/lib/tests
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2016-05-08 16:34:19 +0200
committerSander Vrijders <[email protected]>2016-05-08 16:34:19 +0200
commit5812dfb832e513dc455a0d48624bcad62334d457 (patch)
tree93a02e1b20f54bb869eadc856f201412c633315c /src/lib/tests
parentde8f2015cbd015b1cced366cb12c054be62c23b1 (diff)
parent021af9e01ce6c6376534b33ef1a06ea4189028d4 (diff)
downloadouroboros-5812dfb832e513dc455a0d48624bcad62334d457.tar.gz
ouroboros-5812dfb832e513dc455a0d48624bcad62334d457.zip
Merged in dstaesse/ouroboros/be-fast-path (pull request #65)
irmd: flow allocation and fast path
Diffstat (limited to 'src/lib/tests')
-rw-r--r--src/lib/tests/shm_du_map_test.c53
1 files changed, 29 insertions, 24 deletions
diff --git a/src/lib/tests/shm_du_map_test.c b/src/lib/tests/shm_du_map_test.c
index 85a82e4d..55938a62 100644
--- a/src/lib/tests/shm_du_map_test.c
+++ b/src/lib/tests/shm_du_map_test.c
@@ -32,7 +32,7 @@
#include <ouroboros/logs.h>
-#define SIZE_OF_DU_BUFF 24
+#define SIZE_OF_DU_BUFF 32
#define TEST_BUFF_SIZE (SHM_DU_BUFF_BLOCK_SIZE - SIZE_OF_DU_BUFF)
#define MAX(a,b) (a > b ? a : b)
@@ -44,7 +44,7 @@ void * produce()
{
struct shm_du_map * dum;
long test_buf_size = 0;
- uint8_t * test_values;
+ uint8_t * test_values;
int headspace;
int tailspace;
long i;
@@ -66,9 +66,8 @@ void * produce()
test_values[i] = 170;
clock_gettime(CLOCK_MONOTONIC, &starttime);
- for (i = 1; i < SHM_BLOCKS_IN_MAP; i++) {
- struct shm_du_buff * sdb;
- size_t len;
+ for (i = 1; i < 16 * SHM_BLOCKS_IN_MAP; i++) {
+ size_t len;
test_buf_size = TEST_BUFF_SIZE;
@@ -77,21 +76,19 @@ void * produce()
len = test_buf_size - (headspace + tailspace);
- sdb = shm_create_du_buff(dum,
- test_buf_size,
- headspace,
- test_values,
- len);
-
- if (sdb != NULL) {
- bytes_written += len;
- }
- else {
- sync = -2;
- break;
+ if (shm_create_du_buff(dum,
+ test_buf_size,
+ headspace,
+ test_values,
+ len) < 0) {
+ continue;
}
+
+ bytes_written += len;
}
+ sync = -2;
+
clock_gettime(CLOCK_MONOTONIC, &stoptime);
elapsed =(stoptime.tv_sec + stoptime.tv_nsec / 1000000000.0) -
(starttime.tv_sec + starttime.tv_nsec / 1000000000.0);
@@ -104,13 +101,14 @@ void * produce()
sync = -1;
+ shm_du_map_close(dum);
+
return 0;
}
void * consume()
{
struct shm_du_map * dum;
-
struct timespec ts;
ts.tv_sec = 0;
@@ -123,10 +121,15 @@ void * consume()
return (void *)-1;
}
- while (!sync) {
- while (!shm_release_du_buff(dum));
- nanosleep(&ts, NULL);
+ while (true) {
+ shm_release_du_buff(dum, 1823429173941);
+ if (sync)
+ break;
}
+ nanosleep(&ts, NULL);
+
+
+ shm_du_map_close(dum);
return 0;
}
@@ -149,7 +152,7 @@ int shm_du_map_test(int argc, char ** argv)
return -1;
}
- shm_du_map_close(dum);
+ shm_du_map_destroy(dum);
LOG_INFO("done.");
@@ -165,7 +168,7 @@ int shm_du_map_test(int argc, char ** argv)
pthread_create(&consumer, NULL, consume, NULL);
pthread_join(consumer, NULL);
- shm_du_map_close(dum);
+ shm_du_map_destroy(dum);
LOG_INFO("done.");
@@ -173,6 +176,8 @@ int shm_du_map_test(int argc, char ** argv)
LOG_INFO("starting concurrency test.");
+ sync = 0;
+
dum = shm_du_map_create();
res1 = (int) pthread_create(&producer, NULL, produce, NULL);
@@ -181,7 +186,7 @@ int shm_du_map_test(int argc, char ** argv)
pthread_join(producer, NULL);
pthread_join(consumer, NULL);
- shm_du_map_close(dum);
+ shm_du_map_destroy(dum);
LOG_INFO("done.");