From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

automating sequence analyzer

Hi testergi
I've figured a way to solve the problem.
Attached is the "analyzer" sequence and the analyzer projekt. I'll shortly explain what I'm doing - and why.
 
My customer have a lot different test sequences (more than 100). They are all placed under a specific master release directory. Each test sequence and belonging files (mostly C#.NET DLL's) are placed in each own subdirectory.
The C#.NET DLL name spaces are the same for all tests but the content of the DLL's are different.
The way it works is:
1. All content in test sequence catalog (DLL's and *.seq) is copied to a local folder
2. Load the test sequence into TestStand
3. Run the analyzer project
4. Create report file
5. Unload the "All Modules"
6. Release the sequence file
7. Delete all the files in the local folder
8. Goto 1 (with next test sequence folder)
 
I've had some difficulty unloading modules (DLL's) why I sometimes had to do the "Unload Modules" and delete files twice.
 
The reason I am loading all the sequences into TestStand ahead of running the analyzer project is due to type conflicts which loading sequences with the analyzer project isn't capable of solving but loading the sequences into TestStand ahead of running the analyzer project the conflicts are solved by the TestStand engine. (Don't ask why.....)
 
All the reports (1 for each test sequence) are written into a specific. Use the analyzer project to specify what exactly to investigate.
 
Hope it helps.
0 Kudos
Message 11 of 17
(862 Views)

Thanks Vagn.

 

I think your logic in the AnalyseFolderProject subsequence will be very helpful.

0 Kudos
Message 12 of 17
(851 Views)

Hello guys,

I allow myself to interfere in your discussion
I would like to be able to do the same thing but in python. Is it possible to call the Analyzer Engine directly?
Thank you in advance for your answers,
Guillaume.

0 Kudos
Message 13 of 17
(836 Views)

Hi Guiforfor

 

I am not into python but if it is possible to do .NET call within python the answer is yes

0 Kudos
Message 14 of 17
(824 Views)

I was thinking of doing the same as Teststand Engine in python :
Ref = win32com.client.Dispatch("TestStand.Engine")

But for AnalyzerEngine.

I will try your method anyway !

0 Kudos
Message 15 of 17
(816 Views)

I have created powershell script some time ago for automation and it had one function for analyzer. Should still work. New process was started because analyzer sometimes tends to hang forever...

 

function Run-TSAnalyzer
{
    Param
    (
        [Parameter(Mandatory=$True, Position=1, ValueFromPipeline=$false,
        HelpMessage="Path to sequence analyzer project (tsaproj)).")]
        [Alias('tsaproj')]
        [System.String]
        [ValidateScript({Test-Path $_ })]
        $projectPath,
        [Parameter(Mandatory=$True, Position=2, ValueFromPipeline=$false,
        HelpMessage="Path to TS Analyzer exe.")]
        [Alias('tas')]
        [System.String]
        [ValidateScript({Test-Path $_ })]
        $analyzerPath,
        [Parameter(Mandatory=$True, Position=3, ValueFromPipeline=$false,
        HelpMessage="Path to analyzer raw log file")]
        [Alias('log')]
        [System.String]
        $logPath,
        [Parameter(Mandatory=$True, Position=3, ValueFromPipeline=$false,
        HelpMessage="Path to analyzer junit log file")]
        [Alias('junit')]
        [System.String]
        $junitLogPath,
        [Parameter(Mandatory=$True, Position=3, ValueFromPipeline=$false,
        HelpMessage="Path to analyzer junit transform file")]
        [Alias('transform')]
        [System.String]
        $junitTransformPath,
        [Parameter(Mandatory=$True, Position=5, ValueFromPipeline=$false,
        HelpMessage="build timeout in secounds")]
        [Alias('t')]
        [System.Int32]
        $timeoutSec
    )

    #format analyzer args
    $arg = [string]::Format('"{0}" /analyze /report "{1}" /quit',$projectPath,$logPath)

    #setup process
    $pinfo = New-Object System.Diagnostics.ProcessStartInfo
    $pinfo.FileName = $analyzerPath
    $pinfo.RedirectStandardError = $true
    $pinfo.RedirectStandardOutput = $true
    $pinfo.UseShellExecute = $false
    $pinfo.Arguments = $arg
    $pinfo.CreateNoWindow = $false
    $p = New-Object System.Diagnostics.Process
    $p.StartInfo = $pinfo
    $p.Start() | Out-Null
    $errTask = $p.StandardError.ReadToEndAsync()
    $outTask = $p.StandardOutput.ReadToEndAsync()
    $done = $p.WaitForExit($timeoutSec*1000)

    if ($done -eq $false)
    { 
        $p.Kill() 
        throw 'TS sequence analyzer exceeded run timeout'
    }
    else
    {   
        #convert raw ts log to junit log
        $xslt = New-Object System.Xml.Xsl.XslCompiledTransform
        $xslt.Load($junitTransformPath)
        $xslt.Transform($logPath,$junitLogPath)

        if(-2,-1,1 -contains $p.ExitCode) {throw 'TS analyzer failed'}
        else {Write-Host 'TS analyzer succeeded'}
    }
}

 

0 Kudos
Message 16 of 17
(802 Views)

Hello guys,

 

I am sorry to answer you so late.
Thank you for your answers.

I found a solution to what I was looking for:

- I create a workspace with all the files I want to analyze

- I create a project analyzer with this workspace. The project is created thanks to the AnalyzerEngine.

- I analyse the project by calling the SequenceAnalyzer from the command line.

I tried to directly analyze the project thanks to the AnalyzerEngine. But calling the StartAnalysis (with param 0, don't know why) it's crashing in python. In C#, this remains frozen at : "Preparing Analyzis".

I've tried everything but I can't get it to work, anyone have any idea what the problem is?

Thank you for your help !!!

0 Kudos
Message 17 of 17
(739 Views)