2 * Copyright (c) 2015 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
16 Copyright (c) 2001, 2002, 2003 Eliot Dresselhaus
17 Written by Fred Delley <fdelley@cisco.com> .
19 Permission is hereby granted, free of charge, to any person obtaining
20 a copy of this software and associated documentation files (the
21 "Software"), to deal in the Software without restriction, including
22 without limitation the rights to use, copy, modify, merge, publish,
23 distribute, sublicense, and/or sell copies of the Software, and to
24 permit persons to whom the Software is furnished to do so, subject to
25 the following conditions:
27 The above copyright notice and this permission notice shall be
28 included in all copies or substantial portions of the Software.
30 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
31 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
32 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
33 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
34 LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
35 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
36 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39 #ifdef CLIB_LINUX_KERNEL
40 #include <linux/unistd.h>
49 #include <vppinfra/clib.h>
50 #include <vppinfra/format.h>
51 #include <vppinfra/error.h>
52 #include <vppinfra/random.h>
53 #include <vppinfra/time.h>
58 #define if_verbose(format,args...) \
59 if (verbose) { clib_warning(format, ## args); }
61 #define MAX_CHANGE 100
66 /* Values have to be sequential and start with 0. */
72 OP_IS_VEC_INSERT_ELTS,
84 /* Operations on vectors with custom headers. */
91 #define FIRST_VEC_OP OP_IS_VEC_RESIZE
92 #define LAST_VEC_OP OP_IS_VEC_PREPEND
93 #define FIRST_VEC_HDR_OP OP_IS_VEC_INIT_H
94 #define LAST_VEC_HDR_OP OP_IS_VEC_FREE_H
96 uword g_prob_ratio[] = {
97 [OP_IS_VEC_RESIZE] = 5,
101 [OP_IS_VEC_INSERT] = 5,
102 [OP_IS_VEC_INSERT_ELTS] = 5,
103 [OP_IS_VEC_DELETE] = 30,
105 [OP_IS_VEC_IS_EQUAL] = 5,
106 [OP_IS_VEC_ZERO] = 2,
108 [OP_IS_VEC_VALIDATE] = 5,
109 [OP_IS_VEC_FREE] = 5,
110 [OP_IS_VEC_INIT] = 5,
111 [OP_IS_VEC_CLONE] = 5,
112 [OP_IS_VEC_APPEND] = 5,
113 [OP_IS_VEC_PREPEND] = 5,
114 /* Operations on vectors with custom headers. */
115 [OP_IS_VEC_INIT_H] = 5,
116 [OP_IS_VEC_RESIZE_H] = 5,
117 [OP_IS_VEC_FREE_H] = 5,
123 uword g_call_stats[OP_MAX];
126 /* A structure for both vector headers and vector elements might be useful to
127 uncover potential alignment issues. */
132 CLIB_PACKED (u32 field2);
138 CLIB_PACKED (u32 field2);
142 u32 g_seed = 0xdeadbabe;
147 uword g_set_verbose_at = ~0;
148 uword g_dump_period = ~0;
152 format_vec_op_type (u8 * s, va_list * args)
154 op_t op = va_arg (*args, int);
160 s = format (s, "OP_IS_" #n); \
185 s = format (s, "Unknown vec op (%d)", op);
195 dump_call_stats (uword * stats)
199 fformat (stdout, "Call Stats\n----------\n");
201 for (i = 0; i < OP_MAX; i++)
202 fformat (stdout, "%-8d %U\n", stats[i], format_vec_op_type, i);
206 /* XXX - Purposely low value for debugging the validator. Will be set it to a
207 more sensible value later. */
208 #define MAX_VEC_LEN 10
210 #define create_random_vec_wh(elt_type, len, hdr_bytes, seed) \
212 elt_type *_v (v) = NULL; \
213 uword _v (l) = (len); \
214 uword _v (h) = (hdr_bytes); \
220 /* ~0 means select random length between 0 and MAX_VEC_LEN. */ \
222 _v (l) = bounded_random_u32 (&(seed), 0, MAX_VEC_LEN); \
224 _v (v) = _vec_realloc (NULL, _v (l), sizeof (elt_type), _v (h), 0, 0); \
225 fill_with_random_data (_v (v), vec_bytes (_v (v)), (seed)); \
227 /* Fill header with random data as well. */ \
230 _v (hdr) = vec_header (_v (v)); \
231 fill_with_random_data (_v (hdr), _v (h), (seed)); \
238 #define create_random_vec(elt_type, len, seed) \
239 create_random_vec_wh (elt_type, len, 0, seed)
241 #define compute_vec_hash(hash, vec) \
243 u8 * _v(v) = (u8 *) (vec); \
244 uword _v(n) = vec_len (vec) * sizeof ((vec)[0]); \
245 u8 _v(hh) = (u8) (hash); \
247 compute_mem_hash (_v(hh), _v(v), _v(n)); \
251 validate_vec_free (elt_t * vec)
254 ASSERT (vec == NULL);
259 validate_vec_free_h (elt_t * vec, uword hdr_bytes)
262 ASSERT (vec == NULL);
267 validate_vec_hdr (elt_t * vec, uword hdr_bytes)
276 vh = _vec_find (vec);
277 hdr = vec_header (vec);
278 hdr_end = vec_header_end (hdr);
280 ASSERT (hdr_end == (u8 *) vec);
281 ASSERT ((u8 *) vh - (u8 *) hdr >= hdr_bytes);
285 validate_vec_len (elt_t * vec)
298 end = (u8 *) vec_end (vec);
300 bytes = sizeof (vec[0]) * len;
302 ASSERT (bytes == vec_bytes (vec));
303 ASSERT ((ptr + bytes) == end);
307 /* XXX - TODO: confirm that auto-incrementing in vec_is_member() would not
308 have the expected result. */
309 while (vec_is_member (vec, (__typeof__ (vec[0]) *) ptr))
320 vec_foreach (elt, vec) i++;
326 validate_vec (elt_t * vec, uword hdr_bytes)
328 validate_vec_hdr (vec, hdr_bytes);
329 validate_vec_len (vec);
331 if (!vec || vec_len (vec) == 0)
333 VERBOSE3 ("Vector at %p has zero elements.\n\n", vec);
338 VERBOSE3 ("Header: %U\n", format_hex_bytes, vec_header (vec),
342 format_hex_bytes, vec, vec_len (vec) * sizeof (vec[0]));
347 validate_vec_resize (elt_t * vec, uword num_elts)
349 uword len1 = vec_len (vec);
351 u8 hash = compute_vec_hash (0, vec);
353 vec_resize (vec, num_elts);
354 len2 = vec_len (vec);
356 ASSERT (len2 == len1 + num_elts);
357 ASSERT (compute_vec_hash (hash, vec) == 0);
358 validate_vec (vec, 0);
363 validate_vec_resize_h (elt_t * vec, uword num_elts, uword hdr_bytes)
370 len1 = vec_len (vec);
373 hdr = vec_header (vec);
375 hash = compute_vec_hash (0, vec);
376 hdr_hash = compute_mem_hash (0, hdr, hdr_bytes);
378 vec_resize_ha (vec, num_elts, hdr_bytes, 0);
379 len2 = vec_len (vec);
381 ASSERT (len2 == len1 + num_elts);
383 end1 = (u8 *) (vec + len1);
384 end2 = (u8 *) vec_end (vec);
393 hdr = vec_header (vec);
395 ASSERT (compute_vec_hash (hash, vec) == 0);
396 ASSERT (compute_mem_hash (hdr_hash, hdr, hdr_bytes) == 0);
397 validate_vec (vec, 1);
402 generic_validate_vec_add (elt_t * vec, uword num_elts, uword is_add2)
404 uword len1 = vec_len (vec);
406 u8 hash = compute_vec_hash (0, vec);
411 vec_add2 (vec, new, num_elts);
415 new = create_random_vec (elt_t, num_elts, g_seed);
417 VERBOSE3 ("%U\n", format_hex_bytes, new,
418 vec_len (new) * sizeof (new[0]));
420 /* Add the hash value of the new elements to that of the old vector. */
421 hash = compute_vec_hash (hash, new);
424 vec_add1 (vec, new[0]);
425 else if (num_elts > 1)
426 vec_add (vec, new, num_elts);
431 len2 = vec_len (vec);
432 ASSERT (len2 == len1 + num_elts);
434 ASSERT (compute_vec_hash (hash, vec) == 0);
435 validate_vec (vec, 0);
440 validate_vec_add1 (elt_t * vec)
442 return generic_validate_vec_add (vec, 1, 0);
446 validate_vec_add2 (elt_t * vec, uword num_elts)
448 return generic_validate_vec_add (vec, num_elts, 1);
452 validate_vec_add (elt_t * vec, uword num_elts)
454 return generic_validate_vec_add (vec, num_elts, 0);
458 validate_vec_insert (elt_t * vec, uword num_elts, uword start_elt)
460 uword len1 = vec_len (vec);
464 /* vec_insert() would not handle it properly. */
465 if (start_elt > len1 || num_elts == 0)
468 hash = compute_vec_hash (0, vec);
469 vec_insert (vec, num_elts, start_elt);
470 len2 = vec_len (vec);
472 ASSERT (len2 == len1 + num_elts);
473 ASSERT (compute_vec_hash (hash, vec) == 0);
474 validate_vec (vec, 0);
479 validate_vec_insert_elts (elt_t * vec, uword num_elts, uword start_elt)
481 uword len1 = vec_len (vec);
486 /* vec_insert_elts() would not handle it properly. */
487 if (start_elt > len1 || num_elts == 0)
490 new = create_random_vec (elt_t, num_elts, g_seed);
492 VERBOSE3 ("%U\n", format_hex_bytes, new, vec_len (new) * sizeof (new[0]));
494 /* Add the hash value of the new elements to that of the old vector. */
495 hash = compute_vec_hash (0, vec);
496 hash = compute_vec_hash (hash, new);
498 vec_insert_elts (vec, new, num_elts, start_elt);
499 len2 = vec_len (vec);
503 ASSERT (len2 == len1 + num_elts);
504 ASSERT (compute_vec_hash (hash, vec) == 0);
505 validate_vec (vec, 0);
510 validate_vec_delete (elt_t * vec, uword num_elts, uword start_elt)
512 uword len1 = vec_len (vec);
518 /* vec_delete() would not handle it properly. */
519 if (start_elt + num_elts > len1)
522 start = (u8 *) vec + (start_elt * sizeof (vec[0]));
524 hash = compute_vec_hash (0, vec);
525 hash_del = compute_mem_hash (0, start, num_elts * sizeof (vec[0]));
528 vec_delete (vec, num_elts, start_elt);
529 len2 = vec_len (vec);
531 ASSERT (len2 == len1 - num_elts);
532 ASSERT (compute_vec_hash (hash, vec) == 0);
533 validate_vec (vec, 0);
538 validate_vec_dup (elt_t * vec)
543 hash = compute_vec_hash (0, vec);
546 ASSERT (compute_vec_hash (hash, new) == 0);
548 validate_vec (new, 0);
553 validate_vec_zero (elt_t * vec)
561 end = (u8 *) (vec + vec_len (vec));
565 ASSERT (ptr < (u8 *) vec_end (vec));
566 ASSERT (ptr[0] == 0);
570 validate_vec (vec, 0);
575 validate_vec_is_equal (elt_t * vec)
579 if (vec_len (vec) <= 0)
583 ASSERT (vec_is_equal (new, vec));
588 validate_vec_set (elt_t * vec)
591 uword len = vec_len (vec);
597 new = create_random_vec (elt_t, 1, g_seed);
599 VERBOSE3 ("%U\n", format_hex_bytes, new, vec_len (new) * sizeof (new[0]));
601 vec_set (vec, new[0]);
603 for (i = 0; i < len; i++)
604 ASSERT (memcmp (&vec[i], &new[0], sizeof (vec[0])) == 0);
607 validate_vec (vec, 0);
612 validate_vec_validate (elt_t * vec, uword index)
614 uword len = vec_len (vec);
615 word num_new = index - len + 1;
618 u8 hash = compute_vec_hash (0, vec);
623 vec_validate (vec, index);
625 /* Old len but new vec pointer! */
626 ptr = (u8 *) (vec + len);
627 end = (u8 *) (vec + len + num_new);
629 ASSERT (len + num_new == vec_len (vec));
630 ASSERT (compute_vec_hash (hash, vec) == 0);
634 ASSERT (ptr < (u8 *) vec_end (vec));
635 ASSERT (ptr[0] == 0);
639 validate_vec (vec, 0);
644 validate_vec_init (uword num_elts)
651 new = vec_new (elt_t, num_elts);
654 ASSERT (len == num_elts);
657 end = (u8 *) (new + len);
661 ASSERT (ptr < (u8 *) vec_end (new));
662 ASSERT (ptr[0] == 0);
666 validate_vec (new, 0);
671 validate_vec_init_h (uword num_elts, uword hdr_bytes)
679 new = vec_new_generic (elt_t, num_elts, hdr_bytes, 0, 0);
682 ASSERT (len == num_elts);
684 /* We have 2 zero-regions to check: header & vec data (skip _VEC struct). */
685 for (i = 0; i < 2; i++)
689 ptr = (u8 *) vec_header (new);
690 end = ptr + hdr_bytes;
695 end = (u8 *) (new + len);
700 ASSERT (ptr < (u8 *) vec_end (new));
701 ASSERT (ptr[0] == 0);
706 validate_vec (new, 1);
710 /* XXX - I don't understand the purpose of the vec_clone() call. */
712 validate_vec_clone (elt_t * vec)
716 vec_clone (new, vec);
718 ASSERT (vec_len (new) == vec_len (vec));
719 ASSERT (compute_vec_hash (0, new) == 0);
720 validate_vec (new, 0);
725 validate_vec_append (elt_t * vec)
728 uword num_elts = bounded_random_u32 (&g_seed, 0, MAX_CHANGE);
732 new = create_random_vec (elt_t, num_elts, g_seed);
734 len = vec_len (vec) + vec_len (new);
735 hash = compute_vec_hash (0, vec);
736 hash = compute_vec_hash (hash, new);
738 vec_append (vec, new);
741 ASSERT (vec_len (vec) == len);
742 ASSERT (compute_vec_hash (hash, vec) == 0);
743 validate_vec (vec, 0);
748 validate_vec_prepend (elt_t * vec)
751 uword num_elts = bounded_random_u32 (&g_seed, 0, MAX_CHANGE);
755 new = create_random_vec (elt_t, num_elts, g_seed);
757 len = vec_len (vec) + vec_len (new);
758 hash = compute_vec_hash (0, vec);
759 hash = compute_vec_hash (hash, new);
761 vec_prepend (vec, new);
764 ASSERT (vec_len (vec) == len);
765 ASSERT (compute_vec_hash (hash, vec) == 0);
766 validate_vec (vec, 0);
771 run_validator_wh (uword iter)
779 f64 time[3]; /* [0]: start, [1]: last, [2]: current */
781 vec = create_random_vec_wh (elt_t, ~0, sizeof (hdr_t), g_seed);
782 validate_vec (vec, 0);
783 VERBOSE2 ("Start with len %d\n", vec_len (vec));
785 time[0] = unix_time_now ();
787 dump_time = g_dump_period;
789 for (i = 1; i <= iter; i++)
791 if (i >= g_set_verbose_at)
794 op = bounded_random_u32 (&g_seed, 0, vec_len (g_prob_wh) - 1);
799 case OP_IS_VEC_INIT_H:
800 num_elts = bounded_random_u32 (&g_seed, 0, MAX_CHANGE);
802 VERBOSE2 ("vec_init_h(), new elts %d\n", num_elts);
803 vec = validate_vec_init_h (num_elts, sizeof (hdr_t));
806 case OP_IS_VEC_RESIZE_H:
808 num_elts = bounded_random_u32 (&g_seed, len, len + MAX_CHANGE);
809 VERBOSE2 ("vec_resize_h(), %d new elts.\n", num_elts);
810 vec = validate_vec_resize_h (vec, num_elts, sizeof (hdr_t));
813 case OP_IS_VEC_FREE_H:
814 VERBOSE2 ("vec_free_h()\n");
815 vec = validate_vec_free_h (vec, sizeof (hdr_t));
827 time[2] = unix_time_now ();
828 VERBOSE1 ("%d vec ops in %f secs. (last %d in %f secs.).\n",
829 i, time[2] - time[0], g_dump_period, time[2] - time[1]);
831 dump_time += g_dump_period;
833 VERBOSE1 ("vec len %d\n", vec_len (vec));
835 format_hex_bytes, vec, vec_len (vec) * sizeof (vec[0]));
838 VERBOSE2 ("len %d\n", vec_len (vec));
841 validate_vec (vec, sizeof (hdr_t));
846 run_validator (uword iter)
856 f64 time[3]; /* [0]: start, [1]: last, [2]: current */
858 vec = create_random_vec (elt_t, ~0, g_seed);
859 validate_vec (vec, 0);
860 VERBOSE2 ("Start with len %d\n", vec_len (vec));
862 time[0] = unix_time_now ();
864 dump_time = g_dump_period;
866 for (i = 1; i <= iter; i++)
868 if (i >= g_set_verbose_at)
871 op = bounded_random_u32 (&g_seed, 0, vec_len (g_prob) - 1);
876 case OP_IS_VEC_RESIZE:
878 num_elts = bounded_random_u32 (&g_seed, len, len + MAX_CHANGE);
879 VERBOSE2 ("vec_resize(), %d new elts.\n", num_elts);
880 vec = validate_vec_resize (vec, num_elts);
884 VERBOSE2 ("vec_add1()\n");
885 vec = validate_vec_add1 (vec);
889 num_elts = bounded_random_u32 (&g_seed, 0, MAX_CHANGE);
890 VERBOSE2 ("vec_add2(), %d new elts.\n", num_elts);
891 vec = validate_vec_add2 (vec, num_elts);
895 num_elts = bounded_random_u32 (&g_seed, 0, MAX_CHANGE);
896 VERBOSE2 ("vec_add(), %d new elts.\n", num_elts);
897 vec = validate_vec_add (vec, num_elts);
900 case OP_IS_VEC_INSERT:
902 num_elts = bounded_random_u32 (&g_seed, 0, MAX_CHANGE);
903 index = bounded_random_u32 (&g_seed, 0,
904 (len > 0) ? (len - 1) : (0));
905 VERBOSE2 ("vec_insert(), %d new elts, index %d.\n", num_elts,
907 vec = validate_vec_insert (vec, num_elts, index);
910 case OP_IS_VEC_INSERT_ELTS:
912 num_elts = bounded_random_u32 (&g_seed, 0, MAX_CHANGE);
913 index = bounded_random_u32 (&g_seed, 0,
914 (len > 0) ? (len - 1) : (0));
915 VERBOSE2 ("vec_insert_elts(), %d new elts, index %d.\n",
917 vec = validate_vec_insert_elts (vec, num_elts, index);
920 case OP_IS_VEC_DELETE:
922 index = bounded_random_u32 (&g_seed, 0, len - 1);
923 num_elts = bounded_random_u32 (&g_seed, 0,
924 (len > index) ? (len - index) : (0));
925 VERBOSE2 ("vec_delete(), %d elts, index %d.\n", num_elts, index);
926 vec = validate_vec_delete (vec, num_elts, index);
930 VERBOSE2 ("vec_dup()\n");
931 new = validate_vec_dup (vec);
935 case OP_IS_VEC_IS_EQUAL:
936 VERBOSE2 ("vec_is_equal()\n");
937 validate_vec_is_equal (vec);
941 VERBOSE2 ("vec_zero()\n");
942 vec = validate_vec_zero (vec);
946 VERBOSE2 ("vec_set()\n");
947 vec = validate_vec_set (vec);
950 case OP_IS_VEC_VALIDATE:
952 index = bounded_random_u32 (&g_seed, 0, len - 1 + MAX_CHANGE);
953 VERBOSE2 ("vec_validate(), index %d\n", index);
954 vec = validate_vec_validate (vec, index);
958 VERBOSE2 ("vec_free()\n");
959 vec = validate_vec_free (vec);
963 num_elts = bounded_random_u32 (&g_seed, 0, MAX_CHANGE);
965 VERBOSE2 ("vec_init(), new elts %d\n", num_elts);
966 vec = validate_vec_init (num_elts);
969 case OP_IS_VEC_CLONE:
970 VERBOSE2 ("vec_clone()\n");
971 new = validate_vec_clone (vec);
975 case OP_IS_VEC_APPEND:
976 VERBOSE2 ("vec_append()\n");
977 vec = validate_vec_append (vec);
980 case OP_IS_VEC_PREPEND:
981 VERBOSE2 ("vec_prepend()\n");
982 vec = validate_vec_prepend (vec);
994 time[2] = unix_time_now ();
995 VERBOSE1 ("%d vec ops in %f secs. (last %d in %f secs.).\n",
996 i, time[2] - time[0], g_dump_period, time[2] - time[1]);
998 dump_time += g_dump_period;
1000 VERBOSE1 ("vec len %d\n", vec_len (vec));
1002 format_hex_bytes, vec, vec_len (vec) * sizeof (vec[0]));
1005 VERBOSE2 ("len %d\n", vec_len (vec));
1008 validate_vec (vec, 0);
1015 uword i, j, ratio, len, index;
1017 /* Create the vector to implement the statistical profile:
1018 vec [ op1 op1 op1 op2 op3 op3 op3 op4 op4 .... ] */
1019 for (i = FIRST_VEC_OP; i <= LAST_VEC_OP; i++)
1021 ratio = g_prob_ratio[i];
1025 len = vec_len (g_prob);
1026 index = len - 1 + ratio;
1027 ASSERT (index >= 0);
1029 /* Pre-allocate new elements. */
1030 vec_validate (g_prob, index);
1032 for (j = len; j <= index; j++)
1036 /* Operations on vectors with headers. */
1037 for (i = FIRST_VEC_HDR_OP; i <= LAST_VEC_HDR_OP; i++)
1039 ratio = g_prob_ratio[i];
1043 len = vec_len (g_prob_wh);
1044 index = len - 1 + ratio;
1045 ASSERT (index >= 0);
1047 /* Pre-allocate new elements. */
1048 vec_validate (g_prob_wh, index);
1050 for (j = len; j <= index; j++)
1054 VERBOSE3 ("prob_vec, len %d\n%U\n", vec_len (g_prob),
1055 format_hex_bytes, g_prob, vec_len (g_prob) * sizeof (g_prob[0]));
1056 VERBOSE3 ("prob_vec_wh, len %d\n%U\n", vec_len (g_prob_wh),
1057 format_hex_bytes, g_prob_wh,
1058 vec_len (g_prob_wh) * sizeof (g_prob_wh[0]));
1065 vec_free (g_prob_wh);
1075 test_vec_main (unformat_input_t * input)
1083 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
1085 if (0 == unformat (input, "iter %d", &iter)
1086 && 0 == unformat (input, "seed %d", &g_seed)
1087 && 0 == unformat (input, "verbose %d", &g_verbose)
1088 && 0 == unformat (input, "set %d", &g_set_verbose_at)
1089 && 0 == unformat (input, "dump %d", &g_dump_period)
1090 && 0 == unformat (input, "help %=", &help, 1)
1091 && 0 == unformat (input, "big %=", &big, 1)
1092 && 0 == unformat (input, "ugly %d", &ugly)
1093 && 0 == unformat (input, "align %=", &align, 1))
1095 clib_error ("unknown input `%U'", format_unformat_error, input);
1100 /* Cause a deliberate heap botch */
1106 vec_validate (overrun_me, 31);
1107 for (i = 0; i < vec_len (overrun_me) + ugly; i++)
1110 vec_free (overrun_me);
1116 u64 one_gig = (1 << 30);
1120 fformat (stdout, "giant vector test...");
1121 size = 5ULL * one_gig;
1123 vec_validate (bigboy, size);
1125 for (index = size; index >= 0; index--)
1126 bigboy[index] = index & 0xff;
1134 vec_validate_aligned (v, 9, CLIB_CACHE_LINE_BYTES);
1135 fformat (stdout, "v = 0x%llx, aligned %llx\n",
1136 v, ((uword) v) & ~(CLIB_CACHE_LINE_BYTES - 1));
1145 run_validator (iter);
1146 run_validator_wh (iter);
1148 dump_call_stats (g_call_stats);
1154 fformat (stdout, "Usage: test_vec iter <N> seed <N> verbose <N> "
1155 "set <N> dump <N>\n");
1164 main (int argc, char *argv[])
1169 clib_mem_init (0, 3ULL << 30);
1171 verbose = (argc > 1);
1172 unformat_init_command_line (&i, argv);
1173 ret = test_vec_main (&i);
1178 #endif /* CLIB_UNIX */
1181 * fd.io coding-style-patch-verification: ON
1184 * eval: (c-set-style "gnu")