From patchwork Mon Nov 27 17:55:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Burgess X-Patchwork-Id: 80834 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 A326C385AC23 for ; Mon, 27 Nov 2023 17:56:49 +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 4CD0A385770A for ; Mon, 27 Nov 2023 17:56:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4CD0A385770A 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 4CD0A385770A 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=1701107774; cv=none; b=gIt52jSDYkPyFqpNPGehojpCdY2qf7CzeTIbVMvDXOu814ExyGXNdHL9a5kLcrMcAwavHyBPsWy3bgoJOgN0ScOHFeo7HymXTGC5dDvEeJ3DjnfPXOEeZHlclOb9s+hyoGN6odWV1VCl4kRMyfMP46NAF5NbsBa4p2nD8H8t5cg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701107774; c=relaxed/simple; bh=UwXYKmzPgvHWgn7s9dHs/W5TTETy22aAhwXr7meHjP4=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=rMJGRk/SQlG6ihTdRXY4xJzsnY/4YS4enlSDW1gIUNWQAflBUHR5YQkUFJyD8gbsFVzcV9A7Ll2ytcGw35K0Xq8HJ1OXuN9OlYmCwPoWU2xcoYog37/aSqlnAzQ55qCaJiijtEc+R92MZnN2jJDAhYLffjN2wAXd+shC88k9+dQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701107770; 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=SBGCDW5OhANMsEBJWec5+QMhpb63ydRNpGhvTDqT9uQ=; b=Hbb1TTAwBWNqfjELB7Pk+Z6PaNEcqtcFh41+MEzbn9eDWjZfzqrsbWct3t1SxkO77+PO3V Rl/ChrQT0fX+bgCISkwM3h+JVpGrnfIKe2yjj7Na004O5EwYAliQXOhtdZl0rMGabRR3QP ALonpqHGSZYqXwffwzJgjRzEEFz+Yj4= Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-32-bqFe5JZvO_q_62C9_3L_WA-1; Mon, 27 Nov 2023 12:56:09 -0500 X-MC-Unique: bqFe5JZvO_q_62C9_3L_WA-1 Received: by mail-wm1-f72.google.com with SMTP id 5b1f17b1804b1-40b310b5453so30521815e9.1 for ; Mon, 27 Nov 2023 09:56:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701107767; x=1701712567; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SBGCDW5OhANMsEBJWec5+QMhpb63ydRNpGhvTDqT9uQ=; b=o9pWPqEeTvTblQ5bpdXr75kDSUt+qrdO/0PqWvrdsoftIg3MpVxa/WJ8vkiwdEvqej KFN3cHqeX4yw23VhML9Jor0sQ+XL24ihfCogZuCn9fEclJ4nJN+AZYSBoipujQakK93h D8uq8KcFjbpIjwTcOt7M3XUT9gTFFGkcIU8Dc44UrBsBi22BO1KPsOccvuWfKtGqKk4a Afob1oIW3bP+aDCU+r+WOOWNBbA85L89C4mhs2motgQHmpEQdNYfgEzDXXNL5EWwIbp9 0+JK1sMg1O3pm6HDG8odBTZYEHf7wgXcUFRVg/gmBPTqq/3BOB9rOeTFkA5hy8pFAjwL xkFQ== X-Gm-Message-State: AOJu0YzVQVdWrOdOayrW+87I5QjzEbDn3alrSrBKx27GGpu3l4ky9v6x qr8wsP7D+/JJ2rc6KZ4efFaWwU5kiA7taYDHJj6xXfQqLBQsKMixSu6be6hUKNtlNN2O+UxpCsS nyHbg4ngaCw+dITSUNBXU7KBajZdKDQqioL88m1QLTUhvKnzmNlm3MgYnKw1qf9NNH8xjS3sgs1 3GPkjLXw== X-Received: by 2002:a05:600c:4fcc:b0:408:fe93:a2f7 with SMTP id o12-20020a05600c4fcc00b00408fe93a2f7mr6009715wmq.37.1701107767751; Mon, 27 Nov 2023 09:56:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IGE/eMnJ17NyUQlB1WxvhkMcLt5bgLIl4gyoGiZHQS1+elW6VVm/vfJ0j4ZM8AAAhfz/JDklw== X-Received: by 2002:a05:600c:4fcc:b0:408:fe93:a2f7 with SMTP id o12-20020a05600c4fcc00b00408fe93a2f7mr6009692wmq.37.1701107767244; Mon, 27 Nov 2023 09:56:07 -0800 (PST) Received: from localhost (105.226.159.143.dyn.plus.net. [143.159.226.105]) by smtp.gmail.com with ESMTPSA id r4-20020a05600c458400b0040648217f4fsm15258312wmo.39.2023.11.27.09.56.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 09:56:06 -0800 (PST) From: Andrew Burgess To: gdb-patches@sourceware.org Cc: Andrew Burgess Subject: [PATCH 3/7] gdb/testsuite: small refactor in selftest-support.exp Date: Mon, 27 Nov 2023 17:55:57 +0000 Message-Id: <01785d65d4a04b1b05030ef7569103c4c5afd9de.1701107594.git.aburgess@redhat.com> X-Mailer: git-send-email 2.25.4 In-Reply-To: References: MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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 Split out the code that makes a copy of the GDB executable ready for self testing into a new proc. A later commit in this series wants to load the GDB executable into GDB (for creating an on-disk debug index), but doesn't need to make use of the full do_self_tests proc. There should be no changes in what is tested after this commit. --- gdb/testsuite/lib/selftest-support.exp | 32 ++++++++++++++++++-------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/gdb/testsuite/lib/selftest-support.exp b/gdb/testsuite/lib/selftest-support.exp index 1e7a2cea8b7..abb1f43f1b0 100644 --- a/gdb/testsuite/lib/selftest-support.exp +++ b/gdb/testsuite/lib/selftest-support.exp @@ -92,11 +92,13 @@ proc selftest_setup { executable function } { return 0 } -# A simple way to run some self-tests. - -proc do_self_tests {function body} { - global GDB tool - +# Prepare for running a self-test by moving the GDB executable to a +# location where we can use it as the inferior. Return the filename +# of the new location. +# +# If the current testing setup is not suitable for running a +# self-test, then return an empty string. +proc selftest_prepare {} { # Are we testing with a remote board? In that case, the target # won't have access to the GDB's auxilliary data files # (data-directory, etc.). It's simpler to just skip. @@ -120,19 +122,31 @@ proc do_self_tests {function body} { # Run the test with self. Copy the file executable file in case # this OS doesn't like to edit its own text space. - set GDB_FULLPATH [find_gdb $GDB] + set gdb_fullpath [find_gdb $::GDB] if {[is_remote host]} { - set xgdb x$tool + set xgdb x$::tool } else { - set xgdb [standard_output_file x$tool] + set xgdb [standard_output_file x$::tool] } # Remove any old copy lying around. remote_file host delete $xgdb + set filename [remote_download host $gdb_fullpath $xgdb] + + return $filename +} + +# A simple way to run some self-tests. + +proc do_self_tests {function body} { + set file [selftest_prepare] + if { $file eq "" } { + return + } + gdb_start - set file [remote_download host $GDB_FULLPATH $xgdb] # When debugging GDB with GDB, some operations can take a relatively long # time, especially if the build is non-optimized. Bump the timeout for the