Documentation of tbotlib functions

tbotlib

tbotlib.raw(text)

Returns a raw string representation of text

class tbotlib.tbot(workdir, labfile, cfgfile, logfilen, verbose)

Bases: object

The tbot class

all begins here ...

  • parameters, types, return and return types:
Parameters:
  • arg1 – workdir for tbot
  • arg2 – labfile
  • arg3 – board config file
  • arg4 – name of logfile
  • arg5 – be verbose
call_tc(name, **kwargs)

Call another testcase.

Search for the TC name through all subdirs in ‘src/tc’.
  • parameters, types, return and return types:
Parameters:
  • arg1 – name of testcase
  • arg2 – optional testcase argumentlist
Returns:

False: If testcase was not found

or testcase raised an execption

! called testcase sets the ret variable, which

this function returns. If called testcase not set the ret variable default is false!

check_args(args)

Check if the args are in current argumentstack

  • parameters, types, return and return types:
Parameters:arg1 – args
Returns:If args no found, end testcase with False

else return args argument

check_debugger()

checks if a debugger is attached

If so, run the target. For this tc “tc_lab_bdi_run.py” is called.

  • parameters, types, return and return types:
Returns:True
check_open_fd(c)

check, if stream is open.

  • parameters, types, return and return types:
Parameters:arg1 – connection
Returns:True: If open False: If stream open failed
cleanup()
con_log(*args)

logs a console string

  • parameters, types, return and return types:
Parameters:arg1 – console string
Returns:
connect_to_board(boardname)

connect to the board

  • parameters, types, return and return types:
Parameters:arg1 – boardname
debugprint(*args)

print a debug string on stdout.

This output can be enabled through self.config.debug
  • parameters, types, return and return types:
Parameters:arg1 – argument list
disconnect_from_board(boardname)

disconnect from the board

  • parameters, types, return and return types:
Parameters:arg1 – boardname
end_tc(ret)

end testcase.

simple end a testcase.

ret contains True if testcase ended successfully, False if not.

  • parameters, types, return and return types:
Parameters:arg1 – return value True/False
Returns:calls sys.exit(0 if ret == True 1 else)
eof_call_tc(name, **kwargs)

call tc name, end testcase on failure

  • parameters, types, return and return types:
Parameters:
  • arg1 – name of Testcase
  • arg2 – optional argument list
Returns:

True if called testcase ends True, als call end_tc(False)

eof_expect_string(c, string, wait_prompt=True)

expect a string, if prompt read end tc False

  • parameters, types, return and return types:
Parameters:
  • arg1 – connection
  • arg2 – string expected
  • arg3 – boot If True wait after string is found for prompt
eof_write(c, string, start=True)

write a string to connection c

  • parameters, types, return and return types:
Parameters:
  • arg1 – connection
  • arg2 – string
  • arg3 – start boolean, True, send console start before the

cmdstring. :return: If write_stream returns not True, end tc with failure

eof_write_cmd(c, command, start=True)

write a command to fd, wait for prompt

  • parameters, types, return and return types:
Parameters:
  • arg1 – connection
  • arg2 – commandstring
  • arg3 – start boolean, True, send console start before the

cmdstring. :return: True if prompt read, else end testcase with False

eof_write_cmd_check(c, cmd, string, start=True)

send a cmd and check if a string is read.

  • parameters, types, return and return types:
Parameters:
  • arg1 – connection
  • arg2 – commandstring
  • arg3 – string which must be read
  • arg4 – start boolean, True, send console start before the

cmdstring. :return: True if prompt and string is read else end Testcase with False

eof_write_cmd_list(c, cmdlist, start=True)

send a list of cmd to fd and wait for end

  • parameters, types, return and return types:
Parameters:
  • arg1 – connection
  • arg2 – list of commandstrings
  • arg3 – start boolean, True, send console start before the

cmdstring. :return: True if prompt found else endtestcase with False

eof_write_con(string, start=True)

write a string to console.

  • parameters, types, return and return types:
Parameters:
  • arg1 – commandstring
  • arg2 – start boolean, True, send console start before the

cmdstring. :return: True if write_stream returns True, else end testcase with False

eof_write_con_lx_cmd(command, start=True)

write a linux command to console.

  • parameters, types, return and return types:
Parameters:arg1 – commandstring
Returns:True if linux command was successful

else end testcase with False :param arg2: start boolean, True, send console start before the cmdstring.

eof_write_ctrl(string, start=True)

write a string to control connection.

  • parameters, types, return and return types:
Parameters:
  • arg1 – commandstring
  • arg2 – start boolean, True, send console start before the
Returns:

If write_stream returns not True, end tc with failure

cmdstring.

eof_write_workfd_passwd(user, board)

write a password to workfd. Do not log it.

  • parameters, types, return and return types:
Parameters:
  • arg1 – username
  • arg2 – board
Returns:

If write_stream returns not True, end tc with failure

failure()
flush(c)

read out all bytes from connection

  • parameters, types, return and return types:
Parameters:arg1 – connection
get_board_state(name)
get_power_state(boardname)

Get powerstate of the board in the lab

  • parameters, types, return and return types:
Parameters:arg1 – boardname
Returns:True if power state is on, else False
overwrite_config(filename)
read_line(c)

read a line. line end detected through ‘ ‘

  • parameters, types, return and return types:
param arg1:

connection

return:
True: if a line is read

self.buf contains the line

False :if prompt read

send_console_start(c)

task before starting a tc

send Ctrl-C besfore starting a Testcase
  • parameters, types, return and return types:
Parameters:arg1 – connection
Returns:True: if write was successful None: not able to open the stream
send_ctrl_c(c)

write Ctrl-C to the opened stream

If stream is not open, try to open it
  • parameters, types, return and return types:
Parameters:arg1 – connection
Returns:
Returns:True: if write was successful None: not able to open the stream
send_ctrl_c_con()

write Ctrl-C to the opened stream

If stream is not open, try to open it
  • parameters, types, return and return types:
Parameters:arg1 – connection
Returns:True: if write was successful None: not able to open the stream
send_ctrl_m(c)

write Ctrl-M to the opened stream

If stream is not open, try to open it
  • parameters, types, return and return types:
Parameters:arg1 – connection
Returns:True: if write was successful None: not able to open the stream
set_board_state(state)

set the board to a state

currrent states supported: ‘lab’ ‘u-boot’ ‘linux’

  • parameters, types, return and return types:
Parameters:arg1 – state string
Returns:True if switching to state had success

else testcase fails.

set_power_state(boardname, state)

set powerstate for the board in the lab

  • parameters, types, return and return types:
Parameters:
  • arg1 (string) – boardname
  • arg1 – state on/off
Returns:

True if setting state was successful, else False

set_prompt(c, prompt, ptype)

set the prompt for the connection c.

If ptype = ‘linux’ add some special settings to the prompt.

  • parameters, types, return and return types:
Parameters:
  • arg1 – connection
  • arg2 – new promt string
  • arg3 (string) – prompt type ‘linux’
Returns:

True: If setting the prompt was successful

False: If settting the prompt failed

set_term_length(c)

set terminal line length

ToDo How could this be set longer and do this correct - parameters, types, return and return types:: :param arg1: connection :return: no return value

statusprint(*args)

print a status string on stdout.

This output can be enabled through self.config.debugstatus
  • parameters, types, return and return types:
Parameters:arg1 – argument list
tbot_expect_prompt(c)

searches for prompt, endless

  • parameters, types, return and return types:
Parameters:arg1 – connection
tbot_expect_string(c, string)

expect a string

  • parameters, types, return and return types:
Parameters:
  • arg1 – connection
  • arg2 – string expected
Returns:

‘prompt’ if prompt found, True if string is found, else False

tbot_fakult(n)
tbot_get_password(user, board)

get the password for the user/board

The passwords are in the password.py file in the working directory. For example: if (user == ‘passwordforuserone’):

password = ‘gnlmpf’
if (user == ‘anotheruser’):
password = ‘passwordforanotheruser’
  • parameters, types, return and return types:
Parameters:
  • arg1 – user
  • arg2 – board
Returns:

return password if found end tc if not

tbot_rup_and_check_strings(c, strings)

read until prompt and search, if a string in strings is found.

If found, return index if read some chars, but no line, check if it is a prompt, return ‘prompt’ if it is a prompt. if a string in strings found return index else return None

  • parameters, types, return and return types:
Parameters:
  • arg1 – connection
  • arg2 – a list of strings
Returns:

index of string which is found ‘prompt’ if prompt found

tbot_rup_check_all_strings(c, strings, endtc=False)

read until prompt, and check if all strings in list strings are found

  • parameters, types, return and return types:
Parameters:
  • arg1 – connection
  • arg2 – a list of strings
Returns:

returns False, if not all strings in list are

found, or end tbot if endtc = True.

tbot_rup_error_on_strings(c, strings, endtc=False)

read until prompt and check, if a string in list is found.

If a string is found, end False.

  • parameters, types, return and return types:
Parameters:
  • arg1 – connection
  • arg2 – list of strings
  • arg3 – if endtc = True end with calling end_tc(True/False)
Returns:

True if prompt and no string is found.

tbot_start_wdt()

start the WDT process

tbot_trigger_wdt()

trigger the WDT

verboseprint(*args)

print a verbose string on stdout.

This output can be enabled through self.config.debug
  • parameters, types, return and return types:
Parameters:arg1 – argument list
write_cmd_check(c, cmd, string, start=True)

send a cmd and check if a string is read.

  • parameters, types, return and return types:
Parameters:
  • arg1 – connection
  • arg2 – command send over connection
  • arg3 – string which must be read
  • arg4 – start boolean, True, send console start before the

cmdstring. :return: True if prompt and string is read else False

write_lx_cmd_check(c, command, endTC=True, start=True)

write a linux command to console.

  • parameters, types, return and return types:
Parameters:
  • arg1 – connection
  • arg2 – commandstring
  • arg3 – if True and linux cmd ended False end TC with end_tc(False), else return True
  • arg4 – start boolean, True, send console start before the

cmdstring. :return: if linux cmd ended successful True, else False

write_stream(c, string, send_console_start=True)

write a string to connection

If stream is not open, try to open it
  • parameters, types, return and return types:
Parameters:
  • arg1 – connection
  • arg2 – string
  • arg3 – call send_console_start before sending string, default True
Returns:

True: if write was successful None: not able to open the stream

write_stream_con(string)

write a string to console connection

If stream is not open, try to open it
  • parameters, types, return and return types:
Parameters:arg1 – string
Returns:True: if write was successful None: not able to open the stream
write_stream_ctrl(string)

write a string to the ctrl connection

If stream is not open, try to open it
  • parameters, types, return and return types:
Parameters:arg1 – string
Returns:True: if write was successful None: not able to open the stream
write_stream_passwd(c, user, board)

write a passwd for user to connection

If stream is not open, try to open it Do not log it.
  • parameters, types, return and return types:
Parameters:
  • arg1 – connection
  • arg2 – user
  • arg3 – board
Returns:

return: True: if write was successful None: not able to open the stream

event

class tbot_event.events(tb, logfile)

Bases: object

The event class

create_event(pname, name, id, value)

create an event

  • parameters, types, return and return types:
Parameters:
  • arg1 – parent name
  • arg2 – function name
  • arg3 – Event ID
  • arg4 – value for event ID
create_event_log(c, dir, string)

create a log event

  • parameters, types, return and return types:
Parameters:
  • arg1 – connection
  • arg2 – direction (r or w)
  • arg3 – log string
event_flush()
list_backend()

list all registered backends.

ToDo

register_backend()

register a backend.

ToDo