|
From: <jud...@us...> - 2006-07-11 20:14:18
|
Revision: 301 Author: judith_osdl Date: 2006-07-11 13:14:15 -0700 (Tue, 11 Jul 2006) ViewCVS: http://svn.sourceforge.net/stp/?rev=301&view=rev Log Message: ----------- This packs up stp results for mailing in. Added Paths: ----------- trunk/Test-Sut/lib/Test/Sut/Upload/EmailW.pm Added: trunk/Test-Sut/lib/Test/Sut/Upload/EmailW.pm =================================================================== --- trunk/Test-Sut/lib/Test/Sut/Upload/EmailW.pm (rev 0) +++ trunk/Test-Sut/lib/Test/Sut/Upload/EmailW.pm 2006-07-11 20:14:15 UTC (rev 301) @@ -0,0 +1,111 @@ +# Copyright (C) 2002-2006 Open Source Development Lab +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# +package Test::Sut::Upload::Wsdl; +use Data::Dumper; +use Test::Sut::Upload; +use Test::Sut::Email; +use Test::Transport::Wsdl; +use MIME::Base64; +no warnings 'redefine'; +use Exporter; +our @ISA = qw( Test::Sut::Upload Exporter); +our @EXPORT = qw( upload_all + upload_result + upload_results + upload_file + request_details + request_details_file + ); +use strict; + +# We need to repeat this use or call functions by the fully qualified name +use Test::Sut::Tools; + +sub new{ + my $package = shift; + my $config_file = shift || "/etc/brt/brt_default.cfg"; + + my $self = $package->SUPER::new($config_file); + + return $self; +} + + +# +# This function handles the generic uploading of results +# +# Future work could include reading a stp-upload file for a line-by-line of +# test-specific files that should be copied +# + +sub upload_results { + + my ( $r ) = @_; + + my $test_name = $r->{ 'tr_ref' }->{ 'test_case_descriptor' }; + + my $exec_home = $ENV{ 'EXEC_HOME' }; + my @files; + + syslog "uploading results to the server"; + + # Move the test results to the current directory & archive them + chdir( "$ENV{'EXEC_HOME'}" ); + # Set new RESULTS_TOP + $ENV{'RESULTS_TOP'}= "$ENV{ 'EXEC_HOME' }/$ENV{'TEST_ID'}"; + mkdir $ENV{'RESULTS_TOP'}; + mkdir $ENV{'RESULTS_TOP'}. "/logs", 0777; + mkdir $ENV{'RESULTS_TOP'}. "/results", 0777; + mkdir $ENV{'RESULTS_TOP'}. "/profile", 0777; + mkdir $ENV{'RESULTS_TOP'}. "/oprofile", 0777; + mkdir $ENV{'RESULTS_TOP'}. "/environment", 0777; + system "cp *.html $ENV{'RESULTS_TOP'}/"; + system "cp COPYING $ENV{'RESULTS_TOP'}/"; + system "cp -R environment/* $ENV{'RESULTS_TOP'}/environment/"; + system "cp -R logs/* $ENV{'RESULTS_TOP'}/logs/"; + system "cp -R profile/* $ENV{'RESULTS_TOP'}/profile/"; + system "cp -R oprofile/* $ENV{'RESULTS_TOP'}/oprofile/"; + system "cp $r->{ 'stp_client_log' } $ENV{'RESULTS_TOP'}/logs/stp.log.txt"; + system "cp $ENV{'TEST_ENV'} $ENV{'RESULTS_TOP'}/logs/testEnv.txt"; + system "cp /var/log/plm/plm.log $ENV{'RESULTS_TOP'}/logs/plm.log.txt"; + system "cp /var/log/dmesg $ENV{'RESULTS_TOP'}/logs/dmesg.txt"; + system "cp $ENV{ 'RESULTS_ROOT' }/script_params.txt $ENV{'RESULTS_TOP'}/results/"; + system "mv $test_name/logs/* $ENV{'RESULTS_TOP'}/logs/"; + system "mv $test_name/profile/* $ENV{'RESULTS_TOP'}/profile/"; + system "mv $test_name/oprofile/* $ENV{'RESULTS_TOP'}/oprofile/"; + system "mv -f $test_name/results/* $ENV{'RESULTS_TOP'}/results/"; + system "mv -f $test_name/*.html $ENV{'RESULTS_TOP'}"; + system "mv -f $test_name/result_email.txt $ENV{'RESULTS_TOP'}"; + + require Sys::SyslogMessages; + my $syslog = new Sys::SyslogMessages(); + $syslog->tail({'number_hours' => '6', 'output_file' => './logs/syslog.txt'}); + system "chmod 644 ./logs/syslog.txt"; + + # Go to the final location of the results + $ENV{'RESULTS_TOP'}= "$ENV{ 'EXEC_HOME' }/$ENV{'TEST_ID'}"; + chdir( $ENV{'RESULTS_TOP'} ); + # Make these files read-only + system "chown -R 444 *"; + my $res = $r->upload_all(); + chdir( $ENV{'EXEC_HOME'} ); + return; +} + + +1; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |