Subversion Repositories DevTools

Rev

Rev 5709 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
392 dpurdie 1
########################################################################
6177 dpurdie 2
# COPYRIGHT - VIX IP PTY LTD ("VIX"). ALL RIGHTS RESERVED.
392 dpurdie 3
#
4
# Module name   : jats.sh
5
# Module type   : Makefile system
6
# Compiler(s)   : n/a
7
# Environment(s): jats
8
#
9
# Description   : JATS Make Time Test Harness Support
10
#                 This package contains fucntions that will be used by JATS
11
#                 to invoke the tests.
12
#
13
#                 This is more powerful that the previous shell-based solution
14
#                 that had problems under windows.
15
#
16
#                 The functions are designed to be invoked as:
17
#                   $(GBE_PERL) -Mjats_runtest -e <function> -- <args>+
18
#
19
#                 The functions in this packages are designed to take parameters
20
#                 from @ARVG as this makes the interface easier to read.
21
#
22
#......................................................................#
23
 
24
require 5.006_001;
25
use strict;
26
use warnings;
27
 
28
package jats_runtest;
29
 
30
our (@ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS, $VERSION);
31
use Exporter;
32
use JatsError qw(:name=jats_runtest);
33
use Pod::Usage;                             # For help support
34
use JatsSystem;
35
#use JatsEnv;
36
use Getopt::Long;
37
use FileUtils;
38
 
39
$VERSION = 1.00;
40
@ISA = qw(Exporter);
41
 
42
# Symbols to autoexport (:DEFAULT tag)
43
@EXPORT = qw( runtest
44
            );
45
 
46
#use File::Path qw(rmtree);
47
 
48
BEGIN
49
{
50
    print "-------jats_runtest initiated\n";
51
}
52
 
53
#
54
#   Options
55
#
56
my $opt_debug   = $ENV{'GBE_DEBUG'};        # Allow global debug
57
my $opt_verbose = $ENV{'GBE_VERBOSE'};      # Allow global verbose
58
my $opt_help = 0;
59
my $opt_manual = 0;
60
 
61
my $opt_test_name;              # Text Name of the test
62
my $opt_interface;              # Path to the interface directory
63
my $opt_test_dir;               # Path to directory to run the test in
64
my $opt_platform;               # Current target
65
my $opt_type;                   # Type [ D or P ]
66
my $opt_host;                   # Host Machine
67
my $opt_root;                   # path to build root
68
my $opt_local_bin;              # Path to local bin directory
69
my @opt_copy_once;              # File to copy (once) into the test directory
70
my @opt_copy_in;                # File to copy in each time
71
my $opt_isa_script;             # Command is a script
72
my $opt_test_cmd;               # Test command
73
my @opt_test_args;              # Arguments to be passed to the test
74
 
75
#
76
#   Globals
77
#
78
our $Cwd;
79
 
80
#-------------------------------------------------------------------------------
81
# Function        : runtest
82
#
83
# Description     : Run a test
84
#
85
# Inputs          : All arguments are passed as options
86
#                   test_name               - Text Name of the test
87
#                   interface               - Path to the interface directory
88
#                   test_dir                - Path to directory to run the test in
89
#                   GBE_PLATFORM            - Current target
90
#                   GBE_TYPE                - Type [ D or P ]
91
#                   GBE_HOST                - Host Machine
92
#                   GBE_ROOT                - Abs path to build root
93
#                   BINDIR_LOCAL_PATH       - Path to local bin directory
94
#
95
#                   copy_once               - File to copy (once) into the test directory
96
#                   copy_in                 - File to copy in each time
97
#
98
#                   isa_script              - Command is a script
99
#                   test_cmd                - Test command
100
#                   test_args               - Arguments to be passed to the test
101
#
102
#   
103
#
104
# Returns         : 
105
#
106
sub runtest
107
{
108
    my $result = GetOptions (
109
                    "help+"         => \$opt_help,              # flag, multiple use allowed
110
                    "manual"        => \$opt_manual,            # flag, multiple use allowed
111
                    "verbose+"      => \$opt_verbose,           # flag, multiple use allowed
112
 
113
                    "test_name=s"      => \$opt_test_name,
114
                    "interface=s"      => \$opt_interface,
115
                    "test_dir=s"       => \$opt_test_dir,
116
                    "platform=s"       => \$opt_platform,
117
                    "type=s"           => \$opt_type,
118
                    "host=s"           => \$opt_host,
119
                    "root=s"           => \$opt_root,
120
                    "local_bin=s"      => \$opt_local_bin,
121
                    "copy_once=s"      => \@opt_copy_once,
122
                    "copy_in=s"        => \@opt_copy_in,
123
                    "isa_script"       => \$opt_isa_script,
124
                    "test_cmd=s"       => \$opt_test_cmd,
125
                    "test_args=s"      => \@opt_test_args,
126
 
127
                    );
128
 
129
                    #
130
                    #   UPDATE THE DOCUMENTATION AT THE END OF THIS FILE !!!
131
                    #
132
 
133
    #
134
    #   Process help and manual options
135
    #
136
    pod2usage(-verbose => 0, -message => "Version: $VERSION")  if ($opt_help == 1  || ! $result);
137
    pod2usage(-verbose => 1)  if ($opt_help == 2 );
138
    pod2usage(-verbose => 2)  if ($opt_manual || ($opt_help > 2));
139
 
140
    #
141
    #   Caputure the $Cwd
142
    #
143
    InitFileUtils();
144
 
145
    #
146
    #   Setup the test environment
147
    #   The following EnvVars are for scripts
148
    #
149
    $ENV{GBE_TYPE} = $opt_type;
150
    $ENV{GBE_HOST} = $opt_host;
151
    $ENV{GBE_ROOT} = AbsPath($opt_root);
152
 
153
    #
154
    #   Extend the PATH to pick up utilities that have been placed into the
155
    #   local/bin directory.
156
    #
157
    $ENV{PATH} = AbsPath($opt_local_bin) . $ScmPathSep . $ENV{PATH};
158
 
159
 
160
    #
161
    #   Setup System options
162
    #
163
    my @sysopts = '--NoExit';
164
#    push @sysopts, "--Shell" if ( $opt_isa_script );
165
    push @sysopts, "$ENV{GBE_BIN}/sh" if ( $opt_isa_script );
166
 
167
    #
168
    #   Change to the required target directory and execute the command
169
    #
170
    chdir $opt_test_dir || Error ("Cannot change directory to $opt_test_dir");
171
    $result = System ('--Show',@sysopts, $opt_test_cmd, @opt_test_args );
172
    chdir $Cwd || Error ("Cannot change directory to $Cwd");
173
 
174
    exit $result;
175
}
176
 
177
1;