ea9e92272776e952f0678a6c973cbff26b8ace42
[feisty_meow.git] / testkit / doc / testkit_reference.html
1 <html>
2   <head>
3     <meta http-equiv="content-type" content="text/html; charset=utf-8">
4     <title>TestKit Reference Manual</title>
5   </head>
6   <body vlink="purple" link="blue" lang="EN-US">
7     <h1 style=" text-align:center">Feisty Meow® TestKit Reference Manual</h1>
8     <address style=" text-align:center">Version 1.0 ― Updated August 12 2020</address>
9     <h1>The Feisty Meow® TestKit</h1>
10     <p>The TestKit is a collection of scripts that leverages the ShUnit unit
11       testing environment.&nbsp; TestKit provides a pattern for creating test
12       suites using a simple configuration file approach.&nbsp; Full reporting on
13       test runs is provided in a convenient tabular format.</p>
14     <p>Generally, writing a test script using the TestKit is a matter of
15       minutes.&nbsp; A blank test is provided as a template, and that can be
16       expanded with whatever test steps are needed.</p>
17     <p>TestKit (and ShUnit) are implemented in the GNU Bash script language, but
18       a TestKit test script can invoke external applications, written in
19       whatever programming language or scripting tool is desired, using the
20       standard POSIX interfaces.<br>
21     </p>
22     <h2> Getting the TestKit</h2>
23     <p>Follow these steps to download and install the Feisty Meow TestKit:<br>
24     </p>
25     <div style="border:solid windowtext 1.0pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;
26 background:#DDD9C3;margin-left:.1in;margin-right:.1in">
27       <p class="Code-Box" style="margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
28 margin-left:0in;background:#DDD9C3"><span style="font-family: monospace;">sudo
29           mkdir /opt/feistymeow.org<br>
30           sudo chown -R $USER /opt/feistymeow.org<br>
31           cd /opt/feistymeow.org<br>
32           git clone git://feistymeow.org/feisty_meow</span></p>
33     </div>
34     <h3>Preparing the TestKit on Linux</h3>
35     <p>Linux is the easiest environment for running the TestKit, given that the
36       tests were built using the bash shell within a Linux environment.&nbsp; If
37       some of the packages used in the tests are missing (such as expect and gnu
38       awk), these may need to be installed from the appropriate repository for
39       your Linux distribution.&nbsp; Most distributions include these packages
40       automatically however.</p>
41     <h3> Preparing the TestKit on Mac OS X</h3>
42     <p>The test suite runs well on modern Macs with Intel CPUs.&nbsp; Due to
43       some differences in the versions of a few applications on the Mac, some
44       GNU tools may need to be installed to run the TestKit.&nbsp; These are
45       available via the Brew installer tool. <br>
46     </p>
47     <h3> </h3>
48     <h3> Preparing the TestKit on MS-Windows</h3>
49     <p>The Cygwin Unix emulation system is required to run the TestKit on
50       Windows.&nbsp; This package is available at: <a href="http://cygwin.com/install.html">http://cygwin.com/install.html</a></p>
51     <p>The default packages selected by Cygwin are the starting point of the
52       install.&nbsp; In addition to those packages, the following packages are
53       also required (see list below).&nbsp; Rather than using the cygwin setup
54       program for this task, the next section describes how to install Cygwin
55       with the apt-cyg tool.&nbsp; Apt-cyg is the preferred method, since it
56       involves less interaction with the somewhat clunky Cygwin installer.&nbsp;
57       If necessary, it is possible to install all the packages without apt-cyg
58       just by using the Cygwin setup program.&nbsp; To find each of these
59       packages more easily, try switching the “View” button on the Cygwin setup
60       program to “Full” to get an alphabetized list.</p>
61     <div style="border:solid windowtext 1.0pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;
62 background:#DDD9C3;margin-left:.1in;margin-right:.1in">
63       <p class="Code-Box" style="margin-top:6.0pt;margin-right:0in;margin-bottom:0in;
64 margin-left:0in;margin-bottom:.0001pt;background:#DDD9C3">bc <br>
65         crypt <br>
66         cygutils <br>
67         emacs <br>
68         email <br>
69         expect <br>
70         gcc-g++<br>
71         git <br>
72         gitk <br>
73         gvim <br>
74         inetutils <br>
75         less <br>
76         make <br>
77         mutt <br>
78         ncftp <br>
79         openssh <br>
80         perl <br>
81         procps<br>
82         python <br>
83         sharutils <br>
84         shutdown <br>
85         subversion <br>
86         time <br>
87         unzip <br>
88         util-linux <br>
89         vim<br>
90         wget<br>
91         xinit <br>
92         xterm <br>
93         zip </p>
94     </div>
95     <p>&nbsp;</p>
96     <h3>Apt-cyg Installation Process</h3>
97     <p>The apt-cyg program brings the convenience of the Debian and Ubuntu
98       installer application (apt-get) to Cygwin.&nbsp; This program does require
99       a couple of additional setup steps.&nbsp; This material is drawn from the
100       apt-cyg home page: <a href="https://github.com/transcode-open/apt-cyg">https://github.com/transcode-open/apt-cyg</a></p>
101     <p class="MsoListParagraphCxSpFirst" style="text-indent:-.25in">1.&nbsp;
102       Install the basic Cygwin packages with setup.exe (rather than the long
103       list above), but add these two packages which are not selected by default:</p>
104     <ul>
105       <li>subversion</li>
106       <li>wget</li>
107     </ul>
108     <p class="MsoListParagraphCxSpLast" style="text-indent:-.25in">2.&nbsp;&nbsp;
109       Download and install the apt-cyg program from within a Cygwin bash prompt:</p>
110     <div style="border:solid windowtext 1.0pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;
111 background:#DDD9C3;margin-left:.5in;margin-right:.1in">
112       <p class="Code-Box" style="margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
113 margin-left:0in;background:#DDD9C3">lynx -source
114         rawgit.com/transcode-open/apt-cyg/master/apt-cyg &gt; apt-cyg<br>
115         install apt-cyg /bin</p>
116     </div>
117     <p class="MsoListParagraph" style="text-indent:-.25in">3.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
118       Install the packages required for the TestKit:</p>
119     <div style="border:solid windowtext 1.0pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;
120 background:#DDD9C3;margin-left:.5in;margin-right:.1in">
121       <p class="Code-Box" style="margin-top:6.0pt;margin-right:0in;margin-bottom:0in;
122 margin-left:0in;margin-bottom:.0001pt;background:#DDD9C3">apt-cyg install bc
123         crypt cygutils emacs email expect gcc-g++ git gitk gvim \<br>
124         &nbsp; inetutils less make mutt ncftp openssh perl procps python
125         sharutils \<br>
126         &nbsp; shutdown time unzip util-linux vim xinit xterm zip</p>
127     </div>
128     <p class="MsoListParagraph" style="text-indent:-.25in">4.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
129       The installation will run for a while but then should conclude with all
130       required packages installed.</p>
131     <h2> Setting up a Test Suite</h2>
132     <p>Tunning tests in TestKit uses a configuration file called
133       “testkit.config” to define the environment and, optionally, which test
134       scripts to run.&nbsp; This file is the main switchboard that defines where
135       the tests will find users, home directories, queues, containers, and so
136       forth. &nbsp;The configuration file can be specified via the environment
137       variable “TESTKIT_CFG_FILE”.&nbsp; This variable can be set to any
138       location, enabling the configuration file to reside in a directory other
139       than the toolkit folder.&nbsp; If the variable is not defined, then the
140       testing config file defaults to “$TESTKIT_ROOT/testkit.config”.</p>
141     The TESTKIT_ROOT variable is frequently referred to in command
142     examples.&nbsp; It is set up automatically by the prepare_tools script (see
143     below).
144     <h2>Running a Test Suite</h2>
145     <p>Once the TestKit configuration file has been established, running a whole
146       test suite can be accomplished with this command:<br>
147     </p>
148     <div style="border:solid windowtext 1.0pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;
149 background:#DDD9C3;margin-left:.1in;margin-right:.1in">
150       <p class="Code-Box" style="margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
151 margin-left:0in;background:#DDD9C3">&nbsp;bash <i>{TESTKIT_FOLDER}</i>/test_driver.sh
152         </p> </div>
153     <p>Where the <i>{TESTKIT_FOLDER}</i> should be replaced with whatever path
154       the TestKit is stored in.</p>
155     <p>Alternatively, if the TESTKIT_ROOT folder is already established, the
156       tests can be run with:</p>
157     <div style="border:solid windowtext 1.0pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;
158 background:#DDD9C3;margin-left:.1in;margin-right:.1in">
159       <p class="Code-Box" style="margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
160 margin-left:0in;background:#DDD9C3">&nbsp;bash "$TESTKIT_ROOT/test_driver.sh"</p>
161     </div>
162     <p></p>
163     <h3> What to Expect From the Test Run</h3>
164     <p>The test_driver.sh script will output a few informative lines of text
165       before printing a table of the tests that it intends to run.</p>
166     <p>After the test plan is shown, all of the tests listed will be executed in
167       the order they are listed in, and they will each produce output.&nbsp;
168       Each individual test (usually a separate bash script) produces a summary
169       at the end of its run with a count of tests and a report of the tests
170       success or failure.</p>
171     <p>At the end of all the tests in the suite, the table of tests is printed
172       again with the results for each test.&nbsp; For example, this is a test
173       run that had no errors in any test (that's good, since it is our super
174       simple example test):</p>
175     <div style="border:solid windowtext 1.0pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;
176 background:#DDD9C3;margin-left:.1in;margin-right:.1in">$ cd
177       $FEISTY_MEOW_APEX/testkit<br>
178       $ ./test_driver.sh summary<br>
179       ===========================================================<br>
180       Testkit environment loaded.<br>
181       TESTKIT_ROOT=/opt/feistymeow.org/feisty_meow/testkit<br>
182       TESTKIT_CFG_FILE=/opt/feistymeow.org/feisty_meow/testkit/testkit.config<br>
183       TMP=/Users/fred/.tmp<br>
184       TEST_TEMP=/Users/fred/.tmp/testkit_logs_fred<br>
185       ===========================================================<br>
186       +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br>
187       TestKit running from: /opt/feistymeow.org/feisty_meow/testkit<br>
188       TestKit config file:
189       /opt/feistymeow.org/feisty_meow/testkit/testkit.config<br>
190       +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<br>
191       Full set of tests:<br>
192       1: /opt/feistymeow.org/feisty_meow/testkit/examples/blank_test.sh<br>
193       <br>
194       ======================================================================<br>
195       Wed Aug 12 14:11:00 EDT 2020: Now running test 1:
196       /opt/feistymeow.org/feisty_meow/testkit/examples/blank_test.sh<br>
197       &nbsp; Test output file:
198       /Users/fred/.tmp/testkit_logs_fred/run_2020_08_12/test_log.vKf7J3<br>
199       OK: successful test run for test
200       /opt/feistymeow.org/feisty_meow/testkit/examples/blank_test.sh<br>
201       <br>
202       <br>
203       Results table for this test run:<br>
204       <br>
205       01: OKAY -- /opt/feistymeow.org/feisty_meow/testkit/examples/blank_test.sh<br>
206       <br>
207       Total testing duration: 00:00 hh:mm (1 seconds total)<br>
208       OK: All 1 Tests Ran Successfully.<br>
209       <br>
210       <br>
211       <br>
212       <br>
213       dd<br>
214       <br>
215     </div>
216     <p class="Textbody">The above shows the "summary" view, which does not allow
217       the individual tests to output to the console.&nbsp; If the "summary" flag
218       is not passed, then the output from all the test runs is also shown.</p>
219     <p class="Textbody">Even when the summary view is used, all output files can
220       be examined after the run.&nbsp; For example, in the above, the mentioned
221       output file "test_log.vKf7J3" can be checked to see exactly what happened
222       during the test.</p>
223     <p class="Textbody">A test with a failure in it will have “FAIL” next to the
224       test that failed, and the final output line will start with
225       “FAILURE”.&nbsp; For example:</p>
226     <div style="border:solid windowtext 1.0pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;
227 background:#DDD9C3;margin-left:.1in;margin-right:.1in">
228       <p class="Code-Box" style="margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
229 margin-left:0in;background:#DDD9C3">01: FAIL –
230         AckPfft_Tests/Gorp_Tests/deslagToaster.sh<br>
231         02: OKAY – AckPfft_Tests/Gorp_Tests/spumeMerchantry.sh<br>
232         03: OKAY – AckPfft_Tests/Gorp_Tests/octopusLauncher.sh<br>
233         …<br>
234         22: OKAY -- Snargle_Tests/scramTests/scramForPetunias.sh</p>
235       <p class="Code-Box" style="margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
236 margin-left:0in;background:#DDD9C3">FAILURE: 1 Tests Failed out of 22 Tests.</p>
237     </div>
238     <p>A failed test will also return a non-zero value from the test execution,
239       enabling the run of a test suite to be tested for success when launched
240       externally, such as from a continuous integration system.</p>
241     <h2>Loading the TestKit Environment</h2>
242     <p>If one wishes to run individual tests within the test suite, rather than
243       the entire suite, this is done by loading the TestKit variables into the
244       current shell environment, like so:</p>
245     <div style="border:solid windowtext 1.0pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;
246 background:#DDD9C3;margin-left:.1in;margin-right:.1in">
247       <p class="Code-Box" style="margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
248 margin-left:0in;background:#DDD9C3">cd <i>{TESTKIT_FOLDER}</i>&nbsp; # replace
249         with actual location of TestKit.<br>
250         source prepare_tools.sh prepare_tools.sh<br>
251         source $TESTKIT_ROOT/library/process_configuration.sh<br>
252         define_and_export_variables</p>
253       # Show the important variables.<br>
254       var $TESTKIT_ROOT $TESTKIT_CFG_FILE</div>
255     <p>After loading the TestKit environment, one can execute a specific test
256       and see its results, for example:</p>
257     <div style="border:solid windowtext 1.0pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;background:#DDD9C3;margin-left:.1in;margin-right:.1in">
258       <p class="Code-Box" style="margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
259 margin-left:0in;background:#DDD9C3">cd examples<br>
260         bash blank_test.sh</p>
261     </div>
262     <p>The test will run and output its results to the console (that is, output
263       is sent to standard out and standard error, to be more precise).</p>
264     <p><br>
265     </p>
266     <h3></h3>
267   </body>
268 </html>