blob: a637a63d32fab311e584172ea777f9a6ca1386e3 [file] [log] [blame]
Heiko Schocher334a9942016-01-26 08:42:48 +01001# Copyright (c) 2016 DENX Software Engineering GmbH
2# Heiko Schocher <hs@denx.de>
3#
4# SPDX-License-Identifier: GPL-2.0+
5#
6
7What is tbot ?
8==============
9
10tbot is a tool for executing testcases on boards.
11Source code found on [1]
12Based on DUTS [2]
13written in python
14
15Basic Ideas of tbot
16===================
17(see also the figure:
18https://github.com/hsdenx/tbot/blob/master/doc/tbot_structure.png )
19
20- Virtual laboratory (VL)
21 VL is the basic environment that groups:
22 - [a number of] boards - target devices on which tbot executes testcases.
23 - one Lab PC
24
25- Test case (TC):
26 A piece of python code, which uses the tbot class from [1].
27 Tbot provides functions for sending shell commands and parsing the
28 shell commands output.
29 Tbot waits endless for a shell commands end (detected through reading
30 the consoles prompt).
31 A TC can also call other TC-es.
32
33 remark:
34 Tbot not really waits endless, for a shell commands end, instead
35 tbot starts a watchdog in the background, and if it triggers, tbot
36 ends the TC as failed. In the tbot beginning there was a lot of
37 timeouts / retry cases, but it turned out, that waiting endless
38 is robust and easy ...
39
40- Host PC (where tbot runs, currently only linux host tested)
41 must not a powerful machine (For example [3], I use a
42 raspberry pi for running tbot and buildbot)
43
44- Lab PC:
45 - Host PC connects through ssh to the Lab PC
46 -> so it is possible to test boards, which
47 are not at the same place as the Host PC.
48 (Lab PC and Host PC can be the same of course)
49 -> maybe we can setup a Testsystem, which does nightly
50 U-Boot/Linux builds and test from current mainline U-Boot
51 on boards wherever they are accessible.
52
53 - necessary tasks a Lab PC must deliver:
54 - connect to boards console through a shell command.
55 - power on/off boards through a shell command
56 - detect the current power state of a board through
57 a shell command
58
59 - optional tasks:
60 - tftp server (for example loading images)
61 - nfs server (used as rootfs for linux kernels)
62 - Internet access for example for downloading
63 U-Boot source with git.
64 - toolchains installed for compiling source code
65
66 -> a linux machine is preffered.
67
68 - currently only Lab PC with an installed linux supported/tested.
69
70- Boards(s):
71 the boards on which shell commands are executed.
72
73- Board state:
74 equals to the software, the board is currently running.
75
76 Currently tbot supports 2 board states:
77 - "u-boot", if the board is running U-Boot
78 - "linux", if the board is running a linux kernel
79
80 It should be easy to add other board states to tbot, see
81 https://github.com/hsdenx/tbot/tree/master/src/lab_api/state_[u-boot/linux].py
82
83 A board state is detected through analysing the boards
84 shell prompt. In linux, tbot sets a special tbot prompt,
85 in U-Boot the prompt is static, and configurable in tbot through
86 a board config file.
87
88 A TC can say in which board state it want to send shell commands.
89 Tbot tries to detect the current board state, if board is not in
90 the requested board state, tbot tries to switch into the correct
91 state. If this fails, the TC fails.
92
93 It is possible to switch in a single TC between board states.
94
95- tbot cmdline parameters:
96
97$ python2.7 src/common/tbot.py --help
98Usage: tbot.py [options]
99
100Options:
101 -h, --help show this help message and exit
102 -c CFGFILE, --cfgfile=CFGFILE
103 the tbot common configfilename
104 -l LOGFILE, --logfile=LOGFILE
105 the tbot logfilename, if default, tbot creates a
106 defaultnamelogfile
107 -t TC, --testcase=TC the testcase which should be run
108 -v, --verbose be verbose, print all read/write to stdout
109 -w WORKDIR, --workdir=WORKDIR
110 set workdir, default os.getcwd()
111$
112
113tbot needs the following files for proper execution:
114
115 - tbot board configuration file (option -c):
116 A board configuration file contains settings tbot needs to
117 connect to the Lab PC and board specific variable settings
118 for testcases.
119
120 - name of the logfile tbot creates (option -l)
121 defaultname: 'log/' + now.strftime("%Y-%m-%d-%H-%M") + '.log'
122
123 - tbots working directory (option -w)
124
125 - the testcasename tbot executes (option -t)
126
127You are interested and want to use tbot?
128If so, please read on the file:
129tools/tbot/README.install
130
131If not read [3] ;-)
132
133Heiko Schocher <hs@denx.de>
134v1 2016.01.22
135
136--------------
137[1] https://github.com/hsdenx/tbot
138[2] http://www.denx.de/wiki/DUTS/DUTSDocs
139[3] automated Testsetup with buildbot and tbot doing cyclic tests
140 (buildbot used for starting tbot TC and web presentation of the
141 results, all testing done through tbot):
142 http://xeidos.ddns.net/buildbot/tgrid
143 Host PC in Letkes/hungary
144 VL in munich/germany
145
146 Fancy things are done here, for example:
147 - http://xeidos.ddns.net/buildbot/builders/smartweb_dfu/builds/43/steps/shell/logs/tbotlog
148 (I try to cleanup the logfile soon, so it is not so filled with crap ;-)
149 A first step see here:
150 http://xeidos.ddns.net/buildbot/builders/smartweb_dfu/builds/45/steps/shell/logs/tbotlog
151 (same TC now with the new loglevel = 'CON' ... not yet perfect)
152 Executed steps:
153 - clone u-boot.git
154 - set toolchain
155 - get a list of patchwork patches from my U-Boots ToDo list
156 - download all of them, and check them with checkpatch
157 and apply them to u-boot.git
158 - compile U-Boot for the smartweb board
159 - install the resulting images on the smartweb board
160 - boot U-boot
161 - test DFU
162 - more TC should be added here for testing U-Boot
163
164 - automatic "git bisect"
165 https://github.com/hsdenx/tbot/blob/master/src/tc/tc_board_git_bisect.py
166 http://xeidos.ddns.net/buildbot/builders/tqm5200s/builds/3/steps/shell/logs/tbotlog
167
168 If a current U-Boot image not works on the tqm5200 board
169 this TC can be started. It starts a "git bisect" session,
170 and compiles for each step U-Boot, install it on the tqm5200
171 board, and tests if U-Boot works !
172
173 At the end, it detects the commit, which breaks the board
174
175 This TC is not dependend on U-Boot nor on a special board. It
176 needs only 3 variables:
177 tb.board_git_bisect_get_source_tc: TC which gets the source tree, in which
178 "git bisect" should be executed
179 tb.board_git_bisect_call_tc: TC which gets called every "git bisect" step,
180 which executes commands for detecting if current source code is OK or not.
181 This could be a TC which compiles U-Boot, install it on the board and
182 executes TC on the new booted U-Boot image. ! Board maybe gets borken,
183 as not all U-Boot images work, so you must have a TC which install U-Boot
184 image for example through a debugger.
185 tb.board_git_bisect_good_commit: last nown good commit id