lib/Linux/Slackware/SystemTests.pm

filter: Statementstmt 52.9% 45 / 85 Branchbran 12.5% 5 / 40 Conditioncond 37.9% 11 / 29 MC/DCmcdc 5.8% 1 / 17 Subroutinesub 69.2% 9 / 13 Podpod 66.6% 4 / 6 totaltotal 39.4% 75 / 190 CC 33 SCAR 36.8
CC
33
Cov
40%
log
110.0
invoke_self_id
56.0
init_work_file
20.0
CRAP 39.6
↑ Summary blib/lib/Linux/Slackware/SystemTests/system_tests/test_template.pl »
1 package Linux::Slackware::SystemTests;
2  
3 # ABSTRACT: Helper class for Slacware Linux system test harness.
4  
5 # Encapsulates data and methods intended to be used by:
6 # * the systests/*.t scripts
7 # * the bin/slackware-systemtests test harness
8  
9 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 1 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 1 ▶use File::Valet;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 1 ▶use Time::HiRes;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 1 ▶use vars qw(@EXPORT @EXPORT_OK @ISA $VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 1 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 require Exporter;
18 1 @ISA = qw(Exporter);
19 1 $VERSION = '1.00';
20 1 @EXPORT = @EXPORT_OK = qw(); # zzapp -- do we want to export anything?
21 }
22  
23 1 ▶sub new {
Subroutine new: called CC=12 SCAR=27.3
Pod documented
24 1 my ($class, %opt_hr) = @_;
25 1 my $self = {
26 opt_hr => \%opt_hr, # Anything the caller passes in gets stashed here so $self->opt() can be used to look it up later.
27 ok => 'OK',
28 n_err => 0,
29 n_warn => 0,
30 n_fail => 0,
31 n_pass => 0,
32 err => '',
33 err_ar => [],
34 me => 'Linux::Slackware::SystemTests',
35 js_or => JSON->new->ascii->allow_nonref->space_after()
36 };
37 1 bless ($self, $class);
38  
39 1 foreach my $k0 (keys %{$self->{opt_hr}}) {
40 2 my $k1 = join('_', split(/-/, $k0));
41 2 ▶ next if ($k0 eq $k1);
Branch: 1 branch
BranchTrueFalseTotal
if $k0 eq $k1 1 1 2
42 1 $self->{opt_hr}->{$k1} = $self->{opt_hr}->{$k0};
43 1 delete $self->{opt_hr}->{$k0};
44 }
45  
46 # I was told File::ShareDir was The Answer, but that breaks when running out of the development directory, so reverting to the ugly hack:
47 1 ▶ my $st_dir = $1 if ($INC{'Linux/Slackware/SystemTests.pm'} =~ /(.+?)\.pm$/);
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"Linux/Slackware/SystemTests.pm"} =~ /(.+?)\.pm$/ 1 0 1
48 1 ▶ $self->{share_dir} = $self->opt('share_dir') // $st_dir;
Condition33%1/3
$self->opt("share_dir") // $st_dir
l!l&&r!l&&!r
010
MC/DC0%0/2
$self->opt("share_dir") // $st_dir
$self->opt("share_dir") $st_dir
Truth table33%1/3
A // B
A= $self->opt("share_dir")B= $st_dir
ABresult
1X1
011
000
49 1 ▶ die "need to specify non-undef share_dir because INC of self is not parseable" unless(defined($self->{share_dir})); # zzapp ick .. how to better word that?
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"share_dir"} 0 1 1
50  
51 1 ▶ $self->{temp_dir} = $self->opt('temp_dir') // File::Valet::find_temp();
Condition33%1/3
$self->opt("temp_dir") // File::Valet::find_temp()
l!l&&r!l&&!r
010
MC/DC0%0/2
$self->opt("temp_dir") // File::Valet::find_temp()
$self->opt("temp_dir") File::Valet::find_temp()
Truth table33%1/3
A // B
A= $self->opt("temp_dir")B= File::Valet::find_temp()
ABresult
1X1
011
000
52 1 ▶ die "need to specify non-undef temp_dir because File::Valet::find_temp cannot find one" unless(defined($self->{temp_dir})); # zzapp ick .. how to better word that?
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"temp_dir"} 0 1 1
53  
54 1 ▶ $self->{tests_dir} = $self->opt('tests_dir') // "$self->{share_dir}/system_tests";
Condition50%1/2
$self->opt("tests_dir") // qq[$self->{"share_dir"}/system_tests]
l!l
01
MC/DC0%0/1
$self->opt("tests_dir") // qq[$self->{"share_dir"}/system_tests]
$self->opt("tests_dir")
Truth table50%1/2
A
A= $self->opt("tests_dir")
Aresult
11
00
55 1 ▶ $self->{data_dir} = $self->opt('data_dir') // "$self->{share_dir}/system_test_data";
Condition50%1/2
$self->opt("data_dir") // qq[$self->{"share_dir"}/system_test_data]
l!l
01
MC/DC0%0/1
$self->opt("data_dir") // qq[$self->{"share_dir"}/system_test_data]
$self->opt("data_dir")
Truth table50%1/2
A
A= $self->opt("data_dir")
Aresult
11
00
56 1 ▶ $self->{bin_dir} = $self->opt('bin_dir') // "$self->{share_dir}/bin";
Condition50%1/2
$self->opt("bin_dir") // qq[$self->{"share_dir"}/bin]
l!l
01
MC/DC0%0/1
$self->opt("bin_dir") // qq[$self->{"share_dir"}/bin]
$self->opt("bin_dir")
Truth table50%1/2
A
A= $self->opt("bin_dir")
Aresult
11
00
57 1 ▶ $self->{sys_hr} = $self->opt('self_id') // $self->invoke_self_id();
Condition33%1/3
$self->opt("self_id") // $self->invoke_self_id
l!l&&r!l&&!r
100
MC/DC0%0/2
$self->opt("self_id") // $self->invoke_self_id
$self->opt("self_id") $self->invoke_self_id
Truth table33%1/3
A // B
A= $self->opt("self_id")B= $self->invoke_self_id
ABresult
1X1
011
000
58  
59 1 return $self;
60 }
61  
62 0 ▶sub invoke_self_id {
Subroutine invoke_self_id: not called CC=7 SCAR=40.3
Pod undocumented
63 0 my ($self) = @_;
64 0 my $filename = $self->opt('self_id_cache_pathname','/tmp/self_id.dat');
65  
66 0 my $id_txt;
67  
68 0 ▶ if (-e $filename && (stat($filename))[9] > time() - 8 * 3600) {
Branch: 1 branch
BranchTrueFalseTotal
if (-e $filename and (stat $filename)[9] > time - 28800) { } 0 0 0
Condition0%0/3
-e $filename and (stat $filename)[9] > time - 28800
!ll&&!rl&&r
000
MC/DC0%0/2
-e $filename and (stat $filename)[9] > time - 28800
-e $filename (stat $filename)[9] > time - 28800
Truth table0%0/3
A and B
A= -e $filenameB= (stat $filename)[9] > time - 28800
ABresult
0X0
100
111
69 0 $id_txt = rd_f($filename);
70 0 ▶ die "unable to read self-id cache file $filename ($File::Valet::ERROR)\n" unless (defined($id_txt));
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id_txt 0 0 0
71 } else {
72 0 unlink($filename);
73 0 ▶ die "Expired self-id cache file $filename exists and cannot be removed, which is likely a permissions issue. Please remove, rename or chmod it and try again.\n" if (-e $filename);
Branch: 1 branch
BranchTrueFalseTotal
if -e $filename 0 0 0
74 0 my $self_id_bin = "$self->{bin_dir}/self-id";
75 0 ▶ die "self-id executable is missing from $self_id_bin" unless (-e $self_id_bin);
Branch: 1 branch
BranchTrueFalseTotal
unless -e $self_id_bin 0 0 0
76 0 ▶ die "self-id executable is not executable at $self_id_bin" unless (-x $self_id_bin);
Branch: 1 branch
BranchTrueFalseTotal
unless -x $self_id_bin 0 0 0
77 0 $id_txt = `$self_id_bin`; # zzapp -- yeah yeah, really should use IPC::Open3 or somesuch here
78 0 wr_f($filename, $id_txt); # zzapp -- check for errors
79 }
80  
81 # zzapp -- check $id_txt for well-formedness, validate eval()'s output, rethrow any caught exceptions.
82 0 return eval($id_txt);
83 }
84  
85 0 ▶sub log {
Subroutine log: not called CC=10 SCAR=47.0
Pod documented
86 0 my ($self, $mode, @errs) = @_;
87 0 ▶ return if ($mode eq 'DEBUG' && !$self->opt('debug',0));
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "DEBUG" and not $self->opt("debug", 0) 0 0 0
Condition0%0/3
$mode eq "DEBUG" and not $self->opt("debug", 0)
!ll&&!rl&&r
000
MC/DC0%0/2
$mode eq "DEBUG" and not $self->opt("debug", 0)
$mode eq "DEBUG" not $self->opt("debug", 0)
Truth table0%0/3
A and not(B)
A= $mode eq "DEBUG"B= not $self->opt("debug", 0)
ABresult
0X0
100
111
88 0 ▶ my $err_js = $self->{js_or}->encode(\@errs) if ($self->opt('show_log',0));
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt("show_log", 0) 0 0 0
89 0 my $tm = Time::HiRes::time();
90 0 my $lt = localtime();
91 0 ▶ print STDERR "$tm $lt $$\t$mode\t$err_js\n" if ($self->opt('show_log',0));
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt("show_log", 0) 0 0 0
92 0 ▶ ap_f($self->opt('log_filename','/tmp/st.log'), $self->{js_or}->encode([$mode, $tm, $lt, $$, \@errs])) if ($self->opt('log',1));
Branch: 1 branch
BranchTrueFalseTotal
if $self->opt("log", 1) 0 0 0
93 0 ▶ $self->{n_err}++ if ($mode eq 'ERROR');
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "ERROR" 0 0 0
94 0 ▶ $self->{n_warn}++ if ($mode eq 'WARNING');
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "WARNING" 0 0 0
95 0 ▶ $self->{n_fail}++ if ($mode eq 'FAIL');
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "FAIL" 0 0 0
96 0 ▶ $self->{n_pass}++ if ($mode eq 'PASS');
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "PASS" 0 0 0
97 0 return;
98 }
99  
100 0 ▶sub init_work_file {
Subroutine init_work_file: not called CC=4 SCAR=30.0
Pod documented
101 0 my ($self, $filename) = @_;
102 0 my $subject_file = "$self->{data_dir}/$filename";
103 0 my $target_file = "$self->{temp_dir}/$filename";
104 0 ▶ return ('ERROR', "no such file $subject_file") unless (-e $subject_file);
Branch: 1 branch
BranchTrueFalseTotal
unless -e $subject_file 0 0 0
105 0 unlink($target_file);
106 0 ▶ return ('ERROR', "failed to remove left over turd file $target_file") if (-e $target_file);
Branch: 1 branch
BranchTrueFalseTotal
if -e $target_file 0 0 0
107 0 my $ok = wr_f($target_file, rd_f($subject_file));
108 0 ▶ return ('ERROR', "failed to copy $subject_file to $target_file ($File::Valet::ERROR)") unless ($ok);
Branch: 1 branch
BranchTrueFalseTotal
unless $ok 0 0 0
109 0 return ('OK', $target_file);
110 }
111  
112 0 ▶sub all_is_well {
Subroutine all_is_well: not called CC=1 SCAR=6.9
Pod undocumented
113 0 my ($self) = @_;
114 0 $self->{ok} = 'OK';
115 0 $self->{err} = '';
116 0 $self->{err_ar} = [];
117 0 return;
118 }
119  
120 6 ▶sub opt {
Subroutine opt: called CC=4 SCAR=14.6
Pod documented
121 6 my ($self, $name, $default_value, $alt_hr) = @_;
122 6 ▶ $alt_hr //= {};
Condition50%1/2
$alt_hr //= {}
l!l
06
MC/DC0%0/1
$alt_hr //= {}
$alt_hr
Truth table50%1/2
A
A= $alt_hr
Aresult
11
00
123 6 ▶ return $self->{opt_hr}->{$name} // $alt_hr->{$name} // $default_value;
Condition66%4/6
($self->{"opt_hr"}{$name} // $alt_hr->{$name}) // $default_value
l!l&&r!l&&!r
105
$self->{"opt_hr"}{$name} // $alt_hr->{$name}
l!l&&r!l&&!r
105
MC/DC33%1/3
($self->{"opt_hr"}{$name} // $alt_hr->{$name}) // $default_value
$self->{"opt_hr"}{$name} $alt_hr->{$name} $default_value
Truth table50%2/4
A // B // C
A= $self->{"opt_hr"}{$name}B= $alt_hr->{$name}C= $default_value
ABCresult
1XX1
01X1
0011
0000
124 }
125  
126 1 1;
127  
128 =head1 NAME
129  
130 Linux::Slackware::SystemTests - System tests for Slackware Linux
131  
132 =head1 SYNOPSIS
133  
134 # If you just want to -run- system tests, invoke the slackware-systemtests
135 # test harness and stop reading this document:
136  
137 $ slackware-systemtests
138  
139 # If you are -writing- system tests, use an instance to get useful tools:
140  
141 use Linux::Slackware::SystemTests;
142 my $st = Linux::Slackware::SystemTests->new();
143  
144 # Copy a data file from wherever they are installed to a temp directory so
145 # it can be modified:
146  
147 my ($ok, $file_pathname) = $st->init_work_file("001_sed.1.txt");
148  
149 # $st->{sys_hr} provides useful details about the system being tested, so
150 # you can change the test depending on what version of Slackware is being
151 # tested, or 32-vs-64-bit, etc:
152  
153 if ($st->{sys_hr}->{version} eq "14.2") {
154 # run test for just the Slackware 14.2 release
155 }
156 if ($st->{sys_hr}->{bits} eq "64") {
157 # run test specific to 64-bit Slackware
158 }
159  
160 # If you need to JSONify something, there's already a JSON object
161 # instantiated with sane and robust operating parameters:
162  
163 ok `/bin/uname -a` =~ /CPU \@ ([\d\.]+)GHz (\w+)/, "processor is ".$st->{js_or}->encode([$1, $2]);
164  
165 # If you need to know where the test data files are installed, $st knows:
166  
167 my $data_pathname = "$st->{data_dir}/some_test_file.txt";
168  
169 # If you want to log structured data to a file, that can be done too:
170 $st->log("WARNING", "Something not quite right with environment", \%ENV);
171  
172 # Alternatively, if your test needs none of these things, you don't have to
173 # use this module at all! Any test that produces TAP output should jfw.
174  
175 =head1 DESCRIPTION
176  
177 L<System tests|https://en.wikipedia.org/wiki/System_testing> are are short programs which exercise components of your
178 computer system and make sure they are running correctly.
179  
180 This package implements tests for L<Slackware Linux|http://distrowatch.com/table.php?distribution=slackware> systems,
181 and a test harness for running them and generating reports.
182  
183 This module provides maybe-useful functionality for making those tests easier to write, and for helping to write test
184 harnesses.
185  
186 The eventual goal is to accumulate enough tests that when Slackware updates, you can just re-run the system tests and
187 know that everything works okay. Some sort of continuous integration automation might also happen, eventually.
188  
189 Another goal is to make it easy to write new system tests, to keep the barrier of entry low. There is a lot to test
190 in a full Slackware install, so please write tests and share them with the author :-)
191  
192 =head1 USING THE MODULE
193  
194 The Linux::Slackware::SystemTests module provides some data and methods which may or may not be useful to you.
195  
196 If you do not find them useful, don't use the module! :-) System tests do not require the module. It's just there
197 to make your life easier, if you need it.
198  
199 =head2 METHODS
200  
201 =head3 my $st = Linux::Slackware::SystemTests-E<gt>new(%options)
202  
203 Instantiates a new Linux::Slackware::SystemTests object. Lacking options, sane defaults are assumed.
204  
205 Supported options are:
206  
207 =over 4
208  
209 =item temp_dir => (path string)
210  
211 Set this to override C<$st-E<gt>{temp_dir}>, which changes the behavior of the C<init_work_file> and C<invoke_self_id> methods.
212  
213 When this option is not provided, an appropriate temporary directory will be found via C<File::Valet::find_temp>.
214  
215 Some sane values to pass here might be "/tmp" or "/dev/shm".
216  
217 =item debug => (0 or 1)
218  
219 When true (1), invoking C<$st-E<gt>log> with a mode of "DEBUG" will be silently ignored.
220  
221 When false (0), "DEBUG" mode logging messages will be written to the log file.
222  
223 Defaults to false (0).
224  
225 =item log_filename => (pathname string)
226  
227 Sets the pathname of the structured data log file written to by C<$st-E<gt>log>. Defaults to "/tmp/st.log".
228  
229 =item show_log => (0 or 1)
230  
231 When true (1), invoking C<$st-E<gt>log> will cause a human-friendly representation of the log record to be written to C<STDOUT>.
232  
233 When false (0), no log records will be displayed.
234  
235 Defaults to false (0).
236  
237 =item log => (0 or 1)
238  
239 When true (1), invoking C<$st-E<gt>log> will cause log messages to be written to the logile.
240  
241 When false (0), no log records will be written to file, but might still be written to C<STDOUT> if C<show_log> is set.
242  
243 Defaults to true (1).
244  
245 =item share_dir => (path string)
246  
247 Set this to override C<$st-E<gt>{share_dir}>, the base directory from which C<data_dir>, C<bin_dir>, C<tests_dir> are derived. Mostly useful for mocking purposes.
248  
249 =item data_dir => (path string)
250  
251 Set this to override C<$st-E<gt>{data_dir}>, where the test data files are stored. Mostly useful for mocking purposes.
252  
253 =item tests_dir => (path string)
254  
255 Set this to override C<$st-E<gt>{tests_dir}>, where the system test executables are stored. Mostly useful for mocking purposes.
256  
257 =item bin_dir => (path string)
258  
259 Set this to override C<$st-E<gt>{bin_dir}>, where the module's private executables are stored. Mostly useful for mocking purposes.
260  
261 =item self_id => (hash reference)
262  
263 Set this to override C<$st-E<gt>{sys_hr}>. Mostly useful for mocking purposes.
264  
265 When this option is not provided, a C<self-id> script will be run which figures out various details about the local system.
266  
267 =back
268  
269 =head3 $st-E<gt>log(MODE, DESCRIPTION[, structured data ...])
270  
271 Writes a JSON record to a structured data log file, and optionally to STDOUT as well.
272  
273 =over 4
274  
275 =item MODE
276  
277 Should be one of "DEBUG", "ERROR", "WARNING", "FAIL", or "PASS".
278  
279 =item DESCRIPTION
280  
281 Should be an B<invariant> string (without any variables interpolated into it). Using an invariant makes possible a full enumeration of log record types, which is important for log collation.
282  
283 =item structured data
284  
285 Can be any number of arbitrarily complex data elements. Elements not able to be represented by the C<JSON> module will instead be represented as C<nil>. This includes code refs, glob refs and regex refs.
286  
287 Each JSON record is newline-terminated, and contains the following fields:
288  
289 [MODE, EPOCH_TIME, LOCAL_TIME, PID, DESCRIPTION, structured data ...]
290  
291 The C<MODE>, C<DESCRIPTION> and C<structured data> fields will be the JSON representations of the C<$st-E<gt>log> parameters.
292  
293 The C<EPOCH_TIME> field will be a floating point representation of the epoch time at which the log record was created.
294  
295 The C<LOCAL_TIME> field will be a human-readable representation of C<EPOCH_TIME> in the local timezone.
296  
297 The C<PID> field will be the process identifier of the process which created the log record.
298  
299 For instance, the following C<log> call:
300  
301 $st->log("WARNING", "skipped some tests", {name => "ichi", why => "ploo"}, {name => "ni", why => "glom"}, [1, 2, 3, {foo => "bar"}])
302  
303 .. would append something like the following JSON to the logfile:
304  
305 ["WARNING", 1470253241.25485, "Wed Aug 3 12:40:41 2016", 1472, "skipped some tests", {"name": "ichi", "why": "ploo"}, {"name": "ichi", "why": "glom"}, [1, 2, 3, {"foo": "bar"}]]
306  
307 Furthermore, if the C<show_log> parameter was set when C<$st> was instantiated, the following would be printed to STDOUT:
308  
309 1470253241.25485 Wed Aug 3 12:40:41 2016 1472\tWARNING\t["skipped some tests", {"name": "ichi", "why": "ploo"}, {"name": "ichi", "why": "glom"}, [1, 2, 3, {"foo": "bar"}]]
310  
311 =back
312  
313 =head3 ($ok, $pathname) = $st->init_work_file("314_some_test_file.txt")
314  
315 When the module is installed, it is usually stored as read-only data in some obscure corner of the filesystem. This is inconvenient when a test requires a data file which is writable.
316  
317 Rather than forcing each test author to come up with a way to find the data and copy it to a temporary directory (which might not exist on the system), C<init_work_file> is provided to do the work for them.
318  
319 C<init_work_file> will find the data file, find a temporary directory, delete any old files left over from a previous run, copy the file and return ('OK', $pathname) where $pathname is the full pathname of the copied file.
320  
321 If it encounters any errors at any point in the process, it will return ('ERROR', $description) where $description describes what failed and (maybe) why.
322  
323 If a copy of the file is not required, and a test only needs the full pathname of a data file for reading, use C<$st-E<gt>{data_dir}> instead, like so:
324  
325 my $full_pathname = "$st->{data_dir}/314_some_test_file.txt";
326  
327 =head3 $st->opt(OPTION_NAME[, DEFAULT_VALUE[, ALTERNATIVE_HASHREF]])
328  
329 $st->opt("log")
330 $st->opt("log", 0)
331 $st->opt("log", 0, $alt_hr)
332  
333 Fetches an option field from the object's instantiation parameters.
334  
335 C<opt> will look in C<$st-E<gt>{opt_hr}-E<gt>{OPTION_NAME}> first. If not present there,
336 it will look in C<$alt_hr-E<gt>{OPTION_NAME}> if an C<$alt_hr> parameter was provided.
337  
338 If no option by that name is found anywhere, C<opt> will return C<DEFAULT_VALUE> (0 in the above examples), or C<undef> if no default is provided.
339  
340 =head2 WRITING SYSTEM TESTS
341  
342 System tests can be very simple or as complicated as necessary. They may be written in
343 any language, although /bin/sh and perl are encouraged.
344  
345 The only hard requirement is that they generate their output in L<Test Anything
346 Protocol|http://testanything.org/>, which is pretty easy. TAP libraries are available
347 for most languages.
348  
349 Tests should be executable files located in C<lib/Linux/Slackware/SystemTests/system_tests/> with a C<.t> filename suffix. All such files will be executed by running the C<slackware-system-test> script.
350  
351 =head3 WRITING SYSTEM TESTS IN PERL
352  
353 Writing tests in perl is easy. Just copy C<lib/Linux/Slackware/SystemTests/system_tests/test_template.pl> to a new file (like C<123_my_test.t>) and edit the new file to add your test logic. There are some goodies in C<test_template.pl> (like object instantiation) which are commented out. Uncomment them if you need them.
354  
355 C<test_template.pl> uses L<Test::Most|https://metacpan.org/pod/Test::Most>, but feel free to use any of the other TAP-compliant test modules, such as L<Test::More|https://metacpan.org/pod/Test::More> or L<Test2|https://metacpan.org/pod/Test2>.
356  
357 If you have never written tests for perl before, read the L<Test::Most|https://metacpan.org/pod/Test::Most> documentation and look at the other C<.t> files in the C<system_tests> directory to get a notion.
358  
359 The skinny of it is, C<Test::Most> provides functions like C<ok> and C<is>, to which you pass the results of your tests of system correctness, and it represents those results in TAP format. For instance:
360  
361 ok `lsmod 2>\&1` =~ /ipv6/, "IPv6 module is loaded"
362  
363 .. which displays C<ok 1 - IPv6 module is loaded> or C<not ok 1 - IPv6 module is loaded> depending on the results of the expression.
364  
365 Also feel free to hop onto the C<#perl> IRC channel on C<irc.freenode.org> to ask for help. The good folks there are very enthusiastic about good tests. Just don't take mst's brisk manner personally. He means well.
366  
367 =head3 WRITING SYSTEM TESTS IN BASH
368  
369 Work in progress. More here later.
370  
371 I'm still figuring this out. There is a TAP implementation for bash L<test-more-bash|https://github.com/ingydotnet/test-more-bash> which might be appropriate, but I'm still assessing it.
372  
373 If that doesn't work out, I'll teach C<slackware-system-test> to accept C<*.sh.t> tests which signal pass/fail with an exit code, and drop the TAP requirement. The priority is to get more tests written, and barriers will be lowered to make that happen.
374  
375 =head3 WRITING SYSTEM TESTS IN OTHER LANGUAGES
376  
377 Work in progress. More here later.
378  
379 L<Test Anything Protocol|http://testanything.org/> claims TAP libraries are available for C, C++, Python, PHP, Perl, Java, JavaScript, "and others", which means whatever programming language you like to use, you can likely use it to write system tests.
380  
381 The only stipulation is that the code should jfw using software that ships with stock Slackware. Since C<gcc> and C<g++> are part of Slackware, C and C++ are fine, but Oracle's JVM does not. That means unless your test works with C<gcc-java>, Java is off the table.
382  
383 =head2 RUNNING SYSTEM TESTS
384  
385 At the moment, the test harness is extremely simple. More features will come. The main priority is getting more tests written.
386  
387 For the moment, invoking C<slackware-system-test> without parameters will cause it to run all of the C<*.t> executables in C<system_tests>, display their pathnames, and display only those tests which fail.
388  
389 Invoking C<slackware-system-test> with arguments will treat those arguments as regex patterns which will be applied to the names of the C<*.t> executables in C<system_tests>, and only those which match will be executed.
390  
391 Thus if C<system_tests> contains tests C<123_ichi.t>, C<234_ni.t> and C<345_san.t>, running C<slackware-system-test s> will cause only C<345_san.t> to run, while running C<slackware-system-test i> will cause only C<123_ichi.t> and C<234_ni.t> to run.
392  
393 Alternatively, to run specific system tests, invoke them directly:
394  
395 $ lib/Linux/Slackware/SystemTests/system_tests/001_sed.t
396  
397 Near future plans include a C<--retry> option which only runs tests which failed in the previous invocation and some sort of html report output.
398  
399 Far future plans include continuous integration automation, so that new releases of Slackware can be installed to a VM and tested, and test results made available as a web page.
400  
401 =head1 SEE ALSO
402  
403 The L<Linux Testing Project|https://linux-test-project.github.io/> which does not work under Slackware and has more of a kernel focus.
404  
405 =head1 CONTACTS AND RESOURCES
406  
407 Github page L<https://github.com/ttkciar/linux-slackware-systemtests|https://github.com/ttkciar/linux-slackware-systemtests> is the official project site. Submit bug reports and pull requests there (or just email TTK).
408  
409 Channel C<##slackware> on irc.freenode.net, for Slackware-related questions
410  
411 Channel C<#perl> on irc.freenode.net, for Perl-related questions
412  
413 =head1 AUTHORS
414  
415 Contribute some system tests and get yourself added to this list!
416  
417 TTK Ciar, C<ttk@ciar.org>
418  
419 =head1 COPYRIGHT AND LICENSE
420  
421 Copyright (C) 2016, TTK Ciar and others.
422  
423 This program is free software, you can redistribute it and/or modify it under
424 the terms of Perl itself.
425  
426 =cut
↑ Summary blib/lib/Linux/Slackware/SystemTests/system_tests/test_template.pl »