Re: [PATCH 2/2] perf test: Add selftest to test IBS invocation via core pmu events

From: Ravi Bangoria
Date: Fri Mar 03 2023 - 00:56:19 EST


Hi Namhyung,

>> +static int test__ibs_via_core_pmu(struct test_suite *text __maybe_unused,
>> + int subtest __maybe_unused)
>> +{
>> + struct perf_pmu *ibs_pmu;
>> + int ret = TEST_OK;
>> + int fd, i;
>> +
>> + if (list_empty(&pmus))
>> + perf_pmu__scan(NULL);
>> +
>> + ibs_pmu = perf_pmu__find("ibs_op");
>> + if (!ibs_pmu)
>> + return TEST_SKIP;
>> +
>> + for (i = 0; i < NR_SUB_TESTS; i++) {
>> + fd = event_open(sub_tests[i].type, sub_tests[i].config);
>> + pr_debug("type: 0x%x, config: 0x%lx, fd: %d - ", sub_tests[i].type,
>> + sub_tests[i].config, fd);
>> + if ((sub_tests[i].valid && fd == -1) ||
>> + (!sub_tests[i].valid && fd > 0)) {
>> + pr_debug("Fail\n");
>> + ret = TEST_FAIL;
>
> You need to close(fd) when it's succeeded for invalid one.

Yup. Will fix it.

Thanks,
Ravi