]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.base/info-os.exp
Fix more cases of improper test names
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.base / info-os.exp
CommitLineData
618f726f 1# Copyright 2011-2016 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.
42set inferior_pid -1
43set test "get inferior process ID"
44gdb_test_multiple "call getpid()" $test {
45 -re ".* = ($decimal).*$gdb_prompt $" {
46 set inferior_pid $expect_out(1,string)
47 pass $test
48 }
49}
50
51gdb_breakpoint ${srcfile}:[gdb_get_line_number "Set breakpoint here"]
52gdb_continue_to_breakpoint "Set breakpoint here"
53
855ba978
SS
54# Get keys and IDs of the IPC object instances.
55set shmkey -1
56set test "get shared memory key"
57gdb_test_multiple "print shmkey" $test {
58 -re ".* = ($decimal).*$gdb_prompt $" {
59 set shmkey $expect_out(1,string)
60 pass $test
61 }
62}
85d4a676
SS
63set shmid -1
64set test "get shared memory ID"
65gdb_test_multiple "print shmid" $test {
66 -re ".* = ($decimal).*$gdb_prompt $" {
67 set shmid $expect_out(1,string)
68 pass $test
69 }
70}
71
855ba978
SS
72set semkey -1
73set test "get semaphore key"
74gdb_test_multiple "print semkey" $test {
75 -re ".* = ($decimal).*$gdb_prompt $" {
76 set semkey $expect_out(1,string)
77 pass $test
78 }
79}
80
85d4a676
SS
81set semid -1
82set test "get semaphore ID"
83gdb_test_multiple "print semid" $test {
84 -re ".* = ($decimal).*$gdb_prompt $" {
85 set semid $expect_out(1,string)
86 pass $test
87 }
88}
89
855ba978
SS
90set msgkey -1
91set test "get message queue key"
92gdb_test_multiple "print msgkey" $test {
93 -re ".* = ($decimal).*$gdb_prompt $" {
94 set msgkey $expect_out(1,string)
95 pass $test
96 }
97}
98
85d4a676
SS
99set msqid -1
100set test "get message queue ID"
101gdb_test_multiple "print msqid" $test {
102 -re ".* = ($decimal).*$gdb_prompt $" {
103 set msqid $expect_out(1,string)
104 pass $test
105 }
106}
107
108# Get port number of test socket.
109set port -1
110set test "get socket port number"
111gdb_test_multiple "print port" $test {
112 -re ".* = ($decimal).*$gdb_prompt $" {
113 set port $expect_out(1,string)
114 pass $test
115 }
116}
117
e77afa2e
JK
118# Act like gdb_test but prevent: +ERROR: internal buffer is full.
119
120proc expect_multiline { command expect test } {
121 global gdb_prompt
122
123 # Do not duplicate FAILs from gdb_test_multiple.
124 set pass 0
125 set fail 0
126 gdb_test_multiple $command $test {
127 -re "^$expect *\r\n" {
128 pass $test
129 set pass 1
130 exp_continue
131 }
132 -re "^$gdb_prompt $" {
133 if !$pass {
134 set fail 1
135 }
136 # Exit the loop.
137 }
138 -re "\r\n" {
139 # Drop the buffer.
140 exp_continue
141 }
142 }
143 if $fail {
144 fail $test
145 }
146}
147
85d4a676 148# Test output of the 'info os' commands against the expected results.
e77afa2e
JK
149
150# pid user command cores
151expect_multiline "info os processes" "$inferior_pid +\\S+ +\\S*info-os +\[0-9,\]+" "get process list"
152
153# pgid leader pid command line
154expect_multiline "info os procgroups" "$inferior_pid +info-os +$inferior_pid +\\S*info-os" "get process groups"
155
156# pid command tid core
157expect_multiline "info os threads" "$inferior_pid +info-os +\\d+ +\\d+" "get threads"
158
159# pid command fd name
160expect_multiline "info os files" "$inferior_pid +info-os +\\d+ +/dev/null" "get file descriptors"
161
162# local address l-port remote addr r-port state user family protocol
163expect_multiline "info os sockets" "0\\.0\\.0\\.0 +$port +0\\.0\\.0\\.0 +0 +LISTEN +\\S+ +INET +STREAM" "get internet-domain sockets"
164
165# 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 166expect_multiline "info os shm" "$shmkey +$shmid +666 +4096 +info-os .*" "get shared-memory regions"
e77afa2e
JK
167
168# key semid perm num semaphores user group creator user creator group last semop() time last semctl() time
855ba978 169expect_multiline "info os semaphores" "$semkey +$semid +666 +1 .*" "get semaphores"
e77afa2e
JK
170
171# 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 172expect_multiline "info os msg" "$msgkey +$msqid +666 .*" "get message queues"
e77afa2e 173
85d4a676
SS
174
175# The SysV IPC primitives linger on after the creating process is killed
176# unless they are destroyed explicitly, so allow the test program to tidy
855ba978 177# up after itself.
545f743d 178gdb_test "continue" "exited.*"