diff mbox

Update elf tests to use the support test driver.

Message ID 20170329151407.6476-1-wainersm@linux.vnet.ibm.com
State Superseded
Headers show

Commit Message

Wainer dos Santos Moschetta March 29, 2017, 3:14 p.m. UTC
Replaced test-skeleton.c with support/test-driver.c and
adjusted the tests accordinly.

Checked on x86_64.

2017-03-28  Wainer dos Santos Moschetta  <wainersm@linux.vnet.ibm.com>

	* elf/next.c: Import support/test-driver.c instead of
	test-skeleton.c and delete TEST_FUNCTION macro definition.
	(do_test): adjust return attribute.
	* elf/nodelete.c: Likewise.
	* elf/order2.c: Likewise.
	* elf/tst-_dl_addr_inside_object.c: Likewise.
	* elf/tst-addr1.c: Likewise.
	* elf/tst-align.c: Likewise.
	* elf/tst-align2.c: Likewise.
	* elf/tst-audit11.c: Likewise.
	* elf/tst-audit12.c: Likewise.
	* elf/tst-audit2.c: Likewise.
	* elf/tst-audit9.c: Likewise.
	* elf/tst-auxv.c: Likewise and define
	TEST_FUNCTION_ARGV macro.
	* elf/tst-deep1.c: Likewise.
	* elf/tst-dl-iter-static.c: Likewise.
	* elf/tst-dlmodcount.c: Likewise.
	* elf/tst-dlmopen1.c: Likewise.
	* elf/tst-dlmopen2.c: Likewise.
	* elf/tst-dlmopen3.c: Likewise.
	* elf/tst-dlopen-aout.c: Likewise.
	* elf/tst-dlopenrpath.c: Likewise.
	* elf/tst-dlsym-error.c: Likewise.
	* elf/tst-execstack-needed.c: Likewise.
	* elf/tst-execstack-prog.c: Likewise.
	* elf/tst-execstack.c: Likewise.
	* elf/tst-global1.c: Likewise.
	* elf/tst-gnu2-tls1.c: Likewise.
	* elf/tst-latepthread.c: Likewise.
	* elf/tst-leaks1.c: Likewise.
	* elf/tst-linkall-static.c: Likewise.
	(do_test): New function.
	* elf/tst-nodelete-opened.c: Likewise.
	* elf/tst-nodelete.cc: Likewise.
	* elf/tst-nodelete2.c: Likewise.
	* elf/tst-noload.c: Likewise.
	* elf/tst-null-argv.c: Likewise and define
	TEST_FUNCTION_ARGV marcro.
	* elf/tst-order-main.c: Likewise.
	* elf/tst-pathopt.c: Likewise.
	* elf/tst-pie2.c: Likewise.
	* elf/tst-piemod1.c: Likewise.
	* elf/tst-prelink.c: Likewise.
	* elf/tst-protected1a.c: Likewise.
	* elf/tst-protected1b.c: Likewise.
	* elf/tst-ptrguard1.c: Likewise, import getopt.h,
	and define _GNU_SOURCE macro.
	(cmdline_process_function): New function.
	* elf/tst-relsort1.c: Likewise.
	* elf/tst-stackguard1.c: Likewise, import getopt.h,
	and define _GNU_SOURCE macro.
	(cmdline_process_function): New function.
	* elf/tst-thrlock.c: Likewise.
	* elf/tst-tls-dlinfo.c: Likewise.
	* elf/tst-tls-manydynamic.c: Likewise and import
	support/xthread.h.
	* elf/tst-tls1.c: Likewise.
	* elf/tst-tls10.c: Likewise.
	* elf/tst-tls11.c: Likewise.
	* elf/tst-tls12.c: Likewise.
	* elf/tst-tls13.c: Likewise.
	* elf/tst-tls14.c: Likewise.
	* elf/tst-tls15.c: Likewise.
	* elf/tst-tls16.c: Likewise.
	* elf/tst-tls17.c: Likewise.
	* elf/tst-tls18.c: Likewise.
	* elf/tst-tls19.c: Likewise.
	* elf/tst-tls2.c: Likewise.
	* elf/tst-tls3.c: Likewise.
	* elf/tst-tls4.c: Likewise.
	* elf/tst-tls5.c: Likewise.
	* elf/tst-tls6.c: Likewise.
	* elf/tst-tls7.c: Likewise.
	* elf/tst-tls8.c: Likewise.
	* elf/tst-tls9.c: Likewise.
	* elf/tst-tlsalign-extern.c: Likewise.
	* elf/tst-tlsalign.c: Likewise.
	* elf/tst-unique1.c: Likewise.
	* elf/tst-unique2.c: Likewise.
	* elf/vismain.c: Likewise.
---
 elf/next.c                       |  5 ++---
 elf/nodelete.c                   |  5 ++---
 elf/order2.c                     |  5 ++---
 elf/tst-_dl_addr_inside_object.c |  5 ++---
 elf/tst-addr1.c                  |  5 ++---
 elf/tst-align.c                  |  5 ++---
 elf/tst-align2.c                 |  5 ++---
 elf/tst-audit11.c                |  3 +--
 elf/tst-audit12.c                |  3 +--
 elf/tst-audit2.c                 |  5 ++---
 elf/tst-audit9.c                 |  5 ++---
 elf/tst-auxv.c                   |  5 +++--
 elf/tst-deep1.c                  |  5 ++---
 elf/tst-dl-iter-static.c         |  5 ++---
 elf/tst-dlmodcount.c             |  5 ++---
 elf/tst-dlmopen1.c               |  5 ++---
 elf/tst-dlmopen2.c               |  5 ++---
 elf/tst-dlmopen3.c               |  5 ++---
 elf/tst-dlopen-aout.c            |  2 +-
 elf/tst-dlopenrpath.c            |  5 ++---
 elf/tst-dlsym-error.c            |  5 ++---
 elf/tst-execstack-needed.c       |  6 ++----
 elf/tst-execstack-prog.c         |  6 ++----
 elf/tst-execstack.c              |  5 ++---
 elf/tst-global1.c                |  5 ++---
 elf/tst-gnu2-tls1.c              |  5 ++---
 elf/tst-latepthread.c            |  5 ++---
 elf/tst-leaks1.c                 |  5 ++---
 elf/tst-linkall-static.c         | 11 ++++++++---
 elf/tst-nodelete-opened.c        |  3 +--
 elf/tst-nodelete.cc              |  5 ++---
 elf/tst-nodelete2.c              |  5 ++---
 elf/tst-noload.c                 |  5 ++---
 elf/tst-null-argv.c              |  3 ++-
 elf/tst-order-main.c             |  5 ++---
 elf/tst-pathopt.c                |  5 ++---
 elf/tst-pie2.c                   |  5 ++---
 elf/tst-piemod1.c                |  5 ++---
 elf/tst-prelink.c                |  5 ++---
 elf/tst-protected1a.c            |  4 +---
 elf/tst-protected1b.c            |  4 +---
 elf/tst-ptrguard1.c              | 35 +++++++++++++++++++++++++----------
 elf/tst-relsort1.c               |  5 ++---
 elf/tst-stackguard1.c            | 29 +++++++++++++++++++----------
 elf/tst-thrlock.c                |  5 ++---
 elf/tst-tls-dlinfo.c             |  5 ++---
 elf/tst-tls-manydynamic.c        |  9 +++++----
 elf/tst-tls1.c                   |  5 ++---
 elf/tst-tls10.c                  |  3 +--
 elf/tst-tls11.c                  |  5 ++---
 elf/tst-tls12.c                  |  5 ++---
 elf/tst-tls13.c                  |  5 ++---
 elf/tst-tls14.c                  |  5 ++---
 elf/tst-tls15.c                  |  5 ++---
 elf/tst-tls16.c                  |  5 ++---
 elf/tst-tls17.c                  |  5 ++---
 elf/tst-tls18.c                  |  5 ++---
 elf/tst-tls19.c                  |  5 ++---
 elf/tst-tls2.c                   |  5 ++---
 elf/tst-tls3.c                   |  5 ++---
 elf/tst-tls4.c                   |  5 ++---
 elf/tst-tls5.c                   |  5 ++---
 elf/tst-tls6.c                   |  5 ++---
 elf/tst-tls7.c                   |  5 ++---
 elf/tst-tls8.c                   |  6 ++----
 elf/tst-tls9.c                   |  5 ++---
 elf/tst-tlsalign-extern.c        |  5 ++---
 elf/tst-tlsalign.c               |  5 ++---
 elf/tst-unique1.c                |  5 ++---
 elf/tst-unique2.c                |  5 ++---
 elf/vismain.c                    |  3 +--
 71 files changed, 184 insertions(+), 221 deletions(-)

Comments

Adhemerval Zanella March 30, 2017, 8:52 p.m. UTC | #1
LGTM with just a comment:

On 29/03/2017 12:14, Wainer dos Santos Moschetta wrote:
> Replaced test-skeleton.c with support/test-driver.c and
> adjusted the tests accordinly.
> 
> Checked on x86_64.
> 
> diff --git a/elf/next.c b/elf/next.c
> index 6a3670c..3a7dba9 100644
> --- a/elf/next.c
> +++ b/elf/next.c
> @@ -5,7 +5,7 @@ extern int successful_rtld_next_test (void);
>  extern void *failing_rtld_next_use (void);
>  
>  
> -static int
> +int
>  do_test (void)
>  {
>    int result;
> @@ -40,5 +40,4 @@ do_test (void)
>    return result;
>  }

There is no need to remove the static definition from this function and
for all other every tests which includes the test-driver.c (since it will
end up creating the main entrypoint anyway). I would avoid change it.
Florian Weimer March 30, 2017, 8:55 p.m. UTC | #2
* Adhemerval Zanella:

> There is no need to remove the static definition from this function and
> for all other every tests which includes the test-driver.c (since it will
> end up creating the main entrypoint anyway). I would avoid change it.

Agreed.  The corresponding ChangeLog bit looks a bit strange as well:

	* elf/next.c: Import support/test-driver.c instead of
	test-skeleton.c and delete TEST_FUNCTION macro definition.
	(do_test): adjust return attribute.
	* elf/nodelete.c: Likewise.

I don't think any function attribute is changed in the patch.
Adhemerval Zanella March 30, 2017, 9 p.m. UTC | #3
On 30/03/2017 17:55, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> There is no need to remove the static definition from this function and
>> for all other every tests which includes the test-driver.c (since it will
>> end up creating the main entrypoint anyway). I would avoid change it.
> 
> Agreed.  The corresponding ChangeLog bit looks a bit strange as well:
> 
> 	* elf/next.c: Import support/test-driver.c instead of
> 	test-skeleton.c and delete TEST_FUNCTION macro definition.
> 	(do_test): adjust return attribute.
> 	* elf/nodelete.c: Likewise.
> 
> I don't think any function attribute is changed in the patch.
> 

Also, if you have time I would ask you if you can update the Testing
wiki page onthe 'Writing a test case' [1]. It would be good to just
have it aligned with current practices.

[1] https://sourceware.org/glibc/wiki/Testing/Testsuite.
Florian Weimer March 30, 2017, 9:01 p.m. UTC | #4
* Adhemerval Zanella:

> Also, if you have time I would ask you if you can update the Testing
> wiki page onthe 'Writing a test case' [1]. It would be good to just
> have it aligned with current practices.
>
> [1] https://sourceware.org/glibc/wiki/Testing/Testsuite.

I've made a note.  I didn't know this page existed.
Wainer dos Santos Moschetta March 31, 2017, 8:52 p.m. UTC | #5
On 03/30/2017 05:55 PM, Florian Weimer wrote:
> * Adhemerval Zanella:
>
>> There is no need to remove the static definition from this function and
>> for all other every tests which includes the test-driver.c (since it will
>> end up creating the main entrypoint anyway). I would avoid change it.
> Agreed.  The corresponding ChangeLog bit looks a bit strange as well:
>
> 	* elf/next.c: Import support/test-driver.c instead of
> 	test-skeleton.c and delete TEST_FUNCTION macro definition.
> 	(do_test): adjust return attribute.
> 	* elf/nodelete.c: Likewise.
>
> I don't think any function attribute is changed in the patch.
>
Thanks for the review, I will send a v2 patch soon.

Side note: the original tst-tls-manydynamic.c code uses xpthread_* functions. So I had to include support/xthread.h to avoid its breakage. In test-skeleton.c you can see the following:

#ifdef _PTHREAD_H
# include <support/xthread.h>
#endif  /* _PTHREAD_H */

So I'm considering to add this same block in test-driver.c since it will ease the migration of tests that use xpthread_*. Any objection to this change?
Florian Weimer April 1, 2017, 6:58 a.m. UTC | #6
* Wainer dos Santos Moschetta:

> Side note: the original tst-tls-manydynamic.c code uses xpthread_*
> functions. So I had to include support/xthread.h to avoid its
> breakage. In test-skeleton.c you can see the following:
>
> #ifdef _PTHREAD_H
> # include <support/xthread.h>
> #endif  /* _PTHREAD_H */
>
> So I'm considering to add this same block in test-driver.c since it
> will ease the migration of tests that use xpthread_*. Any objection to
> this change?

#include <support/test-driver.c> really should remain at the end of
the file, so adding this preprocessor conditional to
support/test-driver.c will not have the desired effect.  Please add
the #include directive to the beginning of the file.

And I think less magic is generally better.
Zack Weinberg April 1, 2017, 1:58 p.m. UTC | #7
On Fri, Mar 31, 2017 at 4:52 PM, Wainer dos Santos Moschetta
<wainersm@linux.vnet.ibm.com> wrote:
>
> Side note: the original tst-tls-manydynamic.c code uses xpthread_* functions.
> So I had to include support/xthread.h to avoid its breakage.

This is part of the cost of the change, yes.

> In test-skeleton.c you can see the following:
>
> #ifdef _PTHREAD_H
> # include <support/xthread.h>
> #endif  /* _PTHREAD_H */

This is an example of the implicit magic behavior that we are trying
to get away from with this change.  Please don't add it to the new
test driver.

zw
diff mbox

Patch

diff --git a/elf/next.c b/elf/next.c
index 6a3670c..3a7dba9 100644
--- a/elf/next.c
+++ b/elf/next.c
@@ -5,7 +5,7 @@  extern int successful_rtld_next_test (void);
 extern void *failing_rtld_next_use (void);
 
 
-static int
+int
 do_test (void)
 {
   int result;
@@ -40,5 +40,4 @@  do_test (void)
   return result;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/nodelete.c b/elf/nodelete.c
index 78364a2..475af13 100644
--- a/elf/nodelete.c
+++ b/elf/nodelete.c
@@ -18,8 +18,7 @@  handler (int sig)
 }
 
 
-#define TEST_FUNCTION do_test ()
-static int
+int
 do_test (void)
 {
   /* We are testing the two possibilities to mark an object as not deletable:
@@ -208,4 +207,4 @@  do_test (void)
   return result;
 }
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/order2.c b/elf/order2.c
index 3dbfdd1..f81e79e 100644
--- a/elf/order2.c
+++ b/elf/order2.c
@@ -4,7 +4,7 @@ 
 
 int call_puts;
 
-static int
+int
 do_test (void)
 {
   call_puts = 1;
@@ -34,8 +34,7 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
 
 static void
 __attribute__ ((destructor))
diff --git a/elf/tst-_dl_addr_inside_object.c b/elf/tst-_dl_addr_inside_object.c
index 3def22a..86c1d53 100644
--- a/elf/tst-_dl_addr_inside_object.c
+++ b/elf/tst-_dl_addr_inside_object.c
@@ -25,7 +25,7 @@ 
 extern int internal_function _dl_addr_inside_object (struct link_map *l,
 						     const ElfW(Addr) addr);
 
-static int
+int
 do_test (void)
 {
   int ret, err = 0;
@@ -219,5 +219,4 @@  do_test (void)
   return err;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-addr1.c b/elf/tst-addr1.c
index 637906e..a36186e 100644
--- a/elf/tst-addr1.c
+++ b/elf/tst-addr1.c
@@ -2,7 +2,7 @@ 
 #include <stdio.h>
 #include <string.h>
 
-static int
+int
 do_test (void)
 {
   Dl_info i;
@@ -22,5 +22,4 @@  do_test (void)
 	     && strcmp (i.dli_sname, "_IO_printf") != 0);
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-align.c b/elf/tst-align.c
index 4c14a3d..1bc7c1f 100644
--- a/elf/tst-align.c
+++ b/elf/tst-align.c
@@ -20,7 +20,7 @@ 
 #include <stdio.h>
 #include <stdlib.h>
 
-static int
+int
 do_test (void)
 {
   static const char modname[] = "tst-alignmod.so";
@@ -49,5 +49,4 @@  do_test (void)
   return result;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-align2.c b/elf/tst-align2.c
index eeae609..1eaa02e 100644
--- a/elf/tst-align2.c
+++ b/elf/tst-align2.c
@@ -43,7 +43,7 @@  static void __attribute__ ((destructor)) des (void)
   write (fds[1], &c, 1);
 }
 
-static int
+int
 do_test (void)
 {
   if (!res)
@@ -152,5 +152,4 @@  do_test (void)
   return result;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-audit11.c b/elf/tst-audit11.c
index c65301d..ff91a6b 100644
--- a/elf/tst-audit11.c
+++ b/elf/tst-audit11.c
@@ -32,5 +32,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-audit12.c b/elf/tst-audit12.c
index 4e9e63c..62ac5f2 100644
--- a/elf/tst-audit12.c
+++ b/elf/tst-audit12.c
@@ -45,5 +45,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-audit2.c b/elf/tst-audit2.c
index 1d69cd6..fbc4043 100644
--- a/elf/tst-audit2.c
+++ b/elf/tst-audit2.c
@@ -40,7 +40,7 @@  calloc (size_t n, size_t m)
   return ptr;
 }
 
-static int
+int
 do_test (void)
 {
   /* Make sure that our calloc is called from the dynamic linker at least
@@ -57,5 +57,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-audit9.c b/elf/tst-audit9.c
index 7b90a5a..230738c 100644
--- a/elf/tst-audit9.c
+++ b/elf/tst-audit9.c
@@ -1,6 +1,6 @@ 
 #include <dlfcn.h>
 
-static int
+int
 do_test (void)
 {
   void *h = dlopen("$ORIGIN/tst-auditmod9b.so", RTLD_LAZY);
@@ -8,5 +8,4 @@  do_test (void)
   return fp() - 1;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-auxv.c b/elf/tst-auxv.c
index d2661d9..cbaca8a 100644
--- a/elf/tst-auxv.c
+++ b/elf/tst-auxv.c
@@ -23,7 +23,7 @@ 
 #include <unistd.h>
 #include <misc/sys/auxv.h>
 
-static int
+int
 do_test (int argc, char *argv[])
 {
   errno = 0;
@@ -66,4 +66,5 @@  do_test (int argc, char *argv[])
   return 0;
 }
 
-#include "../test-skeleton.c"
+#define TEST_FUNCTION_ARGV do_test
+#include <support/test-driver.c>
diff --git a/elf/tst-deep1.c b/elf/tst-deep1.c
index 5428d13..eb441b2 100644
--- a/elf/tst-deep1.c
+++ b/elf/tst-deep1.c
@@ -17,7 +17,7 @@  back (void)
 
 extern int foo (void);
 
-static int
+int
 do_test (void)
 {
   void *p = dlopen ("$ORIGIN/tst-deep1mod2.so", RTLD_LAZY|RTLD_DEEPBIND);
@@ -32,5 +32,4 @@  do_test (void)
   return foo () + f ();
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-dl-iter-static.c b/elf/tst-dl-iter-static.c
index 47de698..32bc1a8 100644
--- a/elf/tst-dl-iter-static.c
+++ b/elf/tst-dl-iter-static.c
@@ -32,7 +32,7 @@  callback (struct dl_phdr_info *info, size_t size, void *data)
   return 0;
 }
 
-static int
+int
 do_test (void)
 {
   int count = 0;
@@ -43,5 +43,4 @@  do_test (void)
   return status || count != 1;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-dlmodcount.c b/elf/tst-dlmodcount.c
index 76bae85..da768d1 100644
--- a/elf/tst-dlmodcount.c
+++ b/elf/tst-dlmodcount.c
@@ -92,7 +92,7 @@  unload (const char *path, void *handle)
   dl_iterate_phdr (callback, (void *)(intptr_t) REMOVE);
 }
 
-static int
+int
 do_test (void)
 {
   void *handle1, *handle2;
@@ -105,5 +105,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-dlmopen1.c b/elf/tst-dlmopen1.c
index 5a05891..4fb7865 100644
--- a/elf/tst-dlmopen1.c
+++ b/elf/tst-dlmopen1.c
@@ -4,7 +4,7 @@ 
 
 #define TEST_SO "$ORIGIN/tst-dlmopen1mod.so"
 
-static int
+int
 do_test (void)
 {
   void *h = dlopen (LIBC_SO, RTLD_LAZY|RTLD_NOLOAD);
@@ -77,5 +77,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-dlmopen2.c b/elf/tst-dlmopen2.c
index 0569997..b116549 100644
--- a/elf/tst-dlmopen2.c
+++ b/elf/tst-dlmopen2.c
@@ -5,7 +5,7 @@ 
 #include <ldsodefs.h>
 
 
-static int
+int
 do_test (void)
 {
   int result = 0;
@@ -66,5 +66,4 @@  round %d, namespace %d: duplicate allocate of namespace %ld",
   return result;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-dlmopen3.c b/elf/tst-dlmopen3.c
index 26c86b2..aab5c16 100644
--- a/elf/tst-dlmopen3.c
+++ b/elf/tst-dlmopen3.c
@@ -2,7 +2,7 @@ 
 #include <stdio.h>
 
 
-static int
+int
 do_test (void)
 {
   void *h = dlmopen (LM_ID_NEWLM, "$ORIGIN/tst-dlmopen1mod.so", RTLD_LAZY);
@@ -18,5 +18,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-dlopen-aout.c b/elf/tst-dlopen-aout.c
index d780f8c..34a1cdb 100644
--- a/elf/tst-dlopen-aout.c
+++ b/elf/tst-dlopen-aout.c
@@ -64,4 +64,4 @@  do_test (int argc, char *argv[])
 }
 
 #define TEST_FUNCTION do_test (argc, argv)
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-dlopenrpath.c b/elf/tst-dlopenrpath.c
index ac72a1e..a054bd4 100644
--- a/elf/tst-dlopenrpath.c
+++ b/elf/tst-dlopenrpath.c
@@ -29,7 +29,7 @@  extern int foo (void);
 static const char testsubdir[] = PFX "test-subdir";
 
 
-static int
+int
 do_test (void)
 {
   struct stat64 st;
@@ -67,5 +67,4 @@  do_test (void)
   return result;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-dlsym-error.c b/elf/tst-dlsym-error.c
index 22dcff4..947d2ce 100644
--- a/elf/tst-dlsym-error.c
+++ b/elf/tst-dlsym-error.c
@@ -97,7 +97,7 @@  dlvsym_glibc_private (void *handle, const char *name)
   return dlvsym (handle, name, "GLIBC_PRIVATE");
 }
 
-static int
+int
 do_test (void)
 {
   test_handles ("dlsym", dlsym, "");
@@ -110,5 +110,4 @@  do_test (void)
 }
 
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-execstack-needed.c b/elf/tst-execstack-needed.c
index 03090f7..ae45cd7 100644
--- a/elf/tst-execstack-needed.c
+++ b/elf/tst-execstack-needed.c
@@ -11,7 +11,7 @@  extern void tryme (void);	/* from tst-execstack-mod.so */
 
 static void deeper (void (*f) (void));
 
-static int
+int
 do_test (void)
 {
   tryme ();
@@ -31,6 +31,4 @@  deeper (void (*f) (void))
   memfrob (stack, sizeof stack);
 }
 
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-execstack-prog.c b/elf/tst-execstack-prog.c
index 5a66d63..1a1547e 100644
--- a/elf/tst-execstack-prog.c
+++ b/elf/tst-execstack-prog.c
@@ -10,7 +10,7 @@ 
 
 static void deeper (void (*f) (void));
 
-static int
+int
 do_test (void)
 {
   tryme ();
@@ -30,6 +30,4 @@  deeper (void (*f) (void))
   memfrob (stack, sizeof stack);
 }
 
-
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-execstack.c b/elf/tst-execstack.c
index 02cc270..fc44332 100644
--- a/elf/tst-execstack.c
+++ b/elf/tst-execstack.c
@@ -50,7 +50,7 @@  waiter_thread (void *arg)
 static bool allow_execstack = true;
 
 
-static int
+int
 do_test (void)
 {
   /* Check whether SELinux is enabled and disallows executable stacks.  */
@@ -233,5 +233,4 @@  deeper (void (*f) (void))
 }
 
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-global1.c b/elf/tst-global1.c
index 4df335c..c7d5ca7 100644
--- a/elf/tst-global1.c
+++ b/elf/tst-global1.c
@@ -1,7 +1,7 @@ 
 #include <dlfcn.h>
 #include <stdio.h>
 
-static int
+int
 do_test (void)
 {
   void *h1 = dlopen ("$ORIGIN/testobj6.so", RTLD_GLOBAL|RTLD_LAZY);
@@ -35,5 +35,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-gnu2-tls1.c b/elf/tst-gnu2-tls1.c
index 8acbfa6..40d410b 100644
--- a/elf/tst-gnu2-tls1.c
+++ b/elf/tst-gnu2-tls1.c
@@ -28,7 +28,7 @@  extern int test_ld (int);
 
 __thread int gd = 1;
 
-static int
+int
 do_test (void)
 {
   int *p;
@@ -48,5 +48,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-latepthread.c b/elf/tst-latepthread.c
index a0a55e4..0de6cbe 100644
--- a/elf/tst-latepthread.c
+++ b/elf/tst-latepthread.c
@@ -23,7 +23,7 @@ 
 #include <sys/wait.h>
 #include <unistd.h>
 
-static int
+int
 do_test (void)
 {
   void *handle = dlopen ("tst-latepthreadmod.so", RTLD_LOCAL | RTLD_LAZY);
@@ -101,5 +101,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-leaks1.c b/elf/tst-leaks1.c
index dcff28d..0bab4ff 100644
--- a/elf/tst-leaks1.c
+++ b/elf/tst-leaks1.c
@@ -3,7 +3,7 @@ 
 #include <mcheck.h>
 #include <stdlib.h>
 
-static int
+int
 do_test (void)
 {
   mtrace ();
@@ -24,5 +24,4 @@  do_test (void)
   return ret;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-linkall-static.c b/elf/tst-linkall-static.c
index 964cd7a..449be7c 100644
--- a/elf/tst-linkall-static.c
+++ b/elf/tst-linkall-static.c
@@ -42,6 +42,11 @@  void *references[] =
     &getaddrinfo_a,             /* libanl */
   };
 
-/* This is a link-time test.  There is nothing to run here.  */
-#define TEST_FUNCTION 0
-#include "../test-skeleton.c"
+int
+do_test (void)
+{
+  /* This is a link-time test.  There is nothing to run here.  */
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/elf/tst-nodelete-opened.c b/elf/tst-nodelete-opened.c
index 9db49da..d71efa4 100644
--- a/elf/tst-nodelete-opened.c
+++ b/elf/tst-nodelete-opened.c
@@ -65,5 +65,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-nodelete.cc b/elf/tst-nodelete.cc
index 176cb68..79c31ad 100644
--- a/elf/tst-nodelete.cc
+++ b/elf/tst-nodelete.cc
@@ -2,7 +2,7 @@ 
 #include <stdio.h>
 #include <stdlib.h>
 
-static int
+int
 do_test (void)
 {
   int result = 0;
@@ -47,5 +47,4 @@  do_test (void)
   return result;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-nodelete2.c b/elf/tst-nodelete2.c
index 388e8af..9b9cf27 100644
--- a/elf/tst-nodelete2.c
+++ b/elf/tst-nodelete2.c
@@ -3,7 +3,7 @@ 
 #include <stdlib.h>
 #include <gnu/lib-names.h>
 
-static int
+int
 do_test (void)
 {
   int result = 0;
@@ -33,5 +33,4 @@  do_test (void)
   return result;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-noload.c b/elf/tst-noload.c
index fd1e273..dce6f4b 100644
--- a/elf/tst-noload.c
+++ b/elf/tst-noload.c
@@ -21,7 +21,7 @@ 
 #include <stdio.h>
 #include <gnu/lib-names.h>
 
-static int
+int
 do_test (void)
 {
   /* Test that no object is loaded with RTLD_NOLOAD.  */
@@ -69,5 +69,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-null-argv.c b/elf/tst-null-argv.c
index caf76aa..21b8732 100644
--- a/elf/tst-null-argv.c
+++ b/elf/tst-null-argv.c
@@ -32,4 +32,5 @@  do_test (int argc, char **argv)
   return 0;
 }
 
-#include <test-skeleton.c>
+#define TEST_FUNCTION_ARGV do_test
+#include <support/test-driver.c>
diff --git a/elf/tst-order-main.c b/elf/tst-order-main.c
index 339778a..3e28063 100644
--- a/elf/tst-order-main.c
+++ b/elf/tst-order-main.c
@@ -2,12 +2,11 @@ 
 #include <unistd.h>
 #include <stdlib.h>
 
-static int
+int
 do_test (void)
 {
   printf( "main\n" );
   exit(EXIT_SUCCESS);
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-pathopt.c b/elf/tst-pathopt.c
index 8d73ad4..0f12f2c 100644
--- a/elf/tst-pathopt.c
+++ b/elf/tst-pathopt.c
@@ -4,7 +4,7 @@ 
 #include <stdlib.h>
 
 
-static int
+int
 do_test (void)
 {
   void *h;
@@ -38,5 +38,4 @@  do_test (void)
   return result;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-pie2.c b/elf/tst-pie2.c
index bf11662..668e2bb 100644
--- a/elf/tst-pie2.c
+++ b/elf/tst-pie2.c
@@ -31,11 +31,10 @@  init_g (void)
   g += 1;
 }
 
-static int
+int
 do_test (void)
 {
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-piemod1.c b/elf/tst-piemod1.c
index 6e98b5f..ca00121 100644
--- a/elf/tst-piemod1.c
+++ b/elf/tst-piemod1.c
@@ -6,7 +6,7 @@  foo (void)
   return 21;
 }
 
-static int
+int
 do_test (void)
 {
   int val = foo ();
@@ -19,5 +19,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-prelink.c b/elf/tst-prelink.c
index 6a782ed..9047d2e 100644
--- a/elf/tst-prelink.c
+++ b/elf/tst-prelink.c
@@ -19,12 +19,11 @@ 
 
 #include <stdio.h>
 
-static int
+int
 do_test (void)
 {
   fprintf (stdout, "hello\n");
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-protected1a.c b/elf/tst-protected1a.c
index 3730357..4267b95 100644
--- a/elf/tst-protected1a.c
+++ b/elf/tst-protected1a.c
@@ -40,10 +40,8 @@  extern int do_test (void);
 
 int protected2 = -1;
 
-#define TEST_FUNCTION do_test ()
-
 /* This defines the `main' function and some more.  */
-#include <test-skeleton.c>
+#include <support/test-driver.c>
 
 int
 do_test (void)
diff --git a/elf/tst-protected1b.c b/elf/tst-protected1b.c
index 95f2c47..9fd695b 100644
--- a/elf/tst-protected1b.c
+++ b/elf/tst-protected1b.c
@@ -40,10 +40,8 @@  extern int do_test (void);
 
 int protected2 = -1;
 
-#define TEST_FUNCTION do_test ()
-
 /* This defines the `main' function and some more.  */
-#include <test-skeleton.c>
+#include <support/test-driver.c>
 
 int
 do_test (void)
diff --git a/elf/tst-ptrguard1.c b/elf/tst-ptrguard1.c
index 91fbc79..358421c 100644
--- a/elf/tst-ptrguard1.c
+++ b/elf/tst-ptrguard1.c
@@ -25,6 +25,12 @@ 
 #include <tls.h>
 #include <unistd.h>
 
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+/* Requires _GNU_SOURCE  */
+#include <getopt.h>
+
 #ifndef POINTER_CHK_GUARD
 extern uintptr_t __pointer_chk_guard;
 # define POINTER_CHK_GUARD __pointer_chk_guard
@@ -53,7 +59,7 @@  uintptr_t_cmp (const void *a, const void *b)
   return 0;
 }
 
-static int
+int
 do_test (void)
 {
   if (!ptr_chk_guard_copy_set)
@@ -191,12 +197,21 @@  do_test (void)
 #define CMDLINE_OPTIONS	\
   { "command", required_argument, NULL, OPT_COMMAND },  \
   { "child", no_argument, NULL, OPT_CHILD },
-#define CMDLINE_PROCESS	\
-  case OPT_COMMAND:	\
-    command = optarg;	\
-    break;		\
-  case OPT_CHILD:	\
-    child = true;	\
-    break;
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+
+static void __attribute((used))
+cmdline_process_function (int c)
+{
+  switch (c)
+    {
+      case OPT_COMMAND:
+        command = optarg;
+        break;
+      case OPT_CHILD:
+        child = true;
+        break;
+    }
+}
+
+#define CMDLINE_PROCESS	cmdline_process_function
+
+#include <support/test-driver.c>
diff --git a/elf/tst-relsort1.c b/elf/tst-relsort1.c
index a87b138..93cbfdc 100644
--- a/elf/tst-relsort1.c
+++ b/elf/tst-relsort1.c
@@ -2,7 +2,7 @@ 
 #include <stdio.h>
 
 
-static int
+int
 do_test (void)
 {
   const char lib[] = "$ORIGIN/tst-relsort1mod1.so";
@@ -15,5 +15,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-stackguard1.c b/elf/tst-stackguard1.c
index a3f967b..299452c 100644
--- a/elf/tst-stackguard1.c
+++ b/elf/tst-stackguard1.c
@@ -17,6 +17,7 @@ 
    <http://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
+#include <getopt.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -49,7 +50,7 @@  uintptr_t_cmp (const void *a, const void *b)
   return 0;
 }
 
-static int
+int
 do_test (void)
 {
   if (!stack_chk_guard_copy_set)
@@ -185,12 +186,20 @@  do_test (void)
 #define CMDLINE_OPTIONS	\
   { "command", required_argument, NULL, OPT_COMMAND },  \
   { "child", no_argument, NULL, OPT_CHILD },
-#define CMDLINE_PROCESS	\
-  case OPT_COMMAND:	\
-    command = optarg;	\
-    break;		\
-  case OPT_CHILD:	\
-    child = true;	\
-    break;
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+
+static void __attribute__((used))
+cmdline_process_function (int c)
+{
+  switch (c)
+    {
+      case OPT_COMMAND:
+        command = optarg;
+        break;
+      case OPT_CHILD:
+        child = true;
+        break;
+    }
+}
+#define CMDLINE_PROCESS	cmdline_process_function
+
+#include <support/test-driver.c>
diff --git a/elf/tst-thrlock.c b/elf/tst-thrlock.c
index fe72eba..bd53c44 100644
--- a/elf/tst-thrlock.c
+++ b/elf/tst-thrlock.c
@@ -28,7 +28,7 @@  tf (void *arg)
 }
 
 
-static int
+int
 do_test (void)
 {
 #define N 10
@@ -55,5 +55,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls-dlinfo.c b/elf/tst-tls-dlinfo.c
index 28661b1..8532212 100644
--- a/elf/tst-tls-dlinfo.c
+++ b/elf/tst-tls-dlinfo.c
@@ -3,8 +3,7 @@ 
 #include <stdlib.h>
 
 
-#define TEST_FUNCTION do_test ()
-static int
+int
 do_test (void)
 {
   static const char modname[] = "tst-tlsmod2.so";
@@ -83,4 +82,4 @@  do_test (void)
 }
 
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls-manydynamic.c b/elf/tst-tls-manydynamic.c
index 49bb52c..cc98ac0 100644
--- a/elf/tst-tls-manydynamic.c
+++ b/elf/tst-tls-manydynamic.c
@@ -24,15 +24,16 @@ 
 
 #include "tst-tls-manydynamic.h"
 
+#include <errno.h>
 #include <dlfcn.h>
 #include <pthread.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 
-static int do_test (void);
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+int do_test (void);
+#include <support/xthread.h>
+#include <support/test-driver.c>
 
 void *handles[COUNT];
 set_value_func set_value_funcs[COUNT];
@@ -97,7 +98,7 @@  blocked_thread_func (void *closure)
   return NULL;
 }
 
-static int
+int
 do_test (void)
 {
   {
diff --git a/elf/tst-tls1.c b/elf/tst-tls1.c
index bec0a2f..fc0bc71 100644
--- a/elf/tst-tls1.c
+++ b/elf/tst-tls1.c
@@ -9,8 +9,7 @@  COMMON_INT_DEF(foo);
 COMMON_INT_DEF(bar);
 
 
-#define TEST_FUNCTION do_test ()
-static int
+int
 do_test (void)
 {
   int result = 0;
@@ -80,4 +79,4 @@  do_test (void)
 }
 
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls10.c b/elf/tst-tls10.c
index eb1ecb9..d9611aa 100644
--- a/elf/tst-tls10.c
+++ b/elf/tst-tls10.c
@@ -36,5 +36,4 @@  do_test (void)
   exit (0);
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls11.c b/elf/tst-tls11.c
index 8ceac14..1878904 100644
--- a/elf/tst-tls11.c
+++ b/elf/tst-tls11.c
@@ -5,7 +5,7 @@ 
   if (p->a != S || p->b != S + 1 || p->c != S + 2)	\
     abort ()
 
-static int
+int
 do_test (void)
 {
   struct A *p;
@@ -25,5 +25,4 @@  do_test (void)
   exit (0);
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls12.c b/elf/tst-tls12.c
index 8093894..2c93bf7 100644
--- a/elf/tst-tls12.c
+++ b/elf/tst-tls12.c
@@ -5,7 +5,7 @@ 
   if (p->a != S || p->b != S + 1 || p->c != S + 2)	\
     abort ()
 
-static int
+int
 do_test (void)
 {
   struct A *p;
@@ -16,5 +16,4 @@  do_test (void)
   exit (0);
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls13.c b/elf/tst-tls13.c
index 9af08cf..c288c11 100644
--- a/elf/tst-tls13.c
+++ b/elf/tst-tls13.c
@@ -5,7 +5,7 @@ 
 #include <unistd.h>
 
 
-static int
+int
 do_test (void)
 {
   for (int i = 0; i < 1000;)
@@ -25,5 +25,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls14.c b/elf/tst-tls14.c
index 6bacb59..8054e96 100644
--- a/elf/tst-tls14.c
+++ b/elf/tst-tls14.c
@@ -17,7 +17,7 @@  static struct foo g;
 extern int in_dso1 (void);
 
 
-static int
+int
 do_test (void)
 {
   int result = 0;
@@ -51,5 +51,4 @@  do_test (void)
   return result;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls15.c b/elf/tst-tls15.c
index d2e1f3d..7bca8da 100644
--- a/elf/tst-tls15.c
+++ b/elf/tst-tls15.c
@@ -2,7 +2,7 @@ 
 #include <stdlib.h>
 #include <stdio.h>
 
-static int
+int
 do_test (void)
 {
   void *h = dlopen ("tst-tlsmod15a.so", RTLD_NOW);
@@ -29,5 +29,4 @@  do_test (void)
   return fp ();
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls16.c b/elf/tst-tls16.c
index 347b2f5..2cdc53e 100644
--- a/elf/tst-tls16.c
+++ b/elf/tst-tls16.c
@@ -2,7 +2,7 @@ 
 #include <stdlib.h>
 #include <stdio.h>
 
-static int
+int
 do_test (void)
 {
   void *h = dlopen ("tst-tlsmod16a.so", RTLD_LAZY | RTLD_GLOBAL);
@@ -49,5 +49,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls17.c b/elf/tst-tls17.c
index 6dde974..cdf7d59 100644
--- a/elf/tst-tls17.c
+++ b/elf/tst-tls17.c
@@ -2,7 +2,7 @@ 
 #include <stdlib.h>
 #include <stdio.h>
 
-static int
+int
 do_test (void)
 {
   void *h = dlopen ("tst-tlsmod17b.so", RTLD_LAZY);
@@ -25,5 +25,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls18.c b/elf/tst-tls18.c
index ba4b800..3ca226c 100644
--- a/elf/tst-tls18.c
+++ b/elf/tst-tls18.c
@@ -2,7 +2,7 @@ 
 #include <stdlib.h>
 #include <stdio.h>
 
-static int
+int
 do_test (void)
 {
   char modname[sizeof "tst-tlsmod18aXX.so"];
@@ -34,5 +34,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls19.c b/elf/tst-tls19.c
index acbc1d6..9244b2c 100644
--- a/elf/tst-tls19.c
+++ b/elf/tst-tls19.c
@@ -3,7 +3,7 @@ 
 #include <dlfcn.h>
 
 
-static int
+int
 do_test (void)
 {
   void* dl = dlopen ("tst-tls19mod1.so", RTLD_LAZY | RTLD_GLOBAL);
@@ -23,5 +23,4 @@  do_test (void)
   return fn ();
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls2.c b/elf/tst-tls2.c
index d0b6d51..5abe524 100644
--- a/elf/tst-tls2.c
+++ b/elf/tst-tls2.c
@@ -9,8 +9,7 @@  VAR_INT_DEF(foo);
 VAR_INT_DEF(bar);
 
 
-#define TEST_FUNCTION do_test ()
-static int
+int
 do_test (void)
 {
   int result = 0;
@@ -80,4 +79,4 @@  do_test (void)
 }
 
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls3.c b/elf/tst-tls3.c
index ca96c6a..e8603db 100644
--- a/elf/tst-tls3.c
+++ b/elf/tst-tls3.c
@@ -13,8 +13,7 @@  VAR_INT_DEF(baz);
 extern int in_dso (void);
 
 
-#define TEST_FUNCTION do_test ()
-static int
+int
 do_test (void)
 {
   int result = 0;
@@ -65,4 +64,4 @@  do_test (void)
 }
 
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls4.c b/elf/tst-tls4.c
index 63170c3..e4911c1 100644
--- a/elf/tst-tls4.c
+++ b/elf/tst-tls4.c
@@ -3,8 +3,7 @@ 
 #include <stdlib.h>
 
 
-#define TEST_FUNCTION do_test ()
-static int
+int
 do_test (void)
 {
   static const char modname[] = "tst-tlsmod2.so";
@@ -47,4 +46,4 @@  do_test (void)
 }
 
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls5.c b/elf/tst-tls5.c
index 76905c5..953477c 100644
--- a/elf/tst-tls5.c
+++ b/elf/tst-tls5.c
@@ -3,8 +3,7 @@ 
 #include <stdlib.h>
 
 
-#define TEST_FUNCTION do_test ()
-static int
+int
 do_test (void)
 {
   static const char modname[] = "tst-tlsmod2.so";
@@ -63,4 +62,4 @@  do_test (void)
 }
 
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls6.c b/elf/tst-tls6.c
index 9e6235f..a29a206 100644
--- a/elf/tst-tls6.c
+++ b/elf/tst-tls6.c
@@ -5,8 +5,7 @@ 
 #include <link.h>
 
 
-#define TEST_FUNCTION do_test ()
-static int
+int
 do_test (void)
 {
   static const char modname[] = "tst-tlsmod2.so";
@@ -82,4 +81,4 @@  do_test (void)
 }
 
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls7.c b/elf/tst-tls7.c
index 23a16e4..375b40c 100644
--- a/elf/tst-tls7.c
+++ b/elf/tst-tls7.c
@@ -5,8 +5,7 @@ 
 #include <link.h>
 
 
-#define TEST_FUNCTION do_test ()
-static int
+int
 do_test (void)
 {
   static const char modname[] = "tst-tlsmod3.so";
@@ -53,4 +52,4 @@  do_test (void)
 }
 
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls8.c b/elf/tst-tls8.c
index 4bf3e3f..5260c75 100644
--- a/elf/tst-tls8.c
+++ b/elf/tst-tls8.c
@@ -5,8 +5,7 @@ 
 #include <link.h>
 
 
-#define TEST_FUNCTION do_test ()
-static int
+int
 do_test (void)
 {
   static const char modname1[] = "$ORIGIN/tst-tlsmod3.so";
@@ -165,5 +164,4 @@  do_test (void)
   return result;
 }
 
-
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tls9.c b/elf/tst-tls9.c
index 6306fb5..6a98fc4 100644
--- a/elf/tst-tls9.c
+++ b/elf/tst-tls9.c
@@ -4,8 +4,7 @@ 
 
 #include <link.h>
 
-#define TEST_FUNCTION do_test ()
-static int
+int
 do_test (void)
 {
   static const char modname1[] = "tst-tlsmod5.so";
@@ -34,4 +33,4 @@  do_test (void)
 }
 
 
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tlsalign-extern.c b/elf/tst-tlsalign-extern.c
index 11659a3..a4f3062 100644
--- a/elf/tst-tlsalign-extern.c
+++ b/elf/tst-tlsalign-extern.c
@@ -54,7 +54,7 @@  test_one (const char *which, unsigned int alignment, int *var, int value)
   return misalign != 0;
 }
 
-static int
+int
 do_test (void)
 {
   int fail = 0;
@@ -70,5 +70,4 @@  do_test (void)
   return fail ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-tlsalign.c b/elf/tst-tlsalign.c
index bd82112..a0fc6fa 100644
--- a/elf/tst-tlsalign.c
+++ b/elf/tst-tlsalign.c
@@ -55,7 +55,7 @@  test_one (const char *which, unsigned int alignment, int *var, int value)
   return misalign != 0;
 }
 
-static int
+int
 do_test (void)
 {
   int fail = 0;
@@ -81,5 +81,4 @@  do_test (void)
   return fail ? EXIT_FAILURE : EXIT_SUCCESS;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-unique1.c b/elf/tst-unique1.c
index 17af6f1..e7d9916 100644
--- a/elf/tst-unique1.c
+++ b/elf/tst-unique1.c
@@ -3,7 +3,7 @@ 
 #include <stdio.h>
 #include <sys/mman.h>
 
-static int
+int
 do_test (void)
 {
   void *h1 = dlopen ("tst-unique1mod1.so", RTLD_LAZY);
@@ -70,5 +70,4 @@  do_test (void)
   return 0;
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/tst-unique2.c b/elf/tst-unique2.c
index 4426754..e19186e 100644
--- a/elf/tst-unique2.c
+++ b/elf/tst-unique2.c
@@ -4,7 +4,7 @@ 
 
 extern int var;
 
-static int
+int
 do_test (void)
 {
   var = 1;
@@ -24,5 +24,4 @@  do_test (void)
   return f (&var);
 }
 
-#define TEST_FUNCTION do_test ()
-#include "../test-skeleton.c"
+#include <support/test-driver.c>
diff --git a/elf/vismain.c b/elf/vismain.c
index d001023..43f1d8f 100644
--- a/elf/vismain.c
+++ b/elf/vismain.c
@@ -29,10 +29,9 @@ 
 /* Prototype for our test function.  */
 extern int do_test (void);
 
-#define TEST_FUNCTION do_test ()
 
 /* This defines the `main' function and some more.  */
-#include <test-skeleton.c>
+#include <support/test-driver.c>
 
 
 /* Prototypes for local functions.  */