summaryrefslogtreecommitdiff
path: root/src/lib/tests
diff options
context:
space:
mode:
authorSander Vrijders <[email protected]>2016-03-15 16:04:55 +0100
committerSander Vrijders <[email protected]>2016-03-15 16:04:55 +0100
commit788414c1a728440e25b8a7428af294189e3b70ca (patch)
tree6fb96112f64976ca19d069beaf08dbb4d4e3791b /src/lib/tests
parent7ca8145790db15d7da3c2f1b260ad3421993b67c (diff)
parent8c649a56e61012d0b245defbdea3ff5c3acb21c1 (diff)
downloadouroboros-788414c1a728440e25b8a7428af294189e3b70ca.tar.gz
ouroboros-788414c1a728440e25b8a7428af294189e3b70ca.zip
Merged in dstaesse/ouroboros/b-du_buff (pull request #32)
lib: Updated du_buff to limit allowable PCI size
Diffstat (limited to 'src/lib/tests')
-rw-r--r--src/lib/tests/du_buff_test.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/lib/tests/du_buff_test.c b/src/lib/tests/du_buff_test.c
index 7bdf1459..2b7b5e55 100644
--- a/src/lib/tests/du_buff_test.c
+++ b/src/lib/tests/du_buff_test.c
@@ -20,10 +20,12 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <ouroboros/du_buff.h>
#include "du_buff.c"
-#define TEST_BUFF_SIZE 16 * DU_BUFF_BLOCKSIZE
-#define MAX(a,b) a > b ? a : b
+#define TEST_BUFF_SIZE 16 * DU_BLOCK_DATA_SIZE
+#define MAX(a,b) (a > b ? a : b)
+#define MIN(a,b) (a < b ? a : b)
int du_buff_test(int argc, char ** argv)
{
@@ -35,17 +37,23 @@ int du_buff_test(int argc, char ** argv)
for (i = 0; i < TEST_BUFF_SIZE; i++)
bits[i] = 170;
- i_inc = MAX(1, DU_BUFF_BLOCKSIZE / 4);
- j_inc = MAX(1, DU_BUFF_BLOCKSIZE / 8);
- k_inc = MAX(1, DU_BUFF_BLOCKSIZE / 16);
+ i_inc = MAX(1, DU_BLOCK_DATA_SIZE / 4);
+ j_inc = MAX(1, DU_BLOCK_DATA_SIZE / 8);
+ k_inc = MAX(1, DU_BLOCK_DATA_SIZE / 16);
- for (i = DU_BUFF_BLOCKSIZE / 4; i <= TEST_BUFF_SIZE; i += i_inc) {
+ for (i = DU_BUFF_BLOCK_SIZE / 4; i <= TEST_BUFF_SIZE; i += i_inc) {
for (j = 0; j < i; j += j_inc) {
for (k = 0; k < i - j; k += k_inc) {
du_buff_t * dub = du_buff_create(i);
if (dub == NULL)
return -1;
+ if (k > DU_BLOCK_DATA_SIZE)
+ continue;
+
+ if (i - (j + k) > DU_BLOCK_DATA_SIZE)
+ continue;
+
if (du_buff_init(dub, k, bits, j) < 0)
return -1;