All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michael Ellerman <mpe@ellerman.id.au>
To: Tyrel Datwyler <tyreld@linux.vnet.ibm.com>,
	Breno Leitao <leitao@debian.org>,
	linuxppc-dev@lists.ozlabs.org
Cc: Thiago Jung Bauermann <bauerman@linux.ibm.com>
Subject: Re: [PATCH 2/2] selftests/powerpc: Skip test instead of failing
Date: Wed, 31 Oct 2018 20:41:39 +1100	[thread overview]
Message-ID: <87lg6eihbg.fsf@concordia.ellerman.id.au> (raw)
In-Reply-To: <56cdd832-6229-bf95-58ee-1783f931e7bd@linux.vnet.ibm.com>

Tyrel Datwyler <tyreld@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@linux.ibm.com>
>> Signed-off-by: Breno Leitao <leitao@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

  parent reply	other threads:[~2018-10-31  9:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-23 20:23 [PATCH 1/2] selftests/powerpc: Allocate base registers Breno Leitao
2018-10-23 20:23 ` [PATCH 2/2] selftests/powerpc: Skip test instead of failing Breno Leitao
2018-10-23 20:41   ` Tyrel Datwyler
2018-10-24 14:11     ` Breno Leitao
2018-10-29 22:08       ` Thiago Jung Bauermann
2018-10-30 15:16         ` Michael Ellerman
2018-10-31  0:09           ` Tyrel Datwyler
2018-10-31  9:42             ` Michael Ellerman
2018-10-31  9:41     ` Michael Ellerman [this message]
2018-10-23 21:39 ` [PATCH 1/2] selftests/powerpc: Allocate base registers Segher Boessenkool

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lg6eihbg.fsf@concordia.ellerman.id.au \
    --to=mpe@ellerman.id.au \
    --cc=bauerman@linux.ibm.com \
    --cc=leitao@debian.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=tyreld@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.