README.txt 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. /*!
  2. \mainpage Visual and Interactive Test Automation for SDL 2.0
  3. \section license_sec License
  4. Check the file \c LICENSE.txt for licensing information.
  5. \section intro_sec Introduction
  6. The goal of this GSoC project is to automate the testing of testsprite2.
  7. testsprite2 takes 26 parameters which have thousands of valid combinations and is
  8. used to validate SDL's window, mouse and rendering behaviour. By having a test
  9. harness that runs testsprite2 with various command line argument strings and
  10. validates the output for each run, we can make testing an easier task for
  11. maintainers, contributors and testers. The test harness can be used by a continuous
  12. integration system (like buildbot or jenkins) to validate SDL after checkins.
  13. SDL Homepage: http://libsdl.org/
  14. \section build_sec Building
  15. \subsection build_linux Building on Linux/Cygwin
  16. <tt>./autogen.sh; ./configure; make;</tt>
  17. \subsection build_windows Building on Windows
  18. Use the Visual Studio solution under \c SDL/VisualC/visualtest.
  19. \section docs_sec Documentation
  20. Documentation is available via Doxygen. To build the documentation, cd to the
  21. SDL/visualtest/docs directory and run \c doxygen. A good starting point for
  22. exploring the documentation is \c SDL/visualtest/docs/html/index.html
  23. \section usage_sec Usage
  24. To see all the options supported by the test harness, just run \c testharness
  25. with no arguments.
  26. At the moment the following options are supported:
  27. \li \c sutapp - Path to the system under test (SUT) application
  28. \li \c sutargs - Launch the SUT with the specified arguments string
  29. \li \c timeout - The maximum time after which the SUT process will be killed;
  30. passed as hh:mm:ss; default 00:01:00
  31. \li \c variator - Which variator to use; see \ref variators_sec
  32. \li \c num-variations - The number of variations to run for; taken to be
  33. 1 for the random variator and ALL for the exhaustive variator by default
  34. \li \c no-launch - Just print the arguments string for each variation without
  35. launching the SUT or performing any actions
  36. \li \c parameter-config - A config file that describes the command line parameters
  37. supported by the SUT; see \ref paramconfig_sec or the sample *.parameters files
  38. for more details
  39. \li \c action-config - A config file with a list of actions to be performed while
  40. the SUT is running; see \ref actionconfig_sec or the sample *.actions files
  41. \li \c output-dir - Path to the directory where screenshots should be saved; is
  42. created if it doesn't exist; taken to be "./output" by default
  43. \li \c verify-dir - Path to the directory with the verification images; taken to
  44. be "./verify" by default
  45. Paths can be relative or absolute.
  46. Alternatively, the options can be passed as a config file for convenience:
  47. <tt>testharness \-\-config testsprite2_sample.config</tt>
  48. For a sample, take a look at the *.config files in this repository.
  49. We can also pass a config file and override certain options as necessary:
  50. <tt>testharness \-\-config testsprite2_sample.config \-\-num-variations 10</tt>
  51. Note: You may find it convenient to copy the SUT executable along with any
  52. resources to the test harness directory. Also note that testsprite2 and its
  53. resources (icon.bmp) are automatically copied when using the Visual Studio
  54. solution.
  55. \subsection usageexamples_subsec Usage examples:
  56. Passing a custom arguments string:
  57. <tt>testharness \-\-sutapp testsprite2 \-\-sutargs "\-\-cyclecolor \-\-blend mod
  58. \-\-iterations 2" \-\-action-config xyz.actions</tt>
  59. Using the random variator:
  60. <tt>testharness \-\-sutapp testsprite2 \-\-variator random \-\-num-variations 5
  61. \-\-parameter-config xyz.parameters \-\-action-config xyz.actions</tt>
  62. \subsection config_subsec Config Files
  63. Config files are an alternate way to pass parameters to the test harness. We
  64. describe the paramters in a config file and pass that to the test harness using
  65. the \-\-config option. The config file consists of lines of the form "x=y" where
  66. x is an option and y is it's value. For boolean options, we simply give the name
  67. of the option to indicate that it is to be passed to the testharness.
  68. The hash '#' character can be used to start a comment from that point to the end
  69. of the line.
  70. \section paramconfig_sec The SUT Parameters File
  71. To generate variations we need to describe the parameters the will be passed to
  72. the SUT. This description is given in a parameters file. Each line of the parameters
  73. file (except the blank lines) represents one command line option with five
  74. comma separated fields:
  75. <tt>name, type, values, required, categories</tt>
  76. \li \c name is the name of the option, e.g., \c \-\-cyclecolor.
  77. \li \c type can have one of three values - integer, boolean and enum.
  78. \li \c values - for integer options this is the valid range of values the option
  79. can take, i.e., [min max]. For enum options this is a list of strings that
  80. the option can take, e.g., [val1 val2 val3]. For boolean options this field
  81. is ignored.
  82. \li \c required - true if the option is required, false otherwise.
  83. \li \c categories - a list of categories that the option belongs to. For example,
  84. [video mouse audio]
  85. Just like with config files, hash characters can be used to start comments.
  86. \subsection additionalnotes_subsec Additional Notes
  87. \li If you want to have an option that always takes a certain value, use an enum
  88. with only one value.
  89. \li Currently there isn't any way to turn an option off, i.e., all options will
  90. be included in the command line options string that is generated using the
  91. config. If you don't want an option to be passed to the SUT, remove it from
  92. the config file or comment it out.
  93. \section variators_sec Variators
  94. Variators are the mechanism by which we generate strings of command line arguments
  95. to test the SUT with. A variator is quite simply an iterator that iterates through
  96. different variations of command line options. There are two variators supported at
  97. the moment:
  98. \li \b Exhaustive - Generate all possible combinations of command line arguments
  99. that are valid.
  100. \li \b Random - Generate a random variation each time the variator is called.
  101. As an example, let's try a simple .parameters file:\n
  102. <tt>
  103. \-\-blend, enum, [add mod], false, [] \n
  104. \-\-fullscreen, boolean, [], false, []
  105. </tt>
  106. The exhaustive variator would generate the following four variations:\n
  107. <tt>
  108. \-\-blend add \n
  109. \-\-blend mod \n
  110. \-\-blend add \-\-fullscreen \n
  111. \-\-blend mod \-\-fullscreen \n
  112. </tt>
  113. The random variator would simply generate a random variation like the following:\n
  114. <tt>\-\-blend mod</tt>
  115. \section actionconfig_sec The Actions File
  116. Once the SUT process has been launched, automated testing happens using a mechanism
  117. called actions. A list of actions is read from a file and each action is performed
  118. on the SUT process sequentially. Each line in the actions file describes an action.
  119. The format for an action is <tt>hh:mm:ss ACTION_NAME additional parameters</tt>.
  120. There are five actions supported at the moment:
  121. \li \b SCREENSHOT - Takes a screenshot of each window owned by the SUT process. The
  122. images are saved as \c [hash]_[i].bmp where \c [hash] is the 32 character long
  123. hexadecimal MD5 hash of the arguments string that was passed to the SUT while
  124. launching it and \c i is the window number. i = 1 is an exceptional case
  125. where the \c _[i] is dropped and the filename is simply \c [hash].bmp\n
  126. Note: The screenshots are only of the window's client area.
  127. \li \b VERIFY - Verifies the screenshots taken by the last SCREENSHOT action by
  128. comparing them against a verification image. Each \c [hash]_i.bmp image output
  129. by the SCREENSHOT action is compared against a \c [hash].bmp image in the
  130. verify-dir.
  131. \li \b QUIT - Gracefully quits the SUT process. On Windows this means sending a
  132. WM_CLOSE message to each window owned by the SUT process. On Linux it means
  133. sending a SIGQUIT signal to the SUT process.
  134. \li \b KILL - Forcefully kills the SUT process. This is useful when the SUT process
  135. doesn't respond to the QUIT action.
  136. \li <b>LAUNCH [/path/to/executable] [args]</b> - Runs an executable with \c [args]
  137. as the arguments string.
  138. Just like with config files, hash characters can be used to start comments.
  139. \section contint_sec Continuous Integration (CI)
  140. One of the goals of the project was to create a test harness that integrates
  141. with CI systems to provide automated visual and interactive testing to SDL.
  142. At the moment the test harness can be run in two modes that are useful for CI:
  143. \li Crash testing mode - launch the SUT with every variation and all parameters,
  144. report to the CI if there's a crash
  145. \li Visual testing mode - launch and visually verify the SUT for a smaller subset
  146. of the parameters
  147. Look at the launch_harness.sh/launch_harness.cmd for an example scripts that run the
  148. test harness for all variations with all parameters and report an error on a crash.
  149. The script uses the testsprite2_crashtest config, so remember to copy those files
  150. over to the test harness executable directory along with the script.
  151. \section todo_sec TODOs
  152. \li Allow specifying a clipping box along with the VERIFY action, i.e., hh:mm:ss
  153. VERIFY x, y, w, h
  154. \li Add support for spaces between the equals sign in test harness config files
  155. \li Implement the SCREENSHOT action on Linux
  156. \li Add a pairwise variator
  157. \li Add actions to inject keyboard/mouse events
  158. \li Add actions to manipulate the SUT window, e.g., minimize, restore, resize
  159. \li Add support to load and save screenshots as .pngs instead of .bmps
  160. \section issues_sec Known Issues
  161. \li The QUIT action does not work on a testsprite2 process with multiple windows.
  162. This appears to be an issue with testsprite2.
  163. \li The SCREENSHOT action doesn't capture the testsprite2 window correctly if the
  164. --fullscreen option is supplied. It works with --fullscreen-desktop, however.
  165. \section moreinfo_sec More Information
  166. Author Contact Info:\n
  167. Apoorv Upreti \c \<apoorvupreti@gmail.com\>
  168. Other useful links:
  169. - Project Repository: https://bitbucket.org/nerdap/sdlvisualtest
  170. - Project Wiki: https://github.com/nerdap/autotestsprite2/wiki
  171. - Project Blog: http://nerdap.github.io
  172. - Verification images for testsprite2_blendmodes: https://www.dropbox.com/s/nm02aem76m812ng/testsprite2_blendmodes.zip
  173. - Verification images for testsprite2_geometry: https://www.dropbox.com/s/csypwryopaslpaf/testsprite2_geometry.zip
  174. */