Re: How are data files input for to custom drivers?

2015-06-08 Thread Gavin Smith
On 27 May 2015 at 22:27, Arthur Schwarz aschwarz1...@att.net wrote:
 Then is seems that the test harness would have to do:
 cat data | tap-driver.sh
 ./script.sh | tap-driver.sh

 Because the awk loop in tap-driver.sh does a getline which reads from an
 input pipe (stdin). Have I read the code and the document correctly? This is
 really confusing to me. In 15.3.3.1 Command-line arguments for test drivers
 the manual says The first non-option argument passed to the test driver is
 the program to be run, and all the following ones are command-line options
 and arguments for this program. Which seems to mean that for custom drivers
 we get for:

In Makefile we have something like:

.t.log:
@p='$'; \
$(am__set_b); \
$(am__check_pre) $(T_LOG_DRIVER) --test-name $$f \
--log-file $$b.log --trs-file $$b.trs \
$(am__common_driver_flags) $(AM_T_LOG_DRIVER_FLAGS)
$(T_LOG_DRIVER_FLAGS) -- $(T_LOG_COMPILE) \
$$tst $(AM_TESTS_FD_REDIRECT)


The 'tst' shell variable is set inside 'am__check_pre' and is the name
of the test case.

In tap-driver.sh there is:

$@
echo $?
  ) | LC_ALL=C ${AM_TAP_AWK-awk} \
-v me=$me \
-v test_script_name=$test_name \
-v log_file=$log_file \
-v trs_file=$trs_file \
-v expect_failure=$expect_failure \
-v merge=$merge \
-v ignore_exit=$ignore_exit \
-v comments=$comments \
-v diag_string=$diag_string \
'
That final apostrophe is very important to notice: it is the start of
the awk script.

The $@ line executes the test case. This was all the arguments given
to the tap-driver.sh in the Makefile, but now all the options have
been shift'd. So the output of the test case is the input of awk, via
the pipe (|).



How are data files input for to custom drivers?

2015-05-27 Thread Arthur Schwarz
15.2.1 Scripts-based Testsuites
If the special variable TESTS is defined, its value is taken to be a list of
programs or scripts to run in order to do the testing. Under the appropriate
circumstances, it's possible for TESTS to list also data files to be passed
to one or more test scripts defined by different means (the so-called log
compilers, see Parallel Test Harness). 

If I define:
LOG_DRIVER = myscript.sh
TESTS = data

What happens?

If I define: (the tap-driver.sh is a custom driver by definition)
TEST_EXTENSIONS = .sh
LOG_DRIVER = tap-driver.sh
SH_LOG_DRIVER = tap-driver.sh
TESTS = data script.sh

Then is seems that the test harness would have to do: 
cat data | tap-driver.sh
./script.sh | tap-driver.sh

Because the awk loop in tap-driver.sh does a getline which reads from an
input pipe (stdin). Have I read the code and the document correctly? This is
really confusing to me. In 15.3.3.1 Command-line arguments for test drivers
the manual says The first non-option argument passed to the test driver is
the program to be run, and all the following ones are command-line options
and arguments for this program. Which seems to mean that for custom drivers
we get for:

TEST_EXTENSIONS = SH
SH_LOG_DRIVER = custom_driver
LOG_DRIVER = custom_driver
TESTS = program test.sh

Which should execute as:
custom_driver test_harness_options program
custom_driver test_harness_options test.sh

Which is certainly not done with the tap-driver. So what in tarnation is
going on?

The manual make very clear how to input a data file. For example

If I define:
TESTS = script.sh

Then according to:
15.2.1 Scripts-based Testsuites
Test programs that need data files should look for them in srcdir (which is
both a make variable and an environment variable made available to the
tests), so that they work when building in a separate directory (see Build
Directories in The Autoconf Manual), and in particular for the distcheck
rule (see Checking the Distribution).

So it seems clear what to do if script.sh needs a data file.