请教大家关于自动化测试软件的脚本和用户提交页面

请教大家关于自动化测试软件的脚本和用户提交页面

请教大家关于自动化测试软件的脚本和用户提交页面
写了个自动化测试软件的脚本和用户提交页面:
1。自动测试脚本在remote server 上 (LINUX, Solaris & AIX)
2. CGI sh 组成web 页面, 由用户提交测试需求的参数到remote server上。
3。用PERL完成自动TELNET到remote server 上执行那个自动测试脚本,取得LOG,并在web上显示结果。

问题:
1. 可以得到LOG,但不能显示。。。
2。整体的构造好像很笨的,运算好像很费时间。


请教大家如何改进.
测试的内容是什么?是否很耗时间耗资源?
最好把代码都贴上来
不好意思还忘了说那个脚本.
不好意思还忘了说那个脚本执行时间大概需要20分钟左右。

因为是在XP下先试运行,所有用的是MKS.

测试的内容: 公司的套装软件工作是否正常,全由bash 完成

用户提交页面 ---> 生成tmp env --> auto ftp remote server (Solaris, Linux & AIX) ---> auto telnet remote server ---> execute scripts ---> grep results log --> display within html
========================================================
tmp env
#!c:/perl/bin/perl.exe -w

require "cgi-lib.pl";
use CGI;

print "Content-type: text/html\n\n";
print "";


&getFormData;
$mytmpenv = $request{"tmpenv"};
$myusername = $request{"username"};
$mypassword = $request{"password"};
$mytestcasename = $request{"testcasename"};
$myplatform = $request{"platform"};
$myhostname = $request{"hostname"};
$myinstalltype = $request{"installtype"};
$myinstalllocation = $request{"installlocation"};
$mydr = $request{"dr"};
$myds = $request{"ds"};
$mydf = $request{"df"};
$myrtds = $request{"rtds"};

$myaseversion = $request{"asever"};
$myaselocation = $request{"aselocation"};
$myaseservername = $request{"aseservername"};


open(MYTMPENV,">>$mytmpenv") or die("Can't open environment log file.\n");
print MYTMPENV ("#!/usr/bin/bash\n");
print MYTMPENV ("# generate a tmp environment setting scripts\n");
print MYTMPENV ("user=$myusername\npasswd=$mypassword\ntestcase_name=$mytestcasename\nplatform=$myplatform\nhost=$myhostname\ninstall_type=$myinstalltype\ninstall_location=$myinstalllocation\nase_version=$myaseversion\nase_location=$myaselocation\naseservername=$myaseservername\n#=======================================\n. $myinstalllocation/SYBASE.sh\n");
print MYTMPENV ("mkdir $myinstalllocation/mylogs\n");
close(MYTMPENV);

if ( $mydr ne "")
{
open(MYTMPENV,">>$mytmpenv") or die("Can't open environment log file.\n");
print MYTMPENV ("#=======================================\n. runDR.sh\n#=======================================\n");
close(MYTMPENV);
}
if ( $mydf ne "")
{
open(MYTMPENV,">>$mytmpenv") or die("Can't open environment log file.\n");
print MYTMPENV ("#=======================================\n. runDF.sh\n#=======================================\n");
close(MYTMPENV);
}
if ( $myds ne "")
{
open(MYTMPENV,">>$mytmpenv") or die("Can't open environment log file.\n");
print MYTMPENV ("#=======================================\n. runDS.sh\n#=======================================\n");
close(MYTMPENV);
}
if ( $myrtds ne "")
{
open(MYTMPENV,">>$mytmpenv") or die("Can't open environment log file.\n");
print MYTMPENV ("#=======================================\n. runRTDS.sh\n#=======================================\n");
close(MYTMPENV);
}

open(MYTMPENV,">>$mytmpenv") or die("Can't open environment log file.\n");
print MYTMPENV ("\n");
print MYTMPENV ("mv $myinstalllocation/mylogs/results.log ~\n");
close(MYTMPENV);

# end code

sub getFormData
{
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/\n/ /g;
$request{$name} = $value;
}
}
==================================================
auto telnet
#!c:/perl/bin/perl.exe -w
#

$myhost = $ARGV[0];
$myuser = $ARGV[1];
$mypasswd = $ARGV[2];
$mytestcase = $ARGV[3];

## Connect and login.
use Net::Telnet();
$mynet = new Net::Telnet (Prompt => '/[:#%>\$] $/', Timeout => 2000,
Errmode=>'die');
$mynet->open($myhost);
$mynet->login($myuser, $mypasswd);

@changeshell = $mynet ->cmd("bash");
@chmodscripts = $mynet ->cmd("chmod 775 runDF.sh runDS.sh runDR.sh runRTDS.sh ${myuser}_${mytestcase}_$myhost.sh");
@executesscripts = $mynet->cmd("${myuser}_${mytestcase}_$myhost.sh");
@clearscripts = $mynet ->cmd("rm -rf runDF.sh runDS.sh runDR.sh runRTDS.sh ${myuser}_${mytestcase}_$myhost.sh");
@getresults = $mynet->cmd("cat results.log");
print @getresults;


=====================================================
用户提交页面 调用程序
#!C:/Program Files/MKS Toolkit/mksnt/sh.exe
#
# autogen.sh

./autogenenv.pl
# change mode to execute this script

mv tmpenv.log tmpenv.sh
chmod 0755 tmpenv.sh

# pick up all parameters from form
#
user=`sed -n 's/^user=//p' tmpenv.sh`;export $user
passwd=`sed -n 's/^passwd=//p' tmpenv.sh`; export $passwd
platform=`sed -n 's/^platform=//p' tmpenv.sh`; export $platform
host=`sed -n 's/^host=//p' tmpenv.sh`;export $host
testcase=`sed -n 's/^testcase_name=//p' tmpenv.sh`; export $testcase;

# generate a temp file for different users
#
touch ${user}_${testcase}_$host.sh
cp tmpenv.sh ${user}_${testcase}_$host.sh

# create an auto ftp script file to server
#
echo "#!C:/Program Files/MKS Toolkit/mksnt/sh.exe" > myftp.sh
echo "#" >> myftp.sh
echo "port=21" >> myftp.sh
echo "mode='bin'" >>myftp.sh
echo "ftp -i -n <<!" >>myftp.sh
echo "open $host" >>myftp.sh
echo "user $user $passwd" >>myftp.sh
echo "$mode" >> myftp.sh
echo "mput run*.sh ${user}_${testcase}_$host.sh" >> myftp.sh
echo "bye" >> myftp.sh
echo "!" >>myftp.sh
./myftp.sh


# remove all temp files for safe reason
#
rm -rf ${user}_${testcase}_$host.sh tmpenv.sh myftp.sh

# create auto telnet to remote host, no matter which is Windows, Solaris or linux, ALL should work fine
#
cp autotelnet.pl $user.pl


# create results html based on the logs we get from target machine
#



# print header
#
NOW=`date`
echo ""
echo "<HTML>"
echo "<link rel="stylesheet" type= "text/css" href ="/cgi-bin/style.css" />"
echo "<HEAD><TITLE>Suite Automatic Test Results</TITLE></HEAD>"
echo ""
echo "<a name=TOP></a>"
echo "Last Updated: $NOW"
echo "<hr width='100%' size='3'>"
echo "<h3>Suite Automatic Test Results</h3>"
echo "<PRE>"
echo "Tester:" $user
echo "<PRE>"
echo "Platform:" $platform
echo "<PRE>"
echo "Testcase:" $testcase
echo "<PRE>"
echo "We are procceding your request now, please wait............"
echo "<hr width='100%' size='4'>"
./$user.pl $host $user $passwd $testcase $host << EOM
</BODY>
< /HTML>
EOM



# remove auto telnet files for username
#
rm -rf $user.pl




   

这个程序之前想全由SH完成.
这个程序之前想全由SH完成的,但好像不能decode一些字符,例如(/ ~)等,就该为perl写一部分,再由sh调用perl, 从设计上就有很大的毛病.

大家认为该如何修改好?
嗯,看起来好像是绕了很多.
嗯,看起来好像是绕了很多远路。

用户上传 + 上传到 remote server + 测试 test case + 取得结果再传回 web server
这上面每一步都可以花很长时间,我想你大概需要重新设计一下。提几个问题你考虑一下吧。

比如说为什么不把这个 cgi script 放到 remote server 上? 你的测试程序是否运行的够有效率?

l另外, perl 完全可以做 cgi script , 没必要使用 shell . 而且 Perl 有 CGI 模块可以用来很容易拿到用户传递的参数。cgi-lib.pl 是在 CGI 模块的前身,至少是 6 , 7 年前的东西了。
谢谢 你的comments:-- 谢谢 你的comments:

1. 当初也想放到remote server 上,但是对于一个grid 点来说的话,好像没有什么区别的,再说remote server 不止一台,有大概11,包括Windows (VMWare), Linux, Solaris 和AIX,

2. perl我也是初学,惭愧,惭愧, 我会以你的意见进行修改的。
谢谢
其实如果你对测试软件有研.
其实如果你对测试软件有研究的话,可以用simpletest这个php测试,效果不错的
simpletest 是一个基于php的测试项目http://simpletest.sourceforge.net/