From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3314 invoked by alias); 24 Dec 2013 19:05:02 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 3235 invoked by uid 89); 24 Dec 2013 19:05:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.4 required=5.0 tests=AWL,BAYES_00,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,MSGID_FROM_MTA_HEADER,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=no version=3.3.2 X-HELO: mail-pd0-f178.google.com Received: from mail-pd0-f178.google.com (HELO mail-pd0-f178.google.com) (209.85.192.178) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Tue, 24 Dec 2013 19:04:59 +0000 Received: by mail-pd0-f178.google.com with SMTP id y10so6574859pdj.37 for ; Tue, 24 Dec 2013 11:04:58 -0800 (PST) X-Received: by 10.68.130.130 with SMTP id oe2mr34120279pbb.135.1387911897992; Tue, 24 Dec 2013 11:04:57 -0800 (PST) Received: from sspiff.org (173-13-178-53-sfba.hfc.comcastbusiness.net. [173.13.178.53]) by mx.google.com with ESMTPSA id uf2sm43460754pbc.28.2013.12.24.11.04.55 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Dec 2013 11:04:57 -0800 (PST) Message-ID: <52b9dad9.a2ea440a.5b23.ffff940a@mx.google.com> Received: by sspiff.org (sSMTP sendmail emulation); Tue, 24 Dec 2013 11:04:31 -0800 Date: Tue, 24 Dec 2013 19:05:00 -0000 From: Doug Evans To: gdb-patches@sourceware.org Subject: [PATCH v1 35/36] Guile extension language: error tests X-IsSubscribed: yes X-SW-Source: 2013-12/txt/msg00950.txt.bz2 This patch adds some tests for error conditions. 2013-12-24 Doug Evans testsuite/ * gdb.guile/scm-error.exp: New file. * gdb.guile/scm-error.scm: New file. diff --git a/gdb/testsuite/gdb.guile/scm-error.exp b/gdb/testsuite/gdb.guile/scm-error.exp new file mode 100644 index 0000000..b2d1bee --- /dev/null +++ b/gdb/testsuite/gdb.guile/scm-error.exp @@ -0,0 +1,112 @@ +# Copyright (C) 2010-2013 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 various error conditions. + +set testfile "scm-error" + +load_lib gdb-guile.exp + +# Start with a fresh gdb. +gdb_exit +gdb_start + +# Skip all tests if Guile scripting is not enabled. +if { [skip_guile_tests] } { continue } + +# Test error while loading .scm. + +# Give the file a new name so we don't clobber the real one if +# objfile == srcdir. +set remote_guile_file [gdb_remote_download host \ + ${srcdir}/${subdir}/${testfile}.scm \ + ${subdir}/t-${testfile}.scm] + +gdb_test "source $remote_guile_file" \ + "ERROR: In procedure \[+\]:.*" \ + "error loading scm file caught" + +gdb_test "p 1" " = 1" "no delayed error" + +# Test setting/showing the various states for "guile print-stack". + +gdb_test "show guile print-stack" \ + "The mode of Guile exception printing on error is \"message\".*" \ + "test print-stack show setting of default" +gdb_test_no_output "set guile print-stack full" \ + "test print-stack full setting" +gdb_test "show guile print-stack" \ + "The mode of Guile exception printing on error is \"full\".*" \ + "test print-stack show setting to full" +gdb_test_no_output "set guile print-stack none" \ + "test print-stack none setting" +gdb_test "show guile print-stack" \ + "The mode of Guile exception printing on error is \"none\".*" \ + "test print-stack show setting to none" +# Reset back to default, just in case. +gdb_test_no_output "set guile print-stack message" \ + "reset print-stack to default, post set/show tests" + +# Test "set guile print-stack none". + +gdb_test_no_output "set guile print-stack none" \ + "set print-stack to none, for error test" + +set test_name "no error printed" +set command "guile (define x doesnt-exist)" +gdb_test_multiple $command $test_name { + -re "Backtrace.*$gdb_prompt $" { fail $test_name } + -re "ERROR.*$gdb_prompt $" { fail $test_name } + -re "$gdb_prompt $" { pass $test_name } +} + +# Test "set guile print-stack message". + +gdb_test_no_output "set guile print-stack message" \ + "set print-stack to message, for error test" + +set test_name "error message printed" +set command "guile (define x doesnt-exist)" +gdb_test_multiple $command $test_name { + -re "Backtrace.*$gdb_prompt $" { fail $test_name } + -re "ERROR.*$gdb_prompt $" { pass $test_name } +} + +# Test "set guile print-stack full". + +gdb_test_no_output "set guile print-stack full" \ + "set print-stack to full, for backtrace test" + +gdb_test "guile (define x doesnt-exist)" \ + "Backtrace:.* Unbound variable: doesnt-exist.*" \ + "backtrace printed" + +# Verify gdb-specific errors are printed properly. +# i.e., each gdb error is registered to use init.scm:%error-printer. + +gdb_test_no_output "set guile print-stack message" \ + "set print-stack to message, for error printing tests" + +gdb_test "guile (throw 'gdb:error \"subr\" \"misc error: ~a\" (list 42))" \ + "ERROR: In procedure subr: misc error: 42.*" + +gdb_test "guile (throw 'gdb:invalid-object-error \"subr\" \"invalid object error: ~a\" (list 42))" \ + "ERROR: In procedure subr: invalid object error: 42.*" + +gdb_test "guile (throw 'gdb:memory-error \"subr\" \"memory error: ~a\" (list 42))" \ + "ERROR: In procedure subr: memory error: 42.*" + +gdb_test "guile (throw 'gdb:pp-type-error \"subr\" \"pp-type error: ~a\" (list 42))" \ + "ERROR: In procedure subr: pp-type error: 42.*" diff --git a/gdb/testsuite/gdb.guile/scm-error.scm b/gdb/testsuite/gdb.guile/scm-error.scm new file mode 100644 index 0000000..082ef93 --- /dev/null +++ b/gdb/testsuite/gdb.guile/scm-error.scm @@ -0,0 +1,19 @@ +;; Copyright (C) 2010-2013 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 . + +(use-modules (gdb)) + +;; An intentional error to test error handling when loading a file. +(define foo (+ 42 #f))