diff options
-rw-r--r-- | newlib/testsuite/lib/checkoutput.exp | 20 | ||||
-rw-r--r-- | newlib/testsuite/newlib.locale/UTF-8.c | 62 | ||||
-rw-r--r-- | newlib/testsuite/newlib.locale/UTF-8.exp | 156 |
3 files changed, 119 insertions, 119 deletions
diff --git a/newlib/testsuite/lib/checkoutput.exp b/newlib/testsuite/lib/checkoutput.exp index 5793868fd..8cb46925f 100644 --- a/newlib/testsuite/lib/checkoutput.exp +++ b/newlib/testsuite/lib/checkoutput.exp @@ -5,9 +5,8 @@ # # newlib_check_output takes the basename of the test source file, and -# a list of pairs of the form "testname" "expectedoutput" -# "testname" "expectedoutput"... It assumes one line of output -# per test. +# a list of TCL regular expressions representing the expected output. +# It assumes one line of output per test. proc newlib_check_output { srcfile expectlist } { global objdir subdir srcdir @@ -19,8 +18,7 @@ proc newlib_check_output { srcfile expectlist } { if { $comp_output != "" } { fail "Failed to compile $srcfile.\n" - } else { - pass "Compiled $srcfile.\n" + return } set result [newlib_load $test_driver ""] @@ -29,12 +27,14 @@ proc newlib_check_output { srcfile expectlist } { set output_lines [split $output "\n"] - foreach { testname expectedval } $expectlist { - if [string match "$expectedval" "[lindex $output_lines 0]"] then { - pass $testname - } else { - fail $testname + foreach { expectedval } $expectlist { + set gotval [string trim [lindex $output_lines 0] "\r"] + if { ! [string match $expectedval $gotval] } { + fail "$srcfile: Expected: $expectedval Got: $gotval " + return } set output_lines [lrange $output_lines 1 end] } + + pass $srcfile } diff --git a/newlib/testsuite/newlib.locale/UTF-8.c b/newlib/testsuite/newlib.locale/UTF-8.c index 9970ffa8f..36213af6a 100644 --- a/newlib/testsuite/newlib.locale/UTF-8.c +++ b/newlib/testsuite/newlib.locale/UTF-8.c @@ -151,17 +151,17 @@ int main() /* 2.1 First possible sequence of a certain length */ retval = mbtowc(&wchar, first[0], MAX_BYTES); if (retval == 0) - printf("2.1.1: U-%08d \n", wchar); + printf("2.1.1: U-%08d\n", wchar); else - printf("2.1.1: Invalid \n"); + printf("2.1.1: Invalid\n"); for (i = 2; i < 7; i++) { retval = mbtowc (&wchar, first[i-1], MAX_BYTES); if (retval == i) - printf("2.1.%d: U-%08x \n", i, wchar); + printf("2.1.%d: U-%08x\n", i, wchar); else - printf("2.1.%d: Invalid \n", i); + printf("2.1.%d: Invalid\n", i); } /* 2.2 Last possible sequence of a certain length */ @@ -169,9 +169,9 @@ int main() { retval = mbtowc (&wchar, last[i-1], MAX_BYTES); if (retval == i) - printf("2.2.%d: U-%08x \n", i, wchar); + printf("2.2.%d: U-%08x\n", i, wchar); else - printf("2.2.%d: Invalid \n", i); + printf("2.2.%d: Invalid\n", i); } /* 2.3 Other boundary conditions */ @@ -179,24 +179,24 @@ int main() { retval = mbtowc (&wchar, boundary[i-1], MAX_BYTES); if ((i < 4 && retval == 3) || (i > 3 && retval == 4)) - printf("2.3.%d: U-%08x \n", i, wchar); + printf("2.3.%d: U-%08x\n", i, wchar); else - printf("2.3.%d: Invalid \n", i); + printf("2.3.%d: Invalid\n", i); } /* 3 Malformed sequences */ /* 3.1 Unexpected continuation bytes */ retval = mbtowc (&wchar, continuation_bytes[0], MAX_BYTES); if (retval == 1) - printf("3.1.1: U-%08x \n", wchar); + printf("3.1.1: U-%08x\n", wchar); else - printf("3.1.1: 1 Invalid \n"); + printf("3.1.1: 1 Invalid\n"); retval = mbtowc (&wchar, continuation_bytes[1], MAX_BYTES); if (retval == 1) - printf("3.1.2: U-%08x \n", wchar); + printf("3.1.2: U-%08x\n", wchar); else - printf("3.1.2: 1 Invalid \n"); + printf("3.1.2: 1 Invalid\n"); for(i=2; i< 8; i++) { @@ -204,7 +204,7 @@ int main() if (retval == -1) printf("3.1.%d: Valid Character Found\n", i+1); else - printf("3.1.%d: %d Invalid \n", i+1, retval); + printf("3.1.%d: %d Invalid\n", i+1, retval); } for(i = 0x80; i < 0xc0; i++) @@ -214,7 +214,7 @@ int main() if (retval == -1) printf("3.1.9: Valid Character Found\n"); else - printf("3.1.9: %d Invalid \n", retval); + printf("3.1.9: %d Invalid\n", retval); /* 3.2 Lonely start characters */ for(i = 0xc0; i < 0xe0; i++) @@ -224,7 +224,7 @@ int main() if (retval == -1) printf("3.2.1: Valid Character Found\n"); else - printf("3.2.1: %d Invalid \n", retval); + printf("3.2.1: %d Invalid\n", retval); for(i = 0xe0; i < 0xf0; i++) all_three_byte_seq[i-0xe0] = i; @@ -233,7 +233,7 @@ int main() if (retval == -1) printf("3.2.2: Valid Character Found\n"); else - printf("3.2.2: %d Invalid \n", retval); + printf("3.2.2: %d Invalid\n", retval); for(i = 0xf0; i < 0xf8; i++) all_four_byte_seq[i-0xf0] = i; @@ -242,7 +242,7 @@ int main() if (retval == -1) printf("3.2.3: Valid Character Found\n"); else - printf("3.2.3: %d Invalid \n", retval); + printf("3.2.3: %d Invalid\n", retval); for(i = 0xf8; i < 0xfc; i++) all_five_byte_seq[i-0xf8] = i; @@ -251,7 +251,7 @@ int main() if (retval == -1) printf("3.2.4: Valid Character Found\n"); else - printf("3.2.4: %d Invalid \n", retval); + printf("3.2.4: %d Invalid\n", retval); for(i = 0xfc; i < 0xfe; i++) all_six_byte_seq[i-0xfc] = i; @@ -260,14 +260,14 @@ int main() if (retval == -1) printf("3.2.5: Valid Character Found\n"); else - printf("3.2.5: %d Invalid \n", retval); + printf("3.2.5: %d Invalid\n", retval); /* 3.3 Sequences with last continuation byte missing */ for(i = 1; i < 6; i++) { retval = mbtowc(&wchar, incomplete_seq[i-1], i); if(retval == -1) - printf("3.3.%d: 1 Invalid \n", i); + printf("3.3.%d: 1 Invalid\n", i); else printf("3.3.%d: Valid Character Found\n", i); } @@ -276,7 +276,7 @@ int main() { retval = mbtowc(&wchar, incomplete_seq[i-1], i - 5); if(retval == -1) - printf("3.3.%d: 1 Invalid \n", i); + printf("3.3.%d: 1 Invalid\n", i); else printf("3.3.%d: Valid Character Found\n", i); } @@ -288,19 +288,19 @@ int main() /* 3.5 Impossible bytes */ retval = mbtowc(&wchar, impossible_bytes[0], 1); if(retval == -1) - printf("3.5.1: 1 Invalid \n"); + printf("3.5.1: 1 Invalid\n"); else printf("3.5.1: Valid Character Found\n"); retval = mbtowc(&wchar, impossible_bytes[1], 1); if(retval == -1) - printf("3.5.2: 1 Invalid \n"); + printf("3.5.2: 1 Invalid\n"); else printf("3.5.2: Valid Character Found\n"); retval = mbtowc(&wchar, impossible_bytes[2], 4); if(retval == -1) - printf("3.5.3: 1 Invalid \n"); + printf("3.5.3: 1 Invalid\n"); else printf("3.5.3: Valid Character Found\n"); @@ -310,7 +310,7 @@ int main() { retval = mbtowc(&wchar, overlong[i-2], i); if(retval == -1) - printf("4.1.%d: 1 Invalid \n", i-1); + printf("4.1.%d: 1 Invalid\n", i-1); else printf("4.1.%d: Valid Character Found\n", i-1); } @@ -320,7 +320,7 @@ int main() { retval = mbtowc(&wchar, overlong_max[i-2], i); if(retval == -1) - printf("4.2.%d: 1 Invalid \n", i-1); + printf("4.2.%d: 1 Invalid\n", i-1); else printf("4.2.%d: Valid Character Found\n", i-1); } @@ -330,7 +330,7 @@ int main() { retval = mbtowc(&wchar, overlong_nul[i-2], i); if(retval == -1) - printf("4.3.%d: 1 Invalid \n", i-1); + printf("4.3.%d: 1 Invalid\n", i-1); else printf("4.3.%d: Valid Character Found\n", i-1); } @@ -341,7 +341,7 @@ int main() { retval = mbtowc(&wchar, single_surrogates[i-1], 3); if(retval == -1) - printf("5.1.%d: 1 Invalid \n", i); + printf("5.1.%d: 1 Invalid\n", i); else printf("5.1.%d: Valid Character Found\n", i); } @@ -351,7 +351,7 @@ int main() { retval = mbtowc(&wchar, paired_surrogates[i-1], 6); if(retval == -1) - printf("5.2.%d: 1 Invalid \n", i); + printf("5.2.%d: 1 Invalid\n", i); else printf("5.2.%d: Valid Character Found\n", i); } @@ -359,13 +359,13 @@ int main() /* 5.3 Other illegal code positions */ retval = mbtowc(&wchar, illegal_pos[0], 3); if(retval == -1) - printf("5.3.1: 1 Invalid \n"); + printf("5.3.1: 1 Invalid\n"); else printf("5.3.1: Valid Character Found\n"); retval = mbtowc(&wchar, illegal_pos[1], 3); if(retval == -1) - printf("5.3.2: 1 Invalid \n"); + printf("5.3.2: 1 Invalid\n"); else printf("5.3.2: Valid Character Found\n"); diff --git a/newlib/testsuite/newlib.locale/UTF-8.exp b/newlib/testsuite/newlib.locale/UTF-8.exp index eaced891a..e97c963fc 100644 --- a/newlib/testsuite/newlib.locale/UTF-8.exp +++ b/newlib/testsuite/newlib.locale/UTF-8.exp @@ -6,83 +6,83 @@ load_lib checkoutput.exp -set tests { -"Setting UTF-8 locale" "*Set UTF-8 locale*" -"2.1.1" "* U-00000000 *" -"2.1.2" "* U-00000080 *" -"2.1.3" "* U-00000800 *" -"2.1.4" "* U-00010000 *" -"2.1.5" "* U-00200000 *" -"2.1.6" "* U-04000000 *" -"2.2.1" "* U-0000007f *" -"2.2.2" "* U-000007ff *" -"2.2.3" "* U-0000ffff *" -"2.2.4" "* U-001fffff *" -"2.2.5" "* U-03ffffff *" -"2.2.6" "* U-7fffffff *" -"2.3.1" "* U-0000d7ff *" -"2.3.2" "* U-0000e000 *" -"2.3.3" "* U-0000fffd *" -"2.3.4" "* U-0010ffff *" -"2.3.5" "* U-00110000 *" -"3.1.1" "* 1 Invalid *" -"3.1.2" "* 1 Invalid *" -"3.1.3" "* 2 Invalid *" -"3.1.4" "* 3 Invalid *" -"3.1.5" "* 4 Invalid *" -"3.1.6" "* 5 Invalid *" -"3.1.7" "* 6 Invalid *" -"3.1.8" "* 7 Invalid *" -"3.1.9" "* 64 Invalid *" -"3.2.1" "* 32 Invalid *" -"3.2.2" "* 16 Invalid *" -"3.2.3" "* 8 Invalid *" -"3.2.4" "* 4 Invalid *" -"3.2.5" "* 2 Invalid *" -"3.3.1" "* 1 Invalid *" -"3.3.2" "* 1 Invalid *" -"3.3.3" "* 1 Invalid *" -"3.3.4" "* 1 Invalid *" -"3.3.5" "* 1 Invalid *" -"3.3.6" "* 1 Invalid *" -"3.3.7" "* 1 Invalid *" -"3.3.8" "* 1 Invalid *" -"3.3.9" "* 1 Invalid *" -"3.3.10" "* 1 Invalid *" -"3.5.1" "* 1 Invalid *" -"3.5.2" "* 1 Invalid *" -"3.5.3" "* 1 Invalid *" -"4.1.1" "* 1 Invalid *" -"4.1.2" "* 1 Invalid *" -"4.1.3" "* 1 Invalid *" -"4.1.4" "* 1 Invalid *" -"4.1.5" "* 1 Invalid *" -"4.2.1" "* 1 Invalid *" -"4.2.2" "* 1 Invalid *" -"4.2.3" "* 1 Invalid *" -"4.2.4" "* 1 Invalid *" -"4.2.5" "* 1 Invalid *" -"4.3.1" "* 1 Invalid *" -"4.3.2" "* 1 Invalid *" -"4.3.3" "* 1 Invalid *" -"4.3.4" "* 1 Invalid *" -"4.3.5" "* 1 Invalid *" -"5.1.1" "* 1 Invalid *" -"5.1.2" "* 1 Invalid *" -"5.1.3" "* 1 Invalid *" -"5.1.4" "* 1 Invalid *" -"5.1.5" "* 1 Invalid *" -"5.1.6" "* 1 Invalid *" -"5.1.7" "* 1 Invalid *" -"5.2.1" "* 1 Invalid *" -"5.2.2" "* 1 Invalid *" -"5.2.3" "* 1 Invalid *" -"5.2.4" "* 1 Invalid *" -"5.2.5" "* 1 Invalid *" -"5.2.6" "* 1 Invalid *" -"5.2.7" "* 1 Invalid *" -"5.3.1" "* 1 Invalid *" -"5.3.2" "* 1 Invalid *" +set expected_output { +"Set UTF-8 locale." +"* U-00000000" +"* U-00000080" +"* U-00000800" +"* U-00010000" +"* U-00200000" +"* U-04000000" +"* U-0000007f" +"* U-000007ff" +"* U-0000ffff" +"* U-001fffff" +"* U-03ffffff" +"* U-7fffffff" +"* U-0000d7ff" +"* U-0000e000" +"* U-0000fffd" +"* U-0010ffff" +"* U-00110000" +"* 1 Invalid" +"* 1 Invalid" +"* 2 Invalid" +"* 3 Invalid" +"* 4 Invalid" +"* 5 Invalid" +"* 6 Invalid" +"* 7 Invalid" +"* 64 Invalid" +"* 32 Invalid" +"* 16 Invalid" +"* 8 Invalid" +"* 4 Invalid" +"* 2 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" +"* 1 Invalid" } -newlib_check_output "UTF-8.c" "$tests" +newlib_check_output UTF-8.c $expected_output |