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