From 334a994a3c09607bc0a8f746ee2bbda5eaec3ede Mon Sep 17 00:00:00 2001 From: Heiko Schocher Date: Tue, 26 Jan 2016 08:42:48 +0100 Subject: test, tools: introduce tbot README introduce a README how to use tbot for testing U-Boot and/or linux kernels. Signed-off-by: Heiko Schocher --- tools/tbot/README.create_a_new_testcase | 117 ++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 tools/tbot/README.create_a_new_testcase (limited to 'tools/tbot/README.create_a_new_testcase') diff --git a/tools/tbot/README.create_a_new_testcase b/tools/tbot/README.create_a_new_testcase new file mode 100644 index 0000000..fbf8ae8 --- /dev/null +++ b/tools/tbot/README.create_a_new_testcase @@ -0,0 +1,117 @@ +# Copyright (c) 2016 DENX Software Engineering GmbH +# Heiko Schocher +# +# SPDX-License-Identifier: GPL-2.0+ +# + +write a new testcase +===================== + +A TC is written in python, so you can use python as usual. For accessing +the boards console, use functions from the tbotlib, therefore + +First import the tbotlib with the line: + + from tbotlib import tbot + +If your TC uses variables, please add a line which adds them to +the log file (for debugging purposes): + + logging.info("args: %s ...", tb.varname, ...) + +Say tbot, for which board state your TC is valid with: + + tb.set_board_state("u-boot") + +Then you are ready ... and you can use the tbotlib funtions +for writting/reading to the boards console. + +Big fat warning: + +A TC must worry about to end only if a board has finished the shell +command! + +Not following this rule, will end in unpredictable behaviour. + +(hopefully) useful tbotlib functions +==================================== +- set the board state, you want to test + tb.set_board_state(state) + states are: "u-boot" or "linux" + If tbot could not set the board state, tbot ends with failure. + +- write a command to the boards console: + tb.eof_write_con(command): + write the command to the boards console. If this + fails, tbot ends with failure + +- write a command to boards console and wait for prompt: + tb.eof_write_cmd(fd, command): + fd: filedescriptor which is used, use tb.channel_con for boards console + command: command which is written to fd + + Wait endless for board prompt + +- write a list of commands to boards console: + tb.eof_write_cmd_list(fd, cmdlist): + fd: filedescriptor which is used, use tb.channel_con for boards console + cmdlist: python list of commandstrings which is written to fd + +- wait for boards prompt: + tb.eof_read_end_state_con(retry): + retry: deprecated, not used anymore, cleanup needed here... + tbot waits endless for the boards prompt + +- write a command, wait for prompt and check, if a string is read + tb.write_cmd_check(fd, cmd, string): + fd: filedescriptor which is used, use tb.channel_con for boards console + cmd: command, which is send to fd + string: string which should be read from fd + + return value: + True, if string is read and tbot got back boards prompt + False, else + + tb.eof_write_cmd_check(fd, cmd, string): + same as tb.write_cmd_check(fd, cmd, string) except, that tbot + ends immediately with Failure, if string is not read. + +- read until prompt and search strings: + tb.readline_and_search_strings(fd, strings): + fd: filedescriptor which is used, use tb.channel_con for boards console + strings: python list of strings, which can be read + If one of this strings is read, this function return the index, which + string is read. This function shoud be called in a while loop, + until this function returns 'prompt' + +- read a line from filedescriptor: + not recommended to use, as the TC must check, if tprompt is read for every + readen line. Also TC must ensure, that it ends only, if prompt is read. + tb.read_line(fd, retry) + fd: filedescriptor which is used, use tb.channel_con for boards console + retry: retry of trying to reead a line + + return values: + True, if a line is read. Readen line in tb.buf[fd] + False, if something read, but not a complete line + None, if nothing is read + + check if string contains prompt with: + tb.is_end_fd(fd, string) + fd: filedescriptor which is used, use tb.channel_con for boards console + string: buffer, in which a prompt gets searched. + +- calling other TC: + eof_call_tc(name): + call another TC from "src/tc" + if the called TC fails with failure, tbot ends with failure + + call_tc(name): + call another TC from "src/tc" + if the TC which call_tc calls fails, call_tc() returns False, else True + +There are more functions, but for writting TC this should be enough. But +its software, so new useful functions can always pop up. + +Heiko Schocher +v1 2016.01.23 -- cgit v1.1