ATF-devel archive

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

Re: Another atf_check question



On Sun, 9 Jan 2011, Julio Merino wrote:

On Sat, Jan 8, 2011 at 9:35 PM, Paul Goyette <paul%whooppee.com@localhost> 
wrote:
I've got a helper program that I want to invoke multiple times for a single
test case:

       atf_test_case empty
       empty_head()
       {
               atf_set "descr" "Testing empty name"
       }
       empty_body()
       {
               atf_check 'empty_tests' 0 ${files}empty.exp null
       }
       empty_tests()
       {
               $TEST ::1 ''
               $TEST 127.0.0.1 ''
               $TEST localhost ''
               $TEST '' ''
       }

So, the "command" that I want to pass to atf-check(1) is actually a shell
function.

As expected, this does not work.  I thought of using atf-check directly, and
specifying -x, but that would start another shell to execute the command.

Is there a sane way to do this?

What I have done sometimes is to write the script out to a temporary
file and then run it.  It is ugly, specially because with
here-documents it is not nice to type shell scripts, but does the job.
I have also just put such auxiliary scripts in their own files.

Could you maybe rework your auxiliary function to do the atf_check
calls by itself?  (The sample code above does not really provide
enough detail on what you are trying to accomplish.)  I've also
sometimes generated test cases on-the-fly by means of eval; see the
ipf tests.

What I ended up doing was to call the shell function with output redirection, then using cmp(1) to compare with the golden output.

        xxx_body() {
                xxx_test > out 2>&1
                atf-check -s 0 -o ignore -e ignore \
                        "cmp -s out ${files}xxx.exp"
        }

This was for a rework of the old regress-getaddrinfo test. I've since decided to abandon this for now, since the correct results are not deterministic (they depend heavily on host configuration, particularly network interfaces and /etc/hosts file).


And lastly, any reason why the above didn't go to atf-devel? ;-)

My bad - sorry.



-------------------------------------------------------------------------
| Paul Goyette     | PGP Key fingerprint:     | E-mail addresses:       |
| Customer Service | FA29 0E3B 35AF E8AE 6651 | paul at whooppee.com    |
| Network Engineer | 0786 F758 55DE 53BA 7731 | pgoyette at juniper.net |
| Kernel Developer |                          | pgoyette at netbsd.org  |
-------------------------------------------------------------------------


Home | Main Index | Thread Index | Old Index