From owner-freebsd-testing@FreeBSD.ORG Sat Jul 26 11:30:27 2014 Return-Path: Delivered-To: freebsd-testing@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 449B4307 for ; Sat, 26 Jul 2014 11:30:27 +0000 (UTC) Received: from smtprelay06.ispgateway.de (smtprelay06.ispgateway.de [80.67.31.103]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 06AA0224F for ; Sat, 26 Jul 2014 11:30:26 +0000 (UTC) Received: from [87.79.198.227] (helo=fabiankeil.de) by smtprelay06.ispgateway.de with esmtpsa (SSLv3:AES128-SHA:128) (Exim 4.68) (envelope-from ) id 1XB0B6-0004O4-4y for freebsd-testing@freebsd.org; Sat, 26 Jul 2014 13:30:16 +0200 Date: Sat, 26 Jul 2014 13:30:19 +0200 From: Fabian Keil To: Subject: atf_check() equivalent to test individual shell functions? Message-ID: <41d8a2fb.75b47028@fabiankeil.de> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; boundary="Sig_/RA443hGBEO=kGyPObZgnDDi"; protocol="application/pgp-signature" X-Df-Sender: Nzc1MDY3 X-BeenThere: freebsd-testing@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Testing on FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 26 Jul 2014 11:30:27 -0000 --Sig_/RA443hGBEO=kGyPObZgnDDi Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Here's another zogftw-related problem. Putting something like this in a test case works as expected: | atf_check -s exit:0 -o empty -e empty $ZOGFTW cmd zogftw_string_ends_with= "abc" "c" It would be preferably to source zogftw once at the beginning and call the shell function zogftw_string_ends_with() directly afterwards to reduce the overhead, though. The following sort of does this, but the stdout and stderr output isn't verified, it's tedious to write and if nothing fails, the "kyua debug" output isn't particular useful: | . $ZOGFTW source || atf_fail "Failed to source zogftw" | | if ! zogftw_string_ends_with "abc" "c"; then | atf_fail "Failed to find 'c' at the end of 'abc'" | fi The following also sort of works, but in case of errors the output isn't helpful (because atf_check_equal() doesn't see the actual function) and the stderr output isn't verified either: | . $ZOGFTW source || atf_fail "Failed to source zogftw" | | atf_check_equal $(zogftw_string_ends_with "abc" "c"; echo $?) "0" What I'm looking for is something like this: | atf_check_shell_function -s return:0 -o empty -e empty zogftw_string_ends= _with "abc" "c" atf-sh-api(3) doesn't seem to mention anything like it, so I'm wondering how other people are testing individual shell functions? Fabian --Sig_/RA443hGBEO=kGyPObZgnDDi Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlPTkUsACgkQBYqIVf93VJ0OgwCfbyxvQkkb85gHu4P/JexXBh2f kpUAoJN0FD32/2QTWPGNUoTw8gYtvprB =qBaI -----END PGP SIGNATURE----- --Sig_/RA443hGBEO=kGyPObZgnDDi--