[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Autotest function usage
From: |
Ralf Wildenhues |
Subject: |
Re: Autotest function usage |
Date: |
Sun, 21 Oct 2007 14:36:55 +0200 |
User-agent: |
Mutt/1.5.16 (2007-10-11) |
Hello Paolo,
* Paolo Bonzini wrote on Fri, Oct 19, 2007 at 04:47:34PM CEST:
>
>> Should the individual test source files be deleted at the end, or even
>> after each one is completed? Only if -d is not given?
>
> Yes. The attached patch, redone after Eric's conflicting changes, does
> this too.
Thanks.
> I'll leave the portability shake and possibly the final commit to you.
Well, here's what I'm at now. :-/
> +[{
> + echo 'BEGIN {'
> + for at_group in $at_groups; do
> + at_group_normalized=$at_group
> + ]_AT_NORMALIZE_TEST_GROUP_NUMBER(at_group_normalized)[
> + echo " outfile[\"$at_group\"] =
> \"$at_test_source-$at_group_normalized\""
> + done
> + echo '}
> +!emit && /address@hidden:@AT_START_/ {
Solaris awk barfs over `emit' and `!emit' as tests, but accepts `emit !=
0' and `emit == 0', respectively.
> + test = substr($][1, 11);
I've used `$ 0' here instead of `$][1', first for easier reading, and
then because the latter could induce awk to split the line (if a user
were so mean as to start a line with `#AT_START_' and put many arguments
in it, and that test would be excepted from running.
> + if (test in outfile) emit = 1
`if (key in array)' is not portable, but `if (array[key])' is.
> +}
> +emit && /address@hidden:@AT_STOP_/ {
(*)
> + emit = 0
> +}
> +emit { print > outfile[test] }
Solaris awk barfs when writing to more than 10 files:
| awk: too many output files 10
| record number 3451
| testsuite: unable to parse test groups
Adding at (*) the line
if (outfile[test]) close (outfile[test])
doesn't help though. Does anyone see an easy way out here?
> +'
> +}] > "$at_test_source.awk"
Cheers,
Ralf
2007-10-20 Paolo Bonzini <address@hidden>
and Ralf Wildenhues <address@hidden>
* lib/autotest/general.m4 (at_func_test): Remove.
(AT_INIT): Pre-extract test groups into separate files.
(AT_CLEANUP): Source pre-extracted file instead of calling at_func_test.
Remove at-test-source files together with the $at_group_dir.
diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4
index 29834f1..49026f2 100644
--- a/lib/autotest/general.m4
+++ b/lib/autotest/general.m4
@@ -310,15 +310,6 @@ at_func_diff_devnull ()
$at_diff "$at_devnull" "$[1]"
}
-# at_func_test NUMBER
-# -------------------
-# Parse out test NUMBER from the tail of this file.
-at_func_test ()
-{
- sed -n
'/address@hidden:@AT_START_'$[1]'$/,/address@hidden:@AT_STOP_'$[1]'$/p'
"$at_myself" \
- > "$at_test_source"
-}
-
# at_func_create_debugging_script
# -------------------------------
# Create the debugging script $at_group_dir/run which will reproduce the
@@ -413,7 +404,7 @@ at_status_file=$at_suite_dir/at-status
at_stdout=$at_suite_dir/at-stdout
at_stder1=$at_suite_dir/at-stder1
at_stderr=$at_suite_dir/at-stderr
-# The file containing the function to run a test group.
+# The stem for files containing a test group.
at_test_source=$at_suite_dir/at-test-source
# The file containing dates.
at_times_file=$at_suite_dir/at-times
@@ -853,6 +844,31 @@ else
at_diff=diff
fi
+[{
+ echo 'BEGIN {'
+ for at_group in $at_groups; do
+ at_group_normalized=$at_group
+ ]_AT_NORMALIZE_TEST_GROUP_NUMBER(at_group_normalized)[
+ echo " outfile[\"$at_group\"] = \"$at_test_source-$at_group_normalized\""
+ done
+ echo '}
+emit == 0 && /address@hidden:@AT_START_/ {
+ test = substr($ 0, 11);
+ if (outfile[test]) emit = 1
+}
+emit != 0 && /address@hidden:@AT_STOP_/ {
+ if (outfile[test]) close (outfile[test])
+ emit = 0
+}
+emit != 0 { print > outfile[test] }
+'
+}] > "$at_test_source.awk"
+
+# Extract test group that will be run from the tail of this file
+if awk -f "$at_test_source.awk" "$at_myself"; then :; else
+ AS_ECHO(["$as_me: unable to parse test groups"]) >&2
+ exit 1
+fi
m4_text_box([Driver loop.])
for at_group in $at_groups
@@ -888,10 +904,7 @@ do
at_tee_pipe='cat >> "$at_group_log"'
fi
- if at_func_test $at_group && . "$at_test_source"; then :; else
- AS_ECHO(["$as_me: unable to parse test group: $at_group"]) >&2
- at_failed=:
- fi
+ . "$at_test_source-$at_group_normalized"
# Be sure to come back to the suite directory, in particular
# since below we might `rm' the group directory we are in currently.
@@ -954,9 +967,12 @@ _ATEOF
# Cleanup the group directory, unless the user wants the files.
if $at_debug_p ; then
at_func_create_debugging_script
- elif test -d "$at_group_dir"; then
- find "$at_group_dir" -type d ! -perm -700 -exec chmod u+rwx \{\} \;
- rm -fr "$at_group_dir"
+ else
+ if test -d "$at_group_dir"; then
+ find "$at_group_dir" -type d ! -perm -700 -exec chmod u+rwx \{\} \;
+ rm -fr "$at_group_dir"
+ fi
+ rm -f "$at_test_source-$at_group_normalized"
fi
;;
*)
- Re: Autotest function usage, (continued)
- Re: Autotest function usage, Eric Blake, 2007/10/17
- Re: Autotest function usage, Eric Blake, 2007/10/17
- Re: Autotest function usage, Ralf Wildenhues, 2007/10/17
- Re: Autotest function usage, Paolo Bonzini, 2007/10/18
- Re: Autotest function usage, Ralf Wildenhues, 2007/10/18
- Re: Autotest function usage, Paolo Bonzini, 2007/10/18
- Re: Autotest function usage, Paolo Bonzini, 2007/10/19
- Re: Autotest function usage,
Ralf Wildenhues <=
- Re: Autotest function usage, Ralf Wildenhues, 2007/10/21