summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-12-23 10:18:16 -0800
committerFlorin Coras <fcoras@cisco.com>2020-12-23 10:40:08 -0800
commit7b0fa5569516992aa81c626aa2b426a81eb0ecab (patch)
treea3cffbe29c57b273a50836f6097a5926ab5b6ebf /src/plugins
parentdd9299c68a02b7c476cb60b8d9ac4e145503a44f (diff)
vppinfra: mem bulk test
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Icd44ede9604c29839af250a2be93ecf467467aa0
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/unittest/CMakeLists.txt1
-rw-r--r--src/plugins/unittest/mem_bulk_test.c145
2 files changed, 146 insertions, 0 deletions
diff --git a/src/plugins/unittest/CMakeLists.txt b/src/plugins/unittest/CMakeLists.txt
index ba6a82280f6..2b358a5d906 100644
--- a/src/plugins/unittest/CMakeLists.txt
+++ b/src/plugins/unittest/CMakeLists.txt
@@ -35,6 +35,7 @@ add_vpp_plugin(unittest
ipsec_test.c
llist_test.c
mactime_test.c
+ mem_bulk_test.c
mfib_test.c
mpcap_node.c
punt_test.c
diff --git a/src/plugins/unittest/mem_bulk_test.c b/src/plugins/unittest/mem_bulk_test.c
new file mode 100644
index 00000000000..9d2f60d59a8
--- /dev/null
+++ b/src/plugins/unittest/mem_bulk_test.c
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2020 Cisco and/or its affiliates.
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#include <vppinfra/mem.h>
+#include <vlib/vlib.h>
+
+#define MB_TEST_I(_cond, _comment, _args...) \
+ ({ \
+ int _evald = (_cond); \
+ if (!(_evald)) \
+ { \
+ fformat (stderr, "FAIL:%d: " _comment "\n", __LINE__, ##_args); \
+ } \
+ else \
+ { \
+ fformat (stderr, "PASS:%d: " _comment "\n", __LINE__, ##_args); \
+ } \
+ _evald; \
+ })
+
+#define MB_TEST(_cond, _comment, _args...) \
+ { \
+ if (!MB_TEST_I (_cond, _comment, ##_args)) \
+ { \
+ return 1; \
+ } \
+ }
+
+typedef struct test_struct_
+{
+ u32 data;
+} test_struct_t;
+
+static int
+mem_bulk_test_basic (vlib_main_t *vm, unformat_input_t *input)
+{
+ int __clib_unused verbose, i, rv, n_iter = 1000;
+ test_struct_t *elt, **elts = 0;
+ clib_mem_bulk_handle_t mb;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "verbose"))
+ verbose = 1;
+ else
+ {
+ vlib_cli_output (vm, "parse error: '%U'", format_unformat_error,
+ input);
+ return -1;
+ }
+ }
+
+ mb = clib_mem_bulk_init (sizeof (test_struct_t), 0, 0);
+
+ for (i = 0; i < n_iter; i++)
+ {
+ elt = clib_mem_bulk_alloc (mb);
+ vec_add1 (elts, elt);
+ }
+
+ for (i = 0; i < n_iter; i++)
+ elts[i]->data = i;
+
+ for (i = 0; i < n_iter; i++)
+ if (elts[i]->data != i)
+ MB_TEST (0, "data corrupted");
+
+ for (i = 0; i < n_iter; i++)
+ clib_mem_bulk_free (mb, elts[i]);
+
+ /*
+ * realloc all
+ */
+ for (i = 0; i < n_iter; i++)
+ {
+ elt = clib_mem_bulk_alloc (mb);
+ vec_add1 (elts, elt);
+ }
+
+ for (i = n_iter - 1; i >= 0; i--)
+ elts[i]->data = i;
+
+ for (i = n_iter - 1; i >= 0; i--)
+ if (elts[i]->data != i)
+ MB_TEST (0, "data corrupted");
+
+ for (i = 0; i < n_iter; i++)
+ clib_mem_bulk_free (mb, elts[i]);
+
+ clib_mem_bulk_destroy (mb);
+ vec_free (elts);
+
+ return 0;
+}
+
+static clib_error_t *
+mem_bulk_test (vlib_main_t *vm, unformat_input_t *input,
+ vlib_cli_command_t *cmd_arg)
+{
+ int res = 0;
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "basic"))
+ {
+ res = mem_bulk_test_basic (vm, input);
+ }
+ else if (unformat (input, "all"))
+ {
+ if ((res = mem_bulk_test_basic (vm, input)))
+ goto done;
+ }
+ else
+ break;
+ }
+
+done:
+ if (res)
+ return clib_error_return (0, "llist unit test failed");
+ return 0;
+}
+
+VLIB_CLI_COMMAND (mem_bulk_test_command, static) = {
+ .path = "test membulk",
+ .short_help = "internal membulk unit tests",
+ .function = mem_bulk_test,
+};
+
+/*
+ * fd.io coding-style-patch-verification: ON
+ *
+ * Local Variables:
+ * eval: (c-set-style "gnu")
+ * End:
+ */
-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
3n-hsw-x520-imix-base
---------------------

1t1c
````

.. raw:: html

    <a name="x520-imix-1t1c-base"></a>
    <center><b>

:index:`3n-hsw-x520-l2sw-vhost-imix-base-1t1c-mrr`

.. raw:: html

    </b>
    Links to builds:
    <a href="https://nexus.fd.io/content/repositories/fd.io.master.ubuntu.xenial.main/io/fd/vpp/vpp/" target="_blank">vpp-ref</a>,
    <a href="https://jenkins.fd.io/view/csit/job/csit-vpp-perf-mrr-daily-master" target="_blank">csit-ref</a>
    <iframe width="1100" height="800" frameborder="0" scrolling="no" src="../_static/vpp/cpta-vm-vhost-imix-eth-1t1c-x520-3n-hsw.html"></iframe>
    <p><br><br></p>
    </center>

2t2c
````

.. raw:: html

    <a name="x520-imix-2t2c-base"></a>
    <center><b>

:index:`3n-hsw-x520-l2sw-vhost-imix-base-2t2c-mrr`

.. raw:: html

    </b>
    Links to builds:
    <a href="https://nexus.fd.io/content/repositories/fd.io.master.ubuntu.xenial.main/io/fd/vpp/vpp/" target="_blank">vpp-ref</a>,
    <a href="https://jenkins.fd.io/view/csit/job/csit-vpp-perf-mrr-daily-master" target="_blank">csit-ref</a>
    <iframe width="1100" height="800" frameborder="0" scrolling="no" src="../_static/vpp/cpta-vm-vhost-imix-eth-2t2c-x520-3n-hsw.html"></iframe>
    <p><br><br></p>
    </center>

4t4c
````

.. raw:: html

    <a name="x520-imix-4t4c-base"></a>
    <center><b>

:index:`3n-hsw-x520-l2sw-vhost-imix-base-4t4c-mrr`

.. raw:: html

    </b>
    Links to builds:
    <a href="https://nexus.fd.io/content/repositories/fd.io.master.ubuntu.xenial.main/io/fd/vpp/vpp/" target="_blank">vpp-ref</a>,
    <a href="https://jenkins.fd.io/view/csit/job/csit-vpp-perf-mrr-daily-master" target="_blank">csit-ref</a>
    <iframe width="1100" height="800" frameborder="0" scrolling="no" src="../_static/vpp/cpta-vm-vhost-imix-eth-4t4c-x520-3n-hsw.html"></iframe>
    <p><br><br></p>
    </center>