* [PATCH] grp: testgrp should exit unsupported properly.
@ 2017-04-12 21:01 Wainer dos Santos Moschetta
2017-04-20 11:56 ` Florian Weimer
0 siblings, 1 reply; 3+ messages in thread
From: Wainer dos Santos Moschetta @ 2017-04-12 21:01 UTC (permalink / raw)
To: libc-alpha; +Cc: Wainer dos Santos Moschetta
grp/testgrp should properly exit unsupported if getpweuid() returns
NULL and it does not set errno since it indicates that tests are
executed by a passwordless user.
Also refactor to use the support test driver.
Checked on x86_64-linux-gnu.
2017-04-13 Wainer dos Santos Moschetta <wainersm@gmail.com>
* grp/testgrp.c: Import support/test-driver.
(do_test): New, replace main().
(do_test): exit unsupported if getpwuid() returns NULL
and it does not set errno.
---
grp/testgrp.c | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/grp/testgrp.c b/grp/testgrp.c
index 892cfaa..38f6088 100644
--- a/grp/testgrp.c
+++ b/grp/testgrp.c
@@ -1,12 +1,14 @@
+#include <errno.h>
#include <grp.h>
#include <pwd.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
+#include <support/test-driver.h>
int
-main (int argc, char *argv[])
+do_test (void)
{
uid_t me;
struct passwd *my_passwd;
@@ -14,9 +16,21 @@ main (int argc, char *argv[])
char **members;
me = getuid ();
+ errno = 0;
my_passwd = getpwuid (me);
if (my_passwd == NULL)
- printf ("Cannot find user entry for UID %d\n", me);
+ {
+ if (errno == 0)
+ {
+ printf ("Cannot find user entry for UID %d\n", me);
+ return EXIT_UNSUPPORTED;
+ }
+ else
+ {
+ printf ("FAIL: getpwuid() exited with error: %m\n");
+ return EXIT_FAILURE;
+ }
+ }
else
{
printf ("My login name is %s.\n", my_passwd->pw_name);
@@ -39,3 +53,5 @@ main (int argc, char *argv[])
return my_passwd && my_group ? EXIT_SUCCESS : EXIT_FAILURE;
}
+
+#include <support/test-driver.c>
--
2.7.4
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] grp: testgrp should exit unsupported properly.
2017-04-12 21:01 [PATCH] grp: testgrp should exit unsupported properly Wainer dos Santos Moschetta
@ 2017-04-20 11:56 ` Florian Weimer
[not found] ` <d9428ac5-9895-e28c-3322-5bdb817638e5@gmail.com>
0 siblings, 1 reply; 3+ messages in thread
From: Florian Weimer @ 2017-04-20 11:56 UTC (permalink / raw)
To: Wainer dos Santos Moschetta, libc-alpha
On 04/12/2017 11:01 PM, Wainer dos Santos Moschetta wrote:
> grp/testgrp should properly exit unsupported if getpweuid() returns
> NULL and it does not set errno since it indicates that tests are
> executed by a passwordless user.
Shouldn't this be a regular FAIL? We should assume that the user
running the testsuite has a name.
Thanks,
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] grp: testgrp should exit unsupported properly.
[not found] ` <d9428ac5-9895-e28c-3322-5bdb817638e5@gmail.com>
@ 2017-04-20 13:40 ` Florian Weimer
0 siblings, 0 replies; 3+ messages in thread
From: Florian Weimer @ 2017-04-20 13:40 UTC (permalink / raw)
To: Wainer dos Santos Moschetta, libc-alpha
On 04/20/2017 03:26 PM, Wainer dos Santos Moschetta wrote:
> On 20-04-2017 08:56, Florian Weimer wrote:
>> On 04/12/2017 11:01 PM, Wainer dos Santos Moschetta wrote:
>>> grp/testgrp should properly exit unsupported if getpweuid() returns
>>> NULL and it does not set errno since it indicates that tests are
>>> executed by a passwordless user.
>>
>> Shouldn't this be a regular FAIL? We should assume that the user
>> running the testsuite has a name.
>
> Is there a consensus about FAIL vs UNSUPPORTED?
>
> In https://sourceware.org/glibc/wiki/Testing/Testsuite you read:
> "EXIT_UNSUPPORTEDfrom<support/test-driver.h>is a magic exit status (77)
> which indicates that the test is not supported on this particular system
> (perhaps due to lack of hardware or kernel support detected at run time).".
>
> But I tend to think a test should exit unsupported if the environment
> doesn't provide all requirements to execute the it properly.
>
> Giving a bit of context: I ran glibc's testsuite in an VM provided by a
> cloud provider, which access is granted through SSH keys. Other tests
> also exit FAIL due lack of user's password.
In your case, it's an environment issue. But I think what you are
proposing reduces the scope of the test itself, which is why I think
this change is not appropriate.
Thanks,
Florian
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-04-20 13:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-12 21:01 [PATCH] grp: testgrp should exit unsupported properly Wainer dos Santos Moschetta
2017-04-20 11:56 ` Florian Weimer
[not found] ` <d9428ac5-9895-e28c-3322-5bdb817638e5@gmail.com>
2017-04-20 13:40 ` Florian Weimer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).