README 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. This package contains a test suite for libffi.
  2. This test suite can be compiled with a C compiler. No need for 'expect'
  3. or some other package that is often not installed.
  4. The test suite consists of 81 C functions, each with a different signature.
  5. * test-call verifies that calling each function directly produces the same
  6. results as calling the function indirectly through 'ffi_call'.
  7. * test-callback verifies that calling each function directly produces the same
  8. results as calling a function that is a callback (object build by
  9. 'ffi_prep_closure_loc') and simulates the original function.
  10. Each direct or indirect invocation should produce one line of output to
  11. stdout. A correct output consists of paired lines, such as
  12. void f(void):
  13. void f(void):
  14. int f(void):->99
  15. int f(void):->99
  16. int f(int):(1)->2
  17. int f(int):(1)->2
  18. int f(2*int):(1,2)->3
  19. int f(2*int):(1,2)->3
  20. ...
  21. The Makefile then creates two files:
  22. * failed-call, which consists of the non-paired lines of output of
  23. 'test-call',
  24. * failed-callback, which consists of the non-paired lines of output of
  25. 'test-callback'.
  26. The test suite passes if both failed-call and failed-callback come out
  27. as empty.
  28. How to use the test suite
  29. -------------------------
  30. 1. Modify the Makefile's variables
  31. prefix = the directory in which libffi was installed
  32. CC = the C compiler, often with options such as "-m32" or "-m64"
  33. that enforce a certain ABI,
  34. CFLAGS = optimization options (need to change them only for non-GCC
  35. compilers)
  36. 2. Run "make". If it fails already in "test-call", run also
  37. "make check-callback".
  38. 3. If this failed, inspect the output files.
  39. How to interpret the results
  40. ----------------------------
  41. The failed-call and failed-callback files consist of paired lines:
  42. The first line is the result of the direct invocation.
  43. The second line is the result of invocation through libffi.
  44. For example, this output
  45. uchar f(uchar,ushort,uint,ulong):(97,2,3,4)->255
  46. uchar f(uchar,ushort,uint,ulong):(97,2,3,4)->0
  47. indicates that the arguments were passed correctly, but the return
  48. value came out wrong.
  49. And this output
  50. float f(17*float,3*int,L):(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,6,7,8,561,1105,1729,2465,2821,6601)->15319.1
  51. float f(17*float,3*int,L):(0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,-140443648,10,268042216,-72537980,-140443648,-140443648,-140443648,-140443648,-140443648)->-6.47158e+08
  52. indicates that integer arguments that come after 17 floating-point arguments
  53. were not passed correctly.
  54. Credits
  55. -------
  56. The test suite is based on the one of GNU libffcall-2.0.
  57. Authors: Bill Triggs, Bruno Haible