• Home
  • Company
    • About
    • Customers
    • Testimonials
    • Contact Us
    • My Account
  • Products
  • Downloads
  • Tutorials
  • Professional Services
  • Home
  • Company
    • About
    • Customers
    • Testimonials
    • Contact Us
    • My Account
  • Products
  • Downloads
  • Tutorials
  • Professional Services
Free Edition Compatible
How to Load a Spirent TestCenter Configuration Using Tcl
Objectives
In this tutorial you'll learn HOW TO:
► Write in TCL directly from Coronys ESL script
► Load a Spirent TestCenter GUI configuration using TCL API
► Execute any Spirent TestCenter test automation command
► Get and analyze Spirent TestCenter responses
► Save all Spirent TestCenter session messages in a log
All Tutorials
How to ...
Add a New Test Step
Add a new test step "Load Config" under "Spirent TC" node on the Coronys-ETS Test Step Tree:
Define Test Parameters
Define selection time parameters:
Variable Name will be recognizable and its value available in your script.
Default value
Write a Script
Copy script below to the templates created by the ESL Editor.
Click F1 in ESL Editor for Help and API index.
TCL_Create function initializes the TCL built-in interpreter and returns its handler tclHandler.
At the end of the script you need to call TCL_Delete to close TCL interpreter and release resources
To have a log of the session use OpenLogFile, Do not forget to close it with CloseLogFile. at the end.
 The subroutine CheckForErrors checks if STC resopnse has any errors. Call it after every cammand you send to STC.
DeclareOnce  epCfgFileName = `MyConfig`      ;Configuration file name
Declare  Status ,  tclHandler

; Correct to your installation path
Declare  TclPath  =   "c:\Program Files (x86)\Spirent Communications\Spirent TestCenter 4.20\TCL\bin\tcl85.dll"

; Init TCL and load STC package
TCL_Create  tclHandler ,  TclPath ,   1 ,   1 , 'TCL'

; Open session log file 
OpenLogFile   'c:\temp\stc_log.txt' ,   1

; Initialize stc package
TCL_Eval  Status ,  tclHandler ,   'package require SpirentTestCenter'
GoSub   ' CheckForErrors ' ,  Status

; if the config is .xml format then use
TCL_Eval  Status ,  tclHandler ,   'stc::perform LoadFromXml -Filename '   $  epCfgFileName  $   '.xml'
GoSub   ' CheckForErrors ' ,  Status
 
; if the configurtion is .tcc format then
TCL_Eval  Status ,  tclHandler ,   'stc::perform LoadFromDatabaseCommand -DatabaseConnectionString '   $  epCfgFileName  $   '.tcc'
GoSub   ' CheckForErrors ' ,  Status
TCL_Eval  Status ,  tclHandler ,   'stc::apply'
GoSub   ' CheckForErrors ' ,  Status

; Put here more commands in TCL to start traffic and get statistics
;TCL_Eval Status, tclHandler, '.......'

; Close TCL interpreter and release resources
TCL_Delete  tclHandler

; Close session log file 
CloseLogFile

End
;-------------------------------------------

; Error check sub-routine   
<CheckForErrors>  i_Msg
Declare  Offset

StrSearch  Offset ,  i_Msg ,   `error` ,   0 ,   1

; Check for errors
If  Offset  !=   (- 1 )   Then
     PrintMessage  i_Msg
     Abort  i_Msg
EndIf

PrintMessage  i_Msg
Return

  • Home
  • Products
  • Downloads
  • Tutorials
  • Contact Us
  • Terms of Use
  • Privacy Policy

Copyright © 2002-2017 Coronys Ltd. All Rights Reserved.
 
Back to top