head	1.3;
access;
symbols
	RELENG_6_4_0_RELEASE:1.2.26.1
	RELENG_6_4:1.2.0.26
	RELENG_6_4_BP:1.2
	RELENG_6_3_0_RELEASE:1.2
	RELENG_6_3:1.2.0.24
	RELENG_6_3_BP:1.2
	RELENG_6_2_0_RELEASE:1.2
	RELENG_6_2:1.2.0.22
	RELENG_6_2_BP:1.2
	RELENG_5_5_0_RELEASE:1.2
	RELENG_5_5:1.2.0.20
	RELENG_5_5_BP:1.2
	RELENG_6_1_0_RELEASE:1.2
	RELENG_6_1:1.2.0.18
	RELENG_6_1_BP:1.2
	RELENG_6_0_0_RELEASE:1.2
	RELENG_6_0:1.2.0.16
	RELENG_6_0_BP:1.2
	RELENG_6:1.2.0.14
	RELENG_6_BP:1.2
	RELENG_5_4_0_RELEASE:1.2
	RELENG_5_4:1.2.0.12
	RELENG_5_4_BP:1.2
	RELENG_5_3_0_RELEASE:1.2
	RELENG_5_3:1.2.0.10
	RELENG_5_3_BP:1.2
	RELENG_5:1.2.0.8
	RELENG_5_BP:1.2
	RELENG_5_2_1_RELEASE:1.2
	RELENG_5_2_0_RELEASE:1.2
	RELENG_5_2:1.2.0.6
	RELENG_5_2_BP:1.2
	RELENG_5_1_0_RELEASE:1.2
	RELENG_5_1:1.2.0.4
	RELENG_5_1_BP:1.2
	RELENG_5_0_0_RELEASE:1.2
	RELENG_5_0:1.2.0.2
	RELENG_5_0_BP:1.2
	old_RELENG_4_6_2_RELEASE:1.1.2.2
	old_RELENG_4_6_1_RELEASE:1.1.2.2
	old_RELENG_4_6_0_RELEASE:1.1.2.2
	old_RELENG_4_6:1.1.2.2.0.6
	old_RELENG_4_6_BP:1.1.2.2
	old_RELENG_4_5_0_RELEASE:1.1.2.2
	old_RELENG_4_5:1.1.2.2.0.4
	old_RELENG_4_5_BP:1.1.2.2
	old_RELENG_4_4_0_RELEASE:1.1.2.2
	old_RELENG_4_4:1.1.2.2.0.2
	old_RELENG_4_4_BP:1.1.2.2
	old_RELENG_4_3_0_RELEASE:1.1.2.1
	old_RELENG_4_3:1.1.2.1.0.2
	old_RELENG_4_3_BP:1.1.2.1
	old_RELENG_4_2_0_RELEASE:1.1.2.1
	old_RELENG_4_1_1_RELEASE:1.1.2.1
	old_PRE_SMPNG:1.1
	old_RELENG_4_1_0_RELEASE:1.1.2.1
	old_RELENG_4:1.1.0.2;
locks; strict;
comment	@# @;


1.3
date	2007.10.09.14.16.32;	author obrien;	state dead;
branches;
next	1.2;

1.2
date	2001.05.20.23.11.54;	author jasone;	state Exp;
branches
	1.2.14.1
	1.2.26.1;
next	1.1;

1.1
date	2000.04.24.21.07.40;	author jasone;	state Exp;
branches
	1.1.2.1;
next	;

1.2.14.1
date	2012.11.17.07.40.32;	author svnexp;	state Exp;
branches;
next	;

1.2.26.1
date	2008.10.02.02.57.24;	author kensmith;	state Exp;
branches;
next	;

1.1.2.1
date	2000.07.17.22.18.33;	author jasone;	state Exp;
branches;
next	1.1.2.2;

1.1.2.2
date	2001.06.22.21.44.27;	author jasone;	state Exp;
branches;
next	;


desc
@@


1.3
log
@Repo copy libpthreads to libkse.
This introduces the WITHOUT_LIBKSE nob,
and changes WITHOUT_LIBPTHREADS to mean with neither threading libs.
Approved by:	re(kensmith)
@
text
@#!/usr/bin/perl -w
#-*-mode:perl-*-
#############################################################################
#
# Copyright (C) 1999-2001 Jason Evans <jasone@@freebsd.org>.
# All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice(s), this list of conditions and the following disclaimer as
#    the first lines of this file unmodified other than the possible
#    addition of one or more copyright notices.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice(s), this list of conditions and the following disclaimer in
#    the documentation and/or other materials provided with the
#    distribution.
# 
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
# OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#############################################################################
#
# Test harness.
#
# $FreeBSD: src/lib/libpthread/test/verify,v 1.2 2001/05/20 23:11:54 jasone Exp $
#
#############################################################################

# Shut off buffering.
select(STDOUT);
$| = 1;

#
# Parse command-line arguments.
#
use Getopt::Long;
Getopt::Long::config("bundling"); # Allow -hv rather than forcing -h -v.

# Set option defaults for optional arguments.
$opt_help = 0;
$opt_verbose = 0;
$opt_quiet = 0;
$opt_srcdir = ".";
$opt_objdir = ".";
$opt_ustats = 0;
$opt_zero = 0;

$opt_retval =
&GetOptions("h|help" => \$opt_help,
	    "v|verbose" => \$opt_verbose,
	    "q|quiet" => \$opt_quiet,
	    "s|srcdir=s" => \$opt_srcdir,
            "o|objdir=s" => \$opt_objdir,
	    "u|ustats" => \$opt_ustats,
	    "z|zero" => \$opt_zero
	    );

if ($opt_help)
{
    &usage();
    exit(0);
}

if ($opt_retval == 0)
{
    &usage();
    exit 1;
}

if ($opt_verbose && $opt_quiet)
{
    print STDERR "-v and -q are incompatible\n";
    &usage();
    exit 1;
}

if ($#ARGV + 1 == 0)
{
    print STDERR "No tests specified\n";
    &usage();
    exit 1;
}

if ($opt_verbose)
{
    print STDERR "Option values: h:$opt_help, v:$opt_verbose, "
	. "s:\"$opt_srcdir\", o:\"$opt_objdir\" "
	. "q:$opt_quiet, u:$opt_ustats, z:$opt_zero\n";
    printf STDERR "Tests (%d total): @@ARGV\n", $#ARGV + 1;
}

#
# Create and print header.
#
@@TSTATS =
(
 "--------------------------------------------------------------------------\n",
 "Test                                      c_user c_system c_total     chng\n",
 " passed/FAILED                            h_user h_system h_total   %% chng\n"
 );

if (!$opt_quiet)
{
    foreach $line (@@TSTATS)
    {
	printf STDOUT "$line";
    }
}

#
# Run sequence test(s).
#
$total_utime = 0.0; # Total user time.
$total_stime = 0.0; # Total system time.
$total_hutime = 0.0; # Total historical user time.
$total_hstime = 0.0; # Total historical system time.
$total_ntime = 0.0; # Total time for tests that have historical data.

foreach $test (@@ARGV)
{
    # Strip out any whitespace in $test.
    $test =~ s/^\s*(.*)\s*$/$1/;

    $okay = 1;

    if (-e "$opt_srcdir/$test.exp")
    {
	# Diff mode.

	($okay, $utime, $stime) = &run_test($test);

	if (-e "$opt_objdir/$test.out")
	{
	    `diff $opt_srcdir/$test.exp $opt_objdir/$test.out > $opt_objdir/$test.diff 2>&1`;
	    if ($?)
	    {
		# diff returns non-zero if there is a difference.
		$okay = 0;
	    }
	}
	else
	{
	    $okay = 0;
	    if ($opt_verbose)
	    {
		print STDERR
		    "Nonexistent output file \"$opt_objdir/$test.out\"\n";
	    }
	}

	($hutime, $hstime) = &print_stats($test, $okay, 0, 0, $utime, $stime);
    }
    else
    {
	# Sequence mode.

	($okay, $utime, $stime) = &run_test($test);

	if (open (STEST_OUT, "<$opt_objdir/$test.out"))
	{
	    $num_subtests = 0;
	    $num_failed_subtests = 0;

	    while (defined($line = <STEST_OUT>))
	    {
		if ($line =~ /1\.\.(\d+)/)
		{
		    $num_subtests = $1;
		    last;
		}
	    }
	    if ($num_subtests == 0)
	    {
		$okay = 0;
		if ($opt_verbose)
		{
		    print STDERR "Malformed or missing 1..n line\n";
		}
	    }
	    else
	    {
		for ($subtest = 1; $subtest <= $num_subtests; $subtest++)
		{
		    while (defined($line = <STEST_OUT>))
		    {
			if ($line =~ /^not\s+ok\s+(\d+)?/)
			{
			    $not = 1;
			    $test_num = $1;
			    last;
			}
			elsif ($line =~ /^ok\s+(\d+)?/)
			{
			    $not = 0;
			    $test_num = $1;
			    last;
			}
		    }
		    if (defined($line))
		    {
			if (defined($test_num) && ($test_num != $subtest))
			{
			    # There was no output printed for one or more tests.
			    for (; $subtest < $test_num; $subtest++)
			    {
				$num_failed_subtests++;
			    }
			}
			if ($not)
			{
			    $num_failed_subtests++;
			}
		    }
		    else
		    {
			for (; $subtest <= $num_subtests; $subtest++)
			{
			    $num_failed_subtests++;
			}
		    }
		}

		if (0 < $num_failed_subtests)
		{
		    $okay = 0;
		}
	    }
	}
	else
	{
	    if (!$opt_quiet)
	    {
		print STDERR "Cannot open output file \"$opt_objdir/$test.out\"\n";
	    }
	    exit 1;
	}

	($hutime, $hstime) = &print_stats($test, $okay,
					  $num_failed_subtests, $num_subtests,
					  $utime, $stime);
    }

    $total_hutime += $hutime;
    $total_hstime += $hstime;

    if ($okay)
    {
	$total_utime += $utime;
	$total_stime += $stime;
    }
    else
    {
	@@FAILED_TESTS = (@@FAILED_TESTS, $test);
    }

    # If there were historical data, add the run time to the total time to 
    # compare against the historical run time.
    if (0 < ($hutime + $hstime))
    {
	$total_ntime += $utime + $stime;
    }
}

# Print summary stats.
$tt_str = sprintf ("%d / %d passed (%5.2f%%%%)",
		   ($#ARGV + 1) - ($#FAILED_TESTS + 1),
		   $#ARGV + 1,
		   (($#ARGV + 1) - ($#FAILED_TESTS + 1))
		   / ($#ARGV + 1) * 100);

$t_str = sprintf ("Totals                                   %7.2f  %7.2f %7.2f"
                  . "  %7.2f\n"
		  . " %s %7.2f  %7.2f %7.2f %7.2f%%%%\n",
		  $total_utime, $total_stime, $total_utime + $total_stime,
		  ($total_ntime - ($total_hutime + $total_hstime)),
		  $tt_str . ' ' x (40 - length($tt_str)),
		  $total_hutime, $total_hstime, $total_hutime + $total_hstime,
		  ($total_hutime + $total_hstime == 0.0) ? 0.0 :
		  (($total_ntime
		    - ($total_hutime + $total_hstime))
		   / ($total_hutime + $total_hstime) * 100));

@@TSTATS = ("--------------------------------------------------------------------------\n",
	   $t_str,
	   "--------------------------------------------------------------------------\n"
	   );
if (!$opt_quiet)
{
    foreach $line (@@TSTATS)
    {
	printf STDOUT "$line";
    }
}

if ($#FAILED_TESTS >= 0)
{
    # One or more tests failed, so return an error.
    exit 1;
}
# End of main execution.

sub run_test
{
    my ($test) = @@_;
    my ($okay) = 1;
    my ($tutime, $tstime);
    my ($utime, $stime, $cutime, $cstime);
    my (@@TSTATS, @@TPATH);
    my ($t_str);
    my ($srcdir, $objdir);

    # Get the path component of $test, if any.
    @@TPATH = split(/\//, $test);
    pop(@@TPATH);
    $srcdir = join('/', ($opt_srcdir, @@TPATH));
    $objdir = join('/', ($opt_objdir, @@TPATH));

    @@TSTATS = ("--------------------------------------------------------------------------\n");

    $t_str = sprintf ("%s%s", $test, ' ' x (40 - length($test)));
    @@TSTATS = (@@TSTATS, $t_str);
    @@STATS = (@@STATS, @@TSTATS);
    if (!$opt_quiet)
    {
	foreach $line (@@TSTATS)
	{
	    printf STDOUT "$line";
	}
    }

    ($utime, $stime, $cutime, $cstime) = times;
    `$opt_objdir/$test $srcdir $objdir > $opt_objdir/$test.out 2>&1`;
    ($utime, $stime, $tutime, $tstime) = times;

    # Subtract the before time from the after time.
    $tutime -= $cutime;
    $tstime -= $cstime;

    if ($opt_zero)
    {
	if ($?)
	{
	    $okay = 0;
	    if ($opt_verbose)
	    {
		print STDERR
		    "\"$opt_objdir/$test > $opt_objdir/$test.out 2>&1\" returned $?\n";
	    }
	}
    }

    return ($okay, $tutime, $tstime);
}

sub print_stats
{
    my ($test, $okay, $failed_subtests, $subtests, $utime, $stime) = @@_;
    my ($hutime, $hstime);
#    my (TEST_PERF);
    my (@@TSTATS);
    my ($t_str, $pass_str);

    $pass_str = $okay ? "passed" : "*** FAILED ***";
    if ((0 != $subtests) && (!$okay))
    {
	$pass_str = $pass_str . " ($failed_subtests/$subtests failed)";
    }
    $pass_str = $pass_str . ' ' x (39 - length($pass_str));
    
    if (-r "$test.perf")
    {
	if (!open (TEST_PERF, "<$opt_objdir/$test.perf"))
	{
	    print STDERR "Unable to open \"$opt_objdir/$test.perf\"\n";
	    exit 1;
	}
	$_ = <TEST_PERF>;

	($hutime, $hstime) = split;
	close TEST_PERF;

	$t_str = sprintf (" %7.2f  %7.2f %7.2f  %7.2f\n"
			  . " %s %7.2f  %7.2f %7.2f %7.2f%%%%\n",
			  $utime, $stime, $utime + $stime,
			  ($utime + $stime) - ($hutime + $hstime),
			  $pass_str,
			  $hutime, $hstime, $hutime + $hstime,
			  (($hutime + $hstime) == 0.0) ? 0.0 :
			  ((($utime + $stime) - ($hutime + $hstime))
			   / ($hutime + $hstime) * 100));
    }
    else
    {
	$hutime = 0.0;
	$hstime = 0.0;

	$t_str = sprintf (" %7.2f  %7.2f %7.2f        \n"
			  . " %s\n",
			  $utime, $stime, $utime + $stime,
			  $pass_str);
    }
    @@TSTATS = ($t_str);
    if (!$opt_quiet)
    {
	foreach $line (@@TSTATS)
	{
	    printf STDOUT "$line";
	}
    }

    if ($okay && $opt_ustats)
    {
	if (!open (TEST_PERF, ">$opt_objdir/$test.perf"))
	{
	    if (!$opt_quiet)
	    {
		print STDERR "Unable to update \"$opt_objdir/$test.perf\"\n";
	    }
	}
	else
	{
	    print TEST_PERF "$utime $stime\n";
	    close TEST_PERF;
	}
    }

    return ($hutime, $hstime);
}

sub usage
{
    print <<EOF;
$0 usage:
    $0 [<options>] <test>+

    Option        | Description
    --------------+-------------------------------------------------------------
    -h --help     | Print usage and exit.
    -v --verbose  | Verbose (incompatible with quiet).
    -q --quiet    | Quiet (incompatible with verbose).
    -s --srcdir   | Path to source tree (default is ".").
    -o --objdir   | Path to object tree (default is ".").
    -u --ustats   | Update historical statistics (stored in "<test>.perf".
    -z --zero     | Consider non-zero exit code to be an error.
    --------------+-------------------------------------------------------------

    If <test>.exp exists, <test>'s output is diff'ed with <test>.exp.  Any
    difference is considered failure.

    If <test>.exp does not exist, output to stdout of the following form is
    expected:

        1..<n>
        {not }ok[ 1]
        {not }ok[ 2]
        ...
        {not }ok[ n]

    1 <= <n> < 2^31

    Lines which do not match the patterns shown above are ignored.
EOF
}
@


1.2
log
@Update the verify script.
@
text
@d36 1
a36 1
# $FreeBSD: src/lib/libc_r/test/verify,v 1.1 2000/04/24 21:07:40 jasone Exp $
@


1.2.14.1
log
@Switch importer
@
text
@d36 1
a36 1
# $FreeBSD: stable/6/lib/libpthread/test/verify 76912 2001-05-20 23:11:54Z jasone $
@


1.2.26.1
log
@SVN rev 183531 on 2008-10-02 02:57:24Z by kensmith

Create releng/6.4 from stable/6 in preparation for 6.4-RC1.

Approved by:	re (implicit)
@
text
@d36 1
a36 1
# $FreeBSD$
@


1.1
log
@Automated regression test harness for libc_r.  Existing tests are integrated,
a new test for POSIX semaphores was added, and examples of harness usage are
included.
@
text
@d5 1
a5 1
# Copyright (C) 1999-2000 Jason Evans <jasone@@freebsd.org>.
d36 1
a36 1
# $FreeBSD$
d55 1
d63 2
a64 1
            "s|srcdir=s" => \$opt_srcdir,
a68 31
$mode = "d";
for ($i = 0; $i <= $#ARGV; $i++)
{
    if (($ARGV[$i] eq "-s") || ($ARGV[$i] eq "--sequence"))
    {
	$mode = "s";
    }
    elsif (($ARGV[$i] eq "-d") || ($ARGV[$i] eq "--diff"))
    {
	$mode = "d";
    }
    elsif (-x $ARGV[$i])
    {
	if ($mode eq "s")
	{
	    @@STESTS = (@@STESTS, $ARGV[$i]);
	}
	else
	{
	    @@DTESTS = (@@DTESTS, $ARGV[$i]);
	}
    }
    else
    {
	if (!$opt_quiet)
	{
	    print STDERR "Cannot run \"$ARGV[$i]\"\n";
	}
    }
}

d88 1
a88 1
if ($#STESTS + $#DTESTS + 2 == 0)
d97 4
a100 4
    print STDERR "Option values: h:$opt_help, v:$opt_verbose, q:$opt_quiet, "
	. "u:$opt_ustats\n";
    printf STDERR "Sequence tests (%d total): @@STESTS\n", $#STESTS + 1;
    printf STDERR "Diff tests (%d total): @@DTESTS\n", $#DTESTS + 1;
d130 1
a130 1
foreach $test (@@STESTS)
d132 3
a134 1
    # sequence mode.
d137 1
a137 3
    ($okay, $utime, $stime) = &run_test($test);

    if (open (STEST_OUT, "<./$test.out"))
d139 1
a139 1
	$num_failed_subtests = 0;
d141 1
a141 1
	$_ = <STEST_OUT>;
d143 1
a143 1
	if ($_ =~ /1\.\.(\d+)/)
d145 6
a150 1
	    $num_subtests = $1;
a153 1
	    $num_subtests = 0;
d157 2
a158 1
		print STDERR "Malformed 1..n line: \"$_\"\n";
d161 10
a170 1
	for ($subtest = 1; $subtest <= $num_subtests; $subtest++)
d172 3
d177 1
a177 1
		if ($line =~ /^not\s+ok\s+(\d+)?/)
d179 1
a179 2
		    $not = 1;
		    $test_num = $1;
d182 5
a186 1
		elsif ($line =~ /^ok\s+(\d+)?/)
d188 1
a188 3
		    $not = 0;
		    $test_num = $1;
		    last;
d191 1
a191 1
	    if (defined($line))
d193 1
a193 1
		if (defined($test_num) && ($test_num != $subtest))
d195 31
a225 2
		    # There was no output printed for one or more tests.
		    for (; $subtest < $test_num; $subtest++)
d227 4
a230 1
			$num_failed_subtests++;
d233 2
a234 1
		if ($not)
d236 1
a236 1
		    $num_failed_subtests++;
d239 4
a242 1
	    else
d244 1
a244 4
		for (; $subtest <= $num_subtests; $subtest++)
		{
		    $num_failed_subtests++;
		}
d246 1
d249 3
a251 62
	if (0 < $num_failed_subtests)
	{
	    $okay = 0;
	}
    }
    else
    {
	if (!$opt_quiet)
	{
	    print STDERR "Cannot open output file \"$test.out\"\n";
	}
	exit 1;
    }

    ($hutime, $hstime) = &print_stats($test, $okay, 
				      $num_failed_subtests, $num_subtests,
				      $utime, $stime);
    $total_hutime += $hutime;
    $total_hstime += $hstime;

    if ($okay)
    {
	$total_utime += $utime;
	$total_stime += $stime;
    }
    else
    {
	@@FAILED_TESTS = (@@FAILED_TESTS, $test);
    }

    # If there were historical data, add the run time to the total time to 
    # compare against the historical run time.
    if (0 < ($hutime + $hstime))
    {
	$total_ntime += $utime + $stime;
    }
}
foreach $test (@@DTESTS)
{
    # Diff mode.
    $okay = 1;

    ($okay, $utime, $stime) = &run_test($test);

    if (-e "./$test.out" && -e "$opt_srcdir/$test.exp")
    {
	`diff ./$test.out $opt_srcdir/$test.exp > ./$test.diff 2>&1`;
	if ($?)
	{
	    # diff returns non-zero if there is a difference.
	    $okay = 0;
	}
    }
    else
    {
	$okay = 0;
	if ($opt_verbose)
	{
	    print STDERR
		"Nonexistent expected output file \"$opt_srcdir/$test.exp\"\n";
            print STDERR "\$opt_srcdir is \"$opt_srcdir\"\n";
	}
a253 1
    ($hutime, $hstime) = &print_stats($test, $okay, 0, 0, $utime, $stime);
d277 4
a280 4
		   ($#STESTS + $#DTESTS + 2) - ($#FAILED_TESTS + 1),
		   $#STESTS + $#DTESTS + 2,
		   (($#STESTS + $#DTESTS + 2) - ($#FAILED_TESTS + 1))
		   / ($#STESTS + $#DTESTS + 2) * 100);
d306 5
d319 1
a319 1
    my (@@TSTATS);
d321 7
d343 1
a343 1
    `./$test $opt_srcdir > ./$test.out 2>&1`;
d357 2
a358 1
		print STDERR "\"./$test > ./$test.out 2>&1\" returned $?\n";
d383 1
a383 1
	if (!open (TEST_PERF, "<./$test.perf"))
d385 1
a385 1
	    print STDERR "Unable to open \"./$test.perf\"\n";
d424 1
a424 1
	if (!open (TEST_PERF, ">./$test.perf"))
d428 1
a428 1
		print STDERR "Unable to update \"$test.perf\"\n";
d445 1
a445 1
    $0 [<options>] -- {[-s | -d | --sequence | --diff] <test>+}+
d453 1
d458 15
a472 23
    Flag          | Description
    --------------+-------------------------------------------------------------
    -s --sequence | Sequence mode (default).
                  | Output to stdout of the following form is expected:
                  | 
                  | -----------------
                  | 1..<n>
                  | {not} ok [1]
                  | {not} ok [2]
                  | ...
                  | {not} ok [n]
                  | -----------------
                  | 
                  | 1 <= <n> < 2^31
                  | 
                  | Lines which do not match the patterns shown above are
                  | ignored, except that the 1..<n> construct must be the first
                  | line of output seen.
                  | 
    -d --diff     | Diff mode (incompatible with sequence mode).
                  | If <test>.exp exists, diff it with the output from <test> to
                  | determine success or failure.
    --------------+-------------------------------------------------------------
@


1.1.2.1
log
@MFC: Add a test framework, convert existing tests to work with the
framework, and add a test for semaphores.
@
text
@@


1.1.2.2
log
@MFC: Update libc_r test suite.
@
text
@d5 1
a5 1
# Copyright (C) 1999-2001 Jason Evans <jasone@@freebsd.org>.
d36 1
a36 1
# $FreeBSD: src/lib/libc_r/test/verify,v 1.1.2.1 2000/07/17 22:18:33 jasone Exp $
a54 1
$opt_objdir = ".";
d62 1
a62 2
	    "s|srcdir=s" => \$opt_srcdir,
            "o|objdir=s" => \$opt_objdir,
d67 31
d117 1
a117 1
if ($#ARGV + 1 == 0)
d126 4
a129 4
    print STDERR "Option values: h:$opt_help, v:$opt_verbose, "
	. "s:\"$opt_srcdir\", o:\"$opt_objdir\" "
	. "q:$opt_quiet, u:$opt_ustats, z:$opt_zero\n";
    printf STDERR "Tests (%d total): @@ARGV\n", $#ARGV + 1;
d159 1
a159 1
foreach $test (@@ARGV)
d161 2
a162 2
    # Strip out any whitespace in $test.
    $test =~ s/^\s*(.*)\s*$/$1/;
d164 1
a164 1
    $okay = 1;
d166 1
a166 1
    if (-e "$opt_srcdir/$test.exp")
d168 1
a168 1
	# Diff mode.
d170 1
a170 1
	($okay, $utime, $stime) = &run_test($test);
d172 1
a172 1
	if (-e "$opt_objdir/$test.out")
d174 1
a174 6
	    `diff $opt_srcdir/$test.exp $opt_objdir/$test.out > $opt_objdir/$test.diff 2>&1`;
	    if ($?)
	    {
		# diff returns non-zero if there is a difference.
		$okay = 0;
	    }
d178 1
d182 1
a182 2
		print STDERR
		    "Nonexistent output file \"$opt_objdir/$test.out\"\n";
d185 1
a185 10

	($hutime, $hstime) = &print_stats($test, $okay, 0, 0, $utime, $stime);
    }
    else
    {
	# Sequence mode.

	($okay, $utime, $stime) = &run_test($test);

	if (open (STEST_OUT, "<$opt_objdir/$test.out"))
a186 3
	    $num_subtests = 0;
	    $num_failed_subtests = 0;

d189 1
a189 1
		if ($line =~ /1\.\.(\d+)/)
d191 2
a192 1
		    $num_subtests = $1;
d195 1
a195 5
	    }
	    if ($num_subtests == 0)
	    {
		$okay = 0;
		if ($opt_verbose)
d197 3
a199 1
		    print STDERR "Malformed or missing 1..n line\n";
d202 1
a202 1
	    else
d204 1
a204 1
		for ($subtest = 1; $subtest <= $num_subtests; $subtest++)
d206 2
a207 1
		    while (defined($line = <STEST_OUT>))
d209 1
a209 34
			if ($line =~ /^not\s+ok\s+(\d+)?/)
			{
			    $not = 1;
			    $test_num = $1;
			    last;
			}
			elsif ($line =~ /^ok\s+(\d+)?/)
			{
			    $not = 0;
			    $test_num = $1;
			    last;
			}
		    }
		    if (defined($line))
		    {
			if (defined($test_num) && ($test_num != $subtest))
			{
			    # There was no output printed for one or more tests.
			    for (; $subtest < $test_num; $subtest++)
			    {
				$num_failed_subtests++;
			    }
			}
			if ($not)
			{
			    $num_failed_subtests++;
			}
		    }
		    else
		    {
			for (; $subtest <= $num_subtests; $subtest++)
			{
			    $num_failed_subtests++;
			}
d212 8
a219 2

		if (0 < $num_failed_subtests)
d221 1
a221 1
		    $okay = 0;
d225 9
a233 1
	else
d235 1
a235 5
	    if (!$opt_quiet)
	    {
		print STDERR "Cannot open output file \"$opt_objdir/$test.out\"\n";
	    }
	    exit 1;
d237 30
d268 20
a287 3
	($hutime, $hstime) = &print_stats($test, $okay,
					  $num_failed_subtests, $num_subtests,
					  $utime, $stime);
d290 1
d314 4
a317 4
		   ($#ARGV + 1) - ($#FAILED_TESTS + 1),
		   $#ARGV + 1,
		   (($#ARGV + 1) - ($#FAILED_TESTS + 1))
		   / ($#ARGV + 1) * 100);
a342 5
if ($#FAILED_TESTS >= 0)
{
    # One or more tests failed, so return an error.
    exit 1;
}
d351 1
a351 1
    my (@@TSTATS, @@TPATH);
a352 7
    my ($srcdir, $objdir);

    # Get the path component of $test, if any.
    @@TPATH = split(/\//, $test);
    pop(@@TPATH);
    $srcdir = join('/', ($opt_srcdir, @@TPATH));
    $objdir = join('/', ($opt_objdir, @@TPATH));
d368 1
a368 1
    `$opt_objdir/$test $srcdir $objdir > $opt_objdir/$test.out 2>&1`;
d382 1
a382 2
		print STDERR
		    "\"$opt_objdir/$test > $opt_objdir/$test.out 2>&1\" returned $?\n";
d407 1
a407 1
	if (!open (TEST_PERF, "<$opt_objdir/$test.perf"))
d409 1
a409 1
	    print STDERR "Unable to open \"$opt_objdir/$test.perf\"\n";
d448 1
a448 1
	if (!open (TEST_PERF, ">$opt_objdir/$test.perf"))
d452 1
a452 1
		print STDERR "Unable to update \"$opt_objdir/$test.perf\"\n";
d469 1
a469 1
    $0 [<options>] <test>+
a476 1
    -o --objdir   | Path to object tree (default is ".").
d481 23
a503 15
    If <test>.exp exists, <test>'s output is diff'ed with <test>.exp.  Any
    difference is considered failure.

    If <test>.exp does not exist, output to stdout of the following form is
    expected:

        1..<n>
        {not }ok[ 1]
        {not }ok[ 2]
        ...
        {not }ok[ n]

    1 <= <n> < 2^31

    Lines which do not match the patterns shown above are ignored.
@


