Optimize libmailutils testsuite.
* libmailutils/tests/testsuite.at (MU_TEST_GROUP) (MU_TEST_KEYWORDS, MU_TEST_COMMAND): New defines. (mu_trimstr, mu_firstline): New macros. (MU_GENERIC_TEST): New macro. * libmailutils/tests/addr.c: Accept addresses from stdin. * libmailutils/tests/address.at (TESTADDR): If the address contains single quotes, pass it to the program via stdin. Uncomment all such tests. * libmailutils/tests/argcv.at (TESTARGS): Rewrite as a wrapper over MU_GENERIC_TEST. * libmailutils/tests/decode2047.at (TESTDEC2047): Likewise. * libmailutils/tests/mailcap.at (MAILCAP): Likewise. * libmailutils/tests/url.at (TESTURL): Likewise. * libmailutils/tests/mailcap.c: Accept data from stdin.
Showing
8 changed files
with
116 additions
and
78 deletions
... | @@ -20,6 +20,7 @@ | ... | @@ -20,6 +20,7 @@ |
20 | #ifdef HAVE_CONFIG_H | 20 | #ifdef HAVE_CONFIG_H |
21 | # include <config.h> | 21 | # include <config.h> |
22 | #endif | 22 | #endif |
23 | #include <stdlib.h> | ||
23 | #include <stdio.h> | 24 | #include <stdio.h> |
24 | #include <string.h> | 25 | #include <string.h> |
25 | #include <errno.h> | 26 | #include <errno.h> |
... | @@ -28,13 +29,14 @@ | ... | @@ -28,13 +29,14 @@ |
28 | #include <mailutils/errno.h> | 29 | #include <mailutils/errno.h> |
29 | #include <mailutils/kwd.h> | 30 | #include <mailutils/kwd.h> |
30 | #include <mailutils/mutil.h> | 31 | #include <mailutils/mutil.h> |
32 | #include <mailutils/cstr.h> | ||
33 | #include <mailutils/cctype.h> | ||
31 | 34 | ||
32 | #define EPARSE MU_ERR_NOENT | 35 | #define EPARSE MU_ERR_NOENT |
33 | 36 | ||
34 | int | 37 | int |
35 | main (int argc, char *argv[]) | 38 | parse (const char *str) |
36 | { | 39 | { |
37 | char *str; | ||
38 | size_t i; | 40 | size_t i; |
39 | size_t pcount = 0; | 41 | size_t pcount = 0; |
40 | int status; | 42 | int status; |
... | @@ -42,13 +44,6 @@ main (int argc, char *argv[]) | ... | @@ -42,13 +44,6 @@ main (int argc, char *argv[]) |
42 | mu_address_t address = NULL; | 44 | mu_address_t address = NULL; |
43 | struct mu_address hint; | 45 | struct mu_address hint; |
44 | 46 | ||
45 | if (argc != 2) | ||
46 | { | ||
47 | fprintf (stderr, "usage: %s address\n", argv[0]); | ||
48 | return 2; | ||
49 | } | ||
50 | str = argv[1]; | ||
51 | |||
52 | hint.domain = "localhost"; | 47 | hint.domain = "localhost"; |
53 | status = mu_address_create_hint (&address, str, &hint, MU_ADDR_HINT_DOMAIN); | 48 | status = mu_address_create_hint (&address, str, &hint, MU_ADDR_HINT_DOMAIN); |
54 | mu_address_get_count (address, &pcount); | 49 | mu_address_get_count (address, &pcount); |
... | @@ -101,3 +96,25 @@ main (int argc, char *argv[]) | ... | @@ -101,3 +96,25 @@ main (int argc, char *argv[]) |
101 | mu_address_destroy (&address); | 96 | mu_address_destroy (&address); |
102 | return 0; | 97 | return 0; |
103 | } | 98 | } |
99 | |||
100 | int | ||
101 | main (int argc, char *argv[]) | ||
102 | { | ||
103 | char buf[256]; | ||
104 | |||
105 | if (argc > 2) | ||
106 | { | ||
107 | fprintf (stderr, "usage: %s [address]\n", argv[0]); | ||
108 | return 2; | ||
109 | } | ||
110 | |||
111 | if (argc == 2) | ||
112 | exit (parse (argv[1])); | ||
113 | |||
114 | while (fgets (buf, sizeof buf, stdin)) | ||
115 | { | ||
116 | mu_rtrim_class (buf, MU_CTYPE_SPACE); | ||
117 | parse (buf); | ||
118 | } | ||
119 | return 0; | ||
120 | } | ... | ... |
... | @@ -22,7 +22,10 @@ dnl | ... | @@ -22,7 +22,10 @@ dnl |
22 | m4_define([TESTADDR],[ | 22 | m4_define([TESTADDR],[ |
23 | AT_SETUP([Address: [$1]]) | 23 | AT_SETUP([Address: [$1]]) |
24 | AT_KEYWORDS([address $2]) | 24 | AT_KEYWORDS([address $2]) |
25 | AT_CHECK([addr '[$1]'],m4_shift(m4_shift($@))) | 25 | AT_CHECK([m4_if(m4_index([$1],[']),-1,[addr '[$1]'], |
26 | [AT_DATA([input],[$1 | ||
27 | ]) | ||
28 | addr < input])],m4_shift(m4_shift($@))) | ||
26 | AT_CLEANUP | 29 | AT_CLEANUP |
27 | ]) | 30 | ]) |
28 | 31 | ||
... | @@ -320,9 +323,7 @@ personal <#369> | ... | @@ -320,9 +323,7 @@ personal <#369> |
320 | local-part <guug-bugs-closed> domain <guug.de> | 323 | local-part <guug-bugs-closed> domain <guug.de> |
321 | ]) | 324 | ]) |
322 | 325 | ||
323 | dnl -------------------------------------------------------------------------- | 326 | TESTADDR(["'Aernoudt Bottemanne'" <Aernoudt.Bottemanne@Informix.com>],[], |
324 | dnl FIXME: | ||
325 | m4_if([TESTADDR(["'Aernoudt Bottemanne'" <Aernoudt.Bottemanne@Informix.com>],[], | ||
326 | [0], | 327 | [0], |
327 | [naddr: 1 | 328 | [naddr: 1 |
328 | 1. email <Aernoudt.Bottemanne@Informix.com>: | 329 | 1. email <Aernoudt.Bottemanne@Informix.com>: |
... | @@ -369,12 +370,12 @@ local-part <paul> domain <pitbull-productions.com> | ... | @@ -369,12 +370,12 @@ local-part <paul> domain <pitbull-productions.com> |
369 | ]) | 370 | ]) |
370 | 371 | ||
371 | TESTADDR(["'sam@cogent.ca'" <sam@cogent.ca>, "'sroberts@uniserve.com'"],[], | 372 | TESTADDR(["'sam@cogent.ca'" <sam@cogent.ca>, "'sroberts@uniserve.com'"],[], |
372 | [1], | 373 | [0], |
373 | [], | 374 | [], |
374 | [MU_ERR_BAD_822_FORMAT | 375 | [MU_ERR_BAD_822_FORMAT |
375 | ]) | 376 | ]) |
376 | 377 | ||
377 | TESTADDR(["'sroberts\@certicom\.ca'" <sroberts@certicom.ca>],[] | 378 | TESTADDR(["'sroberts\@certicom\.ca'" <sroberts@certicom.ca>],[], |
378 | [0], | 379 | [0], |
379 | [naddr: 1 | 380 | [naddr: 1 |
380 | 1. email <sroberts@certicom.ca>: | 381 | 1. email <sroberts@certicom.ca>: |
... | @@ -382,9 +383,6 @@ personal <'sroberts@certicom.ca'> | ... | @@ -382,9 +383,6 @@ personal <'sroberts@certicom.ca'> |
382 | local-part <sroberts> domain <certicom.ca> | 383 | local-part <sroberts> domain <certicom.ca> |
383 | ]) | 384 | ]) |
384 | 385 | ||
385 | ]) | ||
386 | dnl -------------------------------------------------------------------------- | ||
387 | |||
388 | TESTADDR(["=?iso-8859-1?Q?Juan_Carlos_Marcos_Rodr=EDguez?=" <jcmarcos@datavoice.es>],[], | 386 | TESTADDR(["=?iso-8859-1?Q?Juan_Carlos_Marcos_Rodr=EDguez?=" <jcmarcos@datavoice.es>],[], |
389 | [0], | 387 | [0], |
390 | [naddr: 1 | 388 | [naddr: 1 |
... | @@ -477,8 +475,6 @@ local-part <jpalme> domain <dsv.su.se> | ... | @@ -477,8 +475,6 @@ local-part <jpalme> domain <dsv.su.se> |
477 | local-part <drums> domain <cs.utk.edu> | 475 | local-part <drums> domain <cs.utk.edu> |
478 | ]) | 476 | ]) |
479 | 477 | ||
480 | dnl FIXME | ||
481 | m4_if([ | ||
482 | TESTADDR(["Jakob 'sparky' Kaivo" <jkaivo@elijah.nodomainname.net>],[], | 478 | TESTADDR(["Jakob 'sparky' Kaivo" <jkaivo@elijah.nodomainname.net>],[], |
483 | [0], | 479 | [0], |
484 | [naddr: 1 | 480 | [naddr: 1 |
... | @@ -486,7 +482,6 @@ TESTADDR(["Jakob 'sparky' Kaivo" <jkaivo@elijah.nodomainname.net>],[], | ... | @@ -486,7 +482,6 @@ TESTADDR(["Jakob 'sparky' Kaivo" <jkaivo@elijah.nodomainname.net>],[], |
486 | personal <Jakob 'sparky' Kaivo> | 482 | personal <Jakob 'sparky' Kaivo> |
487 | local-part <jkaivo> domain <elijah.nodomainname.net> | 483 | local-part <jkaivo> domain <elijah.nodomainname.net> |
488 | ]) | 484 | ]) |
489 | ]) | ||
490 | 485 | ||
491 | TESTADDR(["Lee R. Copp" <Lee.R.Copp@MichiganScientific.com>],[], | 486 | TESTADDR(["Lee R. Copp" <Lee.R.Copp@MichiganScientific.com>],[], |
492 | [0], | 487 | [0], |
... | @@ -528,8 +523,6 @@ personal <fmartens-2000> | ... | @@ -528,8 +523,6 @@ personal <fmartens-2000> |
528 | local-part <fmartens-2000> domain <planet.nl> | 523 | local-part <fmartens-2000> domain <planet.nl> |
529 | ]) | 524 | ]) |
530 | 525 | ||
531 | dnl FIXME | ||
532 | m4_if([ | ||
533 | TESTADDR(["g'o'tz ohnesorge" <gohnesorge@lh-computertechnik.de>],[], | 526 | TESTADDR(["g'o'tz ohnesorge" <gohnesorge@lh-computertechnik.de>],[], |
534 | [0], | 527 | [0], |
535 | [naddr: 1 | 528 | [naddr: 1 |
... | @@ -538,8 +531,6 @@ personal <g'o'tz ohnesorge> | ... | @@ -538,8 +531,6 @@ personal <g'o'tz ohnesorge> |
538 | local-part <gohnesorge> domain <lh-computertechnik.de> | 531 | local-part <gohnesorge> domain <lh-computertechnik.de> |
539 | ]) | 532 | ]) |
540 | 533 | ||
541 | ]) | ||
542 | |||
543 | TESTADDR(["gao jie" <jiegi@public.wh.hb.cn>],[], | 534 | TESTADDR(["gao jie" <jiegi@public.wh.hb.cn>],[], |
544 | [0], | 535 | [0], |
545 | [naddr: 1 | 536 | [naddr: 1 |
... | @@ -607,16 +598,12 @@ personal <zwk@f36.n480.z2.fidonet.org> | ... | @@ -607,16 +598,12 @@ personal <zwk@f36.n480.z2.fidonet.org> |
607 | local-part <zwk%f36.n480.z2.fidonet.org> domain <f36.n480.z2.fidonet.org> | 598 | local-part <zwk%f36.n480.z2.fidonet.org> domain <f36.n480.z2.fidonet.org> |
608 | ]) | 599 | ]) |
609 | 600 | ||
610 | dnl FIXME | ||
611 | m4_if([ | ||
612 | TESTADDR(['Dan Dall'Acqua' <ddallacqua@noetic.ab.ca>, 'Dave Shyong'],[], | 601 | TESTADDR(['Dan Dall'Acqua' <ddallacqua@noetic.ab.ca>, 'Dave Shyong'],[], |
613 | [1], | 602 | [0], |
614 | [], | 603 | [], |
615 | [MU_ERR_BAD_822_FORMAT | 604 | [MU_ERR_BAD_822_FORMAT |
616 | ]) | 605 | ]) |
617 | 606 | ||
618 | ]) | ||
619 | |||
620 | TESTADDR([0xdeadbeef-request@petting-zoo.net],[], | 607 | TESTADDR([0xdeadbeef-request@petting-zoo.net],[], |
621 | [0], | 608 | [0], |
622 | [naddr: 1 | 609 | [naddr: 1 |
... | @@ -914,15 +901,13 @@ personal <Jose C. Garcia Sogo> | ... | @@ -914,15 +901,13 @@ personal <Jose C. Garcia Sogo> |
914 | local-part <jose> domain <jaimedelamo.eu.org> | 901 | local-part <jose> domain <jaimedelamo.eu.org> |
915 | ]) | 902 | ]) |
916 | 903 | ||
917 | dnl FIXME | 904 | TESTADDR([Marco d'Itri <md@Linux.IT>],[], |
918 | m4_if([ | ||
919 | TESTADDR([Marco d'Itri <md@Linux.IT>,[], | ||
920 | [0], | 905 | [0], |
906 | [naddr: 1 | ||
921 | 1. email <md@Linux.IT>: | 907 | 1. email <md@Linux.IT>: |
922 | personal <Marco d'Itri> | 908 | personal <Marco d'Itri> |
923 | local-part <md> domain <Linux.IT> | 909 | local-part <md> domain <Linux.IT> |
924 | ]) | 910 | ]) |
925 | ]) | ||
926 | 911 | ||
927 | TESTADDR([No_Reply-To@mapquest.com],[], | 912 | TESTADDR([No_Reply-To@mapquest.com],[], |
928 | [0], | 913 | [0], |
... | @@ -1007,8 +992,6 @@ personal <ktb> | ... | @@ -1007,8 +992,6 @@ personal <ktb> |
1007 | local-part <x.y.f> domain <home.com> | 992 | local-part <x.y.f> domain <home.com> |
1008 | ]) | 993 | ]) |
1009 | 994 | ||
1010 | dnl FIXME | ||
1011 | m4_if([ | ||
1012 | TESTADDR([mcaustin@eudoramail.com, aposner@usaid.gov, Kieran.O'Leary@anpost.ie],[], | 995 | TESTADDR([mcaustin@eudoramail.com, aposner@usaid.gov, Kieran.O'Leary@anpost.ie],[], |
1013 | [0], | 996 | [0], |
1014 | [naddr: 3 | 997 | [naddr: 3 |
... | @@ -1019,7 +1002,6 @@ local-part <aposner> domain <usaid.gov> | ... | @@ -1019,7 +1002,6 @@ local-part <aposner> domain <usaid.gov> |
1019 | 3. email <Kieran.O'Leary@anpost.ie>: | 1002 | 3. email <Kieran.O'Leary@anpost.ie>: |
1020 | local-part <Kieran.O'Leary> domain <anpost.ie> | 1003 | local-part <Kieran.O'Leary> domain <anpost.ie> |
1021 | ]) | 1004 | ]) |
1022 | ]) | ||
1023 | 1005 | ||
1024 | TESTADDR([rfunk@wks.uts.ohio-state.eduofflinemailer-bounce@dikke.penguin.nl],[], | 1006 | TESTADDR([rfunk@wks.uts.ohio-state.eduofflinemailer-bounce@dikke.penguin.nl],[], |
1025 | [1], | 1007 | [1], |
... | @@ -1034,8 +1016,6 @@ TESTADDR([root],[], | ... | @@ -1034,8 +1016,6 @@ TESTADDR([root],[], |
1034 | local-part <root> domain <localhost> | 1016 | local-part <root> domain <localhost> |
1035 | ]) | 1017 | ]) |
1036 | 1018 | ||
1037 | dnl FIXME srr <sam@localhost>=> error MU_ERR_BAD_822_FORMAT | ||
1038 | |||
1039 | TESTADDR([whom it may concern: ;;whom.it.may.concern: ;],[], | 1019 | TESTADDR([whom it may concern: ;;whom.it.may.concern: ;],[], |
1040 | [1], | 1020 | [1], |
1041 | [], | 1021 | [], | ... | ... |
... | @@ -19,14 +19,14 @@ dnl ------------------------------------------------------------ | ... | @@ -19,14 +19,14 @@ dnl ------------------------------------------------------------ |
19 | dnl TESTARGS([NAME], [KW = `'], [INPUT], [STDOUT = `'], | 19 | dnl TESTARGS([NAME], [KW = `'], [INPUT], [STDOUT = `'], |
20 | dnl [STDERR = `'], [RUN-IF-FAIL], [RUN-IF-PASS]) | 20 | dnl [STDERR = `'], [RUN-IF-FAIL], [RUN-IF-PASS]) |
21 | dnl | 21 | dnl |
22 | m4_define([TESTARGS],[ | 22 | m4_pushdef([TESTARGS],[ |
23 | AT_SETUP([Argcv: $1]) | 23 | m4_pushdef([MU_TEST_GROUP],[Argcv]) |
24 | AT_KEYWORDS([argcv $2]) | 24 | m4_pushdef([MU_TEST_KEYWORDS],[argcv]) |
25 | AT_CHECK([ | 25 | m4_pushdef([MU_TEST_COMMAND],[argcv]) |
26 | AT_DATA([input],[$3 | 26 | MU_GENERIC_TEST([$1],[$2],[$3],[],[$4],[$5]) |
27 | ]) | 27 | m4_popdef([MU_TEST_COMMAND]) |
28 | argcv < input],[0],m4_shift(m4_shift(m4_shift($@)))) | 28 | m4_popdef([MU_TEST_KEYWORDS]) |
29 | AT_CLEANUP | 29 | m4_popdef([MU_TEST_GROUP]) |
30 | ]) | 30 | ]) |
31 | 31 | ||
32 | dnl ------------------------------------------------------------ | 32 | dnl ------------------------------------------------------------ |
... | @@ -84,6 +84,7 @@ TESTARG([unbalanced quote 3],[], | ... | @@ -84,6 +84,7 @@ TESTARG([unbalanced quote 3],[], |
84 | [1: "\"" | 84 | [1: "\"" |
85 | ]) | 85 | ]) |
86 | 86 | ||
87 | m4_popdef([TESTARGS]) | ||
87 | 88 | ||
88 | 89 | ||
89 | 90 | ... | ... |
... | @@ -19,14 +19,14 @@ dnl ------------------------------------------------------------ | ... | @@ -19,14 +19,14 @@ dnl ------------------------------------------------------------ |
19 | dnl TESTDEC2047([NAME], [KW = `'], [INPUT], [STDOUT = `'], | 19 | dnl TESTDEC2047([NAME], [KW = `'], [INPUT], [STDOUT = `'], |
20 | dnl [STDERR = `'], [RUN-IF-FAIL], [RUN-IF-PASS]) | 20 | dnl [STDERR = `'], [RUN-IF-FAIL], [RUN-IF-PASS]) |
21 | dnl | 21 | dnl |
22 | m4_define([TESTDEC2047],[ | 22 | m4_pushdef([TESTDEC2047],[ |
23 | AT_SETUP([Decode 2047: m4_if([$1],[],[$3],[$1])]) | 23 | m4_pushdef([MU_TEST_GROUP],[Decode 2047]) |
24 | AT_KEYWORDS([decode2047 decode $2]) | 24 | m4_pushdef([MU_TEST_KEYWORDS],[decode2047 decode]) |
25 | AT_CHECK([ | 25 | m4_pushdef([MU_TEST_COMMAND],[decode2047 -p]) |
26 | AT_DATA([input],[$3 | 26 | MU_GENERIC_TEST([$1],[$2],[$3],[],[$4],[$5]) |
27 | ]) | 27 | m4_popdef([MU_TEST_COMMAND]) |
28 | decode2047 -p < input],[0],m4_shift(m4_shift(m4_shift($@)))) | 28 | m4_popdef([MU_TEST_KEYWORDS]) |
29 | AT_CLEANUP | 29 | m4_popdef([MU_TEST_GROUP]) |
30 | ]) | 30 | ]) |
31 | 31 | ||
32 | dnl ------------------------------------------------------------ | 32 | dnl ------------------------------------------------------------ |
... | @@ -56,5 +56,6 @@ TESTDEC2047([malformed input],[decode05], | ... | @@ -56,5 +56,6 @@ TESTDEC2047([malformed input],[decode05], |
56 | [Fwd: \322\305\307\311\323\324\322\301\303\311\321 \304\317\315\305 | 56 | [Fwd: \322\305\307\311\323\324\322\301\303\311\321 \304\317\315\305 |
57 | ]) | 57 | ]) |
58 | 58 | ||
59 | m4_popdef([TESTDEC2047]) | ||
59 | 60 | ||
60 | 61 | ... | ... |
... | @@ -19,14 +19,15 @@ dnl ------------------------------------------------------------ | ... | @@ -19,14 +19,15 @@ dnl ------------------------------------------------------------ |
19 | dnl MAILCAP([NAME], [KW = `'], [INPUT], [STDOUT = `'], | 19 | dnl MAILCAP([NAME], [KW = `'], [INPUT], [STDOUT = `'], |
20 | dnl [STDERR = `'], [RUN-IF-FAIL], [RUN-IF-PASS]) | 20 | dnl [STDERR = `'], [RUN-IF-FAIL], [RUN-IF-PASS]) |
21 | dnl | 21 | dnl |
22 | m4_define([MAILCAP],[ | 22 | |
23 | AT_SETUP([Mailcap: [$1]]) | 23 | m4_pushdef([MAILCAP],[ |
24 | AT_KEYWORDS([mailcap $2]) | 24 | m4_pushdef([MU_TEST_GROUP],[Mailcap]) |
25 | AT_CHECK([ | 25 | m4_pushdef([MU_TEST_KEYWORDS],[mailcap]) |
26 | AT_DATA([input],[$3 | 26 | m4_pushdef([MU_TEST_COMMAND],[mailcap]) |
27 | ]) | 27 | MU_GENERIC_TEST([$1],[$2],[$3],[],[$4],[$5]) |
28 | mailcap input],[0],m4_shift(m4_shift(m4_shift($@)))) | 28 | m4_popdef([MU_TEST_COMMAND]) |
29 | AT_CLEANUP | 29 | m4_popdef([MU_TEST_KEYWORDS]) |
30 | m4_popdef([MU_TEST_GROUP]) | ||
30 | ]) | 31 | ]) |
31 | 32 | ||
32 | dnl ------------------------------------------------------------ | 33 | dnl ------------------------------------------------------------ |
... | @@ -277,3 +278,5 @@ nametemplate=%s.au], | ... | @@ -277,3 +278,5 @@ nametemplate=%s.au], |
277 | fields[2]: nametemplate=%s.au | 278 | fields[2]: nametemplate=%s.au |
278 | 279 | ||
279 | ]]) | 280 | ]]) |
281 | |||
282 | m4_popdef([MAILCAP]) | ... | ... |
... | @@ -31,22 +31,22 @@ main (int argc, char **argv) | ... | @@ -31,22 +31,22 @@ main (int argc, char **argv) |
31 | { | 31 | { |
32 | mu_stream_t stream = NULL; | 32 | mu_stream_t stream = NULL; |
33 | int status = 0; | 33 | int status = 0; |
34 | char *file = argc == 1 ? "/etc/mailcap" : argv[1]; | ||
35 | mu_mailcap_t mailcap = NULL; | 34 | mu_mailcap_t mailcap = NULL; |
36 | 35 | ||
37 | status = mu_file_stream_create (&stream, file, MU_STREAM_READ); | 36 | status = mu_stdio_stream_create (&stream, MU_STDIN_FD, |
37 | MU_STREAM_READ|MU_STREAM_SEEK); | ||
38 | if (status) | 38 | if (status) |
39 | { | 39 | { |
40 | mu_error ("cannot create file stream %s: %s", | 40 | mu_error ("cannot create input stream: %s", |
41 | file, mu_strerror (status)); | 41 | mu_strerror (status)); |
42 | exit (1); | 42 | exit (1); |
43 | } | 43 | } |
44 | 44 | ||
45 | status = mu_stream_open (stream); | 45 | status = mu_stream_open (stream); |
46 | if (status) | 46 | if (status) |
47 | { | 47 | { |
48 | mu_error ("cannot open file stream %s: %s", | 48 | mu_error ("cannot open input stream: %s", |
49 | file, mu_strerror (status)); | 49 | mu_strerror (status)); |
50 | exit (1); | 50 | exit (1); |
51 | } | 51 | } |
52 | 52 | ... | ... |
... | @@ -17,6 +17,41 @@ | ... | @@ -17,6 +17,41 @@ |
17 | 17 | ||
18 | m4_include([testsuite.inc]) | 18 | m4_include([testsuite.inc]) |
19 | 19 | ||
20 | dnl ------------------------------------------------------------ | ||
21 | m4_define([MU_TEST_GROUP],[generic]) | ||
22 | dnl ------------------------------------------------------------ | ||
23 | m4_define([MU_TEST_KEYWORDS]) | ||
24 | dnl ------------------------------------------------------------ | ||
25 | m4_define([MU_TEST_COMMAND]) | ||
26 | |||
27 | m4_define([mu_trimstr],[m4_if([$2],-1,[$1],[m4_substr($1,0,$2)...])]) | ||
28 | m4_define([mu_firstline],[mu_trimstr([$1],m4_index([$1],[ | ||
29 | ]))]) | ||
30 | |||
31 | dnl ------------------------------------------------------------ | ||
32 | dnl MU_GENERIC_TEST([NAME], [KW = `'], [INPUT], | ||
33 | dnl [CODE], [STDOUT = `'], [STDERR = `'], | ||
34 | dnl [RUN-IF-FAIL], [RUN-IF-PASS]) | ||
35 | dnl | ||
36 | dnl NAME $1 | ||
37 | dnl KW $2 | ||
38 | dnl INPUT $3 | ||
39 | dnl CODE $4 | ||
40 | dnl STDOUT $5 | ||
41 | dnl STDERR $6 | ||
42 | dnl RUN-IF-FAIL $7 | ||
43 | dnl RUN-IF-PASS $8 | ||
44 | dnl | ||
45 | m4_define([MU_GENERIC_TEST],[ | ||
46 | AT_SETUP([m4_if(MU_TEST_GROUP,[],,MU_TEST_GROUP: )m4_if([$1],[],mu_firstline([$3]),[$1])]) | ||
47 | AT_KEYWORDS([MU_TEST_KEYWORDS $2]) | ||
48 | AT_CHECK([ | ||
49 | AT_DATA([input],[$3 | ||
50 | ]) | ||
51 | MU_TEST_COMMAND < input],[$4],[$5],[$6],[$7],[$8]) | ||
52 | AT_CLEANUP | ||
53 | ]) | ||
54 | |||
20 | AT_INIT | 55 | AT_INIT |
21 | 56 | ||
22 | m4_include([address.at]) | 57 | m4_include([address.at]) | ... | ... |
... | @@ -19,14 +19,15 @@ dnl ------------------------------------------------------------ | ... | @@ -19,14 +19,15 @@ dnl ------------------------------------------------------------ |
19 | dnl TESTURL([NAME], [KW = `'], [INPUT], [STDOUT = `'], | 19 | dnl TESTURL([NAME], [KW = `'], [INPUT], [STDOUT = `'], |
20 | dnl [STDERR = `'], [RUN-IF-FAIL], [RUN-IF-PASS]) | 20 | dnl [STDERR = `'], [RUN-IF-FAIL], [RUN-IF-PASS]) |
21 | dnl | 21 | dnl |
22 | m4_define([TESTURL],[ | 22 | |
23 | AT_SETUP([URL: m4_if([$1],[],[$3],[$1])]) | 23 | m4_pushdef([TESTURL],[ |
24 | AT_KEYWORDS([url $2]) | 24 | m4_pushdef([MU_TEST_GROUP],[Url]) |
25 | AT_CHECK([ | 25 | m4_pushdef([MU_TEST_KEYWORDS],[url]) |
26 | AT_DATA([input],[$3 | 26 | m4_pushdef([MU_TEST_COMMAND],[url-parse]) |
27 | ]) | 27 | MU_GENERIC_TEST([$1],[$2],[$3],[],[$4],[$5]) |
28 | url-parse < input],[0],m4_shift(m4_shift(m4_shift($@)))) | 28 | m4_popdef([MU_TEST_COMMAND]) |
29 | AT_CLEANUP | 29 | m4_popdef([MU_TEST_KEYWORDS]) |
30 | m4_popdef([MU_TEST_GROUP]) | ||
30 | ]) | 31 | ]) |
31 | 32 | ||
32 | dnl ------------------------------------------------------------ | 33 | dnl ------------------------------------------------------------ |
... | @@ -773,4 +774,4 @@ query[1] <arg 1> | ... | @@ -773,4 +774,4 @@ query[1] <arg 1> |
773 | query[2] <arg 2> | 774 | query[2] <arg 2> |
774 | ]]) | 775 | ]]) |
775 | 776 | ||
776 | 777 | m4_popdef([TESTURL]) | ... | ... |
-
Please register or sign in to post a comment