From patchwork Fri Nov 17 11:18:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandra Petlanova Hajkova X-Patchwork-Id: 80122 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7C5573858299 for ; Fri, 17 Nov 2023 11:19:54 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id F10B0385841B for ; Fri, 17 Nov 2023 11:18:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F10B0385841B Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org F10B0385841B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700219936; cv=none; b=KfYnhuVTaXfpqXueBuVxhKKkKS/QV9FdTOB+tGOk8VW0/5UUxYshVil5cU7cuLd3wx5b4Djshha8ux6cSEKUy/XH+E6HbvLLovXXi3GfzywpXrB8ZHnhgtxcJP+mOigV1GGj6/JWuhghnJKs1pNPVvwhP2Ykn8GtZbgg91kKNMw= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1700219936; c=relaxed/simple; bh=9eAt2A5aJlGbZav+974a5VzMZiAhGXcn9LQSw3seQz8=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=LYirt5KvfC47TbS1PcPDThcb8FM7pziJpwMXe6vv6G3xLATzzhUetJKcdcBtdj2bzey9RLoKLoVZfFolsXuucSM40/swW7dXCJ15+bvz+BzYH34/UyOW7vBOnu0mKT0KIydlO1Pss25NrcVdz+Jmk+2uSQB/y2Tz8AvqXF+NTSc= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700219933; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7v6LNSyAaKn+b1KWEYkyDK64oCfWeHTju54macLrf3A=; b=SS2BGgxWACJbsMeqJsO3CaI9aYbUQ9zVFGk4IvYA7uCLf5i0v+rux+ffAMwAVKz6n5Dk3O IZuZxeyAOWUxcylP7vmwEnyFc1F25kx7GzTlNucEW2DgJfjqftI0rMr2jFM3ZFNHNGeHHA VArlWbqaM9NyPtoB5vUFrfRPGKyd8u8= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-622-TV9yJjovM-iuzVITdAImdg-1; Fri, 17 Nov 2023 06:18:52 -0500 X-MC-Unique: TV9yJjovM-iuzVITdAImdg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6818038116E3 for ; Fri, 17 Nov 2023 11:18:52 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.242.6]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 41F882026D4C; Fri, 17 Nov 2023 11:18:51 +0000 (UTC) From: =?utf-8?q?Alexandra_H=C3=A1jkov=C3=A1?= To: gdb-patches@sourceware.org Cc: ahajkova@redhat.com Subject: [PATCH 6/6] Add defaultinf.exp test to the testsuite Date: Fri, 17 Nov 2023 12:18:40 +0100 Message-ID: <20231117111840.2040709-7-ahajkova@redhat.com> In-Reply-To: <20231117111840.2040709-1-ahajkova@redhat.com> References: <20231117111840.2040709-1-ahajkova@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Test the behaviour of the inferior when GDBserver is run locally and using stdio. The inferior should be able to write to STOUT and STDERR and read from STDIN. --- gdb/testsuite/gdb.server/defaultinf.c | 39 ++++++++++++++++ gdb/testsuite/gdb.server/defaultinf.exp | 59 +++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 gdb/testsuite/gdb.server/defaultinf.c create mode 100644 gdb/testsuite/gdb.server/defaultinf.exp diff --git a/gdb/testsuite/gdb.server/defaultinf.c b/gdb/testsuite/gdb.server/defaultinf.c new file mode 100644 index 00000000000..8963c7dbabf --- /dev/null +++ b/gdb/testsuite/gdb.server/defaultinf.c @@ -0,0 +1,39 @@ +/* Copyright 2023 Free Software Foundation, Inc. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . */ + +#include +#include + +int +main () +{ + printf ("Hello stdout!\n"); + fprintf (stderr, "Hello stderr!\n"); + + char *line = NULL; + size_t len = 0; + ssize_t nread; + + while ((nread = getline (&line, &len, stdin)) != -1) + { + if (line[nread - 1] == '\n') + line[nread - 1] = '\0'; + printf ("Got line len %zd: '%s'\n", nread, line); + } + + printf ("Got EOF\n"); + free (line); + return 0; +} diff --git a/gdb/testsuite/gdb.server/defaultinf.exp b/gdb/testsuite/gdb.server/defaultinf.exp new file mode 100644 index 00000000000..03163e150e0 --- /dev/null +++ b/gdb/testsuite/gdb.server/defaultinf.exp @@ -0,0 +1,59 @@ +# This testcase is part of GDB, the GNU debugger. + +# Copyright 2023 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Test the behaviour of the inferior when GDBserver is run locally +# and using stdio. The inferior should be able to write to STOUT +# and STDERR and read from STDIN. + +require {!is_remote target} {!is_remote host} + +load_lib gdbserver-support.exp + +require allow_gdbserver_tests + +set gdbserver [find_gdbserver] +if { $gdbserver == "" } { + unsupported "could not find GDBserver" + return +} + +standard_testfile + +if {[build_executable "failed to prepare" $testfile $srcfile debug]} { + return -1 +} + +clean_restart ${testfile} + +gdb_test "target remote | ${::gdbserver} - [standard_output_file $testfile]" ".*" \ + "start gdbserver using pipe syntax" + + set input_msg "hello world" + set input_len [expr [string length ${input_msg}] + 1] + gdb_test_multiple "c" "Test STDOUT/ERR, STDIN" { + -re "Hello stdout!\r\nHello stderr!" { + send_gdb "${input_msg}\n" + exp_continue + } + -re "${input_msg}\r\nGot line len ${input_len}: '${input_msg}'" { + send_gdb "\004" + exp_continue + } + -re "Got EOF" { + pass "$gdb_test_name" + } + }