Re: [PATCH bpf-next v3 2/3] selftests/bpf: convert test_dev_cgroup to test_progs

From: Alexis Lothoré
Date: Wed Jul 31 2024 - 01:47:15 EST


Hello Martin,

On 7/31/24 02:34, Martin KaFai Lau wrote:
> On 7/30/24 4:59 AM, Alexis Lothoré (eBPF Foundation) wrote:
>> +static void test_read(const char *path, char *buf, int buf_size,
>> +              int expected_ret)
>> +{
>> +    int ret, fd;
>> +
>> +    fd = open(path, O_RDONLY);
>> +
>> +    /* A bare open on unauthorized device should fail */
>> +    if (expected_ret < 0) {
>> +        ASSERT_EQ(fd, expected_ret, "open file for read");
>
> One nit. expected_ret is actually expected_errno. It just happens -EPERM is -1,
> so testing fd against expected_errno works here but is confusing to read. How
> about separating the fd and errno test in the access rejected case. First test
> for fd == -1 and then test for errno == expected_errno.

Ah you are right, I mixed up things here, I'll fix it.

> Please also carry Stanislav's Ack in patch 1 and 3 in the next respin.

Sure, will do.

Thanks,

Alexis

--
Alexis Lothoré, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com