[PATCH 2/2] selftests/powerpc: Skip test instead of failing
Michael Ellerman
mpe at ellerman.id.au
Wed Oct 31 20:41:39 AEDT 2018
Tyrel Datwyler <tyreld at linux.vnet.ibm.com> writes:
> On 10/23/2018 01:23 PM, Breno Leitao wrote:
>> Current core-pkey selftest fails if the test runs without privileges to
>> write into the core pattern file (/proc/sys/kernel/core_pattern). This
>> causes the test to fail and give the impression that the subsystem being
>> tested is broken, when, in fact, the test is being executed without the
>> proper privileges. This is the current error:
>>
>> test: core_pkey
>> tags: git_version:v4.19-3-g9e3363be9bce-dirty
>> Error writing to core_pattern file: Permission denied
>> failure: core_pkey
>>
>> This patch simply skips this test if it runs without the proper privileges,
>> avoiding this undesired failure.
>>
>> CC: Thiago Jung Bauermann <bauerman at linux.ibm.com>
>> Signed-off-by: Breno Leitao <leitao at debian.org>
>> ---
>> tools/testing/selftests/powerpc/ptrace/core-pkey.c | 10 ++--------
>> 1 file changed, 2 insertions(+), 8 deletions(-)
>>
>> diff --git a/tools/testing/selftests/powerpc/ptrace/core-pkey.c b/tools/testing/selftests/powerpc/ptrace/core-pkey.c
>> index e23e2e199eb4..e07949120fc8 100644
>> --- a/tools/testing/selftests/powerpc/ptrace/core-pkey.c
>> +++ b/tools/testing/selftests/powerpc/ptrace/core-pkey.c
>> @@ -352,17 +352,11 @@ static int write_core_pattern(const char *core_pattern)
>> FILE *f;
>>
>> f = fopen(core_pattern_file, "w");
>> - if (!f) {
>> - perror("Error writing to core_pattern file");
>> - return TEST_FAIL;
>> - }
>> + SKIP_IF(!f);
>>
>> ret = fwrite(core_pattern, 1, len, f);
>> fclose(f);
>> - if (ret != len) {
>> - perror("Error writing to core_pattern file");
>> - return TEST_FAIL;
>> - }
>> + SKIP_IF(ret != len);
>
> If we don't have proper privileges we should fail on the open, right?
> So wouldn't we still want to fail on the write if something goes
> wrong?
Yes you're right. If we don't have permission then the open should have
failed, and we skip then.
But if the open succeeded and the write fails then we don't know what's
going on and the test should fail.
cheers
More information about the Linuxppc-dev
mailing list