From 52f512370fe9bfeb973dafea3904b48dfb8e1d9d Mon Sep 17 00:00:00 2001 From: Stephen Heumann Date: Tue, 9 Feb 2021 23:18:36 -0600 Subject: [PATCH] Update tests to account for recent ORCALib changes. These involve recent standards-conformance patches for printf and scanf, which changed some (non-standard) behaviors that the test cases were expecting. I also fixed a couple things that clang flagged as undefined behavior, even though they weren't really causing problems under ORCA/C. --- Tests/Conformance/C17.11.0.1.CC | 12 ++++++------ Tests/Conformance/C17.11.0.2.CC | 14 +++++++------- Tests/Conformance/C17.8.0.1.CC | 14 +++++++------- Tests/Conformance/C17.8.0.12.CC | 6 +++--- Tests/Conformance/C17.8.0.17.CC | 14 +++++++------- Tests/Conformance/C17.8.0.20.CC | 4 ++-- Tests/Conformance/C17.8.0.4.CC | 4 ++-- Tests/Conformance/C17.8.0.9.CC | 14 +++++++------- 8 files changed, 41 insertions(+), 41 deletions(-) diff --git a/Tests/Conformance/C17.11.0.1.CC b/Tests/Conformance/C17.11.0.1.CC index 48a2ac3..7ab0e32 100644 --- a/Tests/Conformance/C17.11.0.1.CC +++ b/Tests/Conformance/C17.11.0.1.CC @@ -30,17 +30,17 @@ main () /* Write formatted output as string to the output files and sstring. */ - i = fprintf (f1, " %-0+10.8hd %0 10.*i %5.d %10.8li %#-*li M\n", + i = fprintf (f1, " %-0+10.8hd %0 10.*i %5.d %10.8li %-*li M\n", i1, i3, i1, i2, L1, i3, L1); if (i != 56) goto Fail; - i = printf (" %-0+10.8hd %0 10.*i %5.d %10.8li %#-*li M\n", + i = printf (" %-0+10.8hd %0 10.*i %5.d %10.8li %-*li M\n", i1, i3, i1, i2, L1, i3, L1); if (i != 56) goto Fail; - i = sprintf (sstring, " %-0+10.8hd %0 10.*i %5.d %10.8li %#-*li M\n", + i = sprintf (sstring, " %-0+10.8hd %0 10.*i %5.d %10.8li %-*li M\n", i1, i3, i1, i2, L1, i3, L1); if (i != 56) goto Fail; @@ -53,7 +53,7 @@ main () if (i != 1) goto Fail3; string [55] = '\0'; - if (strcmp (string, " +000032767 000032767 -00032767\ + if (strcmp (string, " +00032767 00032767 -00032767\ -32767 M")) goto Fail; @@ -62,11 +62,11 @@ main () if (i != 1) goto Fail3; string [55] = '\0'; - if (strcmp (string, " +000032767 000032767 -00032767\ + if (strcmp (string, " +00032767 00032767 -00032767\ -32767 M")) goto Fail; - if (strcmp (sstring, " +000032767 000032767 -00032767\ + if (strcmp (sstring, " +00032767 00032767 -00032767\ -32767 M\n")) goto Fail; diff --git a/Tests/Conformance/C17.11.0.2.CC b/Tests/Conformance/C17.11.0.2.CC index afefbde..a253155 100644 --- a/Tests/Conformance/C17.11.0.2.CC +++ b/Tests/Conformance/C17.11.0.2.CC @@ -29,17 +29,17 @@ main () /* Write formatted output as string to the output files and sstring. */ - i = fprintf (f1, " %-11.10hu %# +07.4lu %.0u %-*.*lu A\n", + i = fprintf (f1, " %-11.10hu % +07.4lu %.0u %-*.*lu A\n", ui1, (long) ui1, ui2, i1, i2, ul1); if (i != 45) goto Fail; - i = printf (" %-11.10hu %# +07.4lu %.0u %-*.*lu A\n", + i = printf (" %-11.10hu % +07.4lu %.0u %-*.*lu A\n", ui1, (long) ui1, ui2, i1, i2, ul1); if (i != 45) goto Fail; - i = sprintf (sstring, " %-11.10hu %# +07.4lu %.0u %-*.*lu A\n", + i = sprintf (sstring, " %-11.10hu % +07.4lu %.0u %-*.*lu A\n", ui1, (long) ui1, ui2, i1, i2, ul1); if (i != 45) goto Fail; @@ -52,9 +52,9 @@ main () if (i != 1) goto Fail3; string [44] = '\0'; - i = fprintf (f1, " %-11.10hu %# +07.4lu %.0u %-*.*lu A\n", + i = fprintf (f1, " %-11.10hu % +07.4lu %.0u %-*.*lu A\n", ui1, (long) ui1, ui2, i1, i2, ul1); - if (strcmp (string, " 0000065535 +065535 0000004294967295 A")) + if (strcmp (string, " 0000065535 +65535 0000004294967295 A")) goto Fail; rewind (stdout); @@ -62,10 +62,10 @@ main () if (i != 1) goto Fail3; string [44] = '\0'; - if (strcmp (string, " 0000065535 +065535 0000004294967295 A")) + if (strcmp (string, " 0000065535 +65535 0000004294967295 A")) goto Fail; - if (strcmp (sstring, " 0000065535 +065535 0000004294967295 A\n")) + if (strcmp (sstring, " 0000065535 +65535 0000004294967295 A\n")) goto Fail; diff --git a/Tests/Conformance/C17.8.0.1.CC b/Tests/Conformance/C17.8.0.1.CC index 8a626b5..c80061e 100644 --- a/Tests/Conformance/C17.8.0.1.CC +++ b/Tests/Conformance/C17.8.0.1.CC @@ -5,9 +5,9 @@ main () { FILE *f1; - short i1; + short i1, i3; int i; - int i2, i3; + int i2; long L1; char ch; @@ -15,25 +15,25 @@ main () f1 = fopen ("3/tmp", "wb+"); /* open input file for test */ if (f1 == NULL) goto Fail1; - fprintf(f1, " +327678 - -002147483647A 327677-22 123*\r"); + fprintf(f1, " -327678 -0 -002147483647A 327677-22 123*\r"); rewind(f1); i1 = 0; /* test format string of no */ - i = fscanf (f1, "%*05hd8"); /* assignment, max. field */ - if (i != 0) /* width of 5, h ignored, */ + i = fscanf (f1, "%*06hd8"); /* assignment, max. field */ + if (i != 0) /* width of 6, h ignored, */ goto Fail; /* character 8 must appear*/ if (i1 != 0) /* after 5 digits read */ goto Fail; i2 = 15; /* test "plain vanilla" fmt */ i = fscanf (f1, "%d", &i2); /* string; data contains */ - if (i != 1) /* a single minus sign */ + if (i != 1) /* "-0" */ goto Fail; if (i2 != 0) goto Fail; L1 = 0; /* test format string of */ - i = fscanf (f1, "%12ldA", &L1); /* max. field width of 12,*/ + i = fscanf (f1, "%13ldA", &L1); /* max. field width of 13,*/ if (i != 1) /* long variable expected,*/ goto Fail; /* character A must appear*/ if (L1 != -2147483647) /* after digits read */ diff --git a/Tests/Conformance/C17.8.0.12.CC b/Tests/Conformance/C17.8.0.12.CC index 6f54481..8a21299 100644 --- a/Tests/Conformance/C17.8.0.12.CC +++ b/Tests/Conformance/C17.8.0.12.CC @@ -4,7 +4,7 @@ main () { - char string [] = " 327678 0x D 0xFFFFFFFFm 0x7fEd0X10 "; + char string [] = " 327678 0x0 D 0xFFFFFFFFm 0x7fEd0X10 "; int i; unsigned short us1; unsigned int ui1; @@ -20,12 +20,12 @@ main () i = sscanf (&string [8], "%X", &ui1); /* test "plain vanilla" fmt */ if (i != 1) /* string; data contains */ - goto Fail; /* the characters 0x */ + goto Fail; /* the characters 0x0 */ if (ui1 != 0) goto Fail; ul1 = 0; /* test fmt string of max */ - i = sscanf (&string [12], " D %12lxm", &ul1); /* field width of 12,*/ + i = sscanf (&string [13], " D %12lxm", &ul1); /* field width of 12,*/ if (i != 1) /* long variable expected,*/ goto Fail; /* character m must appear*/ if (ul1 != 4294967295u) /* after digits read */ diff --git a/Tests/Conformance/C17.8.0.17.CC b/Tests/Conformance/C17.8.0.17.CC index 0a90840..1f1e113 100644 --- a/Tests/Conformance/C17.8.0.17.CC +++ b/Tests/Conformance/C17.8.0.17.CC @@ -4,9 +4,9 @@ main () { - short i1; + short i1, i3; int i; - int i2, i3; + int i2; long L1; char ch; FILE *f1; @@ -17,7 +17,7 @@ main () f1 = fopen ("3/tmp", "wb+"); /* open input file for test */ if (f1 == NULL) goto Fail1; - fprintf(f1, " +327678 - -002147483647A 327677-22 123*\r"); + fprintf(f1, " +327678 -0 -002147483647A 327677-22 123*\r"); fclose(f1); stdin = freopen ("3/tmp", "r", stdin); @@ -25,21 +25,21 @@ main () goto Fail1; i1 = 0; /* test format string of no */ - i = scanf ("%*05hd8"); /* assignment, max. field */ - if (i != 0) /* width of 5, h ignored, */ + i = scanf ("%*06hd8"); /* assignment, max. field */ + if (i != 0) /* width of 6, h ignored, */ goto Fail; /* character 8 must appear*/ if (i1 != 0) /* after 5 digits read */ goto Fail; i2 = 15; /* test "plain vanilla" fmt */ i = scanf ("%d", &i2); /* string; data contains */ - if (i != 1) /* a single minus sign */ + if (i != 1) /* "-0" */ goto Fail; if (i2 != 0) goto Fail; L1 = 0; /* test format string of */ - i = scanf ("%12ldA", &L1); /* max. field width of 12,*/ + i = scanf ("%13ldA", &L1); /* max. field width of 13,*/ if (i != 1) /* long variable expected,*/ goto Fail; /* character A must appear*/ if (L1 != -2147483647) /* after digits read */ diff --git a/Tests/Conformance/C17.8.0.20.CC b/Tests/Conformance/C17.8.0.20.CC index cf51b8c..d43a785 100644 --- a/Tests/Conformance/C17.8.0.20.CC +++ b/Tests/Conformance/C17.8.0.20.CC @@ -16,7 +16,7 @@ main () f1 = fopen ("3/tmp", "wb+"); /* open input file for test */ if (f1 == NULL) goto Fail1; - fprintf(f1, " 327678 0x D 0xFFFFFFFFm 0x7fEd0X10"); + fprintf(f1, " 327678 0x0 D 0xFFFFFFFFm 0x7fEd0X10"); fclose(f1); stdin = freopen ("3/tmp", "r", stdin); @@ -32,7 +32,7 @@ main () i = scanf ("%X", &ui1); /* test "plain vanilla" fmt */ if (i != 1) /* string; data contains */ - goto Fail; /* the characters 0x */ + goto Fail; /* the characters 0x0 */ if (ui1 != 0) goto Fail; diff --git a/Tests/Conformance/C17.8.0.4.CC b/Tests/Conformance/C17.8.0.4.CC index 8fc056c..23e7aec 100644 --- a/Tests/Conformance/C17.8.0.4.CC +++ b/Tests/Conformance/C17.8.0.4.CC @@ -14,7 +14,7 @@ main () f1 = fopen ("3/tmp", "wb+"); /* open input file for test */ if (f1 == NULL) goto Fail1; - fprintf(f1, " 327678 0x D 0xFFFFFFFFm 0x7fEd0X10"); + fprintf(f1, " 327678 0x0 D 0xFFFFFFFFm 0x7fEd0X10"); rewind(f1); us1 = 2; /* test format string of no */ @@ -26,7 +26,7 @@ main () i = fscanf (f1, "%X", &ui1); /* test "plain vanilla" fmt */ if (i != 1) /* string; data contains */ - goto Fail; /* the characters 0x */ + goto Fail; /* the characters 0x0 */ if (ui1 != 0) goto Fail; diff --git a/Tests/Conformance/C17.8.0.9.CC b/Tests/Conformance/C17.8.0.9.CC index 5a75f7f..31fac3e 100644 --- a/Tests/Conformance/C17.8.0.9.CC +++ b/Tests/Conformance/C17.8.0.9.CC @@ -4,30 +4,30 @@ main () { - char string [] = " +327678 - -002147483647A 327677-22 123*"; - short i1; + char string [] = " +327678 -0 -002147483647A 327677-22 123*"; + short i1, i3; int i; - int i2, i3; + int i2; long L1; char ch; i1 = 0; /* test format string of no */ - i = sscanf (string, "%*05hd8"); /* assignment, max. field */ - if (i != 0) /* width of 5, h ignored, */ + i = sscanf (string, "%*06hd8"); /* assignment, max. field */ + if (i != 0) /* width of 6, h ignored, */ goto Fail; /* character 8 must appear*/ if (i1 != 0) /* after 5 digits read */ goto Fail; i2 = 15; /* test "plain vanilla" fmt */ i = sscanf (&string [9], "%d", &i2); /* string; data contains */ - if (i != 1) /* a single minus sign */ + if (i != 1) /* "-0" */ goto Fail; if (i2 != 0) goto Fail; L1 = 0; /* test format string of */ - i = sscanf (&string [15], "%12ldA", &L1); /* max. field width of 12,*/ + i = sscanf (&string [15], "%13ldA", &L1); /* max. field width of 13,*/ if (i != 1) /* long variable expected,*/ goto Fail; /* character A must appear*/ if (L1 != -2147483647) /* after digits read */