From patchwork Fri Jan 19 11:56:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandra Petlanova Hajkova X-Patchwork-Id: 84431 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 772C23858430 for ; Fri, 19 Jan 2024 11:59:32 +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.129.124]) by sourceware.org (Postfix) with ESMTPS id 9C48C38582B2 for ; Fri, 19 Jan 2024 11:57:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9C48C38582B2 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 9C48C38582B2 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705665434; cv=none; b=ML2wL7F0yEGtAdUo67eh3/TtDVzlju4tXfUiNJ0/fbayHWxSxBKPbchYoUeiCSn3PwQvy4G5eZKQFYEafo4Mq5eaQKF7KXmlYX5ASzt6sm06nKPlkKCkQJI+yx1hPfdwDjIfES30L1LjaOReqOhDSkSzNrFs+SmsEmjcwZ6EGxA= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705665434; c=relaxed/simple; bh=IQDRjtelO/AWKuzaR+taQiKSp1Q0uhfygxOUk8JrlZM=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=MivWmvVP/qhWmFVRRzyPKoHz3TLs2lJ/qzRnCUtyLTUyYfby03QU+oqFnOGHbi2vVsRJSF0MLg33nUKUQ/SDxq3w0QBKgjZE4XNt6N/xvOXwTh/KtG6/I2i2TSgTYyH55l0ZDi1Pf8GDkoTSJCCW3Cgt68dVHL/qtzIDIE2Okok= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705665431; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Nh8Ev/IZG8EGjCGsqACR3poa8l138F4FpuVBnEE17qo=; b=Fg6bzWGaN5gbFuHabRgzVfgAFkR8U1bHKksuOQsjJAZ83txtOZrPhFMV4LnJtFK1bm7o/l 3WgQyzmP5YtS/D4b3VrPZ3Bz4Vh6Mtw815PEvbWO/WMw12awDq3aQ1x2S0jHWyoJyElUBH ec/mE2mq9mERREiUO5n2KLPl5gzuf+M= 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-647-WXKs_OuuPHy0sSZ6mwReJg-1; Fri, 19 Jan 2024 06:57:10 -0500 X-MC-Unique: WXKs_OuuPHy0sSZ6mwReJg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (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 5E5BF3C2AB0E for ; Fri, 19 Jan 2024 11:57:10 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.45.242.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D4B724011C41 for ; Fri, 19 Jan 2024 11:57:09 +0000 (UTC) From: =?utf-8?q?Alexandra_H=C3=A1jkov=C3=A1?= To: gdb-patches@sourceware.org Subject: [PATCH v2 6/6] Add defaultinf.exp test to the testsuite Date: Fri, 19 Jan 2024 12:56:30 +0100 Message-ID: <20240119115659.491195-8-ahajkova@redhat.com> In-Reply-To: <20240119115659.491195-1-ahajkova@redhat.com> References: <20240119115659.491195-1-ahajkova@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.9 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_H4, 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" + } + }