[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 4/4] Add a test suite for the sethostname module

From: Ben Walton
Subject: Re: [PATCH 4/4] Add a test suite for the sethostname module
Date: Sun, 04 Dec 2011 11:14:54 -0500
User-agent: Sup/git

Excerpts from Bruno Haible's message of Sat Dec 03 08:50:37 -0500 2011:

Hi Bruno,

> > +#if !HAVE_GETEUID
> > +# define geteuid() ((uid_t) -1)
> > +#endif
> Wow! You have thought at many things. You did it better than if I had
> written this test.

I saw a similar trick somewhere else in gnulib (although I can't find
it now)....

In one of the subsequent tweaks to this test, you restored a space
between the function name and the emtpy () at the call site for
geteuid.  I realize I let some foo() slip through so it's
understandable that you were doing a bunch of corrections.  Will this
not break the use of the macro for platforms lacking geteuid though?

If so, the following patch should fix this.

>From 7b0c5cb00ba3a294ce1919fded4dab2816919c03 Mon Sep 17 00:00:00 2001
From: Ben Walton <address@hidden>
Date: Sun, 4 Dec 2011 10:54:31 -0500
Subject: [PATCH] Tweak test-sethostname2 to intentionally violate coding style

We must violate the coding style in test-sethostname2.c in order to
allow the preprocessor to substitute a value for geteuid() on
platforms that lack it.

Signed-off-by: Ben Walton <address@hidden>
 ChangeLog                 |    7 +++++++
 tests/test-sethostname2.c |    5 ++++-
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 0bd5d06..d9a38b1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2011-12-04  Ben Walton  <address@hidden>
+       sethostname tests: Intentionally violate style
+       * tests/set-sethostname2.c: If geteuid isn't defined, we rely on
+       the macro geteuid() being replaced by the preprocessor.  Remove
+       the space betwen function name and () so that this can happen.
 2011-12-04  Bruno Haible  <address@hidden>
        sethostname: Fix documentation.
diff --git a/tests/test-sethostname2.c b/tests/test-sethostname2.c
index 51f92ae..a791726 100644
--- a/tests/test-sethostname2.c
+++ b/tests/test-sethostname2.c
@@ -48,7 +48,10 @@ main (int argc, char *argv[] _GL_UNUSED)
      consider things like CAP_SYS_ADMIN (linux) or PRIV_SYS_ADMIN
      (solaris), etc.  systems without a working geteuid (mingw, MSVC
      9) will always skip this test. */
-  if (geteuid () != 0)
+  /* NOTE: the missing space between function name and () is
+     intentional here so that in the event geteuid is derived from the
+     macro above it will still work. */
+  if (geteuid() != 0)
       fprintf (stderr, "Skipping test: insufficient permissions.\n");
       return 77;

> Oops, that looks like a tab again.

I did install a .dir-locals.el on one system and forgot to copy it to
other places where I was testing this.  Would a .dir-locals.el (and
vim equivalent) file be something that might be included in the
project?  Something that defined the indentation and C style rules but
nothing else?  I suspect not, but I'm asking just in case.

Ben Walton
Systems Programmer - CHASS
University of Toronto
C:416.407.5610 | W:416.978.4302

reply via email to

[Prev in Thread] Current Thread [Next in Thread]