Avoid "text file busy" in dw2-using-debug-str.exp
[binutils-gdb.git] / gdb / testsuite / gdb.guile / scm-gsmob.exp
blobc0b3eb5e8d0c3c1d8d6ad7507f20dcb38b787b37
1 # Copyright (C) 2014-2024 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 # This file is part of the GDB testsuite.
17 # It tests basic gsmob features.
19 load_lib gdb-guile.exp
21 require allow_guile_tests
23 clean_restart
25 gdb_install_guile_utils
26 gdb_install_guile_module
28 # Test the transition from alist to htab in the property list.
29 # N.B. This has the same value as gdb/guile/scm-gsmob.c.
30 set SMOB_PROP_HTAB_THRESHOLD 7
32 gdb_test_no_output "gu (define arch (current-arch))"
34 # Return a property name for integer I suitable for sorting.
36 proc prop_name { i } {
37     return [format "prop%02d" $i]
40 # Set and ref the properties in separate loops to verify previously set
41 # properties are not lost when we set a new property or switch to htabs.
42 for {set i 0} {$i <= $SMOB_PROP_HTAB_THRESHOLD} {incr i} {
43     gdb_test "gu (print (object-property arch '[prop_name $i]))" \
44         "= #f" "property prop$i not present before set"
45     gdb_test "gu (print (set-object-property! arch '[prop_name $i] $i))" \
46         "= $i" "set prop $i"
47     gdb_test "gu (print (object-property arch '[prop_name $i]))" \
48         "= $i" "property prop$i present after set"
50 for {set i 0} {$i <= $SMOB_PROP_HTAB_THRESHOLD} {incr i} {
51     gdb_test "gu (print (object-property arch '[prop_name $i]))" \
52         "= $i" "ref prop $i"
55 # Verify properties.
56 set prop_list ""
57 for {set i 0} {$i <= $SMOB_PROP_HTAB_THRESHOLD} {incr i} {
58     set prop_list "$prop_list [prop_name $i]"
60 set prop_list [lsort $prop_list]
61 verbose -log "prop_list: $prop_list"
62 gdb_test "gu (print (sort (map car (object-properties arch)) (lambda (a b) (string<? (symbol->string a) (symbol->string b)))))" \
63     "= \\($prop_list\\)" "object-properties"
65 # Check that smob classes are exported properly
66 with_test_prefix "test exports" {
67     # Import (oop goops) for is-a? and <class>
68     gdb_scm_test_silent_cmd "gu (use-modules (oop goops))" "import goops"
69     gdb_test_no_output "gu (define-syntax-rule (gdb-exports-class? x) (is-a? (@ (gdb) x) <class>))"
71     gdb_test "gu (print (gdb-exports-class? <gdb:arch>))" "= #t"
72     gdb_test "gu (print (gdb-exports-class? <gdb:block>))" "= #t"
73     gdb_test "gu (print (gdb-exports-class? <gdb:block-symbols-iterator>))" "= #t"
74     gdb_test "gu (print (gdb-exports-class? <gdb:breakpoint>))" "= #t"
75     gdb_test "gu (print (gdb-exports-class? <gdb:command>))" "= #t"
76     gdb_test "gu (print (gdb-exports-class? <gdb:exception>))" "= #t"
77     gdb_test "gu (print (gdb-exports-class? <gdb:frame>))" "= #t"
78     gdb_test "gu (print (gdb-exports-class? <gdb:iterator>))" "= #t"
79     gdb_test "gu (print (gdb-exports-class? <gdb:lazy-string>))" "= #t"
80     gdb_test "gu (print (gdb-exports-class? <gdb:objfile>))" "= #t"
81     gdb_test "gu (print (gdb-exports-class? <gdb:parameter>))" "= #t"
82     gdb_test "gu (print (gdb-exports-class? <gdb:pretty-printer>))" "= #t"
83     gdb_test "gu (print (gdb-exports-class? <gdb:pretty-printer-worker>))" "= #t"
84     gdb_test "gu (print (gdb-exports-class? <gdb:progspace>))" "= #t"
85     gdb_test "gu (print (gdb-exports-class? <gdb:symbol>))" "= #t"
86     gdb_test "gu (print (gdb-exports-class? <gdb:symtab>))" "= #t"
87     gdb_test "gu (print (gdb-exports-class? <gdb:sal>))" "= #t"
88     gdb_test "gu (print (gdb-exports-class? <gdb:type>))" "= #t"
89     gdb_test "gu (print (gdb-exports-class? <gdb:field>))" "= #t"
90     gdb_test "gu (print (gdb-exports-class? <gdb:value>))" "= #t"