1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129
|
#!/usr/bin/perl -w
########################################################################
# Copyright 2004 by Malcolm Nooning
# This program does not impose any
# licensing restrictions on files generated by their execution, in
# accordance with the 8th article of the Artistic License:
#
# "Aggregation of this Package with a commercial distribution is
# always permitted provided that the use of this Package is embedded;
# that is, when no overt attempt is made to make this Package's
# interfaces visible to the end user of the commercial distribution.
# Such use shall not be construed as a distribution of this Package."
#
# Therefore, you are absolutely free to place any license on the resulting
# executable(s), as long as the packed 3rd-party libraries are also available
# under the Artistic License.
#
# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.
#
# See L<http://www.perl.com/perl/misc/Artistic.html>
#
##
########################################################################
our $VERSION = '0.07';
########################################################################
my $TRUE = 1;
my $FALSE = 0;
#########################################################################
########################################################################
# Usage:
# $error =
# test_in_further_subdir(
# $test_number,
# $sub_test,
# $test_name_string,
# $test_dir,
# $further_subdir, # e.g. $SUBDIR1, 2, 3 or 4
# $command_string, # e.g. "pp -I", or maybe empty ""
# $executable_name, # e.g. $a_default_executable
# $expected_result, # e.g. "hello"
# $os,
# $verbose,
# \$message,
# );
#
# $error will be one of POSIX (EXIT_SUCCESS EXIT_FAILURE)
#
########################################################################
# Outline
# -------
# . Copy the executable to a different subdirectory
# . chdir to the new subdirectory
# . Pipe executable and collect the result.
# . Compare the result with the expected result.
# . Report back success or failure.
########################################################################
#
package test_in_further_subdir;
use Exporter;
@ISA = qw(Exporter);
@EXPORT = ("test_in_further_subdir");
use POSIX qw(EXIT_SUCCESS EXIT_FAILURE);
use File::Copy;
use Cwd qw(chdir);
use pipe_a_command;
use strict;
########################################################################
sub test_in_further_subdir {
my (
$test_number,
$sub_test,
$test_name_string,
$test_dir,
$further_subdir,
$command_string,
$executable_name,
$expected_result,
$os,
$verbose,
$message_ref,
$print_cannot_locate_message,
) = @_;
my $final_subdir = "";
my $final_executable = "";
my $results_copied = "";
my $error = EXIT_FAILURE;
#.................................................................
# Copy created executable to a different directory and make sure
# it executes from there.
$final_subdir = $test_dir . "/$further_subdir";
$final_executable = $final_subdir . "/$executable_name";
if(!(copy("$executable_name", "$final_executable"))) {
$$message_ref = "\n\[300\]sub $test_name_string: " .
"cannot copy $executable_name to $final_subdir\n";
return (EXIT_FAILURE);
}
#.................................................................
$error = pipe_a_command(
$test_number,
$sub_test,
$test_name_string,
$final_subdir,
$command_string,
$executable_name,
$expected_result,
$os,
$verbose,
$message_ref,
$print_cannot_locate_message,
);
#.................................................................
return ($error);
#.................................................................
}
|