1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
/* SPDX-License-Identifier: BSD-3-Clause
* Copyright(C) 2025 Marvell International Ltd.
*/
#include <rte_pmu.h>
#include "test.h"
static int
test_pmu_read(void)
{
const char *name = NULL;
int tries = 10, event;
uint64_t val = 0;
#if defined(RTE_ARCH_ARM64)
name = "cpu_cycles";
#elif defined(RTE_ARCH_X86_64)
name = "cpu-cycles";
#endif
if (name == NULL) {
printf("PMU not supported on this arch\n");
return TEST_SKIPPED;
}
if (rte_pmu_init() < 0)
return TEST_FAILED;
event = rte_pmu_add_event(name);
while (tries--)
val += rte_pmu_read(event);
rte_pmu_fini();
return val ? TEST_SUCCESS : TEST_FAILED;
}
static struct unit_test_suite pmu_tests = {
.suite_name = "PMU autotest",
.setup = NULL,
.teardown = NULL,
.unit_test_cases = {
TEST_CASE(test_pmu_read),
TEST_CASES_END()
}
};
static int __rte_unused
test_pmu(void)
{
return unit_test_suite_runner(&pmu_tests);
}
/* disabled because of reported failures, waiting for a fix
* REGISTER_FAST_TEST(pmu_autotest, true, true, test_pmu);
*/
|