#include "test.h"
-#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
#define REG_METRIC_COUNT 6
#define METRIC_LESSER_COUNT 3
#define KEY 1
return TEST_SUCCESS;
}
+/* Deinitialize metric module. This function must be called
+ * from a primary process after metrics usage is over
+ */
+static int
+test_metrics_deinitialize(void)
+{
+ int err = 0;
+ err = rte_metrics_deinit();
+ TEST_ASSERT(err == 0, "%s, %d", __func__, __LINE__);
+
+ return TEST_SUCCESS;
+}
+
/* Test Case to check failures when memzone init is not done */
static int
test_metrics_without_init(void)
};
/* Success Test: valid array and count size */
- err = rte_metrics_reg_names(&mnames[0], ARRAY_SIZE(mnames));
+ err = rte_metrics_reg_names(&mnames[0], RTE_DIM(mnames));
TEST_ASSERT(err >= 0, "%s, %d", __func__, __LINE__);
return TEST_SUCCESS;
/* Failed Test: Invalid count size */
err = rte_metrics_update_values(RTE_METRICS_GLOBAL,
- KEY, &value[0], ARRAY_SIZE(value));
+ KEY, &value[0], RTE_DIM(value));
TEST_ASSERT(err < 0, "%s, %d", __func__, __LINE__);
/* Failed Test: Invalid port_id(lower value) and valid data */
- err = rte_metrics_update_values(-2, KEY, &value[0], ARRAY_SIZE(value));
+ err = rte_metrics_update_values(-2, KEY, &value[0], RTE_DIM(value));
TEST_ASSERT(err == -EINVAL, "%s, %d", __func__, __LINE__);
/* Failed Test: Invalid port_id(higher value) and valid data */
- err = rte_metrics_update_values(39, 1, &value[0], ARRAY_SIZE(value));
+ err = rte_metrics_update_values(39, 1, &value[0], RTE_DIM(value));
TEST_ASSERT(err == -EINVAL, "%s, %d", __func__, __LINE__);
/* Failed Test: Invalid array */
err = rte_metrics_update_values(RTE_METRICS_GLOBAL,
- KEY, NULL, ARRAY_SIZE(value));
+ KEY, NULL, RTE_DIM(value));
TEST_ASSERT(err == -EINVAL, "%s, %d", __func__, __LINE__);
return TEST_SUCCESS;
* arraylist, count size
*/
TEST_CASE(test_metrics_get_values),
+
+ /* TEST CASE 8: Test to unregister metrics*/
+ TEST_CASE(test_metrics_deinitialize),
+
TEST_CASES_END()
}
};