automake-patches
[Top][All Lists]
Advanced

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

Re: [PATCH] Improvements and extend tests on canonicalization.


From: Ralf Wildenhues
Subject: Re: [PATCH] Improvements and extend tests on canonicalization.
Date: Thu, 16 Dec 2010 19:57:15 +0100
User-agent: Mutt/1.5.20 (2010-08-04)

* Stefano Lattarini wrote on Sat, Dec 11, 2010 at 06:41:46PM CET:
> Ping on this? Reference:
>  <http://lists.gnu.org/archive/html/automake-patches/2010-09/msg00106.html>
> 
> The updated patch is attached.  I will push it in 72 hours (by tuesday
> evening) unless there are objections.

> --- /dev/null
> +++ b/tests/canon7.test
> @@ -0,0 +1,93 @@

> +# Stress test on canonicalization.
[...]
> +cat > Makefile.am << 'END'
> +noinst_PROGRAMS = dummy_static dummy_dynamic ,foo-bar
> +noinst_LIBRARIES = libb.az+baz.a
> +noinst_LTLIBRARIES = lib~zardoz,,.la
> +
> +dummy_static_SOURCES = dummy.c lib.h
> +dummy_dynamic_SOURCES = $(dummy_static_SOURCES)
> +
> +dummy_static_LDADD = $(noinst_LIBRARIES)
> +dummy_dynamic_LDADD = $(noinst_LTLIBRARIES)
> +
> +_foo_bar_SOURCES = libs.c
> +libb_az_baz_a_SOURCES = libs.c
> +lib_zardoz___la_SOURCES = libd.c
> +
> +check-local:
> +     ls -l
> +     ./,foo-bar
> +     ./dummy_static
> +     ./dummy_dynamic
> +     ./,foo-bar | grep 'Hello, FooBar!'
> +     ./dummy_static | grep 'Hello from Static!'
> +     ./dummy_dynamic | grep 'Hello from Dynamic!'
> +END
> +
> +cat > foobar.c << 'END'
> +#include <stdio.h>
> +int main(void)
> +{
> +  printf("Hello, FooBar!\n");
> +  return 0;
> +}
> +END
> +
> +cat > dummy.c << 'END'
> +#include <stdio.h>
> +#include "lib.h"
> +int main(void)
> +{
> +  printf("Hello from %s!\n", dummy_func());
> +  return 0;
> +}
> +END
> +
> +echo 'char *dummy_func(void);' > lib.h
> +echo 'char *dummy_func(void) { return "Dynamic"; }' > libd.c
> +echo 'char *dummy_func(void) { return "Static"; }' > libs.c

I'm not sure how you tested this, but ',foo-bar' fails to link for me on
GNU/Linux (and supposedly everywhere else, lacking a 'main' symbol).
Also, the code passes pointers to read-only memory (literal strings) in
non-const pointers (literal strings may not be modifiable).  I'm pushing
the fix below.

Note that you're lucky using convenience archives here.  With shared
libraries, the const data would need special handling in order to work
on w32.  (See the Libtool documentation, git version, for details.)

Thanks,
Ralf

    Fix canon7.test failure.
    
    * tests/canon7.test (_foo_bar_SOURCES): Add foobar.c.
    (lib.h, libd.c, libs.c): Use const for constant strings.

diff --git a/tests/canon7.test b/tests/canon7.test
index 9b3d8d0..3f25d6f 100755
--- a/tests/canon7.test
+++ b/tests/canon7.test
@@ -43,7 +43,7 @@ dummy_dynamic_SOURCES = $(dummy_static_SOURCES)
 dummy_static_LDADD = $(noinst_LIBRARIES)
 dummy_dynamic_LDADD = $(noinst_LTLIBRARIES)
 
-_foo_bar_SOURCES = libs.c
+_foo_bar_SOURCES = libs.c foobar.c
 libb_az_baz_a_SOURCES = libs.c
 lib_zardoz___la_SOURCES = libd.c
 
@@ -76,9 +76,9 @@ int main(void)
 }
 END
 
-echo 'char *dummy_func(void);' > lib.h
-echo 'char *dummy_func(void) { return "Dynamic"; }' > libd.c
-echo 'char *dummy_func(void) { return "Static"; }' > libs.c
+echo 'const char *dummy_func(void);' > lib.h
+echo 'const char *dummy_func(void) { return "Dynamic"; }' > libd.c
+echo 'const char *dummy_func(void) { return "Static"; }' > libs.c
 
 libtoolize
 $ACLOCAL



reply via email to

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