]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
testsuite: flag failure to detect failures
authorAlexandre Oliva <oliva@adacore.com>
Wed, 29 Apr 2026 01:31:13 +0000 (22:31 -0300)
committerAlexandre Oliva <oliva@gnu.org>
Wed, 29 Apr 2026 01:31:13 +0000 (22:31 -0300)
There are various ways for tests to report an execution failure.

Make sure the testing infrastructure can detect all of them, so that
failures don't go silent.

for  gcc/testsuite/ChangeLog

* gcc.dg/shouldfail-abort.c: New.
* gcc.dg/shouldfail-exit-neg.c: New.
* gcc.dg/shouldfail-exit-pos.c: New.
* gcc.dg/shouldfail-return-neg.c: New.
* gcc.dg/shouldfail-return-pos.c: New.

gcc/testsuite/gcc.dg/shouldfail-abort.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/shouldfail-exit-neg.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/shouldfail-exit-pos.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/shouldfail-return-neg.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/shouldfail-return-pos.c [new file with mode: 0644]

diff --git a/gcc/testsuite/gcc.dg/shouldfail-abort.c b/gcc/testsuite/gcc.dg/shouldfail-abort.c
new file mode 100644 (file)
index 0000000..a00c483
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do run } */
+/* { dg-shouldfail "" } */
+
+/* Raise red flags if the way programs are meant to flag failures aren't
+   detected as such.  This is unlikely to indicate a compiler problem, but
+   maybe a runtime or test infrastructure problem.  */
+
+int main() {
+  __builtin_abort();
+}
diff --git a/gcc/testsuite/gcc.dg/shouldfail-exit-neg.c b/gcc/testsuite/gcc.dg/shouldfail-exit-neg.c
new file mode 100644 (file)
index 0000000..57d6681
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do run } */
+/* { dg-shouldfail "" } */
+
+/* Raise red flags if the way programs are meant to flag failures aren't
+   detected as such.  This is unlikely to indicate a compiler problem, but
+   maybe a runtime or test infrastructure problem.  */
+
+int main() {
+  __builtin_exit(-1);
+}
diff --git a/gcc/testsuite/gcc.dg/shouldfail-exit-pos.c b/gcc/testsuite/gcc.dg/shouldfail-exit-pos.c
new file mode 100644 (file)
index 0000000..2ae16fa
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do run } */
+/* { dg-shouldfail "" } */
+
+/* Raise red flags if the way programs are meant to flag failures aren't
+   detected as such.  This is unlikely to indicate a compiler problem, but
+   maybe a runtime or test infrastructure problem.  */
+
+int main() {
+  __builtin_exit(1);
+}
diff --git a/gcc/testsuite/gcc.dg/shouldfail-return-neg.c b/gcc/testsuite/gcc.dg/shouldfail-return-neg.c
new file mode 100644 (file)
index 0000000..6d32d26
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do run } */
+/* { dg-shouldfail "" } */
+
+/* Raise red flags if the way programs are meant to flag failures aren't
+   detected as such.  This is unlikely to indicate a compiler problem, but
+   maybe a runtime or test infrastructure problem.  */
+
+int main() {
+  return -1;
+}
diff --git a/gcc/testsuite/gcc.dg/shouldfail-return-pos.c b/gcc/testsuite/gcc.dg/shouldfail-return-pos.c
new file mode 100644 (file)
index 0000000..ceb4f4c
--- /dev/null
@@ -0,0 +1,10 @@
+/* { dg-do run } */
+/* { dg-shouldfail "" } */
+
+/* Raise red flags if the way programs are meant to flag failures aren't
+   detected as such.  This is unlikely to indicate a compiler problem, but
+   maybe a runtime or test infrastructure problem.  */
+
+int main() {
+  return 1;
+}