I have create a small robot framework test suit which will communicate with trace32 Lauterbach. My idea is to run different functions name using a loop. Every loop, it will make a breakpoint in the Trace32 later batch. I have written a simple python script as library in the robot framework.
test.robot file
import os
*** Settings ***
Documentation simple test script to control Trace32
Library Collections
Library can.Trace32
Suite Setup
Suite Teardown
*** Variables ***
${temp} 1
*** Test Cases ***
Check Input and Output
[Documentation] test script
[Setup]
#Retrive Data . This list has 5 values
${MainList} Create List
#start debugger
start Debugger
#connect debugger
Connect Debugger
#Iterate 5 times
FOR ${UserAttribute} IN @{MainList}
#sleep 1 sec
Sleep 1 seconds
#call for breakpoint
break Debugger
${temp} +=1
END
Disconnect Debugger
[Teardown]
and the trace 32 script file:
import time
import ctypes
from ctypes import c_void_p
import enum
T32_DEV = 1
class Trace32:
def start_Debugger(self):
self.t32api = ctypes.cdll.LoadLibrary('D:/test/api/python/t32api64.dll')
self.t32api.T32_Config(b"NODE=",b"localhost")
self.t32api.T32_Config(b"PORT=",b"20000")
self.t32api.T32_Config(b"PACKLEN=",b"1024")
rc = self.t32api.T32_GetChannelSize()
ch1 = ctypes.create_string_buffer(rc)
self.t32api.T32_GetChannelDefaults(ctypes.cast(ch1,ctypes.c_void_p))
ch2 = ctypes.create_string_buffer(rc)
self.t32api.T32_GetChannelDefaults(ctypes.cast(ch2,ctypes.c_void_p))
self.t32api.T32_SetChannel(ctypes.cast(ch2,c_void_p))
def Connect_Debugger(self):
rc = self.t32api.T32_Init()
rc = self.t32api.T32_Attach(T32_DEV)
def breakpoint_Debugger(self):
rc = self.t32api.T32_Ping()
time.sleep(2)
rc = self.t32api.T32_Cmd(b"InterCom M7_0 Break")
time.sleep(3)
rc = self.t32api.T32_Cmd(b"InterCom M7_0 Go")
time.sleep(2)
rc = self.t32api.T32_Cmd(b"InterCom M7_0 break.Set My_func")
time.sleep(2)
def Disconnect_Debugger(self):
rc = self.t32api.T32_Exit()
In the robot file, I am calling start Debugger
and Connect Debugger
function to start and connect the debugger. I want self.t32api
to be global. So that I can call break_Debugger
many times to put a breakpoint.
But Unfortunately, I can only put breakpoint in the first iteration. In second iteration, the breakpoint is not working. How can I make self.t32api
global until the robot file executed completely?