mirror of
				https://github.com/Telecominfraproject/wlan-lanforge-scripts.git
				synced 2025-10-31 18:58:01 +00:00 
			
		
		
		
	Improve gui-cli script to be able to run automated tests and save results.
This commit is contained in:
		| @@ -26,6 +26,10 @@ my $lfmgr_port = 3990; | |||||||
| # Default values for ye ole cmd-line args. | # Default values for ye ole cmd-line args. | ||||||
| my $port = ""; | my $port = ""; | ||||||
| my $cmd = ""; | my $cmd = ""; | ||||||
|  | my $ttype = ""; # Test type | ||||||
|  | my $tname = "lfgui-test"; | ||||||
|  | my $tconfig = "";  # test config | ||||||
|  | my $rpt_dest = ""; | ||||||
| my $show_help = 0; | my $show_help = 0; | ||||||
|  |  | ||||||
| ######################################################################## | ######################################################################## | ||||||
| @@ -34,9 +38,14 @@ my $show_help = 0; | |||||||
|  |  | ||||||
| my $usage = qq($0  [--manager { hostname or address of LANforge GUI machine } ] | my $usage = qq($0  [--manager { hostname or address of LANforge GUI machine } ] | ||||||
|                  [--port {port name} ] |                  [--port {port name} ] | ||||||
|  |                  [--ttype {test instance type} ] | ||||||
|  |                  [--tname {test instance name} ] | ||||||
|  |                  [--tconfig {test configuration name, use defaults if not specified} ] | ||||||
|  |                  [--rpt_dest {Copy report to destination once it is complete} ] | ||||||
|                  [--cmd { command to send to the GUI } ] |                  [--cmd { command to send to the GUI } ] | ||||||
|  |  | ||||||
| Example: | Example: | ||||||
|  |  lf_gui_cmd.pl --manager localhost --port 3990 --ttype TR-398 --tname mytest --tconfig comxim --rpt_dest /var/www/html/lf_reports | ||||||
|  lf_gui_cmd.pl --manager localhost --port 3990 --cmd \"help\" |  lf_gui_cmd.pl --manager localhost --port 3990 --cmd \"help\" | ||||||
| ); | ); | ||||||
|  |  | ||||||
| @@ -48,6 +57,10 @@ if (@ARGV < 2) { | |||||||
| GetOptions ( | GetOptions ( | ||||||
|    'help|h'                => \$show_help, |    'help|h'                => \$show_help, | ||||||
|    'manager|mgr|m=s'       => \$lfmgr_host, |    'manager|mgr|m=s'       => \$lfmgr_host, | ||||||
|  |    'ttype=s'               => \$ttype, | ||||||
|  |    'tname=s'               => \$tname, | ||||||
|  |    'tconfig=s'             => \$tconfig, | ||||||
|  |    'rpt_dest=s'            => \$rpt_dest, | ||||||
|    'port=s'                => \$port, |    'port=s'                => \$port, | ||||||
|    'cmd|c=s'               => \$cmd, |    'cmd|c=s'               => \$cmd, | ||||||
| ) || die("$usage"); | ) || die("$usage"); | ||||||
| @@ -67,9 +80,51 @@ $t->open( Host    => $lfmgr_host, | |||||||
|  |  | ||||||
| $t->waitfor("/lfgui\# /"); | $t->waitfor("/lfgui\# /"); | ||||||
|  |  | ||||||
| $t->print($cmd); | if ($cmd ne "") { | ||||||
| my @rslt = $t->waitfor('/lfgui\#/'); |   print doCmd("$cmd"); | ||||||
|  | } | ||||||
|  |  | ||||||
| print join( "\n", @rslt ); | if ($ttype ne "") { | ||||||
|  |   doCmd("cv create '$ttype' '$tname'"); | ||||||
|  |   if ($tconfig ne "") { | ||||||
|  |     doCmd("cv load 'tname' '$tconfig'"); | ||||||
|  |   } | ||||||
|  |   doCmd("cv click '$tname' 'Auto Save Report'"); | ||||||
|  |   doCmd("cv click '$tname' 'Start'"); | ||||||
|  |   while (1) { | ||||||
|  |     my $rslt = doCmd("cv get '$tname' 'Report Location:'"); | ||||||
|  |     print "Result-:$rslt:-\n"; | ||||||
|  |     if ($rslt =~ /^\s*Report Location:::(.*)/) { | ||||||
|  |       my $loc = $1; | ||||||
|  |       if ($loc eq "") { | ||||||
|  | 	# Wait longer | ||||||
|  | 	sleep(1); | ||||||
|  |       } | ||||||
|  |       else { | ||||||
|  | 	# Copy some place it can be seen easily? | ||||||
|  | 	if ($rpt_dest ne "") { | ||||||
|  | 	  my $cp = "cp -ar $loc $rpt_dest"; | ||||||
|  | 	  print "Copy test results: $cp\n"; | ||||||
|  | 	  system($cp); | ||||||
|  | 	} | ||||||
|  | 	last; | ||||||
|  |       } | ||||||
|  |     } | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
| exit(0); | exit(0); | ||||||
|  |  | ||||||
|  | sub doCmd { | ||||||
|  |   my $cmd = shift; | ||||||
|  |  | ||||||
|  |   print ">>>Sending:$cmd\n"; | ||||||
|  |  | ||||||
|  |   $t->print($cmd); | ||||||
|  |   my @rslt = $t->waitfor('/lfgui\#/'); | ||||||
|  |   if ($rslt[@rslt-1] eq "lfgui\#") { | ||||||
|  |     $rslt[@rslt-1] = ""; | ||||||
|  |   } | ||||||
|  |   return join("\n", @rslt); | ||||||
|  | } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Ben Greear
					Ben Greear