Mercurial > hg > xemacs-beta
changeset 4749:dd29ed9c6962
Automated merge with ssh://sperber-guest@hg.debian.org//hg/xemacs/xemacs
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Mon, 16 Nov 2009 08:08:44 +0000 |
parents | 294a86d29f99 (diff) 27b09b4219b1 (current diff) |
children | 91f85b19749f |
files | |
diffstat | 5 files changed, 217 insertions(+), 91 deletions(-) [+] |
line wrap: on
line diff
--- a/src/tests.c Sun Nov 15 20:52:09 2009 +0000 +++ b/src/tests.c Mon Nov 16 08:08:44 2009 +0000 @@ -38,12 +38,18 @@ static Lisp_Object Vtest_function_list; DEFUN ("test-data-format-conversion", Ftest_data_format_conversion, 0, 0, "", /* -Test TO_EXTERNAL_FORMAT() and TO_INTERNAL_FORMAT() + Return list of results of test TO_EXTERNAL_FORMAT() and TO_INTERNAL_FORMAT(). +For use by the automated test suite. See tests/automated/c-tests. + +Each element is a list (DESCRIPTION, STATUS, REASON). +DESCRIPTION is a string describing the test. +STATUS is a symbol, either t (pass) or nil (fail). +REASON is nil or a string describing the failure (not required). */ ()) { void *ptr; Bytecount len; - Lisp_Object string, opaque; + Lisp_Object string, opaque, conversion_result = Qnil; Ibyte int_foo[] = "\n\nfoo\nbar"; Extbyte ext_unix[]= "\n\nfoo\nbar"; @@ -75,129 +81,175 @@ #ifdef MULE #define DFC_CHECK_DATA_COND_MULE(ptr,len, \ constant_string_mule, \ - constant_string_non_mule) \ - DFC_CHECK_DATA (ptr, len, constant_string_mule) + constant_string_non_mule, \ + description) \ + DFC_CHECK_DATA (ptr, len, constant_string_mule, description) #define DFC_CHECK_DATA_COND_MULE_NUL(ptr,len, \ constant_string_mule, \ - constant_string_non_mule) \ - DFC_CHECK_DATA_NUL (ptr, len, constant_string_mule) + constant_string_non_mule, \ + description) \ + DFC_CHECK_DATA_NUL (ptr, len, constant_string_mule, description) #else #define DFC_CHECK_DATA_COND_MULE(ptr,len, \ constant_string_mule, \ - constant_string_non_mule) \ - DFC_CHECK_DATA (ptr, len, constant_string_non_mule) + constant_string_non_mule, \ + description) \ + DFC_CHECK_DATA (ptr, len, constant_string_non_mule, description) #define DFC_CHECK_DATA_COND_MULE_NUL(ptr,len, \ constant_string_mule, \ - constant_string_non_mule) \ - DFC_CHECK_DATA_NUL (ptr, len, constant_string_non_mule) + constant_string_non_mule, \ + description) \ + DFC_CHECK_DATA_NUL (ptr, len, constant_string_non_mule, description) #endif /* These now only apply to base coding systems, and need to test `eol-detection-enabled-p' at runtime. */ -#define DFC_CHECK_DATA_COND_EOL(ptr,len, \ - constant_string_eol, \ - constant_string_non_eol) do { \ - if (autodetect_eol_p) \ - DFC_CHECK_DATA (ptr, len, constant_string_eol); \ - else \ - DFC_CHECK_DATA (ptr, len, constant_string_non_eol); \ +#define DFC_CHECK_DATA_COND_EOL(ptr,len, \ + constant_string_eol, \ + constant_string_non_eol, \ + description) do { \ + if (autodetect_eol_p) \ + DFC_CHECK_DATA (ptr, len, constant_string_eol, description); \ + else \ + DFC_CHECK_DATA (ptr, len, constant_string_non_eol, description); \ } while (0) -#define DFC_CHECK_DATA_COND_EOL_NUL(ptr,len, \ - constant_string_eol, \ - constant_string_non_eol) do { \ - if (autodetect_eol_p) \ - DFC_CHECK_DATA_NUL (ptr, len, constant_string_eol); \ - else \ - DFC_CHECK_DATA_NUL (ptr, len, constant_string_non_eol); \ +#define DFC_CHECK_DATA_COND_EOL_NUL(ptr,len, \ + constant_string_eol, \ + constant_string_non_eol, \ + description) do { \ + if (autodetect_eol_p) \ + DFC_CHECK_DATA_NUL (ptr, len, constant_string_eol, description); \ + else \ + DFC_CHECK_DATA_NUL (ptr, len, constant_string_non_eol, description); \ } while (0) /* Check for expected strings before and after conversion. */ -#define DFC_CHECK_DATA(ptr,len, constant_string) do { \ - assert ((len) == sizeof (constant_string) - 1); \ - assert (!memcmp (ptr, constant_string, len)); \ +#define DFC_CHECK_DATA(ptr,len,constant_string,test) do { \ + DFC_INITIALIZE (test); \ + DFC_CHECK_LENGTH (len, sizeof (constant_string) - 1, test); \ + DFC_CHECK_CONTENT (ptr, constant_string, len, test); \ + DFC_RESULT_PASS (test); \ } while (0) /* Macro version that includes the trailing NULL byte. */ -#define DFC_CHECK_DATA_NUL(ptr,len,constant_string) do {\ - assert ((len) == sizeof (constant_string)); \ - assert (!memcmp (ptr, constant_string, len)); \ +#define DFC_CHECK_DATA_NUL(ptr,len,constant_string,test) do { \ + DFC_INITIALIZE (test); \ + DFC_CHECK_LENGTH (len, sizeof (constant_string), test); \ + DFC_CHECK_CONTENT (ptr, constant_string, len, test); \ + DFC_RESULT_PASS (test); \ } while (0) +/* WARNING WARNING WARNING! + The following macros are NOT protected by "do { ... } while (0)"!! +*/ + +#define DFC_INITIALIZE(test_name) if (0) + +#define DFC_CHECK_LENGTH(len1,len2,str1) \ + else if ((len1) != (len2)) \ + conversion_result = \ + Fcons (list3 (build_string(str1), Qnil, build_string("wrong length")), \ + conversion_result) + +#define DFC_CHECK_CONTENT(str1,str2,len1,str3) \ + else if (memcmp (str1, str2, len1)) \ + conversion_result = \ + Fcons (list3 (build_string(str3), Qnil, \ + build_string("octet comparison failed")), \ + conversion_result) + +#define DFC_RESULT_PASS(str1) \ + else \ + conversion_result = \ + Fcons (list3 (build_string(str1), Qt, Qnil), \ + conversion_result) + #ifdef MULE ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (DATA, (int_latin2, sizeof (int_latin2)), ALLOCA, (ptr, len), intern ("iso-8859-2")); - DFC_CHECK_DATA_NUL (ptr, len, ext_latin); + DFC_CHECK_DATA_NUL (ptr, len, ext_latin, + "Latin-2 DATA, ALLOCA, Latin 2/NUL"); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (LISP_STRING, string_latin2, ALLOCA, (ptr, len), intern ("iso-8859-2")); - DFC_CHECK_DATA (ptr, len, ext_latin); + DFC_CHECK_DATA (ptr, len, ext_latin, + "Latin-2 Lisp string, ALLOCA, Latin 2"); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (LISP_STRING, string_latin1, ALLOCA, (ptr, len), intern ("iso-latin-2-with-esc")); - DFC_CHECK_DATA (ptr, len, ext_latin12); + DFC_CHECK_DATA (ptr, len, ext_latin12, + "Latin-1 Lisp string, ALLOCA, Latin 2/ESC"); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (DATA, (int_latin2, sizeof (int_latin2) - 1), MALLOC, (ptr, len), intern ("iso-8859-2")); - DFC_CHECK_DATA (ptr, len, ext_latin); + DFC_CHECK_DATA (ptr, len, ext_latin, "Latin-2 DATA, MALLOC, Latin-2"); xfree (ptr, void *); TO_EXTERNAL_FORMAT (DATA, (int_latin2, sizeof (int_latin2) - 1), LISP_OPAQUE, opaque, intern ("iso-8859-2")); - DFC_CHECK_DATA (XOPAQUE_DATA (opaque), XOPAQUE_SIZE (opaque), ext_latin); + DFC_CHECK_DATA (XOPAQUE_DATA (opaque), XOPAQUE_SIZE (opaque), ext_latin, + "Latin-2 DATA, Lisp opaque, Latin-2"); ptr = NULL, len = rand(); TO_INTERNAL_FORMAT (DATA, (ext_latin, sizeof (ext_latin) - 1), ALLOCA, (ptr, len), intern ("iso-latin-2-with-esc")); - DFC_CHECK_DATA (ptr, len, int_latin2); + DFC_CHECK_DATA (ptr, len, int_latin2, + "Latin-2/ESC, ALLOCA, Latin-1 DATA"); ptr = NULL, len = rand(); TO_INTERNAL_FORMAT (DATA, (ext_latin, sizeof (ext_latin) - 1), MALLOC, (ptr, len), intern ("iso-latin-2-with-esc")); - DFC_CHECK_DATA (ptr, len, int_latin2); + DFC_CHECK_DATA (ptr, len, int_latin2, + "Latin-2/ESC, MALLOC, Latin-1 DATA"); xfree (ptr, void *); TO_INTERNAL_FORMAT (DATA, (ext_latin, sizeof (ext_latin) - 1), LISP_STRING, string, intern ("iso-latin-2-with-esc")); - DFC_CHECK_DATA (XSTRING_DATA (string), XSTRING_LENGTH (string), int_latin2); + DFC_CHECK_DATA (XSTRING_DATA (string), XSTRING_LENGTH (string), int_latin2, + "Latin-2/ESC, Lisp string, Latin-2"); TO_INTERNAL_FORMAT (LISP_OPAQUE, opaque_latin, LISP_STRING, string, intern ("iso-latin-2-with-esc")); - DFC_CHECK_DATA (XSTRING_DATA (string), XSTRING_LENGTH (string), int_latin2); + DFC_CHECK_DATA (XSTRING_DATA (string), XSTRING_LENGTH (string), int_latin2, + "Lisp opaque, Lisp string, Latin-2/ESC"); TO_INTERNAL_FORMAT (LISP_OPAQUE, opaque0_latin, LISP_STRING, string, intern ("iso-latin-2-with-esc")); - DFC_CHECK_DATA_NUL (XSTRING_DATA (string), XSTRING_LENGTH (string), int_latin2); + DFC_CHECK_DATA_NUL (XSTRING_DATA (string), XSTRING_LENGTH (string), int_latin2, + "Lisp opaque, Lisp string, Latin-2/ESC/NUL"); TO_INTERNAL_FORMAT (LISP_OPAQUE, opaque0_latin, LISP_BUFFER, Fcurrent_buffer(), intern ("iso-latin-2-with-esc")); DFC_CHECK_DATA_NUL (BUF_BYTE_ADDRESS (current_buffer, BUF_PT (current_buffer)), - sizeof (int_latin2), int_latin2); + sizeof (int_latin2), int_latin2, + "Lisp opaque, Lisp buffer, Latin-2/ESC/NUL"); TO_INTERNAL_FORMAT (LISP_OPAQUE, opaque_latin, LISP_BUFFER, Fcurrent_buffer(), intern ("iso-8859-1")); DFC_CHECK_DATA (BUF_BYTE_ADDRESS (current_buffer, BUF_PT (current_buffer)), - sizeof (int_latin1) - 1, int_latin1); + sizeof (int_latin1) - 1, int_latin1, + "Lisp opaque, Lisp buffer, Latin-1"); TO_INTERNAL_FORMAT (DATA, (ext_latin12, sizeof (ext_latin12) - 1), ALLOCA, (ptr, len), intern ("iso-latin-2-with-esc")); - DFC_CHECK_DATA (ptr, len, int_latin1); + DFC_CHECK_DATA (ptr, len, int_latin1, "DATA, ALLOCA, Latin-1"); #endif /* MULE */ @@ -205,127 +257,147 @@ TO_EXTERNAL_FORMAT (DATA, (int_latin1, sizeof (int_latin1) - 1), ALLOCA, (ptr, len), Qbinary); - DFC_CHECK_DATA_COND_MULE (ptr, len, ext_latin, int_latin1); + DFC_CHECK_DATA_COND_MULE (ptr, len, ext_latin, int_latin1, + "Latin-1 DATA, ALLOCA, binary"); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (DATA, (int_latin1, sizeof (int_latin1)), ALLOCA, (ptr, len), Qbinary); - DFC_CHECK_DATA_COND_MULE_NUL (ptr, len, ext_latin, int_latin1); + DFC_CHECK_DATA_COND_MULE_NUL (ptr, len, ext_latin, int_latin1, + "Latin-1 DATA, ALLOCA, binary/NUL"); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (DATA, (int_latin2, sizeof (int_latin2) - 1), ALLOCA, (ptr, len), Qbinary); - DFC_CHECK_DATA_COND_MULE (ptr, len, ext_tilde, int_latin2); + DFC_CHECK_DATA_COND_MULE (ptr, len, ext_tilde, int_latin2, + "Latin-2 DATA, ALLOCA, binary"); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (DATA, (int_latin1, sizeof (int_latin1) - 1), ALLOCA, (ptr, len), intern ("iso-8859-1")); - DFC_CHECK_DATA_COND_MULE (ptr, len, ext_latin, int_latin1); + DFC_CHECK_DATA_COND_MULE (ptr, len, ext_latin, int_latin1, + "Latin-1 DATA, ALLOCA, Latin-1"); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (LISP_STRING, string_latin1, ALLOCA, (ptr, len), Qbinary); - DFC_CHECK_DATA_COND_MULE (ptr, len, ext_latin, int_latin1); + DFC_CHECK_DATA_COND_MULE (ptr, len, ext_latin, int_latin1, + "Latin-1 Lisp string, ALLOCA, binary"); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (LISP_STRING, string_latin1, ALLOCA, (ptr, len), Qbinary); - DFC_CHECK_DATA_COND_MULE (ptr, len, ext_latin, int_latin1); + DFC_CHECK_DATA_COND_MULE (ptr, len, ext_latin, int_latin1, + "Latin-1 Lisp string, ALLOCA, binary"); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (LISP_STRING, string_latin1, ALLOCA, (ptr, len), intern ("iso-8859-1")); - DFC_CHECK_DATA_COND_MULE (ptr, len, ext_latin, int_latin1); + DFC_CHECK_DATA_COND_MULE (ptr, len, ext_latin, int_latin1, + "Latin-1 Lisp string, ALLOCA, Latin-1"); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (DATA, (int_latin1, sizeof (int_latin1) - 1), MALLOC, (ptr, len), Qbinary); - DFC_CHECK_DATA_COND_MULE (ptr, len, ext_latin, int_latin1); + DFC_CHECK_DATA_COND_MULE (ptr, len, ext_latin, int_latin1, + "Latin-1 DATA, MALLOC, binary"); xfree (ptr, void *); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (DATA, (int_latin2, sizeof (int_latin2)), MALLOC, (ptr, len), Qbinary); - DFC_CHECK_DATA_COND_MULE_NUL (ptr, len, ext_tilde, int_latin2); + DFC_CHECK_DATA_COND_MULE_NUL (ptr, len, ext_tilde, int_latin2, + "Latin-2 DATA, MALLOC, binary/NUL"); xfree (ptr, void *); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (DATA, (int_latin1, sizeof (int_latin1) - 1), MALLOC, (ptr, len), intern ("iso-8859-1")); - DFC_CHECK_DATA_COND_MULE (ptr, len, ext_latin, int_latin1); + DFC_CHECK_DATA_COND_MULE (ptr, len, ext_latin, int_latin1, + "Latin-1 DATA, MALLOC, Latin-1"); xfree (ptr, void *); TO_EXTERNAL_FORMAT (DATA, (int_latin1, sizeof (int_latin1) - 1), LISP_OPAQUE, opaque, Qbinary); DFC_CHECK_DATA_COND_MULE (XOPAQUE_DATA (opaque), - XOPAQUE_SIZE (opaque), ext_latin, int_latin1); + XOPAQUE_SIZE (opaque), ext_latin, int_latin1, + "Latin-1 DATA, Lisp opaque, binary"); TO_EXTERNAL_FORMAT (DATA, (int_latin2, sizeof (int_latin2)), LISP_OPAQUE, opaque, Qbinary); DFC_CHECK_DATA_COND_MULE_NUL (XOPAQUE_DATA (opaque), - XOPAQUE_SIZE (opaque), ext_tilde, int_latin2); + XOPAQUE_SIZE (opaque), ext_tilde, int_latin2, + "Latin-2 DATA, Lisp opaque, binary"); TO_EXTERNAL_FORMAT (DATA, (int_latin1, sizeof (int_latin1) - 1), LISP_OPAQUE, opaque, intern ("iso-8859-1")); DFC_CHECK_DATA_COND_MULE (XOPAQUE_DATA (opaque), - XOPAQUE_SIZE (opaque), ext_latin, int_latin1); + XOPAQUE_SIZE (opaque), ext_latin, int_latin1, + "Latin-1 DATA, Lisp opaque, Latin-1"); ptr = NULL, len = rand(); TO_INTERNAL_FORMAT (DATA, (ext_latin, sizeof (ext_latin) - 1), ALLOCA, (ptr, len), Qbinary); - DFC_CHECK_DATA_COND_MULE (ptr, len, int_latin1, ext_latin); + DFC_CHECK_DATA_COND_MULE (ptr, len, int_latin1, ext_latin, + "Latin-1 DATA, ALLOCA, binary"); ptr = NULL, len = rand(); TO_INTERNAL_FORMAT (DATA, (ext_latin, sizeof (ext_latin)), ALLOCA, (ptr, len), intern ("iso-8859-1")); - DFC_CHECK_DATA_COND_MULE_NUL (ptr, len, int_latin1, ext_latin); + DFC_CHECK_DATA_COND_MULE_NUL (ptr, len, int_latin1, ext_latin, + "Latin-1 DATA, ALLOCA, Latin-1"); ptr = NULL, len = rand(); TO_INTERNAL_FORMAT (DATA, (ext_latin, sizeof (ext_latin)), MALLOC, (ptr, len), intern ("iso-8859-1")); - DFC_CHECK_DATA_COND_MULE_NUL (ptr, len, int_latin1, ext_latin); + DFC_CHECK_DATA_COND_MULE_NUL (ptr, len, int_latin1, ext_latin, + "Latin-1 DATA, MALLOC, Latin-1"); xfree (ptr, void *); ptr = NULL, len = rand(); TO_INTERNAL_FORMAT (DATA, (ext_latin, sizeof (ext_latin)), MALLOC, (ptr, len), Qnil); - DFC_CHECK_DATA_COND_MULE_NUL (ptr, len, int_latin1, ext_latin); + DFC_CHECK_DATA_COND_MULE_NUL (ptr, len, int_latin1, ext_latin, + "Latin-1 DATA, MALLOC, nil"); xfree (ptr, void *); TO_INTERNAL_FORMAT (DATA, (ext_latin, sizeof (ext_latin) - 1), LISP_STRING, string, intern ("iso-8859-1")); DFC_CHECK_DATA_COND_MULE (XSTRING_DATA (string), - XSTRING_LENGTH (string), int_latin1, ext_latin); + XSTRING_LENGTH (string), int_latin1, ext_latin, + "Latin-1 DATA, Lisp stirng, Latin-1"); TO_INTERNAL_FORMAT (LISP_OPAQUE, opaque_latin, LISP_STRING, string, intern ("iso-8859-1")); DFC_CHECK_DATA_COND_MULE (XSTRING_DATA (string), - XSTRING_LENGTH (string), int_latin1, ext_latin); + XSTRING_LENGTH (string), int_latin1, ext_latin, + "Latin-1 Lisp opaque, Lisp string, Latin-1"); TO_INTERNAL_FORMAT (LISP_OPAQUE, opaque0_latin, LISP_STRING, string, intern ("iso-8859-1")); DFC_CHECK_DATA_COND_MULE_NUL (XSTRING_DATA (string), - XSTRING_LENGTH (string), int_latin1, ext_latin); + XSTRING_LENGTH (string), int_latin1, ext_latin, + "Latin-1 Lisp opaque, Lisp string, Latin-1/NUL"); /* This next group used to use the COND_EOL macros, but with the new Mule, they all specify an EOL convention, and all XEmacsen can grok them. */ @@ -333,45 +405,47 @@ TO_EXTERNAL_FORMAT (DATA, (int_foo, sizeof (int_foo)), MALLOC, (ptr, len), Qbinary); - DFC_CHECK_DATA_NUL (ptr, len, ext_unix); + DFC_CHECK_DATA_NUL (ptr, len, ext_unix, + "ASCII DATA, MALLOC, binary/LF/NUL"); xfree (ptr, void *); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (DATA, (int_foo, sizeof (int_foo) - 1), LISP_OPAQUE, opaque, intern ("raw-text-mac")); - DFC_CHECK_DATA (XOPAQUE_DATA (opaque), XOPAQUE_SIZE (opaque), ext_mac); + DFC_CHECK_DATA (XOPAQUE_DATA (opaque), XOPAQUE_SIZE (opaque), ext_mac, + "ASCII DATA, Lisp opaque, binary/CR"); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (LISP_STRING, string_foo, ALLOCA, (ptr, len), intern ("raw-text-dos")); - DFC_CHECK_DATA (ptr, len, ext_dos); + DFC_CHECK_DATA (ptr, len, ext_dos, "ASCII Lisp string, ALLOCA, binary/CRLF"); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (DATA, (int_foo, sizeof (int_foo) - 1), ALLOCA, (ptr, len), intern ("raw-text-unix")); - DFC_CHECK_DATA (ptr, len, ext_unix); + DFC_CHECK_DATA (ptr, len, ext_unix, "ASCII DATA, ALLOCA, binary/LF"); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (LISP_STRING, string_foo, MALLOC, (ptr, len), intern ("no-conversion-mac")); - DFC_CHECK_DATA (ptr, len, ext_mac); + DFC_CHECK_DATA (ptr, len, ext_mac, "ASCII Lisp string, MALLOC, binary/CR"); xfree (ptr, void *); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (DATA, (int_foo, sizeof (int_foo) - 1), ALLOCA, (ptr, len), intern ("no-conversion-dos")); - DFC_CHECK_DATA (ptr, len, ext_dos); + DFC_CHECK_DATA (ptr, len, ext_dos, "ASCII DATA, ALLOCA, binary/CRLF"); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (DATA, (int_foo, sizeof (int_foo)), ALLOCA, (ptr, len), intern ("no-conversion-unix")); - DFC_CHECK_DATA_NUL (ptr, len, ext_unix); + DFC_CHECK_DATA_NUL (ptr, len, ext_unix, "ASCII DATA, ALLOCA, binary/LF/NUL"); /* Oh, Lawdy, Lawdy, Lawdy, this done broke mah heart! @@ -401,7 +475,8 @@ LISP_BUFFER, Fcurrent_buffer(), cs_to_use); DFC_CHECK_DATA (BUF_BYTE_ADDRESS (current_buffer, BUF_PT (current_buffer)), - sizeof (ext_dos) - 1, ext_dos); + sizeof (ext_dos) - 1, ext_dos, + "DOS Lisp opaque, Lisp buffer, undecided-unix"); /* Check eol autodetection works when enabled -- honest. */ cs_to_use = @@ -413,7 +488,8 @@ LISP_BUFFER, Fcurrent_buffer(), cs_to_use); DFC_CHECK_DATA (BUF_BYTE_ADDRESS (current_buffer, BUF_PT (current_buffer)), - sizeof (int_foo) - 1, int_foo); + sizeof (int_foo) - 1, int_foo, + "DOS Lisp opaque, Lisp buffer, undecided"); /* reset to default */ XCODING_SYSTEM_EOL_TYPE (cs_to_use) = autodetect_eol_p ? EOL_AUTODETECT : EOL_LF; @@ -427,18 +503,20 @@ if (autodetect_eol_p) DFC_CHECK_DATA (BUF_BYTE_ADDRESS (current_buffer, BUF_PT (current_buffer)), - sizeof (int_foo) - 1, int_foo); + sizeof (int_foo) - 1, int_foo, + "DOS Lisp opaque, Lisp buffer, autodetect eol"); else DFC_CHECK_DATA (BUF_BYTE_ADDRESS (current_buffer, BUF_PT (current_buffer)), - sizeof (ext_dos) - 1, ext_dos); + sizeof (ext_dos) - 1, ext_dos, + "DOS Lisp opaque, Lisp buffer, no autodetect eol"); TO_INTERNAL_FORMAT (DATA, (ext_mac, sizeof (ext_mac) - 1), LISP_STRING, string, intern ("iso-8859-1")); DFC_CHECK_DATA_COND_EOL (XSTRING_DATA (string), - XSTRING_LENGTH (string), int_foo, ext_mac); - + XSTRING_LENGTH (string), int_foo, ext_mac, + "Mac DATA, Lisp string, Latin-1/EOL"); { Lisp_Object stream = make_fixed_buffer_input_stream (ext_dos, sizeof (ext_dos) - 1); @@ -446,23 +524,24 @@ LISP_STRING, string, intern ("iso-8859-1")); DFC_CHECK_DATA_COND_EOL (XSTRING_DATA (string), - XSTRING_LENGTH (string), int_foo, ext_dos); + XSTRING_LENGTH (string), int_foo, ext_dos, + "DOS lstream, Lisp string, Latin-1/EOL"); } TO_INTERNAL_FORMAT (DATA, (ext_unix, sizeof (ext_unix) - 1), LISP_STRING, string, intern ("no-conversion")); DFC_CHECK_DATA_COND_EOL (XSTRING_DATA (string), - XSTRING_LENGTH (string), int_foo, ext_unix); - + XSTRING_LENGTH (string), int_foo, ext_unix, + "Unix DATA, Lisp string, no-conversion"); ptr = NULL, len = rand(); TO_EXTERNAL_FORMAT (LISP_OPAQUE, opaque_dos, ALLOCA, (ptr, len), Qbinary); - DFC_CHECK_DATA (ptr, len, ext_dos); + DFC_CHECK_DATA (ptr, len, ext_dos, "DOS Lisp opaque, ALLOCA, binary"); - return intern ("PASS"); + return conversion_result; } @@ -510,6 +589,8 @@ */ ()) { + Lisp_Object hash_result = Qnil; + test_hash_tables_data data; data.hash_table = make_lisp_hash_table (50, HASH_TABLE_NON_WEAK, HASH_TABLE_EQUAL); @@ -520,19 +601,28 @@ data.sum = 0; elisp_maphash_unsafe (test_hash_tables_mapper, data.hash_table, (void *) &data); - assert (data.sum == 2 + 4); + hash_result = Fcons (list3 (build_string ("simple mapper"), + (data.sum == 2 + 4) ? Qt : Qnil, + build_string ("sum != 2 + 4")), + hash_result); data.sum = 0; elisp_maphash (test_hash_tables_modifying_mapper, data.hash_table, (void *) &data); - assert (data.sum == 2 + 4); + hash_result = Fcons (list3 (build_string ("modifying mapper"), + (data.sum == 2 + 4) ? Qt : Qnil, + build_string ("sum != 2 + 4")), + hash_result); /* hash table now contains: (1, 2) (3, 4) (-1, 2*2) (-3, 2*4) */ data.sum = 0; elisp_maphash_unsafe (test_hash_tables_mapper, data.hash_table, (void *) &data); - assert (data.sum == 3 * (2 + 4)); + hash_result = Fcons (list3 (build_string ("simple mapper"), + (data.sum == 3 * (2 + 4)) ? Qt : Qnil, + build_string ("sum != 3 * (2 + 4)")), + hash_result); /* Remove entries with negative keys, added by modifying mapper */ elisp_map_remhash (test_hash_tables_predicate, @@ -541,9 +631,12 @@ data.sum = 0; elisp_maphash_unsafe (test_hash_tables_mapper, data.hash_table, (void *) &data); - assert (data.sum == 2 + 4); + hash_result = Fcons (list3 (build_string ("remove negatives mapper"), + (data.sum == 2 + 4) ? Qt : Qnil, + build_string ("sum != 2 + 4")), + hash_result); - return intern ("PASS"); + return hash_result; } @@ -583,3 +676,4 @@ For use by the automated test suite. See tests/automated/c-tests. */ ); } +
--- a/tests/ChangeLog Sun Nov 15 20:52:09 2009 +0000 +++ b/tests/ChangeLog Mon Nov 16 08:08:44 2009 +0000 @@ -1,3 +1,7 @@ +2009-11-16 Stephen J. Turnbull <stephen@xemacs.org> + + * reproduce-crashes.el (13): New bug reported by Adam Sjogren. + 2009-11-14 Aidan Kehoe <kehoea@parhasard.net> * automated/lisp-tests.el:
--- a/tests/automated/c-tests.el Sun Nov 15 20:52:09 2009 +0000 +++ b/tests/automated/c-tests.el Mon Nov 16 08:08:44 2009 +0000 @@ -40,4 +40,6 @@ (when (boundp 'test-function-list) ; Only if configure --debug (loop for fun in test-function-list do - (Assert (eq 'PASS (funcall fun))))) + ;; #### I hope there's no way we can signal ... + (loop for result in (funcall fun) do + (Assert (nth 1 result) (nth 2 result) (nth 0 result)))))
--- a/tests/automated/test-harness.el Sun Nov 15 20:52:09 2009 +0000 +++ b/tests/automated/test-harness.el Mon Nov 16 08:08:44 2009 +0000 @@ -267,22 +267,27 @@ (Print-Skip ,description ,reason)) ,@body)) - (defmacro Assert (assertion &optional failing-case) + (defmacro Assert (assertion &optional failing-case description) + "Test passes if ASSERTION is true. +Optional FAILING-CASE describes the particular failure. +Optional DESCRIPTION describes the assertion. +FAILING-CASE and DESCRIPTION are useful when Assert is used in a loop." `(condition-case error-info (progn (assert ,assertion) - (Print-Pass "%S" (quote ,assertion)) + (Print-Pass "%S" (quote ,(or description assertion))) (incf passes)) (cl-assertion-failed (Print-Failure (if ,failing-case "Assertion failed: %S; failing case = %S" "Assertion failed: %S") - (quote ,assertion) ,failing-case) + (quote ,(or description assertion)) ,failing-case) (incf assertion-failures)) (t (Print-Failure (if ,failing-case "%S ==> error: %S; failing case = %S" "%S ==> error: %S") - (quote ,assertion) error-info ,failing-case) + (quote ,(or description assertion)) + error-info ,failing-case) (incf other-failures) )))
--- a/tests/reproduce-crashes.el Sun Nov 15 20:52:09 2009 +0000 +++ b/tests/reproduce-crashes.el Mon Nov 16 08:08:44 2009 +0000 @@ -133,6 +133,27 @@ ;;; ------------------------------------------------------------------ ;;;; Bugs follow: +(defbug 13 current + "Crash when reading a message in Gnus, in sys_re_search_2 in regex.c. +Reported by Adam Sjogren on xemacs-beta <87ocn5xt5a.fsf@topper.koldfront.dk>. +issue630 on the tracker. +Reproduced on Mac OS X 10.4.11 iBook G4 (PPC). +Reproduced on Gentoo Linux 2.6.30 AMD (Opteron)." + (string-match (base64-decode-string "\ +WyAJXSo804DFgPOApHWAtXuApliArID5gLZVgLSA2oChRUwvQ4DDQoCrgNeAwoDggLJ7gL6A +94CogOOAtlWAtIDagKFFgLCA6oC7gNqApFSAqICkgLZUgKmA9oC5gOqAsIDIgL6A3oCnQICh +RUwvQ4C2fYCqgKyAw0KAq4DXgKWA04C9gNCAoUWAxXeAqoDvgLF6gKiA04C5cYChR4CigK+A +ooC4gKKAtICigLctgKKAtICigLWAooC4LYCigK+AooCygKKAtIChRUwvQ4CrSIClgM6AqoCs +gMNCgKuA14DFgNyApoDbgKWA0YC5QoClgM6AuIDqgKqA94ChRYCrSIClgM6AqoCsgLZ9gKqA +rIDDQoCrgNeApYDTgL2A0IChRT4=") + (base64-decode-string "\ +XCKAqYDTgMWA84CkdYC1e4CmWICsgPmAtlWAtIDagKFFTC9DgMNCgKuA14DCgOCAsnuAvoD3 +gKiA44C2VYC0gNqAoUWAsIDqgLuA2oCkVICogKSAtlSAqYD2gLmA6oCwgMiAvoDegKdAgKFF +TC9DgLZ9gKqArIDDQoCrgNeApYDTgL2A0IChRYDFd4CqgO+AsXqAqIDTgLlxgKFHgKKAr4Ci +gLiAooC0gKKAty2AooC0gKKAtYCigLgtgKKAr4CigLKAooC0gKFFTC9DgKtIgKWAzoCqgKyA +w0KAq4DXgMWA3ICmgNuApYDRgLlCgKWAzoC4gOqAqoD3gKFFgKtIgKWAzoCqgKyAtn2AqoCs +gMNCgKuA14ClgNOAvYDQgKFFXCIgPHRzZW5nLWNoaXVAdW1haWwu"))) + (defbug 12 current "Crash when clicking on the menubar, triggered by a Lisp error due to a version of truncate-string-to-width that does not take 5 parameters.