3 <meta http-equiv="content-type" content="text/html; charset=utf-8">
4 <title>TestKit Reference Manual</title>
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. TestKit provides a pattern for creating test
12 suites using a simple configuration file approach. 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. 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>
22 <h2> Getting the TestKit</h2>
23 <p>Follow these steps to download and install the Feisty Meow TestKit:<br>
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>
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. 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. 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. 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. These are
45 available via the Brew installer tool. <br>
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. 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. In addition to those packages, the following packages are
53 also required (see list below). 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. Apt-cyg is the preferred method, since it
56 involves less interaction with the somewhat clunky Cygwin installer.
57 If necessary, it is possible to install all the packages without apt-cyg
58 just by using the Cygwin setup program. 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>
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. This program does require
99 a couple of additional setup steps. 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.
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>
108 <p class="MsoListParagraphCxSpLast" style="text-indent:-.25in">2.
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 > apt-cyg<br>
115 install apt-cyg /bin</p>
117 <p class="MsoListParagraph" style="text-indent:-.25in">3.
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 inetutils less make mutt ncftp openssh perl procps python
126 shutdown time unzip util-linux vim xinit xterm zip</p>
128 <p class="MsoListParagraph" style="text-indent:-.25in">4.
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. This file is the main switchboard that defines where
135 the tests will find users, home directories, queues, containers, and so
136 forth. The configuration file can be specified via the environment
137 variable “TESTKIT_CFG_FILE”. This variable can be set to any
138 location, enabling the configuration file to reside in a directory other
139 than the toolkit folder. 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. It is set up automatically by the prepare_tools script (see
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>
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"> bash <i>{TESTKIT_FOLDER}</i>/test_driver.sh
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"> bash "$TESTKIT_ROOT/test_driver.sh"</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.
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. 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>
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>
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 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>
203 Results table for this test run:<br>
205 01: OKAY -- /opt/feistymeow.org/feisty_meow/testkit/examples/blank_test.sh<br>
207 Total testing duration: 00:00 hh:mm (1 seconds total)<br>
208 OK: All 1 Tests Ran Successfully.<br>
210 <p class="Textbody">The above shows the "summary" view, which does not allow
211 the individual tests to output to the console. If the "summary" flag
212 is not passed, then the output from all the test runs is also shown.</p>
213 <p class="Textbody">Even when the summary view is used, all output files can
214 be examined after the run. For example, in the above, the mentioned
215 output file "test_log.vKf7J3" can be checked to see exactly what happened
217 <p class="Textbody">A test with a failure in it will have “FAIL” next to the
218 test that failed, and the final output line will start with
219 “FAILURE”. For example:</p>
220 <div style="border:solid windowtext 1.0pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;
221 background:#DDD9C3;margin-left:.1in;margin-right:.1in">
222 <p class="Code-Box" style="margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
223 margin-left:0in;background:#DDD9C3">01: FAIL –
224 AckPfft_Tests/Gorp_Tests/deslagToaster.sh<br>
225 02: OKAY – AckPfft_Tests/Gorp_Tests/spumeMerchantry.sh<br>
226 03: OKAY – AckPfft_Tests/Gorp_Tests/octopusLauncher.sh<br>
228 22: OKAY -- Snargle_Tests/scramTests/scramForPetunias.sh</p>
229 <p class="Code-Box" style="margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
230 margin-left:0in;background:#DDD9C3">FAILURE: 1 Tests Failed out of 22 Tests.</p>
232 <p>A failed test will also return a non-zero value from the test execution,
233 enabling the run of a test suite to be tested for success when launched
234 externally, such as from a continuous integration system.</p>
235 <h2>Loading the TestKit Environment</h2>
236 <p>If one wishes to run individual tests within the test suite, rather than
237 the entire suite, this is done by loading the TestKit variables into the
238 current shell environment, like so:</p>
239 <div style="border:solid windowtext 1.0pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;
240 background:#DDD9C3;margin-left:.1in;margin-right:.1in">
241 <p class="Code-Box" style="margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
242 margin-left:0in;background:#DDD9C3">cd <i>{TESTKIT_FOLDER}</i> # replace
243 with actual location of TestKit.<br>
244 source prepare_tools.sh prepare_tools.sh<br>
245 source $TESTKIT_ROOT/library/process_configuration.sh<br>
246 define_and_export_variables</p>
247 # Show the important variables.<br>
248 var $TESTKIT_ROOT $TESTKIT_CFG_FILE</div>
249 <p>After loading the TestKit environment, one can execute a specific test
250 and see its results, for example:</p>
251 <div style="border:solid windowtext 1.0pt;padding:1.0pt 4.0pt 1.0pt 4.0pt;background:#DDD9C3;margin-left:.1in;margin-right:.1in">
252 <p class="Code-Box" style="margin-top:6.0pt;margin-right:0in;margin-bottom:6.0pt;
253 margin-left:0in;background:#DDD9C3">cd examples<br>
254 bash blank_test.sh</p>
256 <p>The test will run and output its results to the console (that is, output
257 is sent to standard out and standard error, to be more precise).</p>