automake
[Top][All Lists]
Advanced

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

Re: How do a copy a file?


From: Bob Proulx
Subject: Re: How do a copy a file?
Date: Thu, 17 Apr 2003 22:38:52 -0600
User-agent: Mutt/1.3.28i

Dr. David Kirkby wrote:
> I now have 3 lines.
> 
> 1) Does an ls, which reports the file does not exist.
> 2) Tries unsuccesfully to copy the file.
> 3) 'atlc' tries unsuccesfully to use the copied file.
> 4) Tries unsucessfully to report computer by the program 'atlc'
> 
> #! /bin/sh
> ls -l $top_srcdir/examples/undefined_permittivities.bmp
> cp $top_srcdir/examples/test-coupler1.bmp $top_builddir/tmp
> Zo=`$top_builddir/src/non_gui/atlc
> $top_builddir/tmp/undefined_permittivities.bmp`
> echo Zo = $Zo

You do an ls.  But since the copy failed you know the file really does
not exist.  Better to run ls on the directory of the ../../ so that
you can verify it is listing what you think it is listing.  I am sure
you are not in the directory you think you are in.

> The exact message generated are:
> ../../examples/undefined_permittivities.bmp: No such file or directory
> cp: cannot access ../../examples/undefined_permittivities.bmp
> cannot open ../tmp/undefined_permittivities.bmp

Interesting that you appear to be getting two different messages out
of cp for the same error.  Can't open source and can't write the
target at the same time?  Usually it would stop at the first error.
Unusual.  Are you sure tmp is getting created prior to this test?  It
is probably better to run 'mkdir -p $top_builddir/tmp' just prior to
the performing the copy.

> In the tests/Makefile.am I have:
> 
> TESTS_ENVIRONMENT = \
> top_builddir=$(top_builddir) \
> top_srcdir=$(top_srcdir) \
> built_with_posix_threads=$(built_with_posix_threads)

If you can tolerate making a relative directory from your source
directory instead using your top source directory ($srcdir/../examples
instead of $top_srcdir) then you should probably follow the documented
interface.  That also saves you needing to define it specifically in
your TESTS_ENVIRONMENT.  But defining it yourself seems safe too.

In the "Support for test suites" node:

    Programs needing data files should look for them in 'srcdir' (which is
    both an environment variable and a make variable) so they work when
    building in a separate directory, and in particular for the
    'distcheck' target.

> The messages suggest the files does not exits, but it does:
> 
> % find . -name undefined_permittivities.bmp
> ./examples/undefined_permittivities.bmp
> 
> So 'undefined_permittivities.bmp' does exist, but neither ls or cp can
> find it when I do a 'make distcheck'. But when I do a simple 'make
> check', both ls and cp file it okay and the test passes. 

This works for me.

Which version of automake are you using?  If you said in your message
I missed it.  But I seem to recall you saying you were current in a
previous message.

Since I myself was in the middle of setting up some tests I tried an
experiment.  This all worked fine for me.  I am using autoconf-2.57
and automake-1.7.3.  Here are the abbreviated details of my test.

My directory structure looks like this:
    configure.ac
    Makefile.am
    configure
    tests/Makefile.am
    tests/file1                # Hello, world!
    tests/test1.t
    examples/file2             # Now is the time...
    examples/Makefile.am

  File tests/Makefile.am:
    TESTS = test1.t
    EXTRA_DIST = $(TESTS) file1

  File test1.t:
    #!/bin/sh
    set -x
    pwd
    cat $srcdir/file1
    cat $srcdir/../examples/file2

Here is my resulting output when running 'make check' in the source.

  make[2]: Entering directory `/var/tmp/testtrial/tests'
  + pwd
  /var/tmp/testtrial/tests
  + cat ./file1
  Hello, world!
  + cat ./../examples/file2
  Now is the time for all good men to come to the aid of their party.

Here is my result when running 'make check' in a build directory.

  make[2]: Entering directory `/var/tmp/testtrial/build/tests'
  + pwd
  /var/tmp/testtrial/build/tests
  + cat ../../tests/file1
  Hello, world!
  + cat ../../tests/../examples/file2
  Now is the time for all good men to come to the aid of their party.

Here is my result when running 'make distcheck' in a build directory.

  make[3]: Entering directory
  `/var/tmp/testtrial/testtrial-0.1/_build/tests'
  + pwd
  /var/tmp/testtrial/testtrial-0.1/_build/tests
  + cat ../../tests/file1
  Hello, world!
  + cat ../../tests/../examples/file2
  Now is the time for all good men to come to the aid of their party.

Hope this helps.

Bob




reply via email to

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