Stop assuming no-debug-info functions return int
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.base / info-os.exp
CommitLineData
61baf725 1# Copyright 2011-2017 Free Software Foundation, Inc.
85d4a676
SS
2
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.
7#
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.
12#
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/>.
15
f8b41b00 16standard_testfile .c
85d4a676
SS
17
18# This test is Linux-only.
19if ![istarget *-*-linux*] then {
20 unsupported "info-os.exp"
21 return -1
22}
23
24# Support for XML-output is needed to run this test.
25if [gdb_skip_xml_test] then {
26 unsupported "info-os.exp"
27 return -1
28}
29
30# Compile test program.
5b362f04 31if { [prepare_for_testing "failed to prepare" $testfile $srcfile {debug additional_flags=-lpthread}] } {
85d4a676
SS
32 fail "cannot compile test program"
33 return -1
34}
35
36if ![runto_main] then {
37 fail "cannot run to main"
ae59b1da 38 return -1
85d4a676
SS
39}
40
41# Get PID of test program.
7022349d 42set inferior_pid ""
85d4a676 43set test "get inferior process ID"
7022349d 44gdb_test_multiple "call (int) getpid()" $test {
85d4a676
SS
45 -re ".* = ($decimal).*$gdb_prompt $" {
46 set inferior_pid $expect_out(1,string)
47 pass $test
48 }
49}
7022349d
PA
50if {$inferior_pid == ""} {
51 untested "failed to get pid"
52 return
53}
85d4a676
SS
54
55gdb_breakpoint ${srcfile}:[gdb_get_line_number "Set breakpoint here"]
56gdb_continue_to_breakpoint "Set breakpoint here"
57
855ba978
SS
58# Get keys and IDs of the IPC object instances.
59set shmkey -1
60set test "get shared memory key"
61gdb_test_multiple "print shmkey" $test {
62 -re ".* = ($decimal).*$gdb_prompt $" {
63 set shmkey $expect_out(1,string)
64 pass $test
65 }
66}
85d4a676
SS
67set shmid -1
68set test "get shared memory ID"
69gdb_test_multiple "print shmid" $test {
70 -re ".* = ($decimal).*$gdb_prompt $" {
71 set shmid $expect_out(1,string)
72 pass $test
73 }
74}
75
855ba978
SS
76set semkey -1
77set test "get semaphore key"
78gdb_test_multiple "print semkey" $test {
79 -re ".* = ($decimal).*$gdb_prompt $" {
80 set semkey $expect_out(1,string)
81 pass $test
82 }
83}
84
85d4a676
SS
85set semid -1
86set test "get semaphore ID"
87gdb_test_multiple "print semid" $test {
88 -re ".* = ($decimal).*$gdb_prompt $" {
89 set semid $expect_out(1,string)
90 pass $test
91 }
92}
93
855ba978
SS
94set msgkey -1
95set test "get message queue key"
96gdb_test_multiple "print msgkey" $test {
97 -re ".* = ($decimal).*$gdb_prompt $" {
98 set msgkey $expect_out(1,string)
99 pass $test
100 }
101}
102
85d4a676
SS
103set msqid -1
104set test "get message queue ID"
105gdb_test_multiple "print msqid" $test {
106 -re ".* = ($decimal).*$gdb_prompt $" {
107 set msqid $expect_out(1,string)
108 pass $test
109 }
110}
111
112# Get port number of test socket.
113set port -1
114set test "get socket port number"
115gdb_test_multiple "print port" $test {
116 -re ".* = ($decimal).*$gdb_prompt $" {
117 set port $expect_out(1,string)
118 pass $test
119 }
120}
121
e77afa2e
JK
122# Act like gdb_test but prevent: +ERROR: internal buffer is full.
123
124proc expect_multiline { command expect test } {
125 global gdb_prompt
126
127 # Do not duplicate FAILs from gdb_test_multiple.
128 set pass 0
129 set fail 0
130 gdb_test_multiple $command $test {
131 -re "^$expect *\r\n" {
132 pass $test
133 set pass 1
134 exp_continue
135 }
136 -re "^$gdb_prompt $" {
137 if !$pass {
138 set fail 1
139 }
140 # Exit the loop.
141 }
142 -re "\r\n" {
143 # Drop the buffer.
144 exp_continue
145 }
146 }
147 if $fail {
148 fail $test
149 }
150}
151
85d4a676 152# Test output of the 'info os' commands against the expected results.
e77afa2e
JK
153
154# pid user command cores
155expect_multiline "info os processes" "$inferior_pid +\\S+ +\\S*info-os +\[0-9,\]+" "get process list"
156
157# pgid leader pid command line
158expect_multiline "info os procgroups" "$inferior_pid +info-os +$inferior_pid +\\S*info-os" "get process groups"
159
160# pid command tid core
161expect_multiline "info os threads" "$inferior_pid +info-os +\\d+ +\\d+" "get threads"
162
163# pid command fd name
164expect_multiline "info os files" "$inferior_pid +info-os +\\d+ +/dev/null" "get file descriptors"
165
166# local address l-port remote addr r-port state user family protocol
167expect_multiline "info os sockets" "0\\.0\\.0\\.0 +$port +0\\.0\\.0\\.0 +0 +LISTEN +\\S+ +INET +STREAM" "get internet-domain sockets"
168
169# key shmid perm size creator command last op command num attached user group creator user creator group last shmat() time last shmdt() time last shmctl() time
855ba978 170expect_multiline "info os shm" "$shmkey +$shmid +666 +4096 +info-os .*" "get shared-memory regions"
e77afa2e
JK
171
172# key semid perm num semaphores user group creator user creator group last semop() time last semctl() time
855ba978 173expect_multiline "info os semaphores" "$semkey +$semid +666 +1 .*" "get semaphores"
e77afa2e
JK
174
175# key msqid perm num used bytes num messages last msgsnd() command last msgrcv() command user group creator user creator group last msgsnd() time last msgrcv() time last msgctl() time
855ba978 176expect_multiline "info os msg" "$msgkey +$msqid +666 .*" "get message queues"
e77afa2e 177
85d4a676
SS
178
179# The SysV IPC primitives linger on after the creating process is killed
180# unless they are destroyed explicitly, so allow the test program to tidy
855ba978 181# up after itself.
545f743d 182gdb_test "continue" "exited.*"
This page took 0.677506 seconds and 4 git commands to generate.