#include <rte_memzone.h>
#include <rte_metrics.h>
#include <rte_bitrate.h>
+#include <rte_ethdev.h>
#include "sample_packet_forward.h"
#include "test.h"
#define BIT_NUM_PACKETS 10
#define QUEUE_ID 0
-uint16_t portid;
-struct rte_stats_bitrates *bitrate_data;
-struct rte_ring *ring;
+static uint16_t portid;
+static struct rte_stats_bitrates *bitrate_data;
+static struct rte_ring *ring;
/* To test whether rte_stats_bitrate_create is successful */
static int
return TEST_SUCCESS;
}
+/* To test free the resources from bitrate_create test */
+static int
+test_stats_bitrate_free(void)
+{
+ int ret = 0;
+
+ rte_stats_bitrate_free(bitrate_data);
+
+ ret = rte_metrics_deinit();
+ TEST_ASSERT(ret >= 0, "Test Failed: rte_metrics_deinit failed");
+
+ return TEST_SUCCESS;
+}
+
/* To test bit rate registration */
static int
test_stats_bitrate_reg(void)
int ret = 0;
ret = rte_stats_bitrate_calc(bitrate_data, 33);
- TEST_ASSERT(ret == -EINVAL, "Test Failed: Expected -%d for higher "
- "portid rte_stats_bitrate_calc ret:%d", EINVAL, ret);
+ TEST_ASSERT(ret == -ENODEV, "Test Failed: Expected -%d for higher "
+ "portid rte_stats_bitrate_calc ret:%d", ENODEV, ret);
return TEST_SUCCESS;
}
int ret = 0;
ret = rte_stats_bitrate_calc(bitrate_data, -1);
- TEST_ASSERT(ret == -EINVAL, "Test Failed: Expected -%d for invalid "
- "portid rte_stats_bitrate_calc ret:%d", EINVAL, ret);
+ TEST_ASSERT(ret == -ENODEV, "Test Failed: Expected -%d for invalid "
+ "portid rte_stats_bitrate_calc ret:%d", ENODEV, ret);
return TEST_SUCCESS;
}
int ret = 0;
ret = rte_stats_bitrate_calc(bitrate_data, 31);
- TEST_ASSERT(ret == -EINVAL, "Test Failed: Expected -%d for "
+ TEST_ASSERT(ret == -ENODEV, "Test Failed: Expected -%d for "
"non-existing portid rte_stats_bitrate_calc ret:%d",
- EINVAL, ret);
+ ENODEV, ret);
return TEST_SUCCESS;
}
printf("allocate mbuf pool Failed\n");
return TEST_FAILED;
}
+ ret = test_dev_start(portid, mp);
+ if (ret < 0) {
+ printf("test_dev_start(%hu, %p) failed, error code: %d\n",
+ portid, mp, ret);
+ return TEST_FAILED;
+ }
+
ret = test_packet_forward(pbuf, portid, QUEUE_ID);
if (ret < 0)
printf("send pkts Failed\n");
+
+ rte_eth_dev_stop(portid);
test_put_mbuf_to_pool(mp, pbuf);
- return TEST_SUCCESS;
+ return (ret >= 0) ? TEST_SUCCESS : TEST_FAILED;
}
static int
*/
TEST_CASE_ST(test_bit_packet_forward, NULL,
test_stats_bitrate_calc),
+ /* TEST CASE 9: Test to do the cleanup w.r.t create */
+ TEST_CASE(test_stats_bitrate_free),
TEST_CASES_END()
}
};