exceptions.
m4_pattern_forbid([^_?AS_])

# Bangshe and minimal initialization.
# Put only the basename of __file__ into HEADER-COMMENT, so that the
# path to the source directory is not embedded in the output file.
m4_divert_text([BINSH], [@%:@! /bin/sh])
m4_divert_text([HEADER-COMMENT],
	       [@%:@ Generated from m4_bpatsubst(__file__,[^.*/\([^/]*\)$],[[\1]]) by m4_PACKAGE_STRING.])
m4_divert_text([M4SH-SANITIZE], [_AS_SHELL_SANITIZE])
m4_divert_text([M4SH-INIT-FN], [m4_text_box([M4sh Shell Functions.])])

# Let's go!
m4_divert([BODY])dnl
m4_text_box([Main body of script.])
_AS_DETECT_REQUIRED([_AS_SHELL_FN_WORK])dnl
_AS_DETECT_REQUIRED([_AS_MODERN_CMDSUBST_WORKS])dnl
_AS_DETECT_REQUIRED([_AS_TEST_X_WORKS])dnl
AS_REQUIRE([_AS_UNSET_PREPARE], [], [M4SH-INIT-FN])dnl

T7,44559
AT_INITm4_pushdef([AT_INIT], [m4_fatal([$0: invoked multiple times])])
m4_pattern_forbid([^_?AT_])
m4_pattern_allow([^_ATEOF$])
m4_ifndef([AT_PACKAGE_BUGREPORT], [m4_fatal(
  [$1: AT_PACKAGE_BUGREPORT is missing, consider writing package.m4])])
m4_define([AT_TESTSUITE_NAME],
  m4_defn([AT_PACKAGE_STRING])[ test suite]m4_ifval([$1],
   [m4_expand([: $1])]))
m4_define([AT_ordinal], 0)
m4_define([AT_banner_ordinal], 0)
m4_define([AT_help_all], [])
m4_map_args([_m4_popdef], _AT_DEFINE_INIT_LIST)
m4_wrap([_AT_FINISH])
AS_INIT[]m4_cleardivert([BODY])AS_ME_PREPARE[]m4_divert_push([DEFAULTS])AT_COPYRIGHT(m4_defn([_AT_COPYRIGHT_YEARS]), [
m4_copyright_condense])
AT_COPYRIGHT(
[This test suite is free software; the Free Software Foundation gives
unlimited permission to copy, distribute and modify it.], [m4_echo])
AS_PREPARE

SHELL=${CONFIG_SHELL-/bin/sh}

# How were we run?
at_cli_args="$[@]"

m4_divert_push([BANNERS])dnl

# Should we print banners?  Yes if more than one test is run.
case $at_groups in #(
  *$as_nl* )
      at_print_banners=: ;; #(
  * ) at_print_banners=false ;;
esac
# Text for banner N, set to a single space once printed.
m4_divert_pop([BANNERS])dnl back to DEFAULTS
m4_divert_push([PREPARE_TESTS])dnl

m4_text_box([Autotest shell functions.])

AS_FUNCTION_DESCRIBE([at_fn_banner], [NUMBER],
[Output banner NUMBER, provided the testsuite is running multiple groups
and this particular banner has not yet been printed.])
at_fn_banner ()
{
  $at_print_banners || return 0
  eval at_banner_text=\$at_banner_text_$[1]
  test "x$at_banner_text" = "x " && return 0
  eval "at_banner_text_$[1]=\" \""
  if test -z "$at_banner_text"; then
    $at_first || echo
  else
    AS_ECHO(["$as_nl$at_banner_text$as_nl"])
  fi
} # at_fn_banner

AS_FUNCTION_DESCRIBE([at_fn_check_prepare_notrace], [REASON LINE],
[Perform AT_CHECK preparations for the command at LINE for an
untraceable command; REASON is the reason for disabling tracing.])
at_fn_check_prepare_notrace ()
{
  $at_trace_echo "Not enabling shell tracing (command contains $[1])"
  AS_ECHO(["$[2]"]) >"$at_check_line_file"
  at_check_trace=: at_check_filter=:
  : >"$at_stdout"; : >"$at_stderr"
}

AS_FUNCTION_DESCRIBE([at_fn_check_prepare_trace], [LINE],
[Perform AT_CHECK preparations for the command at LINE for a traceable
command.])
at_fn_check_prepare_trace ()
{
  AS_ECHO(["$[1]"]) >"$at_check_line_file"
  at_check_trace=$at_traceon at_check_filter=$at_check_filter_trace
  : >"$at_stdout"; : >"$at_stderr"
}

AS_FUNCTION_DESCRIBE([at_fn_check_prepare_dynamic], [COMMAND LINE],
[Decide if COMMAND at LINE is traceable at runtime, and call the
appropriate preparation function.])
at_fn_check_prepare_dynamic ()
{
  case $[1] in
    *$as_nl*)
      at_fn_check_prepare_notrace 'an embedded newline' "$[2]" ;;
    *)
      at_fn_check_prepare_trace "$[2]" ;;
  esac
}

AS_FUNCTION_DESCRIBE([at_fn_filter_trace], [],
[Remove the lines in the file "$at_stderr" generated by "set -x" and print
them to stderr.])
at_fn_filter_trace ()
{
  mv "$at_stderr" "$at_stder1"
  grep '^ *+' "$at_stder1" >&2
  grep -v '^ *+' "$at_stder1" >"$at_stderr"
}

AS_FUNCTION_DESCRIBE([at_fn_log_failure], [FILE-LIST],
[Copy the files in the list on stdout with a "> " prefix, and exit the shell
with a failure exit code.])
at_fn_log_failure ()
{
  for file
    do AS_ECHO(["$file:"]); sed 's/^/> /' "$file"; done
  echo 1 > "$at_status_file"
  exit 1
}

AS_FUNCTION_DESCRIBE([at_fn_check_skip], [EXIT-CODE LINE],
[Check whether EXIT-CODE is a special exit code (77 or 99), and if so exit
the test group subshell with that same exit code.  Use LINE in any report
about test failure.])
at_fn_check_skip ()
{
  case $[1] in
    99) echo 99 > "$at_status_file"; at_failed=:
	AS_ECHO(["$[2]: hard failure"]); exit 99;;
    77) echo 77 > "$at_status_file"; exit 77;;
  esac
}

AS_FUNCTION_DESCRIBE([at_fn_check_status], [EXPECTED EXIT-CODE LINE],
[Check whether EXIT-CODE is the EXPECTED exit code, and if so do nothing.
Otherwise, if it is 77 or 99, exit the test group subshell with that same
exit code; if it is anything else print an error message referring to LINE,
and fail the test.])
at_fn_check_status ()
{
dnl This order ensures that we don't 'skip' if we are precisely checking
dnl $? = 77 or $? = 99.
  case $[2] in
    $[1] ) ;;
    77) echo 77 > "$at_status_file"; exit 77;;
    99) echo 99 > "$at_status_file"; at_failed=:
	AS_ECHO(["$[3]: hard failure"]); exit 99;;
    *) AS_ECHO(["$[3]: exit code was $[2], expected $[1]"])
      at_failed=:;;
  esac
}

AS_FUNCTION_DESCRIBE([at_fn_diff_devnull], [FILE],
[Emit a diff between /dev/null and FILE.  Uses "test -s" to avoid useless
diff invocations.])
at_fn_diff_devnull ()
{
  test -s "$[1]" || return 0
  $at_diff "$at_devnull" "$[1]"
}

AS_FUNCTION_DESCRIBE([at_fn_test], [NUMBER],
[Parse out test NUMBER from the tail of this file.])
at_fn_test ()
{
  eval at_sed=\$at_sed$[1]
  sed "$at_sed" "$at_myself" > "$at_test_source"
}

AS_FUNCTION_DESCRIBE([at_fn_create_debugging_script], [],
[Create the debugging script $at_group_dir/run which will reproduce the
current test group.])
at_fn_create_debugging_script ()
{
  {
    echo "#! /bin/sh" &&
    echo 'test ${ZSH_VERSION+y} dnl
&& alias -g '\''${1+"$[@]"}'\''='\''"$[@]"'\''' &&
    AS_ECHO(["cd '$at_dir'"]) &&
    AS_ECHO(["exec \${CONFIG_SHELL-$SHELL} \"$at_myself\" -v -d ]dnl
[$at_debug_args $at_group \${1+\"\$[@]\"}"]) &&
    echo 'exit 1'
  } >"$at_group_dir/run" &&
  chmod +x "$at_group_dir/run"
}

m4_text_box([End of autotest shell functions.])
m4_divert_pop([PREPARE_TESTS])dnl back to DEFAULTS

# Not all shells have the 'times' builtin; the subshell is needed to make
# sure we discard the 'times: not found' message from the shell.
at_times_p=false
(times) >/dev/null 2>&1 && at_times_p=:

# CLI Arguments to pass to the debugging scripts.
at_debug_args=
# -e sets to true
at_errexit_p=false
# Shall we be verbose?  ':' means no, empty means yes.
at_verbose=:
at_quiet=
# Running several jobs in parallel, 0 means as many as test groups.
at_jobs=1
at_traceon=:
at_trace_echo=:
at_check_filter_trace=:

# Shall we keep the debug scripts?  Must be ':' when the suite is
# run by a debug script, so that the script doesn't remove itself.
at_debug_p=false
# Display help message?
at_help_p=false
# Display the version message?
at_version_p=false
# List test groups?
at_list_p=false
# --clean
at_clean=false
# Test groups to run
at_groups=
# Whether to rerun failed tests.
at_recheck=
# Whether a write failure occurred
at_write_fail=0

# The directory we run the suite in.  Default to . if no -C option.
at_dir=`pwd`
# An absolute reference to this testsuite script.
dnl m4-double quote, to preserve []
[case $as_myself in
  [\\/]* | ?:[\\/]* ) at_myself=$as_myself ;;
  * ) at_myself=$at_dir/$as_myself ;;
esac]
# Whether -C is in effect.
at_change_dir=false
m4_divert_pop([DEFAULTS])dnl
m4_define([_AT_FINISH],
[m4_ifdef([AT_ingroup], [m4_fatal([missing AT_CLEANUP detected])])dnl
m4_divert_text([DEFAULTS],
[
# Whether to enable colored test results.
at_color=m4_ifdef([AT_color], [AT_color], [no])
# As many question marks as there are digits in the last test group number.
# Used to normalize the test group numbers so that 'ls' lists them in
# numerical order.
at_format='m4_bpatsubst(m4_defn([AT_ordinal]), [.], [?])'
# Description of all the test groups.
at_help_all="AS_ESCAPE(m4_dquote(m4_defn([AT_help_all])))"
# List of the all the test groups.
at_groups_all=`AS_ECHO(["$at_help_all"]) | sed 's/;.*//'`

AS_FUNCTION_DESCRIBE([at_fn_validate_ranges], [NAME...],
[Validate and normalize the test group number contained in each
variable NAME.  Leading zeroes are treated as decimal.])
at_fn_validate_ranges ()
{
  for at_grp
  do
    eval at_value=\$$at_grp
    if test $at_value -lt 1 || test $at_value -gt AT_ordinal; then
      AS_ECHO(["invalid test group: $at_value"]) >&2
      exit 1
    fi
    case $at_value in
      0*) # We want to treat leading 0 as decimal, like expr and test, but
	  # AS_VAR_ARITH treats it as octal if it uses $(( )).
	  # With XSI shells, ${at_value#${at_value%%[1-9]*}} avoids the
	  # expr fork, but it is not worth the effort to determine if the
	  # shell supports XSI when the user can just avoid leading 0.
	  eval $at_grp='`expr $at_value + 0`' ;;
    esac
  done
}])])dnl
m4_divert_push([PARSE_ARGS])dnl

at_prev=
for at_option
do
  # If the previous option needs an argument, assign it.
  if test -n "$at_prev"; then
    at_option=$at_prev=$at_option
    at_prev=
  fi

  case $at_option in
  *=?*) at_optarg=`expr "X$at_option" : '[[^=]]*=\(.*\)'` ;;
  *)    at_optarg= ;;
  esac

  case $at_option in
    --help | -h )
	at_help_p=:
	;;

    --list | -l )
	at_list_p=:
	;;

    --version | -V )
	at_version_p=:
	;;

    --clean | -c )
	at_clean=:
	;;

    --color )
	at_color=always
	;;
    --color=* )
	case $at_optarg in
	no | never | none) at_color=never ;;
	auto | tty | if-tty) at_color=auto ;;
	always | yes | force) at_color=always ;;
	*) at_optname=`echo " $at_option" | sed 's/^ //; s/=.*//'`
	   AS_ERROR([unrecognized argument to $at_optname: $at_optarg]) ;;
	esac
	;;

    --debug | -d )
	at_debug_p=:
	;;

    --errexit | -e )
	at_debug_p=:
	at_errexit_p=:
	;;

    --verbose | -v )
	at_verbose=; at_quiet=:
	;;

    --trace | -x )
	at_traceon='set -x'
	at_trace_echo=echo
	at_check_filter_trace=at_fn_filter_trace
	;;

    [[0-9] | [0-9][0-9] | [0-9][0-9][0-9] | [0-9][0-9][0-9][0-9]])
	at_fn_validate_ranges at_option
	AS_VAR_APPEND([at_groups], ["$at_option$as_nl"])
	;;

    # Ranges
    [[0-9]- | [0-9][0-9]- | [0-9][0-9][0-9]- | [0-9][0-9][0-9][0-9]-])
	at_range_start=`echo $at_option |tr -d X-`
	at_fn_validate_ranges at_range_start
	at_range=`AS_ECHO(["$at_groups_all"]) | \
	  sed -ne '/^'$at_range_start'$/,$p'`
	AS_VAR_APPEND([at_groups], ["$at_range$as_nl"])
	;;

    [-[0-9] | -[0-9][0-9] | -[0-9][0-9][0-9] | -[0-9][0-9][0-9][0-9]])
	at_range_end=`echo $at_option |tr -d X-`
	at_fn_validate_ranges at_range_end
	at_range=`AS_ECHO(["$at_groups_all"]) | \
	  sed -ne '1,/^'$at_range_end'$/p'`
	AS_VAR_APPEND([at_groups], ["$at_range$as_nl"])
	;;

    [[0-9]-[0-9] | [0-9]-[0-9][0-9] | [0-9]-[0-9][0-9][0-9]] | \
    [[0-9]-[0-9][0-9][0-9][0-9] | [0-9][0-9]-[0-9][0-9]] | \
    [[0-9][0-9]-[0-9][0-9][0-9] | [0-9][0-9]-[0-9][0-9][0-9][0-9]] | \
    [[0-9][0-9][0-9]-[0-9][0-9][0-9]] | \
    [[0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]] | \
    [[0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]] )
	at_range_start=`expr $at_option : '\(.*\)-'`
	at_range_end=`expr $at_option : '.*-\(.*\)'`
	if test $at_range_start -gt $at_range_end; then
	  at_tmp=$at_range_end
	  at_range_end=$at_range_start
	  at_range_start=$at_tmp
	fi
	at_fn_validate_ranges at_range_start at_range_end
	at_range=`AS_ECHO(["$at_groups_all"]) | \
	  sed -ne '/^'$at_range_start'$/,/^'$at_range_end'$/p'`
	AS_VAR_APPEND([at_groups], ["$at_range$as_nl"])
	;;

    # Directory selection.
    --directory | -C )
	at_prev=--directory
	;;
    --directory=* )
	at_change_dir=:
	at_dir=$at_optarg
	if test x- = "x$at_dir" ; then
	  at_dir=./-
	fi
	;;

    # Parallel execution.
    --jobs | -j )
	at_jobs=0
	;;
    --jobs=* | -j[[0-9]]* )
	if test -n "$at_optarg"; then
	  at_jobs=$at_optarg
	else
	  at_jobs=`expr X$at_option : 'X-j\(.*\)'`
	fi
	case $at_jobs in *[[!0-9]]*)
	  at_optname=`echo " $at_option" | sed 's/^ //; s/[[0-9=]].*//'`
	  AS_ERROR([non-numeric argument to $at_optname: $at_jobs]) ;;
	esac
	;;

    # Keywords.
    --keywords | -k )
	at_prev=--keywords
	;;
    --keywords=* )
	at_groups_selected=$at_help_all
	at_save_IFS=$IFS
	IFS=,
	set X $at_optarg
	shift
	IFS=$at_save_IFS
	for at_keyword
	do
	  at_invert=
	  case $at_keyword in
	  '!'*)
	    at_invert="-v"
	    at_keyword=`expr "X$at_keyword" : 'X!\(.*\)'`
	    ;;
	  esac
	  # It is on purpose that we match the test group titles too.
	  at_groups_selected=`AS_ECHO(["$at_groups_selected"]) |
	      grep -i $at_invert ["^[1-9][^;]*;.*[; ]$at_keyword[ ;]"]`
	done
	# Smash the keywords.
	at_groups_selected=`AS_ECHO(["$at_groups_selected"]) | sed 's/;.*//'`
	AS_VAR_APPEND([at_groups], ["$at_groups_selected$as_nl"])
	;;
    --recheck)
	at_recheck=:
	;;
m4_divert_pop([PARSE_ARGS])dnl
dnl Process *=* last to allow for user specified --option=* type arguments.
m4_divert_push([PARSE_ARGS_END])dnl

    *=*)
	at_envvar=`expr "x$at_option" : 'x\([[^=]]*\)='`
	# Reject names that are not valid shell variable names.
	case $at_envvar in
	  '' | [[0-9]]* | *[[!_$as_cr_alnum]]* )
	    AS_ERROR([invalid variable name: '$at_envvar']) ;;
	esac
	at_value=`AS_ECHO(["$at_optarg"]) | sed "s/'/'\\\\\\\\''/g"`
	# Export now, but save eval for later and for debug scripts.
	export $at_envvar
	AS_VAR_APPEND([at_debug_args], [" $at_envvar='$at_value'"])
	;;

     *) AS_ECHO(["$as_me: invalid option: $at_option"]) >&2
	AS_ECHO(["Try '$[0] --help' for more information."]) >&2
	exit 1
	;;
  esac
done

# Verify our last option didn't require an argument
AS_IF([test -n "$at_prev"], [AS_ERROR(['$at_prev' requires an argument])])

# The file containing the suite.
at_suite_log=$at_dir/$as_me.log

# Selected test groups.
if test -z "$at_groups$at_recheck"; then
  at_groups=$at_groups_all
else
  if test -n "$at_recheck" && test -r "$at_suite_log"; then
    at_oldfails=`sed -n ['
      /^Failed tests:$/,/^Skipped tests:$/{
	s/^[ ]*\([1-9][0-9]*\):.*/\1/p
      }
      /^Unexpected passes:$/,/^## Detailed failed tests/{
	s/^[ ]*\([1-9][0-9]*\):.*/\1/p
      }
      /^## Detailed failed tests/q
      '] "$at_suite_log"`
    AS_VAR_APPEND([at_groups], ["$at_oldfails$as_nl"])
  fi
  # Sort the tests, removing duplicates.
  at_groups=`AS_ECHO(["$at_groups"]) | sort -nu | sed '/^$/d'`
fi

if test x"$at_color" = xalways \
   || { test x"$at_color" = xauto && test -t 1; }; then
  at_red=`printf '\033@<:@0;31m'`
  at_grn=`printf '\033@<:@0;32m'`
  at_lgn=`printf '\033@<:@1;32m'`
  at_blu=`printf '\033@<:@1;34m'`
  at_std=`printf '\033@<:@m'`
else
  at_red= at_grn= at_lgn= at_blu= at_std=
fi
m4_divert_pop([PARSE_ARGS_END])dnl
m4_divert_push([HELP])dnl

# Help message.
if $at_help_p; then
  cat <<_ATEOF || at_write_fail=1
Usage: $[0] [[OPTION]... [VARIABLE=VALUE]... [TESTS]]

Run all the tests, or the selected TESTS, given by numeric ranges, and
save a detailed log file.  Upon failure, create debugging scripts.

Do not change environment variables directly.  Instead, set them via
command line arguments.  Set 'AUTOTEST_PATH' to select the executables
to exercise.  Each relative directory is expanded as build and source
directories relative to the top level of this distribution.
E.g., from within the build directory /tmp/foo-1.0, invoking this:

  $ $[0] AUTOTEST_PATH=bin

is equivalent to the following, assuming the source directory is /src/foo-1.0:

  PATH=/tmp/foo-1.0/bin:/src/foo-1.0/bin:\$PATH $[0]
_ATEOF
m4_divert_pop([HELP])dnl
m4_divert_push([HELP_MODES])dnl
cat <<_ATEOF || at_write_fail=1

Operation modes:
  -h, --help     print the help message, then exit
  -V, --version  print version number, then exit
  -c, --clean    remove all the files this test suite might create and exit
  -l, --list     describes all the tests, or the selected TESTS
_ATEOF
m4_divert_pop([HELP_MODES])dnl
m4_wrap([m4_divert_push([HELP_TUNING_BEGIN])dnl
cat <<_ATEOF || at_write_fail=1

dnl extra quoting prevents emacs whitespace mode from putting tabs in output
Execution tuning:
  -C, --directory=DIR
[                 change to directory DIR before starting]
      --color[[=never|auto|always]]
[                 ]m4_ifdef([AT_color],
		      [disable colored test results, or enable even without terminal],
		      [enable colored test results on terminal, or always])
  -j, --jobs[[=N]]
[                 Allow N jobs at once; infinite jobs with no arg (default 1)]
  -k, --keywords=KEYWORDS
[                 select the tests matching all the comma-separated KEYWORDS]
[                 multiple '-k' accumulate; prefixed '!' negates a KEYWORD]
      --recheck  select all tests that failed or passed unexpectedly last time
  -e, --errexit  abort as soon as a test fails; implies --debug
  -v, --verbose  force more detailed output
[                 default for debugging scripts]
  -d, --debug    inhibit clean up and top-level logging
[                 default for debugging scripts]
  -x, --trace    enable tests shell tracing
_ATEOF
m4_divert_pop([HELP_TUNING_BEGIN])])dnl
m4_divert_push([HELP_END])dnl
cat <<_ATEOF || at_write_fail=1

Report bugs to <AT_PACKAGE_BUGREPORT>.dnl
m4_ifdef([AT_PACKAGE_NAME],
[m4_ifset([AT_PACKAGE_URL], [
m4_defn([AT_PACKAGE_NAME]) home page: <AT_PACKAGE_URL>.])dnl
m4_if(m4_index(m4_defn([AT_PACKAGE_NAME]), [GNU ]), [0], [
General help using GNU software: <https://www.gnu.org/gethelp/>.])])
_ATEOF
  exit $at_write_fail
fi

# List of tests.
if $at_list_p; then
  cat <<_ATEOF || at_write_fail=1
AT_TESTSUITE_NAME test groups:

 NUM: FILE-NAME:LINE     TEST-GROUP-NAME
      KEYWORDS

_ATEOF
  # Pass an empty line as separator between selected groups and help.
  AS_ECHO(["$at_groups$as_nl$as_nl$at_help_all"]) |
    awk 'NF == 1 && FS != ";" {
	   selected[[$ 1]] = 1
	   next
	 }
	 /^$/ { FS = ";" }
	 NF > 0 {
	   if (selected[[$ 1]]) {
	     printf " %3d: %-18s %s\n", $ 1, $ 2, $ 3
	     if ($ 4) {
	       lmax = 79
	       indent = "     "
	       line = indent
	       len = length (line)
	       n = split ($ 4, a, " ")
	       for (i = 1; i <= n; i++) {
		 l = length (a[[i]]) + 1
		 if (i > 1 && len + l > lmax) {
		   print line
		   line = indent " " a[[i]]
		   len = length (line)
		 } else {
		   line = line " " a[[i]]
		   len += l
		 }
	       }
	       if (n)
		 print line
	     }
	   }
	 }' || at_write_fail=1
  exit $at_write_fail
fi
m4_divert_pop([HELP_END])dnl
m4_divert_push([VERSION])dnl
if $at_version_p; then
  AS_ECHO(["$as_me (AT_PACKAGE_STRING)"]) &&
  cat <<\_ATEOF || at_write_fail=1
m4_divert_pop([VERSION])dnl
m4_divert_push([VERSION_END])dnl
_ATEOF
  exit $at_write_fail
fi
m4_divert_pop([VERSION_END])dnl
m4_divert_push([TESTS_BEGIN])dnl

# Take any -C into account.
if $at_change_dir ; then
  test x != "x$at_dir" && cd "$at_dir" \
    || AS_ERROR([unable to change directory])
  at_dir=`pwd`
fi

# Load the config files for any default variable assignments.
for at_file in atconfig atlocal
do
  test -r $at_file || continue
  . ./$at_file || AS_ERROR([invalid content: $at_file])
done

# Autoconf <=2.59b set at_top_builddir instead of at_top_build_prefix:
: "${at_top_build_prefix=$at_top_builddir}"

# Perform any assignments requested during argument parsing.
eval "$at_debug_args"

# atconfig delivers names relative to the directory the test suite is
# in, but the groups themselves are run in testsuite-dir/group-dir.
if test -n "$at_top_srcdir"; then
  builddir=../..
  for at_dir_var in srcdir top_srcdir top_build_prefix
  do
    AS_VAR_COPY([at_val], [at_$at_dir_var])
    case $at_val in
      [[\\/$]]* | ?:[[\\/]]* ) at_prefix= ;;
      *) at_prefix=../../ ;;
    esac
    AS_VAR_SET([$at_dir_var], [$at_prefix$at_val])
  done
fi

m4_text_box([Directory structure.])

# This is the set of directories and files used by this script
# (non-literals are capitalized):
#
# TESTSUITE         - the testsuite
# TESTSUITE.log     - summarizes the complete testsuite run
# TESTSUITE.dir/    - created during a run, remains after -d or failed test
# + at-groups/      - during a run: status of all groups in run
# | + NNN/          - during a run: meta-data about test group NNN
# | | + check-line  - location (source file and line) of current AT_CHECK
# | | + status      - exit status of current AT_CHECK
# | | + stdout      - stdout of current AT_CHECK
# | | + stder1      - stderr, including trace
# | | + stderr      - stderr, with trace filtered out
# | | + test-source - portion of testsuite that defines group
# | | + times       - timestamps for computing duration
# | | + pass        - created if group passed
# | | + xpass       - created if group xpassed
# | | + fail        - created if group failed
# | | + xfail       - created if group xfailed
# | | + skip        - created if group skipped
# + at-stop         - during a run: end the run if this file exists
# + at-source-lines - during a run: cache of TESTSUITE line numbers for extraction
# + 0..NNN/         - created for each group NNN, remains after -d or failed test
# | + TESTSUITE.log - summarizes the group results
# | + ...           - files created during the group

# The directory the whole suite works in.
# Should be absolute to let the user 'cd' at will.
at_suite_dir=$at_dir/$as_me.dir
# The file containing the suite ($at_dir might have changed since earlier).
at_suite_log=$at_dir/$as_me.log
# The directory containing helper files per test group.
at_helper_dir=$at_suite_dir/at-groups
# Stop file: if it exists, do not start new jobs.
at_stop_file=$at_suite_dir/at-stop
# The fifo used for the job dispatcher.
at_job_fifo=$at_suite_dir/at-job-fifo

if $at_clean; then
  test -d "$at_suite_dir" &&
    find "$at_suite_dir" -type d ! -perm -700 -exec chmod u+rwx \{\} \;
  rm -f -r "$at_suite_dir" "$at_suite_log"
  exit $?
fi

# Don't take risks: use only absolute directories in PATH.
#
# For stand-alone test suites (ie. atconfig was not found),
# AUTOTEST_PATH is relative to '.'.
#
# For embedded test suites, AUTOTEST_PATH is relative to the top level
# of the package.  Then expand it into build/src parts, since users
# may create executables in both places.
AUTOTEST_PATH=`AS_ECHO(["$AUTOTEST_PATH"]) | sed "s|:|$PATH_SEPARATOR|g"`
at_path=
_AS_PATH_WALK([$AUTOTEST_PATH $PATH],
[test -n "$at_path" && AS_VAR_APPEND([at_path], [$PATH_SEPARATOR])
case $as_dir in
  [[\\/]]* | ?:[[\\/]]* )
    AS_VAR_APPEND([at_path], ["$as_dir"])
    ;;
  * )
    if test -z "$at_top_build_prefix"; then
      # Stand-alone test suite.
      AS_VAR_APPEND([at_path], ["$as_dir"])
    else
      # Embedded test suite.
      AS_VAR_APPEND([at_path], ["$at_top_build_prefix$as_dir$PATH_SEPARATOR"])
      AS_VAR_APPEND([at_path], ["$at_top_srcdir/$as_dir"])
    fi
    ;;
esac])

# Now build and simplify PATH.
#
# There might be directories that don't exist, but don't redirect
# builtins' (eg., cd) stderr directly: Ultrix's sh hates that.
at_new_path=
_AS_PATH_WALK([$at_path],
[test -d "$as_dir" || continue
case $as_dir in
  [[\\/]]* | ?:[[\\/]]* ) ;;
  * ) as_dir=`(cd "$as_dir" && pwd) 2>/dev/null` ;;
esac
case $PATH_SEPARATOR$at_new_path$PATH_SEPARATOR in
  *$PATH_SEPARATOR$as_dir$PATH_SEPARATOR*) ;;
  $PATH_SEPARATOR$PATH_SEPARATOR) at_new_path=$as_dir ;;
  *) AS_VAR_APPEND([at_new_path], ["$PATH_SEPARATOR$as_dir"]) ;;
esac])
PATH=$at_new_path
export PATH

# Setting up the FDs.
[#] AS_MESSAGE_LOG_FD is the log file.  Not to be overwritten if '-d'.
if $at_debug_p; then
  at_suite_log=/dev/null
else
  : >"$at_suite_log"
fi
exec AS_MESSAGE_LOG_FD>>"$at_suite_log"

# Banners and logs.
AS_BOX(m4_defn([AT_TESTSUITE_NAME])[.])
{
  AS_BOX(m4_defn([AT_TESTSUITE_NAME])[.])
  echo

  AS_ECHO(["$as_me: command line was:"])
  AS_ECHO(["  \$ $[0] $at_cli_args"])
  echo

  # If ChangeLog exists, list a few lines in case it might help determining
  # the exact version.
  if test -n "$at_top_srcdir" && test -f "$at_top_srcdir/ChangeLog"; then
    AS_BOX([ChangeLog.])
    echo
    sed 's/^/| /;10q' "$at_top_srcdir/ChangeLog"
    echo
  fi

  AS_UNAME
  echo

  # Contents of the config files.
  for at_file in atconfig atlocal
  do
    test -r $at_file || continue
    AS_ECHO(["$as_me: $at_file:"])
    sed 's/^/| /' $at_file
    echo
  done
} >&AS_MESSAGE_LOG_FD

m4_divert_pop([TESTS_BEGIN])dnl
m4_divert_push([TESTS])dnl
{
  AS_BOX([Running the tests.])
} >&AS_MESSAGE_LOG_FD

at_start_date=`date`
at_start_time=`date +%s 2>/dev/null`
AS_ECHO(["$as_me: starting at: $at_start_date"]) >&AS_MESSAGE_LOG_FD

# Create the master directory if it doesn't already exist.
AS_MKDIR_P(["$at_suite_dir"]) ||
  AS_ERROR([cannot create '$at_suite_dir'])

# Can we diff with '/dev/null'?  DU 5.0 refuses.
if diff /dev/null /dev/null >/dev/null 2>&1; then
  at_devnull=/dev/null
else
  at_devnull=$at_suite_dir/devnull
  >"$at_devnull"
fi

# Use 'diff -u' when possible.
if at_diff=`diff -u "$at_devnull" "$at_devnull" 2>&1` && test -z "$at_diff"
then
  at_diff='diff -u'
else
  at_diff=diff
fi

# Get the last needed group.
for at_group in : $at_groups; do :; done

# Extract the start and end lines of each test group at the tail
# of this file
awk '
BEGIN { FS="