Code Review
/
vpp.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
vppinfra: add u64x2_scatter/u32x4_scatter
[vpp.git]
/
src
/
vppinfra
/
test_vec.c
diff --git
a/src/vppinfra/test_vec.c
b/src/vppinfra/test_vec.c
index
f0497ac
..
bc878ee
100644
(file)
--- a/
src/vppinfra/test_vec.c
+++ b/
src/vppinfra/test_vec.c
@@
-47,7
+47,6
@@
#endif
#include <vppinfra/clib.h>
#endif
#include <vppinfra/clib.h>
-#include <vppinfra/mheap.h>
#include <vppinfra/format.h>
#include <vppinfra/error.h>
#include <vppinfra/random.h>
#include <vppinfra/format.h>
#include <vppinfra/error.h>
#include <vppinfra/random.h>
@@
-125,7
+124,7
@@
uword g_call_stats[OP_MAX];
/* A structure for both vector headers and vector elements might be useful to
/* A structure for both vector headers and vector elements might be useful to
- uncover potential align
e
ment issues. */
+ uncover potential alignment issues. */
typedef struct
{
typedef struct
{
@@
-1067,12
+1066,20
@@
prob_free (void)
vec_free (g_prob_wh);
}
vec_free (g_prob_wh);
}
+int
+vl (void *v)
+{
+ return vec_len (v);
+}
+
int
test_vec_main (unformat_input_t * input)
{
uword iter = 1000;
uword help = 0;
uword big = 0;
int
test_vec_main (unformat_input_t * input)
{
uword iter = 1000;
uword help = 0;
uword big = 0;
+ uword align = 0;
+ uword ugly = 0;
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
@@
-1082,13
+1089,28
@@
test_vec_main (unformat_input_t * input)
&& 0 == unformat (input, "set %d", &g_set_verbose_at)
&& 0 == unformat (input, "dump %d", &g_dump_period)
&& 0 == unformat (input, "help %=", &help, 1)
&& 0 == unformat (input, "set %d", &g_set_verbose_at)
&& 0 == unformat (input, "dump %d", &g_dump_period)
&& 0 == unformat (input, "help %=", &help, 1)
- && 0 == unformat (input, "big %=", &big, 1))
+ && 0 == unformat (input, "big %=", &big, 1)
+ && 0 == unformat (input, "ugly %d", &ugly)
+ && 0 == unformat (input, "align %=", &align, 1))
{
clib_error ("unknown input `%U'", format_unformat_error, input);
goto usage;
}
}
{
clib_error ("unknown input `%U'", format_unformat_error, input);
goto usage;
}
}
+ /* Cause a deliberate heap botch */
+ if (ugly)
+ {
+ u8 *overrun_me = 0;
+ int i;
+
+ vec_validate (overrun_me, 31);
+ for (i = 0; i < vec_len (overrun_me) + ugly; i++)
+ overrun_me[i] = i;
+
+ vec_free (overrun_me);
+ }
+
if (big)
{
u8 *bigboy = 0;
if (big)
{
u8 *bigboy = 0;
@@
-1106,6
+1128,16
@@
test_vec_main (unformat_input_t * input)
return 0;
}
return 0;
}
+ if (align)
+ {
+ u8 *v = 0;
+
+ vec_validate_aligned (v, 9, CLIB_CACHE_LINE_BYTES);
+ fformat (stdout, "v = 0x%llx, aligned %llx\n",
+ v, ((uword) v) & ~(CLIB_CACHE_LINE_BYTES - 1));
+ vec_free (v);
+ }
+
if (help)
goto usage;
if (help)
goto usage;
@@
-1139,7
+1171,7
@@
main (int argc, char *argv[])
unformat_input_t i;
int ret;
unformat_input_t i;
int ret;
-
mheap_alloc (0, (uword) 10
ULL << 30);
+
clib_mem_init (0, 3
ULL << 30);
verbose = (argc > 1);
unformat_init_command_line (&i, argv);
verbose = (argc > 1);
unformat_init_command_line (&i, argv);