diff options
author | Emil Velikov | 2016-11-30 12:23:51 -0600 |
---|---|---|
committer | Emil Velikov | 2016-12-05 11:23:45 -0600 |
commit | 0c80fddd1d01206756bf2a3227cdf1efbfb16aaf (patch) | |
tree | c854540ccd9dac23b9b6f246171a61e1633c2dfa /tests/dristat.c | |
parent | b305238ceb5092dd9d78c06e4dbe99a1e0287ba6 (diff) | |
download | external-libdrm-0c80fddd1d01206756bf2a3227cdf1efbfb16aaf.tar.gz external-libdrm-0c80fddd1d01206756bf2a3227cdf1efbfb16aaf.tar.xz external-libdrm-0c80fddd1d01206756bf2a3227cdf1efbfb16aaf.zip |
tests: remove useless legacy tests
All of these 'tests' cover UMS functionality which is neither being
worked on or actively maintained.
The only cases where developers touch UMS code is to unwrap it from the
KMS codepaths and ensure that those are secure.
Anyone who feels strong about having these around can revive them, but
in all honestly do consider _seriously_ what you're doing ;-)
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Diffstat (limited to 'tests/dristat.c')
-rw-r--r-- | tests/dristat.c | 285 |
1 files changed, 0 insertions, 285 deletions
diff --git a/tests/dristat.c b/tests/dristat.c deleted file mode 100644 index cca4b03a..00000000 --- a/tests/dristat.c +++ /dev/null | |||
@@ -1,285 +0,0 @@ | |||
1 | /* dristat.c -- | ||
2 | * Created: Mon Jan 15 05:05:07 2001 by faith@acm.org | ||
3 | * | ||
4 | * Copyright 2000 VA Linux Systems, Inc., Fremont, California. | ||
5 | * All Rights Reserved. | ||
6 | * | ||
7 | * Permission is hereby granted, free of charge, to any person obtaining a | ||
8 | * copy of this software and associated documentation files (the "Software"), | ||
9 | * to deal in the Software without restriction, including without limitation | ||
10 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
11 | * and/or sell copies of the Software, and to permit persons to whom the | ||
12 | * Software is furnished to do so, subject to the following conditions: | ||
13 | * | ||
14 | * The above copyright notice and this permission notice (including the next | ||
15 | * paragraph) shall be included in all copies or substantial portions of the | ||
16 | * Software. | ||
17 | * | ||
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
21 | * PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | ||
22 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | ||
23 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
24 | * DEALINGS IN THE SOFTWARE. | ||
25 | * | ||
26 | * Authors: Rickard E. (Rik) Faith <faith@valinux.com> | ||
27 | * | ||
28 | */ | ||
29 | |||
30 | #ifdef HAVE_CONFIG_H | ||
31 | # include <config.h> | ||
32 | #endif | ||
33 | |||
34 | #include <stdio.h> | ||
35 | #include <stdlib.h> | ||
36 | #include <unistd.h> | ||
37 | #include "xf86drm.h" | ||
38 | #include "xf86drmRandom.c" | ||
39 | #include "xf86drmHash.c" | ||
40 | #include "xf86drm.c" | ||
41 | |||
42 | #define DRM_VERSION 0x00000001 | ||
43 | #define DRM_MEMORY 0x00000002 | ||
44 | #define DRM_CLIENTS 0x00000004 | ||
45 | #define DRM_STATS 0x00000008 | ||
46 | #define DRM_BUSID 0x00000010 | ||
47 | |||
48 | static void getversion(int fd) | ||
49 | { | ||
50 | drmVersionPtr version; | ||
51 | |||
52 | version = drmGetVersion(fd); | ||
53 | if (version) { | ||
54 | printf(" Version information:\n"); | ||
55 | printf(" Name: %s\n", version->name ? version->name : "?"); | ||
56 | printf(" Version: %d.%d.%d\n", | ||
57 | version->version_major, | ||
58 | version->version_minor, | ||
59 | version->version_patchlevel); | ||
60 | printf(" Date: %s\n", version->date ? version->date : "?"); | ||
61 | printf(" Desc: %s\n", version->desc ? version->desc : "?"); | ||
62 | drmFreeVersion(version); | ||
63 | } else { | ||
64 | printf(" No version information available\n"); | ||
65 | } | ||
66 | } | ||
67 | |||
68 | static void getbusid(int fd) | ||
69 | { | ||
70 | const char *busid = drmGetBusid(fd); | ||
71 | |||
72 | printf(" Busid: %s\n", *busid ? busid : "(not set)"); | ||
73 | drmFreeBusid(busid); | ||
74 | } | ||
75 | |||
76 | |||
77 | static void getvm(int fd) | ||
78 | { | ||
79 | int i; | ||
80 | const char *typename; | ||
81 | char flagname[33]; | ||
82 | drm_handle_t offset; | ||
83 | drmSize size; | ||
84 | drmMapType type; | ||
85 | drmMapFlags flags; | ||
86 | drm_handle_t handle; | ||
87 | int mtrr; | ||
88 | |||
89 | printf(" VM map information:\n"); | ||
90 | printf(" flags: (R)estricted (r)ead/(w)rite (l)ocked (k)ernel (W)rite-combine (L)ock:\n"); | ||
91 | printf(" slot offset size type flags address mtrr\n"); | ||
92 | |||
93 | for (i = 0; | ||
94 | !drmGetMap(fd, i, &offset, &size, &type, &flags, &handle, &mtrr); | ||
95 | i++) { | ||
96 | |||
97 | switch (type) { | ||
98 | case DRM_FRAME_BUFFER: typename = "FB"; break; | ||
99 | case DRM_REGISTERS: typename = "REG"; break; | ||
100 | case DRM_SHM: typename = "SHM"; break; | ||
101 | case DRM_AGP: typename = "AGP"; break; | ||
102 | case DRM_SCATTER_GATHER: typename = "SG"; break; | ||
103 | case DRM_CONSISTENT: typename = "CON"; break; | ||
104 | default: typename = "???"; break; | ||
105 | } | ||
106 | |||
107 | flagname[0] = (flags & DRM_RESTRICTED) ? 'R' : ' '; | ||
108 | flagname[1] = (flags & DRM_READ_ONLY) ? 'r' : 'w'; | ||
109 | flagname[2] = (flags & DRM_LOCKED) ? 'l' : ' '; | ||
110 | flagname[3] = (flags & DRM_KERNEL) ? 'k' : ' '; | ||
111 | flagname[4] = (flags & DRM_WRITE_COMBINING) ? 'W' : ' '; | ||
112 | flagname[5] = (flags & DRM_CONTAINS_LOCK) ? 'L' : ' '; | ||
113 | flagname[6] = '\0'; | ||
114 | |||
115 | printf(" %4d 0x%08lx 0x%08lx %3.3s %6.6s 0x%08lx ", | ||
116 | i, (unsigned long)offset, (unsigned long)size, | ||
117 | typename, flagname, (unsigned long)handle); | ||
118 | if (mtrr < 0) printf("none\n"); | ||
119 | else printf("%4d\n", mtrr); | ||
120 | } | ||
121 | } | ||
122 | |||
123 | static void getclients(int fd) | ||
124 | { | ||
125 | int i; | ||
126 | int auth; | ||
127 | int pid; | ||
128 | int uid; | ||
129 | unsigned long magic; | ||
130 | unsigned long iocs; | ||
131 | char buf[64]; | ||
132 | char cmd[40]; | ||
133 | int procfd; | ||
134 | |||
135 | printf(" DRI client information:\n"); | ||
136 | printf(" a pid uid magic ioctls prog\n"); | ||
137 | |||
138 | for (i = 0; !drmGetClient(fd, i, &auth, &pid, &uid, &magic, &iocs); i++) { | ||
139 | sprintf(buf, "/proc/%d/cmdline", pid); | ||
140 | memset(cmd, 0, sizeof(cmd)); | ||
141 | if ((procfd = open(buf, O_RDONLY, 0)) >= 0) { | ||
142 | read(procfd, cmd, sizeof(cmd)-1); | ||
143 | close(procfd); | ||
144 | } | ||
145 | if (*cmd) { | ||
146 | char *pt; | ||
147 | |||
148 | for (pt = cmd; *pt; pt++) if (!isprint(*pt)) *pt = ' '; | ||
149 | printf(" %c %5d %5d %10lu %10lu %s\n", | ||
150 | auth ? 'y' : 'n', pid, uid, magic, iocs, cmd); | ||
151 | } else { | ||
152 | printf(" %c %5d %5d %10lu %10lu\n", | ||
153 | auth ? 'y' : 'n', pid, uid, magic, iocs); | ||
154 | } | ||
155 | } | ||
156 | } | ||
157 | |||
158 | static void printhuman(unsigned long value, const char *name, int mult) | ||
159 | { | ||
160 | const char *p; | ||
161 | double f; | ||
162 | /* Print width 5 number in width 6 space */ | ||
163 | if (value < 100000) { | ||
164 | printf(" %5lu", value); | ||
165 | return; | ||
166 | } | ||
167 | |||
168 | p = name; | ||
169 | f = (double)value / (double)mult; | ||
170 | if (f < 10.0) { | ||
171 | printf(" %4.2f%c", f, *p); | ||
172 | return; | ||
173 | } | ||
174 | |||
175 | p++; | ||
176 | f = (double)value / (double)mult; | ||
177 | if (f < 10.0) { | ||
178 | printf(" %4.2f%c", f, *p); | ||
179 | return; | ||
180 | } | ||
181 | |||
182 | p++; | ||
183 | f = (double)value / (double)mult; | ||
184 | if (f < 10.0) { | ||
185 | printf(" %4.2f%c", f, *p); | ||
186 | return; | ||
187 | } | ||
188 | } | ||
189 | |||
190 | static void getstats(int fd, int i) | ||
191 | { | ||
192 | drmStatsT prev, curr; | ||
193 | unsigned j; | ||
194 | double rate; | ||
195 | |||
196 | printf(" System statistics:\n"); | ||
197 | |||
198 | if (drmGetStats(fd, &prev)) return; | ||
199 | if (!i) { | ||
200 | for (j = 0; j < prev.count; j++) { | ||
201 | printf(" "); | ||
202 | printf(prev.data[j].long_format, prev.data[j].long_name); | ||
203 | if (prev.data[j].isvalue) printf(" 0x%08lx\n", prev.data[j].value); | ||
204 | else printf(" %10lu\n", prev.data[j].value); | ||
205 | } | ||
206 | return; | ||
207 | } | ||
208 | |||
209 | printf(" "); | ||
210 | for (j = 0; j < prev.count; j++) | ||
211 | if (!prev.data[j].verbose) { | ||
212 | printf(" "); | ||
213 | printf(prev.data[j].rate_format, prev.data[j].rate_name); | ||
214 | } | ||
215 | printf("\n"); | ||
216 | |||
217 | for (;;) { | ||
218 | sleep(i); | ||
219 | if (drmGetStats(fd, &curr)) return; | ||
220 | printf(" "); | ||
221 | for (j = 0; j < curr.count; j++) { | ||
222 | if (curr.data[j].verbose) continue; | ||
223 | if (curr.data[j].isvalue) { | ||
224 | printf(" %08lx", curr.data[j].value); | ||
225 | } else { | ||
226 | rate = (curr.data[j].value - prev.data[j].value) / (double)i; | ||
227 | printhuman(rate, curr.data[j].mult_names, curr.data[j].mult); | ||
228 | } | ||
229 | } | ||
230 | printf("\n"); | ||
231 | memcpy(&prev, &curr, sizeof(prev)); | ||
232 | } | ||
233 | |||
234 | } | ||
235 | |||
236 | int main(int argc, char **argv) | ||
237 | { | ||
238 | int c; | ||
239 | int mask = 0; | ||
240 | int minor = 0; | ||
241 | int interval = 0; | ||
242 | int fd; | ||
243 | char buf[64]; | ||
244 | int i; | ||
245 | |||
246 | while ((c = getopt(argc, argv, "avmcsbM:i:")) != EOF) | ||
247 | switch (c) { | ||
248 | case 'a': mask = ~0; break; | ||
249 | case 'v': mask |= DRM_VERSION; break; | ||
250 | case 'm': mask |= DRM_MEMORY; break; | ||
251 | case 'c': mask |= DRM_CLIENTS; break; | ||
252 | case 's': mask |= DRM_STATS; break; | ||
253 | case 'b': mask |= DRM_BUSID; break; | ||
254 | case 'i': interval = strtol(optarg, NULL, 0); break; | ||
255 | case 'M': minor = strtol(optarg, NULL, 0); break; | ||
256 | default: | ||
257 | fprintf( stderr, "Usage: dristat [options]\n\n" ); | ||
258 | fprintf( stderr, "Displays DRM information. Use with no arguments to display available cards.\n\n" ); | ||
259 | fprintf( stderr, " -a Show all available information\n" ); | ||
260 | fprintf( stderr, " -b Show DRM bus ID's\n" ); | ||
261 | fprintf( stderr, " -c Display information about DRM clients\n" ); | ||
262 | fprintf( stderr, " -i [interval] Continuously display statistics every [interval] seconds\n" ); | ||
263 | fprintf( stderr, " -v Display DRM module and card version information\n" ); | ||
264 | fprintf( stderr, " -m Display memory use information\n" ); | ||
265 | fprintf( stderr, " -s Display DRM statistics\n" ); | ||
266 | fprintf( stderr, " -M [minor] Select card by minor number\n" ); | ||
267 | return 1; | ||
268 | } | ||
269 | |||
270 | for (i = 0; i < 16; i++) if (!minor || i == minor) { | ||
271 | sprintf(buf, DRM_DEV_NAME, DRM_DIR_NAME, i); | ||
272 | fd = drmOpenMinor(i, 1, DRM_NODE_PRIMARY); | ||
273 | if (fd >= 0) { | ||
274 | printf("%s\n", buf); | ||
275 | if (mask & DRM_BUSID) getbusid(fd); | ||
276 | if (mask & DRM_VERSION) getversion(fd); | ||
277 | if (mask & DRM_MEMORY) getvm(fd); | ||
278 | if (mask & DRM_CLIENTS) getclients(fd); | ||
279 | if (mask & DRM_STATS) getstats(fd, interval); | ||
280 | close(fd); | ||
281 | } | ||
282 | } | ||
283 | |||
284 | return 0; | ||
285 | } | ||