chap8 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. .NH 1
  2. Testing the program
  3. .PP
  4. There is no test-suite for testing
  5. .I lint.
  6. I have written a lot of small files that each test one
  7. particular property of the program.
  8. At this moment there are about 220 test programs.
  9. .PP
  10. It would take a lot of time and effort to run these tests by hand.
  11. To ease this work I wrote a program that runs these tests
  12. automatically.
  13. The test program (the program that runs the tests) needs, associated
  14. with each .c file, a .w file, containing from each expected warning
  15. a substring. E.g. when the following warnings should be given by
  16. .I lint:
  17. .DS B
  18. .ft CW
  19. file t.c, line 3, i evaluation order undefined
  20. file t.c, line 6, a set but not used in function main
  21. .R
  22. .DE
  23. it is sufficient to write a file \f(CWt.w\fP containing
  24. .DS B
  25. .ft CW
  26. a set but not used in function main
  27. i evaluation order undefined
  28. .R
  29. .DE
  30. The test program is called with all the .c files to be tested
  31. as arguments.
  32. .PP
  33. Sometimes it is necessary to test
  34. .I lint
  35. on two files.
  36. The test program runs
  37. .I lint
  38. on two files when two consecutive
  39. arguments are of the form \fIname\fPa.c and \fIname\fPb.c.
  40. It then compares the output of
  41. .I lint
  42. with the file \fIname\fP.w.
  43. .PP
  44. .I Lint
  45. is also tested by running it on existing programs.
  46. .I Lint
  47. has been run on some \s-2UNIX\s+2 utility programs in
  48. /usr/src/cmd, on Unipress Emacs (consisting of more than 30,000
  49. lines of code) and the program itself.
  50. Bugs have been found in e.g. /usr/src/cmd/cat.c and
  51. /usr/src/cmd/ld.c.
  52. To test the robustness of the program, it was run on the
  53. password file /etc/passwd and on `mixed' C program files.
  54. These mixed C program files are C program files that were
  55. broken in chunks and then put together in a different order.
  56. .bp