p≡p engine fork for my own dirty testing of stuff
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

170 lines
5.1 KiB

  1. # Building and Running the Tests for the p≡p Engine
  2. Work in progress... Currently have the debian build/run instructions in.
  3. ## Caveat, before you begin
  4. Right now, the engine tests only function on \*nix-like systems (including
  5. MacOS).
  6. *(Conversion to Windows will require, at the very least, looking at some of the
  7. file-handling code. If you want to fix this, start by looking in Engine.cc
  8. in the test/src directory!)*
  9. ## Requirements
  10. In addition to the engine requirements, you will need:
  11. * `cmake`
  12. * `python3`
  13. * `git` (for getting the `gtest-parallel` repository, unless you grab the
  14. tarball from somewhere)
  15. ## Building the prerequisites
  16. The Engine test suite now requires (at least) two additional pieces to run:
  17. * `googletest`
  18. * `gtest-parallel`
  19. How this proceeds depends on your platform and whether or not you use a packaged
  20. distribution.
  21. These instructions do this with `cmake`. If you can manage it with `bazel`
  22. instead, more power to you ;)
  23. ### Installing `googletest`
  24. #### Packaged distributions
  25. This is the currently preferred way to do this, because everyone was doing it
  26. anyway and who am I to judge?
  27. ##### Debian and Ubuntu (and derivatives)
  28. Thanks to Erik Smistad for this starting point (condensed from [Getting Started
  29. with Google Test On
  30. Ubuntu](https://www.eriksmistad.no/getting-started-with-google-test-on-ubuntu/)):
  31. 1. Install the packages `cmake` and `libgtest-dev` from the repository. This
  32. will install the gtest source files to `/usr/src/gtest`. You'll still need to
  33. compile the code and link the library files to be able to use them.
  34. 2. Compile the source files:
  35. ```
  36. cd /usr/src/gtest
  37. sudo cmake CMakeLists.txt
  38. sudo make
  39. ```
  40. 3. Copy/symlink the libraries to the library location of your choice (here,
  41. it's `/usr/lib`, hence the `sudo`, but as long as it's in your library path,
  42. it shouldn't matter where you stick it):
  43. ```
  44. sudo cp *.a /usr/lib
  45. ```
  46. ##### MacOS
  47. I am totally guessing for now - this is a placeholder - that
  48. macports gtest install will do the same. Will need to find the directories this
  49. goes in. Guessing `/opt/local/src`.
  50. #### Downloading and compiling the source yourself
  51. For now, don't.
  52. Or do, and document it for me.
  53. If you were using the git repo and it was working before, please follow the
  54. instructions above for Debian/Ubuntu, only with your source repository in mind
  55. instead of `/usr/src`, and pay attention to the variables you'll need to set in
  56. `local.conf` for the Makefile - they are different from before.
  57. It should work, but I haven't tested it yet.
  58. ### Installing `gtest-parallel`
  59. Pick a source directory and put your `gtest-parallel` source there
  60. (e.g. via `git clone https://github.com/google/gtest-parallel.git`).
  61. We'll deal more with this when preparing to compile the test suite.
  62. ## Building the test suite
  63. ### `Makefile` and `local.conf`
  64. So `local.conf` in the top-level engine directory is where we stick all of the
  65. Makefile overrides. The test Makefile contains some defaults for relevant
  66. variables here, but if you need to override them, please either create or modify
  67. `local.conf` in the top-level engine directory as needed. The relevant variables
  68. are:
  69. * `GTEST_SRC_DIR`: This is the directory where the gtest source you compiled
  70. above is located (defaults to `/usr/src/gtest`)
  71. * `GTEST_INC_DIR`: This is where the include files for gtest are located
  72. (defaults to `$(GTEST_SRC_DIR)/include`)
  73. * `GTEST_PL`: This is the full path to the *python file* for `gtest_parallel`
  74. (default presumes you cloned it under `src` in your home directory, i.e. it is
  75. `$(HOME)/src/gtest-parallel/gtest_parallel.py`)
  76. ### Building
  77. Presuming the above works, then from the top test directory, simply run make.
  78. ## Running the test suite
  79. ### To simply run the test suite and see what tests fail...
  80. Do one of:
  81. 1. `make test` OR
  82. 2. `python3 <path to gtest-parallel.py> ./EngineTests`
  83. ### To run individual test suites, especially for debugging purposes
  84. Note that for some test suites, this will, if something goes dreadfully wrong,
  85. mean that one test's failure may pollute another test. This generally means you
  86. have found a dastardly bug in the engine, but it can also be a test issue.
  87. *Caveat lector*.
  88. 1. To run sequentially, *in the same process*:
  89. ```
  90. ./EngineTests --gtest_filter=TestSuiteName*
  91. ```
  92. For example, for `DeleteKeyTest`:
  93. ```
  94. ./EngineTests DeleteKeyTest*
  95. ```
  96. 2. To debug the same with lldb:
  97. ```
  98. lldb ./EngineTests -- --gtest_filter=TestSuiteName*
  99. ```
  100. 3. To debug with gdb:
  101. ```
  102. gdb --args ./EngineTests --gtest_filter=TestSuiteName*
  103. ```
  104. ### To run and/or debug individual test cases
  105. 1. To run:
  106. ```
  107. ./EngineTests --gtest_filter=TestSuiteName.test_function_name
  108. ```
  109. For example, for `check_delete_single_pubkey` in `DeleteKeyTest`:
  110. ```
  111. ./EngineTests DeleteKeyTest.check_delete_single_pubkey
  112. ```
  113. 2. To debug the same with lldb:
  114. ```
  115. lldb ./EngineTests -- --gtest_filter=TestSuiteName.test_function_name
  116. ```
  117. 3. To debug with gdb:
  118. ```
  119. gdb --args ./EngineTests --gtest_filter=TestSuiteName.test_function_name
  120. ```
  121. # Creating new tests
  122. Script next on the agenda...