diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-10-22 03:16:00 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-10-22 03:41:03 +0300 |
commit | 09372ddfbaeb45facface67dea795f8e9059d899 (patch) | |
tree | 6240cdadf4ed6bc9b28f28cc7195e9f737285d38 | |
parent | 2f34f8ae2c0f9207d94629d94f664f728094e990 (diff) | |
download | mailutils-09372ddfbaeb45facface67dea795f8e9059d899.tar.gz mailutils-09372ddfbaeb45facface67dea795f8e9059d899.tar.bz2 |
Fixes in the testsuite & some minor fixes.
* comsat/comsat.c (main): Use real UID to determine user name. Don't
rely on environment variables.
* maidag/util.c (maidag_error): Re-initialize va_list before reusing it.
* mh/ali.c (ali_print_name_list): Change printing loop to correctly
handle empty lists.
* mh/mh_whatnow.c (quit): Print newline before returning.
* comsat/tests/testsuite.at: Skip tests if run as root.
* maidag/tests/forward.at: Skip test if run as root.
* mh/tests/ali.at: Ignore comment lines in /etc/passwd and /etc/group.
Make sure awk is run with a valid stdin. Some implementations
(true awk, in particular) try to close stdin even if it is not used and
bail out if unable to do so.
* mh/tests/atlocal.in (mimeflt): Make sure awk is run with a valid
stdin (see above).
* mh/tests/anno.at: Always use semicolon before closing curly brace in
sed expressions.
* mh/tests/mark.at: Likewise.
* mh/tests/pick.at: Likewise.
* testsuite/testsuite.inc: Likewise.
* mh/tests/comp.at: Reflect changes to mh_whatnow.c.
* mh/tests/mhn.at: Don't rely on a particular tar output format.
-rw-r--r-- | comsat/comsat.c | 19 | ||||
-rw-r--r-- | comsat/tests/testsuite.at | 5 | ||||
-rw-r--r-- | maidag/tests/forward.at | 3 | ||||
-rw-r--r-- | maidag/util.c | 2 | ||||
-rw-r--r-- | mh/ali.c | 15 | ||||
-rw-r--r-- | mh/mh_whatnow.c | 4 | ||||
-rw-r--r-- | mh/tests/ali.at | 12 | ||||
-rw-r--r-- | mh/tests/anno.at | 8 | ||||
-rw-r--r-- | mh/tests/atlocal.in | 2 | ||||
-rw-r--r-- | mh/tests/comp.at | 3 | ||||
-rw-r--r-- | mh/tests/mark.at | 12 | ||||
-rw-r--r-- | mh/tests/mhn.at | 18 | ||||
-rw-r--r-- | mh/tests/pick.at | 2 | ||||
-rw-r--r-- | testsuite/testsuite.inc | 2 |
14 files changed, 52 insertions, 55 deletions
diff --git a/comsat/comsat.c b/comsat/comsat.c index 9592e484c..e9a5a220c 100644 --- a/comsat/comsat.c +++ b/comsat/comsat.c @@ -578,6 +578,7 @@ main (int argc, char **argv) if (test_mode) { + struct passwd *pw; char *user; argc -= ind; @@ -591,21 +592,13 @@ main (int argc, char **argv) exit (EXIT_FAILURE); } - user = getenv ("LOGNAME"); - if (!user) + pw = getpwuid (getuid ()); + if (!pw) { - user = getenv ("USER"); - if (!user) - { - struct passwd *pw = getpwuid (getuid ()); - if (!pw) - { - mu_error (_("cannot determine user name")); - exit (EXIT_FAILURE); - } - user = pw->pw_name; - } + mu_error (_("cannot determine user name")); + exit (EXIT_FAILURE); } + user = pw->pw_name; if (biffrc[0] == '.' && (biffrc[1] == '/' || (biffrc[1] == '.' && biffrc[2] == '/'))) diff --git a/comsat/tests/testsuite.at b/comsat/tests/testsuite.at index c61308cff..4ccda9ab0 100644 --- a/comsat/tests/testsuite.at +++ b/comsat/tests/testsuite.at @@ -29,11 +29,14 @@ m4_pushdef([comsatcmd],[comsatd --no-site --no-user --file ./biff.rc dnl dnl ------------------------------------------------------------ dnl BIFFTEST(DESCR, KW, DATA, CMDLINE, [STDOUT = `'], [STDERR = `']) dnl +dnl NOTE: The test is skipped if run as root, because .biffrc is +dnl ignored for root (see open_rc() in action.c +dnl m4_pushdef([BIFFTEST],[ AT_SETUP([comsatd: $1]) AT_KEYWORDS([comsatd $2]) $3 -AT_CHECK([$4],[0],[$5],[$6]) +AT_CHECK([test -w / && AT_SKIP_TEST; $4],[0],[$5],[$6]) AT_CLEANUP]) AT_INIT diff --git a/maidag/tests/forward.at b/maidag/tests/forward.at index bed72d70a..5413d6083 100644 --- a/maidag/tests/forward.at +++ b/maidag/tests/forward.at @@ -23,8 +23,9 @@ m4_pushdef([FORWARD_OPTIONS],[dnl --set "^forward-file-checks=none"]) AT_CHECK([ +test -w / && AT_SKIP_TEST forward=`pwd`/my.forward -namelist=`sed 's/:.*//;3,$d' /etc/passwd 2>/dev/null` +namelist=`sed '/^#/d;s/:.*//' /etc/passwd | sed '3,$d'` test -n "$namelist" || AT_SKIP_TEST cat > my.forward <<EOT diff --git a/maidag/util.c b/maidag/util.c index 406488203..8d46dcc14 100644 --- a/maidag/util.c +++ b/maidag/util.c @@ -73,6 +73,8 @@ maidag_error (const char *fmt, ...) vfprintf (stderr, fmt, ap); fputc ('\n', stderr); } + va_end (ap); + va_start (ap, fmt); mu_verror (fmt, ap); va_end (ap); } @@ -128,24 +128,23 @@ ali_print_name_list (mu_list_t list, int off) { int ncol = getcols (); int n = off; + int i = 0; - mu_iterator_first (itr); - - for (;;) + for (mu_iterator_first (itr), i = 0; + !mu_iterator_is_done (itr); + mu_iterator_next (itr), i++) { int len; + if (i > 0) + n += printf (", "); + mu_iterator_current (itr, (void **)&item); len = strlen (item) + 2; if (n + len > ncol) n = printf ("\n "); len = printf ("%s", item); - mu_iterator_next (itr); - if (!mu_iterator_is_done (itr)) - len += printf (", "); - else - break; n += len; } printf ("\n"); diff --git a/mh/mh_whatnow.c b/mh/mh_whatnow.c index 85a13d6e2..ad2749085 100644 --- a/mh/mh_whatnow.c +++ b/mh/mh_whatnow.c @@ -427,12 +427,12 @@ quit (struct mh_whatnow_env *wh, int argc, char **argv, int *status) unlink (wh->draftfile); else { - mu_printf (_("draft left on \"%s\".\n"), wh->draftfile); + mu_printf (_("draft left on \"%s\"."), wh->draftfile); if (strcmp (wh->file, wh->draftfile)) rename (wh->file, wh->draftfile); } } - + mu_printf ("\n"); return 1; } diff --git a/mh/tests/ali.at b/mh/tests/ali.at index 4686aa8a2..21372a226 100644 --- a/mh/tests/ali.at +++ b/mh/tests/ali.at @@ -75,7 +75,7 @@ ali: mh_aliases2:2: `mh_aliases' already included at top level ]) MH_CHECK([ali: group name],[ali04 ali-group-name],[ -awk -F : '$4!="" { print $1; print $4; exit 0 }' /etc/group > tmpout +cat /etc/group | awk -F : '/^#/ { next } $4!="" { print $1; print $4; exit 0 }' > tmpout test -s tmpout || AT_SKIP_TEST sed -n '1s/.*/korzen: =&/p' tmpout > mh_aliases sed '1d' tmpout | tr -d ' ' > expout @@ -85,14 +85,12 @@ ali -a ./mh_aliases korzen | tr -d ' ' [expout]) MH_CHECK([ali: group id],[ali05 ali-group-id ali-gid],[ -awk -F : '$4==0 { print $1 }' /etc/passwd > expout +cat /etc/passwd | awk -F : '/^#/ { next } $4==0 { print $1 }' > expout test -s expout || AT_SKIP_TEST -name=`awk -F : '$3==0 { print $1 }' /etc/group` +name=`awk -F : '/^#/ { next } $3==0 { print $1 }' /etc/group < /dev/null` test -z "$name" && AT_SKIP_TEST -AT_DATA([mh_aliases],[ -korzen: +root -]) +echo "korzen: +$name" > mh_aliases # FIXME: Do I need to sort the output? ali -list -a ./mh_aliases korzen ], @@ -100,7 +98,7 @@ ali -list -a ./mh_aliases korzen [expout]) MH_CHECK([ali: everybody],[ali06 ali-everybody],[ -awk -F : '$3>200 { print $1 }' /etc/passwd > expout +cat /etc/passwd | awk -F : '/^#/ { next } $3>200 { print $1 }' > expout test -s expout || AT_SKIP_TEST AT_DATA([mh_aliases],[ everybody: * diff --git a/mh/tests/anno.at b/mh/tests/anno.at index 25bed0911..a6d97ad06 100644 --- a/mh/tests/anno.at +++ b/mh/tests/anno.at @@ -22,7 +22,7 @@ MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox]) echo "Current-Folder: inbox" > Mail/context echo "cur: 1" > Mail/inbox/.mh_sequences echo Replied | anno || exit $? -sed -n '1{s/Replied: .*/REPLIED/p}' Mail/inbox/1 +sed -n '1{s/Replied: .*/REPLIED/p;}' Mail/inbox/1 ], [0], [REPLIED @@ -32,7 +32,7 @@ MH_CHECK([anno -component],[anno01 anno-component],[ MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox]) echo "Current-Folder: inbox" > Mail/context anno -component Replied 1 || exit $? -sed -n '1{s/Replied: .*/REPLIED/p}' Mail/inbox/1 +sed -n '1{s/Replied: .*/REPLIED/p;}' Mail/inbox/1 ], [0], [REPLIED @@ -42,7 +42,7 @@ MH_CHECK([anno -component -text],[anno02 anno-component-text],[ MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox]) echo "Current-Folder: inbox" > Mail/context anno -component Replied -text OK 1 || exit $? -sed -n '3,$d;/Replied/{s/Replied: [[A-Z][a-z][a-z], [0-9][0-9] [A-Z][a-z][a-z] [0-9][0-9][0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] .*]/Replied: DATE/;p}' Mail/inbox/1 +sed -n '3,$d;/Replied/{s/Replied: [[A-Z][a-z][a-z], [0-9][0-9] [A-Z][a-z][a-z] [0-9][0-9][0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] .*]/Replied: DATE/;p;}' Mail/inbox/1 ], [0], [Replied: OK @@ -53,7 +53,7 @@ MH_CHECK([anno -component -text -nodate],[anno03 anno-component-text-nodate],[ MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox]) echo "Current-Folder: inbox" > Mail/context anno -component Replied -text OK -nodate 1 || exit $? -sed -n '3,$d;/Replied/{s/Replied: [[A-Z][a-z][a-z], [0-9][0-9] [A-Z][a-z][a-z] [0-9][0-9][0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] .*]/Replied: DATE/;p}' Mail/inbox/1 +sed -n '3,$d;/Replied/{s/Replied: [[A-Z][a-z][a-z], [0-9][0-9] [A-Z][a-z][a-z] [0-9][0-9][0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9] .*]/Replied: DATE/;p;}' Mail/inbox/1 ], [0], [Replied: OK diff --git a/mh/tests/atlocal.in b/mh/tests/atlocal.in index 6a38c2bee..18e9d842f 100644 --- a/mh/tests/atlocal.in +++ b/mh/tests/atlocal.in @@ -35,5 +35,5 @@ awk ' } else print } -' $* +' $* </dev/null } diff --git a/mh/tests/comp.at b/mh/tests/comp.at index b264f2532..88f423d67 100644 --- a/mh/tests/comp.at +++ b/mh/tests/comp.at @@ -49,7 +49,8 @@ cc: Subject: -------- -- Input file end -What now?]) +What now? +]) MH_CHECK([comp file],[comp02 comp_file],[ echo 'quit' | compcmd file | remove_curdir | sed 's/ *$//' diff --git a/mh/tests/mark.at b/mh/tests/mark.at index 3646e6c40..8072dc72b 100644 --- a/mh/tests/mark.at +++ b/mh/tests/mark.at @@ -22,7 +22,7 @@ MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox]) echo 'Current-Folder: inbox' > Mail/context mark -sequence andro -add 2 mark -sequence andro -add 3-5 -sed -n '/^andro:/{s/ */ /g;s/ $//;p}' Mail/inbox/.mh_sequences +sed -n '/^andro:/{s/ */ /g;s/ $//;p;}' Mail/inbox/.mh_sequences ], [0], [andro: 2 3 4 5 @@ -32,9 +32,9 @@ MH_CHECK([mark -add -zero],[mark01 mark-add-zero],[ MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox]) echo 'Current-Folder: inbox' > Mail/context mark -sequence andro -add 2 -sed -n '/^andro:/{s/ */ /g;s/ $//;p}' Mail/inbox/.mh_sequences +sed -n '/^andro:/{s/ */ /g;s/ $//;p;}' Mail/inbox/.mh_sequences mark -zero -sequence andro -add 1 3 -sed -n '/^andro:/{s/ */ /g;s/ $//;p}' Mail/inbox/.mh_sequences +sed -n '/^andro:/{s/ */ /g;s/ $//;p;}' Mail/inbox/.mh_sequences ], [0], [andro: 2 @@ -45,7 +45,7 @@ MH_CHECK([mark -add -nopublic],[mark02 mark-add-nopublic],[ MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox]) echo 'Current-Folder: inbox' > Mail/context mark -nopublic -sequence andro -add 1 2 3 -sed -n '/^atr-andro/{s/ */ /g;s/ $//;s/^[[^:]]*:/atr-andro:/;p}' Mail/context +sed -n '/^atr-andro/{s/ */ /g;s/ $//;s/^[[^:]]*:/atr-andro:/;p;}' Mail/context ], [0], [atr-andro: 1 2 3 @@ -56,7 +56,7 @@ MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mbox1,[Mail/inbox]) echo 'Current-Folder: inbox' > Mail/context echo 'andro: 2 3 4 5' > Mail/inbox/.mh_sequences mark -sequence andro -del 3 -sed -n '/^andro:/{s/ */ /g;s/ $//;p}' Mail/inbox/.mh_sequences +sed -n '/^andro:/{s/ */ /g;s/ $//;p;}' Mail/inbox/.mh_sequences ], [0], [andro: 2 4 5 @@ -70,7 +70,7 @@ cat > Mail/context <<EOT atr-andro-$inbox: 2 3 4 5 EOT mark -nopublic -sequence andro -del 3 -sed -n '/^atr-andro/{s/ */ /g;s/ $//;s/^[[^:]]*:/atr-andro:/;p}' Mail/context +sed -n '/^atr-andro/{s/ */ /g;s/ $//;s/^[[^:]]*:/atr-andro:/;p;}' Mail/context ], [0], [atr-andro: 2 4 5 diff --git a/mh/tests/mhn.at b/mh/tests/mhn.at index d55d4e73c..74b96db67 100644 --- a/mh/tests/mhn.at +++ b/mh/tests/mhn.at @@ -337,7 +337,7 @@ MH_CHECK([mhn-show type=tar],[mhn13 mhn-show-type=tar],[ MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mime,[Mail/inbox],[700]) AT_DATA([filter.awk],[ /^X-IMAPbase/ { next } -/^-rw-r--r--/ { print $1, $2, $3, $6; next } +/^-rw-r--r--/ { print $NF; next } { print } ]) mhn -show 2 | awk -f filter.awk @@ -355,8 +355,8 @@ X-Envelope-Sender: gray@example.net part 1 text/plain 15 Initial text. --rw-r--r-- gray/staff 1418 Father_William --rw-r--r-- gray/staff 937 Jabberwocky +Father_William +Jabberwocky ]) # FIXME: What about exit code? @@ -388,7 +388,7 @@ MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mime,[Mail/inbox],[700]) echo "mhn-show-application/x-tar: %ltar tvf '%F'" >> $MH AT_DATA([filter.awk],[ /^X-IMAPbase/ { next } -/^-rw-r--r--/ { print $1, $2, $3, $6; next } +/^-rw-r--r--/ { print $NF; next } { sub(/ *$/,""); print } ]) mhn -show 1 | awk -f filter.awk @@ -407,8 +407,8 @@ part 1 text/plain 15 Initial text. part 2 application/x-tar 13835 --rw-r--r-- gray/staff 1418 Father_William --rw-r--r-- gray/staff 937 Jabberwocky +Father_William +Jabberwocky ]) MH_CHECK([mhn-show- variable (without subtype)], @@ -417,7 +417,7 @@ MUT_MBCOPY($abs_top_srcdir/testsuite/mh/mime,[Mail/inbox],[700]) echo "mhn-show-application: %ltar tvf '%F'" >> $MH AT_DATA([filter.awk],[ /^X-IMAPbase/ { next } -/^-rw-r--r--/ { print $1, $2, $3, $6; next } +/^-rw-r--r--/ { print $NF; next } { sub(/ *$/,""); print } ]) mhn -show 1 | awk -f filter.awk @@ -436,8 +436,8 @@ part 1 text/plain 15 Initial text. part 2 application/x-tar 13835 --rw-r--r-- gray/staff 1418 Father_William --rw-r--r-- gray/staff 937 Jabberwocky +Father_William +Jabberwocky ]) dnl ------------------------------------------------------------------- diff --git a/mh/tests/pick.at b/mh/tests/pick.at index 726b4bdb3..81ffe750d 100644 --- a/mh/tests/pick.at +++ b/mh/tests/pick.at @@ -46,7 +46,7 @@ MUT_MBCOPY($abs_top_srcdir/testsuite/mh/teaparty,[Mail/inbox]) echo "Current-Folder: inbox" > Mail/context echo "cur: 1" > Mail/inbox/.mh_sequences pick -from dormouse -sequence dormouse || exit $? -sed -n '/^dormouse:/{s/ */ /g;s/ $//;p}' Mail/inbox/.mh_sequences +sed -n '/^dormouse:/{s/ */ /g;s/ $//;p;}' Mail/inbox/.mh_sequences ], [0], [dormouse: 17 31 49 61 65 67 69 77 79 81 83 88 89 91 92 diff --git a/testsuite/testsuite.inc b/testsuite/testsuite.inc index 64407a007..02c89a0bc 100644 --- a/testsuite/testsuite.inc +++ b/testsuite/testsuite.inc @@ -27,7 +27,7 @@ dnl m4_define([MUT_VERSION],[ AT_SETUP([$1 version]) -AT_CHECK([$1 --version | sed '1{s/ *[\[.*\]]//;q}' ], +AT_CHECK([$1 --version | sed '1{s/ *[\[.*\]]//;q;}' ], [0], [$1 (AT_PACKAGE_NAME) AT_PACKAGE_VERSION ], |