Home | History | Annotate | Line # | Download | only in gdb.xml
tdesc-arch.exp revision 1.1.1.4
      1  1.1.1.4  christos # Copyright 2007-2017 Free Software Foundation, Inc.
      2      1.1  christos 
      3      1.1  christos # This program is free software; you can redistribute it and/or modify
      4      1.1  christos # it under the terms of the GNU General Public License as published by
      5      1.1  christos # the Free Software Foundation; either version 3 of the License, or
      6      1.1  christos # (at your option) any later version.
      7      1.1  christos #
      8      1.1  christos # This program is distributed in the hope that it will be useful,
      9      1.1  christos # but WITHOUT ANY WARRANTY; without even the implied warranty of
     10      1.1  christos # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11      1.1  christos # GNU General Public License for more details.
     12      1.1  christos #
     13      1.1  christos # You should have received a copy of the GNU General Public License
     14      1.1  christos # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15      1.1  christos 
     16      1.1  christos if {[gdb_skip_xml_test]} {
     17      1.1  christos     unsupported "tdesc-arch.exp"
     18      1.1  christos     return -1
     19      1.1  christos }
     20      1.1  christos 
     21      1.1  christos gdb_start
     22      1.1  christos 
     23      1.1  christos # Find some valid architectures - we just need legitimate values
     24      1.1  christos # to put in our <architecture> elements.
     25      1.1  christos set arch1 ""
     26      1.1  christos set arch2 ""
     27      1.1  christos set msg "read valid architectures"
     28      1.1  christos gdb_test_multiple "set architecture" $msg {
     29      1.1  christos     -re "Requires an argument. Valid arguments are (\[^ \]*), (\[^ \]*), .*auto\\.\r\n$gdb_prompt $" {
     30      1.1  christos 	set arch1 $expect_out(1,string)
     31      1.1  christos 	set arch2 $expect_out(2,string)
     32      1.1  christos 	pass $msg
     33      1.1  christos     }
     34      1.1  christos     -re "Requires an argument. Valid arguments are (\[^ \]*), auto\\.\r\n$gdb_prompt $" {
     35      1.1  christos 	# If there is just one supported architecture, we can't do this test.
     36      1.1  christos 	unsupported "tdesc-arch.exp"
     37      1.1  christos 	return -1
     38      1.1  christos     }
     39      1.1  christos }
     40      1.1  christos 
     41      1.1  christos set default_arch ""
     42      1.1  christos set msg "read default architecture"
     43      1.1  christos gdb_test_multiple "show architecture" $msg {
     44      1.1  christos     -re "The target architecture is set automatically \\(currently (\[^ \]*)\\)\r\n$gdb_prompt $" {
     45      1.1  christos 	set default_arch $expect_out(1,string)
     46      1.1  christos 	pass $msg
     47      1.1  christos     }
     48      1.1  christos }
     49      1.1  christos 
     50      1.1  christos # If that did not work, no point running further tests.
     51      1.1  christos if { "$arch1" == "" || "$arch2" == "" || "$default_arch" == "" } {
     52      1.1  christos     unresolved "architecture XML tests"
     53      1.1  christos     return -1
     54      1.1  christos }
     55      1.1  christos 
     56      1.1  christos # Run these tests twice, once for $arch1 and once for $arch2, to
     57      1.1  christos # make sure that the tdesc file overrides the global default.
     58      1.1  christos 
     59      1.1  christos proc set_arch { arch which } {
     60      1.1  christos     global gdb_prompt
     61      1.1  christos     global subdir
     62      1.1  christos 
     63      1.1  christos     set filename [standard_output_file tdesc-arch.xml]
     64      1.1  christos     set fd [open $filename w]
     65      1.1  christos     puts $fd \
     66      1.1  christos 	"<target>
     67      1.1  christos 	    <architecture>$arch</architecture>
     68      1.1  christos 	 </target>"
     69      1.1  christos     close $fd
     70      1.1  christos     if {[is_remote host]} {
     71      1.1  christos 	set filename [remote_download host $filename tdesc-arch.xml]
     72      1.1  christos     }
     73      1.1  christos 
     74      1.1  christos     # Anchor the test output, so that error messages are detected.
     75      1.1  christos     set cmd "set tdesc filename $filename"
     76      1.1  christos     set msg "set tdesc filename tdesc-arch.xml ($which architecture)"
     77      1.1  christos     set cmd_regex [string_to_regexp $cmd]
     78      1.1  christos     gdb_test_multiple $cmd $msg {
     79      1.1  christos 	-re "^$cmd_regex\r\n$gdb_prompt $" {
     80      1.1  christos 	    pass $msg
     81      1.1  christos 	}
     82      1.1  christos 	-re "^$cmd_regex\r\nwarning: A handler for the OS ABI.*\r\n$gdb_prompt $" {
     83      1.1  christos 	    kfail gdb/2225 $msg
     84      1.1  christos 	}
     85      1.1  christos     }
     86      1.1  christos 
     87      1.1  christos     set cmd "show architecture"
     88      1.1  christos     gdb_test $cmd \
     89      1.1  christos 	"The target architecture is set automatically \\(currently $arch\\)" \
     90      1.1  christos 	"$cmd ($which architecture)"
     91      1.1  christos 
     92      1.1  christos     remote_file host delete $filename
     93      1.1  christos }
     94      1.1  christos 
     95      1.1  christos set_arch $arch1 first
     96      1.1  christos set_arch $arch2 second
     97      1.1  christos 
     98      1.1  christos # Check an invalid architecture setting.
     99      1.1  christos set filename [standard_output_file tdesc-arch.xml]
    100      1.1  christos set fd [open $filename w]
    101      1.1  christos puts $fd \
    102      1.1  christos     "<target>
    103      1.1  christos        <architecture>invalid</architecture>
    104      1.1  christos      </target>"
    105      1.1  christos close $fd
    106      1.1  christos if {[is_remote host]} {
    107      1.1  christos     set filename [remote_download host $filename "tdesc-arch.xml"]
    108      1.1  christos }
    109      1.1  christos 
    110      1.1  christos set cmd "set tdesc filename $filename"
    111      1.1  christos gdb_test $cmd \
    112      1.1  christos     "warning:.*Target description specified unknown architecture.*" \
    113      1.1  christos     "set tdesc filename tdesc-arch.xml (invalid architecture)"
    114      1.1  christos 
    115      1.1  christos set cmd "show architecture"
    116      1.1  christos gdb_test $cmd \
    117      1.1  christos     "The target architecture is set automatically \\(currently $default_arch\\)" \
    118      1.1  christos     "$cmd (invalid architecture)"
    119      1.1  christos 
    120      1.1  christos remote_file host delete $filename
    121