| 1 |
|
| 2 |
The Lsof Test Suite |
| 3 |
|
| 4 |
Contents |
| 5 |
|
| 6 |
A. Introduction |
| 7 |
1. Test Suite Goals |
| 8 |
2. Not a FAQ |
| 9 |
3. Where have the tests been tested? |
| 10 |
B. Test Methodology |
| 11 |
1. Test Limitations |
| 12 |
2. Test Data Base and Scripts |
| 13 |
3. The Makefile |
| 14 |
3.1 The CkTestDB Script |
| 15 |
4. The Lsof Executable and LT_LSOF_PATH |
| 16 |
5. Automated Testing |
| 17 |
C. Configure Script Participation |
| 18 |
1. config.cc |
| 19 |
2. config.cflags |
| 20 |
2.1 config.cflags Contents |
| 21 |
3. config.ldflags |
| 22 |
4. config.xobj |
| 23 |
D. Cleaning -- Quick or Spotless |
| 24 |
E. Test Libraries |
| 25 |
1. LTlib.c |
| 26 |
F. The Individual Tests |
| 27 |
1. LTbasic, a Basic Lsof Test |
| 28 |
2. LTbigf, Test Sizes and Offsets for Large |
| 29 |
(> 32 bit) Files |
| 30 |
3. LTdnlc, Test the Kernel's Dynamic Name Lookup |
| 31 |
Cache |
| 32 |
4. LTlock, Lock Tests |
| 33 |
5. LTnfs, NFS Test |
| 34 |
6. LTnlink, Link Count Test |
| 35 |
7. LTsock, Test IPv4 Sockets |
| 36 |
8. LTszoff, Test Sizes and Offsets for Small |
| 37 |
(< 32 bit) Files |
| 38 |
9. LTunix, Test UNIX Domain Sockets |
| 39 |
Appendix A, Test Files |
| 40 |
Appendix B, Test Validations |
| 41 |
Appendix C, Test Failures |
| 42 |
|
| 43 |
|
| 44 |
A. Introduction |
| 45 |
=============== |
| 46 |
|
| 47 |
Lsof has an automated test suite whose components are located in |
| 48 |
the tests/ sub-directory of the lsof top-level directory. Configuring, |
| 49 |
building and testing lsof can be done with these shell commands: |
| 50 |
|
| 51 |
$ Configure -n <dialect-abbreviation> |
| 52 |
$ make |
| 53 |
$ cd tests |
| 54 |
$ make |
| 55 |
|
| 56 |
That's all there is to it! |
| 57 |
|
| 58 |
But read on for more dirty details. |
| 59 |
|
| 60 |
A.1. Test Suite Goals |
| 61 |
===================== |
| 62 |
|
| 63 |
The lsof test suite attempts to test basic lsof features. It does |
| 64 |
not promise to test every lsof feature for every supported dialect. |
| 65 |
(That's a nearly impossible goal.) |
| 66 |
|
| 67 |
As a result, the test suite cannot promise that every lsof feature |
| 68 |
works as documented. At best the test suite gives some assurance |
| 69 |
that basic, standard and some optional lsof features work. |
| 70 |
|
| 71 |
A.2. Not a FAQ |
| 72 |
============== |
| 73 |
|
| 74 |
One caution: this is not a frequently asked questions (FAQ) file |
| 75 |
for the lsof test suite. FAQs on the lsof test suite will be found |
| 76 |
in the one and only lsof FAQ in file 00FAQ of the lsof distribution, |
| 77 |
or on-line at: |
| 78 |
|
| 79 |
ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/FAQ |
| 80 |
|
| 81 |
A.3. Where have the tests been tested? |
| 82 |
====================================== |
| 83 |
|
| 84 |
OK, I just said this isn't an FAQ and here comes a question and |
| 85 |
answer that looks like an FAQ. Consider it a very frequently asked |
| 86 |
question and indulge me -- let me answer it here. |
| 87 |
|
| 88 |
The lsof test suite hasn't been tested everywhere it might be |
| 89 |
possible to build lsof successfully. That "everywhere" includes |
| 90 |
dialect versions -- e.g., Solaris < 2.6 -- to which I no longer |
| 91 |
have access. On some dialect versions to which I have access, some |
| 92 |
tests won't run because the test system lacks support. |
| 93 |
|
| 94 |
In "Appendix B, Test Validations" I've tried to list where I compiled |
| 95 |
and tested the test suite and information on any tests I was unable |
| 96 |
to run. In "Appendix C, Test Failures" I list where the test suite |
| 97 |
fails and why it failed. |
| 98 |
|
| 99 |
A.4 Where are the tests? |
| 100 |
======================== |
| 101 |
|
| 102 |
This is another FAQ whose answer is that the tests are in the tests/ |
| 103 |
sub-directory of the main lsof source directory. |
| 104 |
|
| 105 |
|
| 106 |
B. Test Methodology |
| 107 |
=================== |
| 108 |
|
| 109 |
The test suite is made up of individual C programs. Test setup is |
| 110 |
performed by the lsof Configure script itself, which writes a set |
| 111 |
of dialect configuration files in the tests/ subdirectory. (See |
| 112 |
"C. Configure Script Participation.") |
| 113 |
|
| 114 |
Each program or script performs a specialized tests. Those tests |
| 115 |
are described below in "F. The Individual Tests". |
| 116 |
|
| 117 |
Each test measures lsof functionality by putting a specific lsof |
| 118 |
command execution at the end of an in-bound (to the test) pipe. |
| 119 |
The caller asks lsof to write its results to the pipe in field |
| 120 |
output form. (See the -F option in the lsof man page.) |
| 121 |
|
| 122 |
Using an in-bound lsof pipe allows the tests to measure a great |
| 123 |
deal of lsof functionality, including as an interesting side effect, |
| 124 |
the performance of field output. Consequently, there's no special |
| 125 |
field output test. |
| 126 |
|
| 127 |
B.1. Test Limitations |
| 128 |
===================== |
| 129 |
|
| 130 |
One limitation of the tests is that they don't measure lsof formatted |
| 131 |
output -- i.e., the output normally see when lsof is run. There |
| 132 |
are just too many variants of lsof output produced across the range |
| 133 |
of dialects where lsof runs, so field output is a more consistent |
| 134 |
way to process lsof output. |
| 135 |
|
| 136 |
But using field output does mean that the test suite doesn't check |
| 137 |
for lsof formatting problems, except in the field output itself. |
| 138 |
|
| 139 |
B.2. Test Data Base and Scripts |
| 140 |
=============================== |
| 141 |
|
| 142 |
The TestDB file contains a simple data base that describes where |
| 143 |
the tests have been validated. Entries are formed from a combination |
| 144 |
of the lines in the config.cflags file produced by the lsof Configure |
| 145 |
script. The entries can be considered "lsof dialect footprints," |
| 146 |
hereafter simply called "dialect footprints" or just "footprints." |
| 147 |
|
| 148 |
Two shell scripts support TestDB. The first, Add2TestDB, will add |
| 149 |
a footprint to TestDB. I don't recommend you use this script. |
| 150 |
Mostly it's for my use when I find that the test suite has been |
| 151 |
validated on a new dialect. |
| 152 |
|
| 153 |
It's also possible to add a footprint to TestDB by simply editing |
| 154 |
TestDB and pasting into it a copy of the footprint reported by a |
| 155 |
failed Makefile rule. I don't generally recommend this be done, |
| 156 |
either. |
| 157 |
|
| 158 |
There are Makefile rules that use (and avoid) the CkTestDB script. |
| 159 |
(See "B.3 The Makefile".) |
| 160 |
|
| 161 |
The default (i.e., "all") Makefile rule uses the CkTestDB script |
| 162 |
to look for the footprint in TestDB. If no footprint is found, the |
| 163 |
script issues a warning, displays the unfound footprint, and asks |
| 164 |
if running the test suite should continue. |
| 165 |
|
| 166 |
The "auto" Makefile rule also uses CkTestDB, but with a special |
| 167 |
call that causes CkTestDB to look in TestDB for the footprint, |
| 168 |
report it when it can't be found, and then fail. That CkTestDB |
| 169 |
failure causes the "auto" rule to fail, too. |
| 170 |
|
| 171 |
The "silent" Makefile rule doesn't use CkTestDB to look in TestDB |
| 172 |
for the footprint. It runs the standard and basic tests as silently |
| 173 |
as possible, then returns a failure or success exit code that |
| 174 |
signals the result of the running of the tests. (Use the "silent" |
| 175 |
rule carefully, because it will skip proving the tests have previously |
| 176 |
run on the dialect.) |
| 177 |
|
| 178 |
B.3. The Makefile |
| 179 |
======================= |
| 180 |
|
| 181 |
The Makefile runs the tests in the test suite. It has these rules. |
| 182 |
|
| 183 |
all runs the basic test and the standard tests, |
| 184 |
interacting with the caller should the footprint |
| 185 |
not be found in TestDB. |
| 186 |
|
| 187 |
(This is the default rule.) |
| 188 |
|
| 189 |
auto runs the basic test and the standard tests on a |
| 190 |
previously validated system as silently as possible. |
| 191 |
|
| 192 |
The footprint must be found in TestDB for this rule |
| 193 |
to succeed. (See the "silent" rule for one that |
| 194 |
avoids checking TestDB.) |
| 195 |
|
| 196 |
This rule is designed for lsof build scripts that |
| 197 |
want a quick noiseless test to make sure what they |
| 198 |
built works as it previously did. |
| 199 |
|
| 200 |
This rule calls CkTestDB in a way that inhibits |
| 201 |
its normal go-ahead request. (See "B.2.1 The CkTestDB |
| 202 |
Script".) If CkTestDB finds the footprint and all |
| 203 |
tests succeed, this rule returns a zero exit code |
| 204 |
(success). If the footprint isn't found or if any |
| 205 |
test fails, a non-zero exit code (failure) is |
| 206 |
returned. |
| 207 |
|
| 208 |
ckDB calls the CkTestDB script to look for a footprint. |
| 209 |
If none is found, the way CkTestDB was called (See |
| 210 |
"B.3.1 The CkTestDB Script".) causes it to return |
| 211 |
a non-zero exit code (failure) to this rule, and |
| 212 |
the rule then returns a non-zero exit code (failure) |
| 213 |
itself. |
| 214 |
|
| 215 |
This rule is used by the "auto" rule. If this rule |
| 216 |
succeeds (zero exit code), the "auto" rule then |
| 217 |
uses the "silent" rule. |
| 218 |
|
| 219 |
clean removes test and compiler output. (See the "D. |
| 220 |
Cleaning -- Quick or Spotless" section.) |
| 221 |
|
| 222 |
opt runs the optional tests. |
| 223 |
optional |
| 224 |
|
| 225 |
silent runs the lsof basic and standard tests as silently |
| 226 |
as possible (as the "auto" rule does), but without |
| 227 |
using CkTestDB to look for a footprint. If all |
| 228 |
tests succeed, the rule returns a zero exit code |
| 229 |
(success). If any test fails, the rule returns a |
| 230 |
non-zero exit code (failure). |
| 231 |
|
| 232 |
Use the "silent" rule carefully, because it will |
| 233 |
skip proving the tests have previously run on the |
| 234 |
dialect. |
| 235 |
|
| 236 |
spotless does what the clean rule does and also removes the |
| 237 |
config.* files created by ../Configure. (See the |
| 238 |
"D. Cleaning -- Quick or Spotless" section.) |
| 239 |
|
| 240 |
std runs the basic test and the standard tests. |
| 241 |
standard |
| 242 |
|
| 243 |
The Makefile cleaning rules are further described in "D. Cleaning |
| 244 |
-- Quick or Spotless." |
| 245 |
|
| 246 |
B.3.1 The CkTestDB Script |
| 247 |
========================= |
| 248 |
|
| 249 |
Some Makefile rules (e.g., "all" and "auto") use the CkTestDB script |
| 250 |
to make sure the tests have been run previously on the dialect. |
| 251 |
CkTestDB does that by looking for the dialect's footprint in TestDB. |
| 252 |
|
| 253 |
If no footprint is found, and if standard input is a TTY, CkTestDB |
| 254 |
asks for a go-ahead signal. If standard input isn't a TTY, CkTestDB |
| 255 |
aborts the test run. (See "B.2. Test Data Base and Scripts".) |
| 256 |
|
| 257 |
The Makefile "silent" rule does not call CkTestDB. use the "silent" |
| 258 |
rule carefully, because it will skip proving the tests have previously |
| 259 |
run on the dialect. |
| 260 |
|
| 261 |
B.4. The Lsof Executable and LT_LSOF_PATH |
| 262 |
========================================= |
| 263 |
|
| 264 |
Normally the programs in the test suite use the lsof executable in |
| 265 |
their parent directory, ../lsof. Usually that lsof has just been |
| 266 |
built and testing it is the next logical step. |
| 267 |
|
| 268 |
Be careful that ../lsof has sufficient permission to access the |
| 269 |
necessary kernel resources -- e.g., /dev/kmem, /dev/mem, /proc, |
| 270 |
etc. If it doesn't the tests will fail. (The tests do check to |
| 271 |
see if they can open /dev/mem and /dev/kmem for read access if |
| 272 |
LT_KMEM is defined in config.cflags and if the path to the lsof |
| 273 |
executable is ../lsof.) |
| 274 |
|
| 275 |
Here are two possible ways you can make sure the lsof being tested |
| 276 |
has sufficient permission: 1) use chmod and chgrp to enable its |
| 277 |
running and put its path in LT_LSOF_PATH, thus disabling the check |
| 278 |
in the tests for kernel memory access; or 2) run the tests (and |
| 279 |
hence the lsof being tested) under a login that has sufficient |
| 280 |
permission -- e.g., is in a group that can read /dev/kmem. |
| 281 |
|
| 282 |
You can direct the tests to use a different lsof executable by |
| 283 |
specifying its path in the LT_LSOF_PATH environment variable. To |
| 284 |
test an lsof executable already installed in /usr/local/etc -- |
| 285 |
provided that lsof is at revision 4.63 or higher -- do this: |
| 286 |
|
| 287 |
$ LT_LSOF_PATH=/usr/local/etc/lsof |
| 288 |
$ export LT_LSOF_PATH |
| 289 |
$ cd .../lsof_<version>/tests |
| 290 |
$ make |
| 291 |
|
| 292 |
When you specify an alternate executable path via LT_LSOF_PATH, |
| 293 |
that also prevents the tests from checking to see if they have |
| 294 |
kernel memory access. |
| 295 |
|
| 296 |
B.5 Automated Testing |
| 297 |
===================== |
| 298 |
|
| 299 |
Normally the lsof test suite is wordy and may require interaction. |
| 300 |
When you want to avoid those interferences, use the Makefile "auto" |
| 301 |
or "silent" rules. (See the description of the "auto" and "silent" |
| 302 |
rules in "B.3 The Makefile".) |
| 303 |
|
| 304 |
The footprint must be present in TestDB in order to use the "auto" |
| 305 |
rule. If it is not, the "auto" rule will fail and report the |
| 306 |
missing footprint. Footprints in TestDB proclaim that the tests |
| 307 |
have previously succeeded on the dialect. |
| 308 |
|
| 309 |
The footprint need not be present in TestDB in order to use the |
| 310 |
"silent" rule. Use the "silent" rule carefully, because it will |
| 311 |
skip proving the tests have previously run on the dialect. |
| 312 |
|
| 313 |
|
| 314 |
C. Configure Script Participation |
| 315 |
================================= |
| 316 |
|
| 317 |
An important step in setting up the test suite is performed by the |
| 318 |
Configure script in the lsof home directory (the parent to tests/.) |
| 319 |
|
| 320 |
Configure writes four files in tests/ that describe how the tests |
| 321 |
are to be compiled, configured and loaded. The files also describe |
| 322 |
options that Configure selected that are important to the test |
| 323 |
suite. |
| 324 |
|
| 325 |
C.1. config.cc |
| 326 |
============== |
| 327 |
|
| 328 |
This file, config.cc, contains the name of or the path to the C |
| 329 |
compiler used to compile lsof. The Makefile uses this file in |
| 330 |
place of the standard make(1) CC string with a shell in-place |
| 331 |
execution statement -- i.e., `cat config.cc`. |
| 332 |
|
| 333 |
If the LSOF_CC environment variable is supplied to the lsof Configure |
| 334 |
script, its value will appear in the config.cc file. |
| 335 |
|
| 336 |
C.2. config.cflags |
| 337 |
================== |
| 338 |
|
| 339 |
This file, config.cflags, contains C compiler flags that Makefile |
| 340 |
uses to compile the C programs in the test suite. As with the |
| 341 |
compiler file, config.cc, the make rules incorporate the contents |
| 342 |
of this file into C compiler options with `cat config.cflags`. |
| 343 |
|
| 344 |
This file is also used by the Add2TestDB and CkTestDB shell scripts |
| 345 |
to build and match footprints. (See "B.2. Test Data Base and |
| 346 |
Scripts.") |
| 347 |
|
| 348 |
C.2.1 config.cflags Contents |
| 349 |
============================ |
| 350 |
|
| 351 |
The config.cflags file may contain the following C compiler flags. |
| 352 |
|
| 353 |
|
| 354 |
-DLT_AIXA is present if lsof was built for AIX. |
| 355 |
It contains the AIX architecture flag. |
| 356 |
(See the lsof Configure script or |
| 357 |
dialects/aix/dlsof.h for more information |
| 358 |
on the AIX architecture flag.) |
| 359 |
|
| 360 |
-DLT_BIGF is present if lsof was built for a dialect |
| 361 |
that has large file (sizes and offsets > |
| 362 |
32 bits). |
| 363 |
|
| 364 |
-DLT_CC is present if the lsof compiler is cc. |
| 365 |
|
| 366 |
-DLT_DEV64 is present if the FreeBSD dialect uses a 64 |
| 367 |
devite type. |
| 368 |
|
| 369 |
|
| 370 |
-DLT_DIAL_<abbr> always ends in (the <abbr> part) the |
| 371 |
"canonical" -- i.e., usually the most |
| 372 |
common abbreviation by which the dialect |
| 373 |
is known. |
| 374 |
|
| 375 |
Example: -DLT_DIAL_solaris |
| 376 |
|
| 377 |
-DLT_GCC is present if the lsof compiler is gcc. |
| 378 |
|
| 379 |
-DLT_K64 is present if lsof has been built for a |
| 380 |
64 bit kernel |
| 381 |
|
| 382 |
-DLT_KMEM is present if lsof has been built to |
| 383 |
use /dev/kmem to obtain kernel values. |
| 384 |
|
| 385 |
-DLT_VERS=<vn> contains the version number for the |
| 386 |
dialect, as used in lsof pre-processor |
| 387 |
tests. |
| 388 |
|
| 389 |
Example for Solaris 10: -DLT_VERS=100000 |
| 390 |
|
| 391 |
-DLT_VPATH is present if the dialect has the v_path |
| 392 |
member in the vnode structure (e.g., some |
| 393 |
versions of Solaris 10). |
| 394 |
|
| 395 |
The config.cflags file may also contain dialect-specific compiler |
| 396 |
flags needed to activate a specific feature on the dialect. For |
| 397 |
example, for HP-UX config.cflags might contain: |
| 398 |
|
| 399 |
-D_LARGEFILE64_SOURCE This compiler flag enables the use of |
| 400 |
large-file system library functions |
| 401 |
--e.g., open64(). |
| 402 |
|
| 403 |
The lsof Configure script stanzas for |
| 404 |
the dialects select these options. |
| 405 |
|
| 406 |
|
| 407 |
C.3. config.ldflags |
| 408 |
=================== |
| 409 |
|
| 410 |
This file, config.ldflags, contains the dialect loader flags -- |
| 411 |
i.e., the equivalent to make(1) LFLAGS -- for loading the test |
| 412 |
programs. |
| 413 |
|
| 414 |
Example for Solaris: -lsocket this adds the socket library |
| 415 |
to the loading of the lsof |
| 416 |
test programs. |
| 417 |
|
| 418 |
Example for UnixWare: -lsocket -lnsl this adds the socket and |
| 419 |
name server libraries to |
| 420 |
the loading of the lsof |
| 421 |
test programs. |
| 422 |
|
| 423 |
|
| 424 |
C.4. config.xobj |
| 425 |
================ |
| 426 |
|
| 427 |
This file, config.xobj, contains the paths to any extra object |
| 428 |
files (.o's) that must be loaded when the test suite C programs |
| 429 |
are loaded. Like config.cc and config.cflags, it's incorporated |
| 430 |
into the loader statements of the Makefile's rules with `cat |
| 431 |
config.xobj`. |
| 432 |
|
| 433 |
Examples for DEC OSF/1 and NEXTSTEP: |
| 434 |
|
| 435 |
../lib/snpf.o this loads the private lsof object file |
| 436 |
that contains an snprintf() function. (The |
| 437 |
DEC OSF/1 4.0 and NEXTSTEP 3.1 C libraries |
| 438 |
don't have snprintf().) |
| 439 |
|
| 440 |
|
| 441 |
D. Cleaning -- Quick or Spotless |
| 442 |
================================ |
| 443 |
|
| 444 |
There are two Makefile rules that clean the tests/ subdirectory -- |
| 445 |
"clean" and "spotless". They cause different degrees of cleaning. |
| 446 |
|
| 447 |
clean a "quick" clean that removes compiled object files, |
| 448 |
executables and test files. It does NOT remove |
| 449 |
the configuration files that ../Configure and the |
| 450 |
config.perl rule wrote. |
| 451 |
|
| 452 |
spotless cleans out everything clean does -- plus the |
| 453 |
configuration files that ../Configure and the |
| 454 |
config.perl rule wrote. |
| 455 |
|
| 456 |
This is the rule used when `./Configure -clean` is |
| 457 |
specified. If this rule is used, `../Configure -n |
| 458 |
<abbr>` and `../make`) must be run again before |
| 459 |
the test suite can be used. |
| 460 |
|
| 461 |
|
| 462 |
E. Test Library |
| 463 |
=============== |
| 464 |
|
| 465 |
The lsof test suite provides a C library. |
| 466 |
|
| 467 |
E.1. LTlib.c |
| 468 |
============ |
| 469 |
|
| 470 |
This is a C library of common functions used by tests. Configured |
| 471 |
at compile time by the contents of config.cflags, it uses the single |
| 472 |
header file LsofTest.h. LsofTest.h tailors its definitions to the |
| 473 |
dialect at compile time, using the LT_DIAL_* definitions in |
| 474 |
config.cflags. |
| 475 |
|
| 476 |
Two particularly useful functions in the library are: ExecLsof(), |
| 477 |
which will execute an lsof child process; and RdFromLsof(), which |
| 478 |
will read from the in-bound lsof pipe, and decode the fields into |
| 479 |
structures that are easy for C programs to process. |
| 480 |
|
| 481 |
This library is a good model for processing field output in a C |
| 482 |
program from an in-bound lsof pipe. |
| 483 |
|
| 484 |
The source for the library, LTlib.c, contains more documentation. |
| 485 |
|
| 486 |
|
| 487 |
F. The Individual Tests |
| 488 |
======================= |
| 489 |
|
| 490 |
The individual tests are listed in this section. The listings |
| 491 |
explain what the tests do, a few errors they might report, and how |
| 492 |
to use options and environment variables to customize the tests. |
| 493 |
|
| 494 |
The test descriptions are listed in this section in alphabetical |
| 495 |
order, not in the order they are run by Makefile. |
| 496 |
|
| 497 |
The Makefile runs the tests in three groups, basic tests, standard |
| 498 |
tests, and optional tests. The default make "all" rule runs the |
| 499 |
basic and standard tests. (The "standard", "std", and "test" |
| 500 |
Makefile rules are synonyms to "all".) If the standard tests succeed, |
| 501 |
Makefile suggests running the optional tests with the "opt" (or |
| 502 |
"optional") rule. |
| 503 |
|
| 504 |
The Makefile "auto" and "silent" rules run only the basic and |
| 505 |
standard tests. They do not run or suggest you run the optional |
| 506 |
tests. |
| 507 |
|
| 508 |
The basic test: |
| 509 |
LTbasic |
| 510 |
|
| 511 |
Standard tests: |
| 512 |
LTnlink |
| 513 |
LTsock |
| 514 |
LTszoff |
| 515 |
LTunix |
| 516 |
|
| 517 |
Optional tests: |
| 518 |
LTbigf |
| 519 |
LTdnlc |
| 520 |
LTlock |
| 521 |
LTnfs |
| 522 |
|
| 523 |
The basic and standard tests should all succeed on all dialects, |
| 524 |
although LTnlink may warn that it can't perform its unlink test on |
| 525 |
an NFS file system. |
| 526 |
|
| 527 |
The optional tests may run, they may be disabled for specific |
| 528 |
dialects, or they may fail because of special resource needs -- |
| 529 |
e.g., LTbigf will run only on UNIX dialects where it knows how to |
| 530 |
handle files whose lengths exceed 32 bits, and LTnfs needs access |
| 531 |
to an NFS file system mounted from a remote NFS server. |
| 532 |
|
| 533 |
Tests that need special resources usually provide a hint about the |
| 534 |
resources when they fail. Information about special resource needs |
| 535 |
may also be found in the following sections about the individual |
| 536 |
tests. |
| 537 |
|
| 538 |
G.1. LTbasic, a Basic Lsof Test |
| 539 |
=============================== |
| 540 |
|
| 541 |
This is the basic lsof test. If it doesn't run, it's not likely |
| 542 |
any other tests will run, either. Hence, if it fails, no Makefile |
| 543 |
rule runs any other tests. |
| 544 |
|
| 545 |
This test uses lsof to locate files in the lsof process, including |
| 546 |
current working directory, the lsof executable, and the /dev/kmem |
| 547 |
open file. |
| 548 |
|
| 549 |
Finding the lsof executable may not be possible on AIX if lsof was |
| 550 |
compiled without support for its -X option. |
| 551 |
|
| 552 |
Finding /dev/kmem use by lsof is only possible on dialects where |
| 553 |
lsof uses /dev/kmem. The -DLT_KMEM define indicates that. |
| 554 |
|
| 555 |
Run this test: |
| 556 |
|
| 557 |
$ ./LTbasic |
| 558 |
|
| 559 |
Environment variables: LT_LSOF_PATH defines the path to the lsof |
| 560 |
executable. (The default is ../lsof.) |
| 561 |
|
| 562 |
G.2. LTbigf, Test Sizes and Offsets for Large (> 32 bit) Files |
| 563 |
============================================================== |
| 564 |
|
| 565 |
This is a test in the optional test group. |
| 566 |
|
| 567 |
This test is effective only when ../Configure has put -DLT_BIGF in |
| 568 |
config.cflags. Without that definition this test simply reports |
| 569 |
that the dialect doesn't support large files. That report is |
| 570 |
accompanied by a successful test exit code, so that the runner of |
| 571 |
the test (e.g., the Makefile) won't believe the test failed. |
| 572 |
|
| 573 |
When a dialect does support large files, the test attempts to create |
| 574 |
a file that looks very large -- e.g., has a length as reported by |
| 575 |
ls(1) of 0x140000000 bytes. However, the file really has only a |
| 576 |
small amount of data in it, the rest of the file consists of a |
| 577 |
large standard UNIX file system "hole." |
| 578 |
|
| 579 |
By default the test file is named config.LTbigf<PID>, where PID is |
| 580 |
the Process ID of the LTbigf process. |
| 581 |
|
| 582 |
When that file is not on a file system enabled for large files, or |
| 583 |
when the process that runs LTbigf can't create a big file, LTbigf |
| 584 |
will report an error. The error will be accompanied by hints that |
| 585 |
the -p option may need to be used to define a path where the test |
| 586 |
can write a large file, or the process ulimit file block size may |
| 587 |
need to be raised -- e.g., to "unlimited." |
| 588 |
|
| 589 |
LTbigf can't test file offset reporting on Linux kernels below |
| 590 |
2.6.22, because the /proc file systems of those kernels don't make |
| 591 |
file offsets available to lsof. |
| 592 |
|
| 593 |
Run this test: |
| 594 |
|
| 595 |
$ ./LTbigf [-p <path>] |
| 596 |
|
| 597 |
Environment variables: LT_LSOF_PATH defines the path to the lsof |
| 598 |
executable. (The default is ../lsof.) |
| 599 |
|
| 600 |
G.3. LTdnlc, Test the Kernel's Dynamic Name Lookup Cache |
| 601 |
======================================================== |
| 602 |
|
| 603 |
This is a test in the optional test group. |
| 604 |
|
| 605 |
This test asks lsof to locate the current working directory of its |
| 606 |
own process and report the path it has assembled from the components |
| 607 |
it found in the kernel's Dynamic Name Lookup Cache (DNLC) or via |
| 608 |
other dialect-specific methods. (E.g., Linux, HP-UX 11.11, and |
| 609 |
some Tru64 UNIX versions have private name lookup methods.) |
| 610 |
|
| 611 |
The test checks what lsof reports as the current working directory |
| 612 |
path for any missing components and counts the number of full paths |
| 613 |
returned. (Symbolic link complications prevent testing for exact |
| 614 |
path matches.) The test is repeated. If full paths are returned |
| 615 |
at least half the time, the test considers itself successful. |
| 616 |
|
| 617 |
This test can't be run on AIX, because lsof can't access the DNLC |
| 618 |
there. It can't be run on Apple Darwin versions below 8.0, either, |
| 619 |
because insufficiently reliable DNLC information is available there. |
| 620 |
This test may fail on other dialects when the file system -- e.g., NFS. |
| 621 |
/tmp, loopback -- doesn't fully participate in the dialect's DNLC. |
| 622 |
|
| 623 |
Run this test: |
| 624 |
|
| 625 |
$ ./LTdnlc |
| 626 |
|
| 627 |
Environment variables: LT_LSOF_PATH defines the path to the lsof |
| 628 |
executable. (The default is ../lsof.) |
| 629 |
|
| 630 |
G.4. LTlock, Lock Tests |
| 631 |
======================= |
| 632 |
|
| 633 |
This is a test in the optional test group. |
| 634 |
|
| 635 |
This test uses flock() and fcntl() to set and clear file locks, |
| 636 |
and measures lsof's ability to report them. The choice of system |
| 637 |
lock call is based on the dialect. (There are LT_DIAL_* pre-processor |
| 638 |
tests in LTlock.c.) |
| 639 |
|
| 640 |
This test can't be run on an NFS client file system, because NFS |
| 641 |
lock information is kept on the server. Lsof on the client can't |
| 642 |
see that server kernel data. |
| 643 |
|
| 644 |
By default the test attempts to create a file named config.LTlock<PID>, |
| 645 |
where PID is the Process ID of the locking test process. It uses |
| 646 |
lsof to determine if the file is on a client NFS file system. If |
| 647 |
it is, the test aborts, hinting that the -p option can be used to |
| 648 |
specify a non-client-NFS test file path. |
| 649 |
|
| 650 |
This test can't be run on Darwin, because insufficient file system |
| 651 |
lock information is available to lsof there. |
| 652 |
|
| 653 |
Run this test: |
| 654 |
|
| 655 |
$ ./LTlock [-p <path>] |
| 656 |
|
| 657 |
Environment variables: LT_LSOF_PATH defines the path to the lsof |
| 658 |
executable. (The default is ../lsof.) |
| 659 |
|
| 660 |
G.6. LTnfs, NFS Test |
| 661 |
==================== |
| 662 |
|
| 663 |
This is a test in the optional test group. |
| 664 |
|
| 665 |
This test verifies that lsof can locate files mounted on a client |
| 666 |
NFS system from an NFS server. |
| 667 |
|
| 668 |
By default it creates a test file, config.LTnfs<PID>, where PID is |
| 669 |
the Process ID of the test process. The test then uses lsof to |
| 670 |
find the file on an NFS file system. |
| 671 |
|
| 672 |
If lsof can't find the file the test warns that the test file might |
| 673 |
not be on an NFS file system and hints that the -p option may be |
| 674 |
used to specify the path of an NFS file, provided the test can have |
| 675 |
read access to it there. The test warning also states that the |
| 676 |
file at the path specified with -p must be a regular file, not a |
| 677 |
directory. |
| 678 |
|
| 679 |
This test can't be run on Darwin versions below 8.0, because |
| 680 |
insufficient NFS file information is available to lsof there. |
| 681 |
|
| 682 |
Run this test: |
| 683 |
|
| 684 |
$ ./LTnfs [-p <path>] |
| 685 |
|
| 686 |
Environment variables: LT_LSOF_PATH defines the path to the lsof |
| 687 |
executable. (The default is ../lsof.) |
| 688 |
|
| 689 |
G.7. LTnlink, Link Count Test |
| 690 |
============================= |
| 691 |
|
| 692 |
This is a test in the standard test group. |
| 693 |
|
| 694 |
The test checks lsof's reporting of link count (nlink in UNIX |
| 695 |
argot.) |
| 696 |
|
| 697 |
It creates a test file in the current working directory named |
| 698 |
config.LTnlink<PID>, where PID is the Process ID of the test |
| 699 |
process. It then uses stat(2) and lsof to measure the link count |
| 700 |
of the file. |
| 701 |
|
| 702 |
If LTnlink creates the test file in the current working directory |
| 703 |
and it is on an NFS file system, LTnlink won't be able to perform |
| 704 |
one section of its test. In that section the test file is unlinked |
| 705 |
so its link count will be zero and lsof is asked to find it among |
| 706 |
the set of files whose link counts are zero. |
| 707 |
|
| 708 |
When an NFS file is unlinked its link count isn't reduced until |
| 709 |
the last open instance is closed on either the NFS clients or the |
| 710 |
NFS. That's a consequence of NFS statelessness and leads to the |
| 711 |
occasional presence of files with names of the form .nfsxxxx. |
| 712 |
|
| 713 |
Should LTnlink find its test file on an NFS file system, it disables |
| 714 |
the unlink section of its tests and issues a warning. It also |
| 715 |
issues a hint that the test file path can be named via the -p option |
| 716 |
to give a test file location that isn't on an NFS file system. |
| 717 |
|
| 718 |
This test can't be run on Darwin, because insufficient file system link |
| 719 |
count information is available to lsof there. |
| 720 |
|
| 721 |
Because some UNIX dialects delay the reporting of a link count |
| 722 |
update after a file has been unlinked, LTnlink may not get its |
| 723 |
expected response from lsof for a while after the test file has |
| 724 |
been unlinked. In that cause LTnlink may delay for up to a minute, |
| 725 |
calling lsof once every two seconds and displaying a "waiting for |
| 726 |
link count update: ..." message. |
| 727 |
|
| 728 |
Some file systems -- e.g., ZFS on Solaris 11 -- don't allow LTnlink to |
| 729 |
unlink its test file, because LTnlink has the file open. LTnlink |
| 730 |
explains that failure and suggests that it be run with path of the "-p |
| 731 |
path" option set to a file on /tmp. See 00FAQ for more information. |
| 732 |
|
| 733 |
Run this test: |
| 734 |
|
| 735 |
$ ./LTnlink [-p <path>] |
| 736 |
|
| 737 |
Environment variables: LT_LSOF_PATH defines the path to the lsof |
| 738 |
executable. (The default is ../lsof.) |
| 739 |
|
| 740 |
G.7. LTsock, Test IPv4 Sockets |
| 741 |
============================== |
| 742 |
|
| 743 |
This is a test in the standard test group. |
| 744 |
|
| 745 |
This test uses lsof to locate open IPv4 socket files that the test |
| 746 |
has created itself. The test opens a server socket, then forks a |
| 747 |
child process to connect to that socket. After both are running, |
| 748 |
the test uses lsof to find the open socket files at their known |
| 749 |
host and port addresses. |
| 750 |
|
| 751 |
Run this test: |
| 752 |
|
| 753 |
$ ./LTsock |
| 754 |
|
| 755 |
Environment variables: LT_LSOF_PATH defines the path to the lsof |
| 756 |
executable. (The default is ../lsof.) |
| 757 |
|
| 758 |
G.8. LTszoff, Test Sizes and Offsets for Small (< 32 bit) Files |
| 759 |
=============================================================== |
| 760 |
|
| 761 |
This is a test in the standard test group. |
| 762 |
|
| 763 |
This test checks lsof's reporting of file size and offset for small |
| 764 |
(< 32 bits) files. |
| 765 |
|
| 766 |
It creates a test file in the current working directory named |
| 767 |
config.LTszoff<PID>. PID is the Process ID of the test process. |
| 768 |
|
| 769 |
LTszoff can't test file offset reporting on Linux kernels below |
| 770 |
2.6.22, because the /proc file systems of those kernels don't make |
| 771 |
file offsets available to lsof. |
| 772 |
|
| 773 |
Run this test: |
| 774 |
|
| 775 |
$ ./LTszoff [-p <path>] |
| 776 |
|
| 777 |
Environment variables: LT_LSOF_PATH defines the path to the lsof |
| 778 |
executable. (The default is ../lsof.) |
| 779 |
|
| 780 |
G.9. LTunix, Test UNIX Domain Sockets |
| 781 |
====================================== |
| 782 |
|
| 783 |
This is a test in the standard test group. |
| 784 |
|
| 785 |
This test checks lsof's reporting of UNIX domain sockets. |
| 786 |
|
| 787 |
The test creates a pair of UNIX domain sockets and uses bind(2) to |
| 788 |
associate the file system names config.LT0U<PID> (client) and |
| 789 |
config.LT1U<PID> (server) with them. (PID is the test process ID.) |
| 790 |
The test then uses lsof to find the two open UNIX domain socket |
| 791 |
files. |
| 792 |
|
| 793 |
Run this test: |
| 794 |
|
| 795 |
$ ./LTunix |
| 796 |
|
| 797 |
Environment variables: LT_LSOF_PATH defines the path to the lsof |
| 798 |
executable. (The default is ../lsof.) |
| 799 |
|
| 800 |
|
| 801 |
Appendix A, Test Files |
| 802 |
====================== |
| 803 |
|
| 804 |
These files may be created by suite tests. |
| 805 |
|
| 806 |
Created |
| 807 |
./tests Name by Test Use |
| 808 |
============ ======= === |
| 809 |
|
| 810 |
config.LTbifg** LTbigf to test lsof's large file size |
| 811 |
and offset reporting |
| 812 |
|
| 813 |
config.LTlock* LTlock for locking tests |
| 814 |
|
| 815 |
config.LTnfs* LTnfs for NFS tests |
| 816 |
|
| 817 |
config.LTnlink* LTnlink for link count tests |
| 818 |
|
| 819 |
config.LTszoff* LTszoff for small file size and |
| 820 |
offset reporting |
| 821 |
|
| 822 |
config.LT[01]U* LTunix two UNIX domain sockets, used |
| 823 |
to determine if lsof can report |
| 824 |
their open instances properly |
| 825 |
|
| 826 |
|
| 827 |
Appendix B, Test Validations |
| 828 |
============================ |
| 829 |
|
| 830 |
This appendix lists the UNIX dialects and their versions where I |
| 831 |
have validated the test suite. The list indicates the particular |
| 832 |
tests I was unable to run, mostly LTnfs because the test systems |
| 833 |
I used had no NFS file systems mounted. |
| 834 |
|
| 835 |
The information in the following table is encoded in a test data |
| 836 |
base file, TestDB, as footprints, using the tests compiler options |
| 837 |
written to config.cflags by the lsof Configure script. See "B.2. |
| 838 |
Test Data Base and Scripts" for more information on the test data |
| 839 |
base, footprints, and the scripts that support them. |
| 840 |
|
| 841 |
UNIX |
| 842 |
Dialect Dialect Description Untested Tests |
| 843 |
======= =================== ============== |
| 844 |
AIX 4.3.3, Power, cc |
| 845 |
5.1, Power-32, cc |
| 846 |
5.1, Power-32, gcc |
| 847 |
5.1, Power-64, cc |
| 848 |
5.2, Power-32, cc |
| 849 |
5.2, Power-32, gcc |
| 850 |
5.2, Power-64, cc |
| 851 |
5.2, Power-64, gcc |
| 852 |
5.3, Power-64, cc |
| 853 |
Darwin 1.4, 5.5, 6.x, 7.x gcc Darwin lsof doesn't |
| 854 |
have adequate support |
| 855 |
to allow the LTbigf, |
| 856 |
Ltdnlc, LTlock, LTnfs, |
| 857 |
and LTnlink tests to |
| 858 |
run. |
| 859 |
8.0, gcc Darwin lsof doesn't |
| 860 |
have adequate support |
| 861 |
to allow the LTbigf, |
| 862 |
LTlock and LTnlink |
| 863 |
tests to run. |
| 864 |
9.0, gcc Darwin lsof doesn't |
| 865 |
have adequate support |
| 866 |
to allow the LTlock |
| 867 |
test to run. |
| 868 |
10.0, gcc Darwin lsof doesn't |
| 869 |
have adequate support |
| 870 |
to allow the LTlock test |
| 871 |
to run. |
| 872 |
11.0, gcc Darwin lsof doesn't |
| 873 |
have adequate support |
| 874 |
to allow the LTlock test |
| 875 |
to run. |
| 876 |
FreeBSD 4.5, i386, gcc |
| 877 |
4.6, i386, gcc |
| 878 |
4.7, i386, gcc |
| 879 |
4.8, i386, gcc |
| 880 |
4.9, i386, gcc |
| 881 |
4.10, i386 gcc |
| 882 |
5.0, Alpha, gcc |
| 883 |
5.0, Sparc, gcc |
| 884 |
5.0, i386, gcc |
| 885 |
5.1, Alpha, gcc |
| 886 |
5.1, Amd64, gcc |
| 887 |
5.1, Sparc, gcc |
| 888 |
5.1, i386, gcc |
| 889 |
5.2, i386, gcc |
| 890 |
5.2, Alpha, gcc |
| 891 |
5.2, Amd64, gcc |
| 892 |
5.2, Sparc, gcc |
| 893 |
5.3, Alpha, gcc |
| 894 |
5.4, Alpha, gcc |
| 895 |
5.5, Alpha, gcc |
| 896 |
6.0, Alpha, gcc |
| 897 |
6.0, Amd64, gcc |
| 898 |
6.0, Sparc, gcc |
| 899 |
6.1, i386, gcc |
| 900 |
6.4, i386, gcc |
| 901 |
7.0 Alpha, gcc |
| 902 |
7.0 Amd64, gcc |
| 903 |
7.1 Amd64, gcc |
| 904 |
7.2 Amd64, gcc |
| 905 |
7.3 Amd64, gcc |
| 906 |
7.4 Amd64, gcc |
| 907 |
8.0 Amd64, gcc |
| 908 |
8.2 Amd64, gcc |
| 909 |
8.3 Amd64, gcc |
| 910 |
8.4 Amd64, gcc |
| 911 |
9.0 Amd64, gcc |
| 912 |
10.0 Amd64, gcc |
| 913 |
10.0 Amd64, clang |
| 914 |
11.0 Amd64, clang |
| 915 |
12.0 Amd64, clang |
| 916 |
HP-UX 10.20, cc LTbigf |
| 917 |
10.20, gcc (1) LTbigf |
| 918 |
11.00-32, ANSI-C LTbigf, LTnfs |
| 919 |
11.00-64, ANSI-C |
| 920 |
11.11, ANSI-C |
| 921 |
11.23, ANSI-C |
| 922 |
Linux 2.4.12-686 LTbigf, no offset tests |
| 923 |
LTszoff, no offset tests |
| 924 |
2.4.18-686 LTbigf, no offset tests |
| 925 |
LTszoff, no offset tests |
| 926 |
2.4.21-686 LTbigf, no offset tests |
| 927 |
LTszoff, no offset tests |
| 928 |
2.4.23-686 LTbigf, no offset tests |
| 929 |
LTszoff, no offset tests |
| 930 |
2.4.24-686 LTbigf, no offset tests |
| 931 |
LTszoff, no offset tests |
| 932 |
2.4.25-686 LTbigf, no offset tests |
| 933 |
LTszoff, no offset tests |
| 934 |
2.4.26-686 LTbigf, no offset tests |
| 935 |
LTszoff, no offset tests |
| 936 |
2.4.27-686 LTbigf, no offset tests |
| 937 |
LTszoff, no offset tests |
| 938 |
2.4.28-686 LTbigf, no offset tests |
| 939 |
LTszoff, no offset tests |
| 940 |
2.4.29-686 LTbigf, no offset tests |
| 941 |
LTszoff, no offset tests |
| 942 |
2.4.30-686 LTbigf, no offset tests |
| 943 |
LTszoff, no offset tests |
| 944 |
2.6.1-rc2 LTbigf, no offset tests |
| 945 |
LTszoff, no offset tests |
| 946 |
2.6.18-686 LTbigf, no offset tests |
| 947 |
LTszoff, no offset tests |
| 948 |
2.6.22-686 (Note: this Linux kernel |
| 949 |
supplies file offsets to |
| 950 |
lsof.) |
| 951 |
2.6.32-686 (Note: this Linux kernel |
| 952 |
supplies file offsets to |
| 953 |
lsof.) |
| 954 |
2.6.38-686 |
| 955 |
3.10.004 |
| 956 |
3.10.08 |
| 957 |
4.14.14 |
| 958 |
3.10.0-229.1.2.el7 |
| 959 |
NetBSD 1.4.1, Alpha, gcc LTnfs |
| 960 |
1.5x, x86, gcc LTnfs |
| 961 |
1.6x, Alpha, gcc LTnfs |
| 962 |
1.6x, x86, gcc LTnfs |
| 963 |
2.0x, alpha, gcc LTnfs |
| 964 |
2.0x, sparc64, gcc LTnfs |
| 965 |
2.0x, x86, gcc LTnfs |
| 966 |
2.99.9, x86, gcc LTnfs |
| 967 |
2.99.10, x86, gcc LTnfs |
| 968 |
2.99.11, x86, gcc LTnfs |
| 969 |
2.99.12, x86, gcc LTnfs |
| 970 |
3.99., x86, gcc LTnfs |
| 971 |
OpenBSD 3.0, gcc |
| 972 |
3.1, gcc |
| 973 |
3.2, gcc |
| 974 |
3.3, gcc |
| 975 |
3.4, gcc |
| 976 |
3.5, gcc |
| 977 |
3.6, gcc |
| 978 |
3.7, gcc |
| 979 |
3.9, gcc |
| 980 |
OSR 5.04, cc LTnfs |
| 981 |
5.06, cc LTnfs |
| 982 |
Solaris 2.6, cc LTnfs |
| 983 |
2.6, gcc LTnfs |
| 984 |
7-32, cc |
| 985 |
7-32, gcc LTnfs |
| 986 |
8-32, cc |
| 987 |
8-32, gcc |
| 988 |
8-64, cc |
| 989 |
8-64, gcc |
| 990 |
9-64, Beta-Refresh, cc |
| 991 |
9-64, Beta-Refresh, gcc |
| 992 |
9-64, FCS, cc |
| 993 |
9-64, FCS, gcc |
| 994 |
10-32, i86pc, gcc |
| 995 |
10-32, i86pc, cc |
| 996 |
10-64, Sparc, cc |
| 997 |
10-64, Sparc, gcc |
| 998 |
11-64, Amd64, cc |
| 999 |
UnixWare 7.1.1, NSC, cc LTnfs |
| 1000 |
7.1.3, cc |
| 1001 |
7.1.4, cc |
| 1002 |
|
| 1003 |
If you are able to run the test suite on dialect versions other |
| 1004 |
than the ones listed above, please send e-mail to <[email protected]>, |
| 1005 |
indicating the dialect version where you were able to run the test |
| 1006 |
suite. Please send me the footprint formed by CkTestDB, or run |
| 1007 |
the Add2TestDB script and send me the footprint it reports. |
| 1008 |
|
| 1009 |
If you encounter problems compiling the tests or running them on |
| 1010 |
a dialect version listed above, please send e-mail to <[email protected]>, |
| 1011 |
naming the dialect version and providing the output from the lsof |
| 1012 |
Configure script and make operation. |
| 1013 |
|
| 1014 |
1) John Dzubera did the HP-UX 10.20 gcc testing and provided its |
| 1015 |
footprint. |
| 1016 |
|
| 1017 |
|
| 1018 |
Appendix C, Test Failures |
| 1019 |
========================= |
| 1020 |
|
| 1021 |
I was unable to make the test suite run on the following dialects. |
| 1022 |
|
| 1023 |
UNIX Dialect |
| 1024 |
and Description Failure |
| 1025 |
=============== ======= |
| 1026 |
HP-UX 11-64, gcc 64 bit gcc 3.0 didn't compile the LTsock |
| 1027 |
test correctly on my 64 bit HP-UX 11 test |
| 1028 |
system. |
| 1029 |
|
| 1030 |
|
| 1031 |
Vic Abell <[email protected]> |
| 1032 |
February 14, 2018 |