Subversion Repositories DevTools

Rev

Rev 4780 | Rev 4784 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4780 Rev 4781
Line 33... Line 33...
33
use Exporter;
33
use Exporter;
34
use JatsError qw(:name=jats_runutf);
34
use JatsError qw(:name=jats_runutf);
35
use Pod::Usage;                             # required for help support
35
use Pod::Usage;                             # required for help support
36
use Getopt::Long;
36
use Getopt::Long;
37
use File::Spec;
37
use File::Spec;
38
use Time::HiRes;
-
 
39
 
38
 
40
$VERSION = 1.00;
39
$VERSION = 1.00;
41
@ISA = qw(Exporter);
40
@ISA = qw(Exporter);
42
 
41
 
43
# Symbols to autoexport (:DEFAULT tag)
42
# Symbols to autoexport (:DEFAULT tag)
Line 50... Line 49...
50
my $opt_utfOuput;
49
my $opt_utfOuput;
51
my $opt_help = 0;
50
my $opt_help = 0;
52
 
51
 
53
#   Data to be passed into the filter function
52
#   Data to be passed into the filter function
54
#   Defined values are:
53
#   Defined values are:
-
 
54
#       ARGS            - An hash of user arguments
-
 
55
#       DIR             - Optional. Name of test subdir
55
#       FILTER          - Name of the filter 
56
#       FILTER          - Name of the filter 
-
 
57
#       IDIR            - Path to original directory
56
#       INTERFACE       - Abs Path to Interface directory
58
#       INTERFACE       - Abs Path to Interface directory
57
#       LOCAL           - Abs Path to Local directory
59
#       LOCAL           - Abs Path to Local directory
58
#       OUTDIR          - Abs Path to output directory
60
#       OUTDIR          - Abs Path to output directory
59
#       OUTFILE         - Abs Path to suggested output file
61
#       OUTFILE         - Abs Path to suggested output file
60
#       PKGDIR          - Abs Path to Packaging directory
62
#       PKGDIR          - Abs Path to Packaging directory
61
#       ROOT            - Abs Path to Root of the build
63
#       ROOT            - Abs Path to Root of the build
62
#       TARGET          - Current make target
64
#       TARGET          - Current make target
63
#       TYPE            - Built type P or D
65
#       TYPE            - Built type P or D
-
 
66
#       UFTUID          - Unique Test Identifier
-
 
67
#       UTFNAME         - Test Name
64
#
68
#
65
our %filterData;
69
our %filterData;
66
 
70
 
67
#-------------------------------------------------------------------------------
71
#-------------------------------------------------------------------------------
68
# Function        : help
72
# Function        : help
Line 115... Line 119...
115
                    "interface=s"   => \$filterData{INTERFACE},
119
                    "interface=s"   => \$filterData{INTERFACE},
116
                    "local=s"       => \$filterData{LOCAL},
120
                    "local=s"       => \$filterData{LOCAL},
117
                    "target=s"      => \$filterData{TARGET},
121
                    "target=s"      => \$filterData{TARGET},
118
                    "pkgdir=s"      => \$filterData{PKGDIR},
122
                    "pkgdir=s"      => \$filterData{PKGDIR},
119
                    "type=s"        => \$filterData{TYPE},
123
                    "type=s"        => \$filterData{TYPE},
-
 
124
                    "dir=s"         => \$filterData{DIR},
-
 
125
                    "arg=s"         => sub {my ( $key, $value) = split('=', $_[1], 2); $filterData{ARGS}{$key} = $value;},
120
                    );
126
                    );
121
 
127
 
122
    pod2usage(-verbose => 0, -input =>  __FILE__) if ($opt_help == 1 || ! $result || $argCount < 1);
128
    pod2usage(-verbose => 0, -input =>  __FILE__) if ($opt_help == 1 || ! $result || $argCount < 1);
123
    pod2usage(-verbose => 1, -input =>  __FILE__) if ($opt_help == 2 );
129
    pod2usage(-verbose => 1, -input =>  __FILE__) if ($opt_help == 2 );
124
    pod2usage(-verbose => 2, -input =>  __FILE__) if ($opt_help  > 2);
130
    pod2usage(-verbose => 2, -input =>  __FILE__) if ($opt_help  > 2);
Line 215... Line 221...
215
    #   Add in known values from the environment
221
    #   Add in known values from the environment
216
    #
222
    #
217
    $filterData{TYPE} = $ENV{'GBE_MAKE_TYPE'};
223
    $filterData{TYPE} = $ENV{'GBE_MAKE_TYPE'};
218
    Error("Internal: EnvVar 'GBE_MAKE_TYPE' not specified") unless $filterData{TYPE};
224
    Error("Internal: EnvVar 'GBE_MAKE_TYPE' not specified") unless $filterData{TYPE};
219
 
225
 
-
 
226
    $filterData{UFTUID} = $ENV{'GBE_UTFUID'};
-
 
227
    Error("Internal: EnvVar 'GBE_UTFUID' not specified") unless $filterData{UFTUID};
-
 
228
 
-
 
229
    $filterData{UTFNAME} = $ENV{'GBE_UTFNAME'};
-
 
230
    Error("Internal: EnvVar 'GBE_UTFNAME' not specified") unless $filterData{UTFNAME};
-
 
231
 
-
 
232
    $filterData{IDIR} = File::Spec->rel2abs('.');
-
 
233
 
220
    #
234
    #
221
    #   Create a uniq filename as a suggestion to the filter tool
235
    #   Create a uniq filename as a suggestion to the filter tool
222
    #       The filter is not forced to use it, but it is a good idea
236
    #       The filter is not forced to use it, but it is a good idea
223
    #
237
    #
224
    #   Construct the output filename from the microsecond time.
238
    my $filename = File::Spec->catfile($opt_utfOuput, "$filterData{TARGET}-$filterData{TYPE}-$filterData{UFTUID}.xml");
225
    my $time = Time::HiRes::time;
-
 
226
    $time =~ s/\.//;
-
 
227
    #   Append enough '0' to make 15 chars. This make uniform length numbers
-
 
228
    #   and allows filename sorting.
-
 
229
    $time .= "0" x (15-length($time));
-
 
230
 
239
 
-
 
240
    #   Allow the output file to be used
231
    my $filename = File::Spec->catfile($opt_utfOuput, "$filterData{TARGET}-$filterData{TYPE}-$time.xml");
241
    #       Not in the build system, but in a user development area
232
 
-
 
-
 
242
    unlink $filename if -e $filename;
233
    Error("Output file:$filename already exists: $!") if -e $filename;
243
    Error("Output file:Cannot delete $filename: $!") if -e $filename;
234
    Verbose("Writing output to $filename");
244
    Verbose("Writing output to $filename");
235
 
245
 
236
    $filterData{OUTFILE} = $filename;
246
    $filterData{OUTFILE} = $filename;
237
 
247
 
238
    #
248
    #
-
 
249
    #   Change to the test directory
-
 
250
    #       Only if required
-
 
251
    #       Ensure that the specified directory exists
-
 
252
    #
-
 
253
    if (defined $filterData{DIR})
-
 
254
    {
-
 
255
        Verbose("Change directory");
-
 
256
        Error("Internal: Test directory does not exist: $filterData{DIR}")
-
 
257
            unless (-d $filterData{DIR});
-
 
258
        chdir $filterData{DIR} || Error("Internal: Could not chdir to: $filterData{DIR}");
-
 
259
    }
-
 
260
 
-
 
261
    #
239
    #   Diagnostics
262
    #   Diagnostics
240
    #
263
    #
241
    if (IsVerbose(1))
264
    if (IsVerbose(1))
242
    {
265
    {
243
        DebugDumpData("Filter Parameters", \%filterData);
266
        DebugDumpData("Filter Parameters", \%filterData);
Line 273... Line 296...
273
    -target=name    - Current build target
296
    -target=name    - Current build target
274
    -root=path      - Path to the root of the build
297
    -root=path      - Path to the root of the build
275
    -pkgdir=path    - Path to the packaging directory
298
    -pkgdir=path    - Path to the packaging directory
276
    -interface=path - Path to the build interface directory
299
    -interface=path - Path to the build interface directory
277
    -local=path     - Path to the local build directory
300
    -local=path     - Path to the local build directory
-
 
301
    -dir=path       - Path to test directory
278
 
302
 
279
=head1 OPTIONS
303
=head1 OPTIONS
280
 
304
 
281
=over 8
305
=over 8
282
 
306
 
Line 318... Line 342...
318
 
342
 
319
=item B<-local=path>
343
=item B<-local=path>
320
 
344
 
321
The path to the local build directory
345
The path to the local build directory
322
 
346
 
-
 
347
=item B<-dir=path>
-
 
348
 
-
 
349
The path to the directory in which the test was run.
-
 
350
 
-
 
351
This is optional. If provided the filter will be invoked with the 
-
 
352
current working directory
-
 
353
 
323
=back
354
=back
324
 
355
 
325
=head1 DESCRIPTION
356
=head1 DESCRIPTION
326
 
357
 
327
This tool is not designed to be run directly by users. It is intended to be run by the 
358
This tool is not designed to be run directly by users. It is intended to be run by the 
Line 436... Line 467...
436
 
467
 
437
A reference to a Perl hash. The hach will contain the following named items:
468
A reference to a Perl hash. The hach will contain the following named items:
438
 
469
 
439
=over 4
470
=over 4
440
 
471
 
-
 
472
=item       ARGS          
-
 
473
 
-
 
474
Optional. A hash of User Arguments passed into the filter. Use of these is filter specific.
-
 
475
 
-
 
476
Arguments of the form '--UtfArg=UserArg1=Value1' will be stored with a key of 'UserArg1 and a value of 'Value1'.
-
 
477
 
-
 
478
Arguments of the form '--UtfArg=UserArg2' will be stored with a key of 'UserArg2' and an undefined value.
-
 
479
 
-
 
480
=item       DIR          
-
 
481
 
-
 
482
Optional. If the Unit Test is executed in a subdirectory of the current build 
-
 
483
location, then DIR will be set to the name of the subdirectory. 
-
 
484
 
-
 
485
The current working directory will be changed to DIR before the filter function is invoked. 
-
 
486
 
-
 
487
This item will aways exist, but it may not be defined.
-
 
488
 
441
=item       FILTER          
489
=item       FILTER          
442
 
490
 
443
The Name of the filter 
491
The Name of the filter 
444
 
492
 
-
 
493
=item       IDIR
-
 
494
 
-
 
495
The absolute path to the working directory, when the module is invoked, before the working
-
 
496
directory has been chnaged to 'DIR'.
-
 
497
 
445
=item       INTERFACE       
498
=item       INTERFACE       
446
 
499
 
447
The absolute Path to Interface directory
500
The absolute path to Interface directory
448
 
501
 
449
=item       LOCAL
502
=item       LOCAL
450
 
503
 
451
The absolute Path to Local directory
504
The absolute path to Local directory
452
 
505
 
453
=item       OUTDIR
506
=item       OUTDIR
454
 
507
 
455
The absolute Path to output directory
508
The absolute path to output directory
456
 
509
 
457
=item       OUTFILE
510
=item       OUTFILE
458
 
511
 
459
The absolute Path to suggested output file. The user does not need to use this name. It is 
512
The absolute path to suggested output file. The user does not need to use this name. It is 
460
provided to remove the need for each filter to create a unique name.
513
provided to remove the need for each filter to create a unique name.
461
 
514
 
462
This file will not exist.
515
This file will not exist.
463
 
516
 
464
=item       PKGDIR
517
=item       PKGDIR
465
 
518
 
466
The absolute Path to Packaging directory. This directory will exist.
519
The absolute path to Packaging directory. This directory will exist.
467
 
520
 
468
=item       ROOT
521
=item       ROOT
469
 
522
 
470
The absolute Path to Root of the build
523
The absolute path to Root of the build
471
 
524
 
472
=item       TARGET
525
=item       TARGET
473
 
526
 
474
The current make target
527
The current make target
475
 
528
 
476
=item       TYPE
529
=item       TYPE
477
 
530
 
478
The build type P or D
531
The build type P or D
479
 
532
 
-
 
533
=item       UTFNAME
-
 
534
 
-
 
535
The name of the test.
-
 
536
 
-
 
537
This may be provided by the user, or it may be system generated. Intended to be used by 
-
 
538
test filters that do not have test names generated as a part of the test
-
 
539
 
-
 
540
=item       UTFUID
-
 
541
 
-
 
542
A unique test identifier. This is unique with the build and is intended to:
-
 
543
 
-
 
544
=over 4
-
 
545
 
-
 
546
=item   *
-
 
547
 
-
 
548
Allow the generation of test-unique file names for the storage of results.
-
 
549
 
-
 
550
=item *
-
 
551
 
-
 
552
Allow the reuse of output file names.
-
 
553
 
-
 
554
=back
-
 
555
 
480
=back
556
=back
481
 
557
 
482
The return value from the function 'processUtf' is ignored. If the function encounters 
558
The return value from the function 'processUtf' is ignored. If the function encounters 
483
any error it should use the Jats 'Error' function to report the error.
559
any error it should use the Jats 'Error' function to report the error.
484
 
560
 
Line 509... Line 585...
509
 
585
 
510
=head3 The Output Format
586
=head3 The Output Format
511
 
587
 
512
Yet to be defined.
588
Yet to be defined.
513
 
589
 
-
 
590
The output format is known to the build system. It should not be 
-
 
591
changed without also chnaging it for the consuming tools.
-
 
592
 
514
=cut
593
=cut
515
 
594
 
516
 
595
 
517
1;
596
1;