Add selftest for tui_setup_io
Checks
| Context |
Check |
Description |
| linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
| linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
success
|
Test passed
|
| linaro-tcwg-bot/tcwg_gdb_check--master-arm |
success
|
Test passed
|
Commit Message
Add a selftest for the problem described in commit b171f68e945 ("[gdb/tui]
Make tui_setup_io more robust").
---
gdb/tui/tui-io.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
base-commit: db4f00be62d3396374df989b5f938c3ebec6833e
Comments
On 4/3/26 8:31 AM, Tom de Vries wrote:
> Add a selftest for the problem described in commit b171f68e945 ("[gdb/tui]
> Make tui_setup_io more robust").
Hi Tom!
I looked over this patch and it makes sense, and I verified that it does
trigger a crash before the listed commit, so it is properly testing it.
Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
On 4/10/26 3:31 PM, Guinevere Larsen wrote:
> On 4/3/26 8:31 AM, Tom de Vries wrote:
>> Add a selftest for the problem described in commit b171f68e945 ("[gdb/
>> tui]
>> Make tui_setup_io more robust").
>
> Hi Tom!
>
> I looked over this patch and it makes sense, and I verified that it does
> trigger a crash before the listed commit, so it is properly testing it.
Hi Guinevere,
thanks for the review, I've pushed this.
- Tom
> Reviewed-By: Guinevere Larsen <guinevere@redhat.com>
@@ -46,6 +46,7 @@
#include "pager.h"
#include "gdbsupport/gdb-checked-static-cast.h"
#include "logging-file.h"
+#include "gdbsupport/selftest.h"
/* This redefines CTRL if it is not already defined, so it must come
after terminal state related include files like <term.h> and
@@ -1328,3 +1329,36 @@ tui_getc (FILE *fp)
return 0;
}
}
+
+#if GDB_SELF_TEST
+namespace selftests {
+namespace tui {
+namespace io {
+
+static void
+run_tests ()
+{
+ if (!tui_active)
+ {
+ /* Calling tui_setup_io (0) when tui is disabled should have no effect. */
+ tui_setup_io (0);
+
+ /* If the output streams are reduced to nullptrs, then the self-test
+ infrastructure will crash when trying to report these failures. */
+ SELF_CHECK (*redirectable_stdout () != nullptr);
+ SELF_CHECK (*redirectable_stderr () != nullptr);
+ SELF_CHECK (*redirectable_stdlog () != nullptr);
+ }
+}
+
+} /* namespace io */
+} /* namespace tui */
+} /* namespace selftests */
+#endif /* GDB_SELF_TEST */
+
+INIT_GDB_FILE (tui_io)
+{
+#if GDB_SELF_TEST
+ selftests::register_test ("tui-io", selftests::tui::io::run_tests);
+#endif
+}