summaryrefslogtreecommitdiffstats
path: root/support/testing/infra/emulator.py
Commit message (Collapse)AuthorAgeFilesLines
* support/testing: allow to use a multiplier for timeoutsRicardo Martincoski2017-08-101-3/+10
| | | | | | | | | | | | | Add a parameter to run-tests to act as a multiplier for all timeouts of emulator. It can be used to avoid sporadic failures on slow host machines as well in elastic runners on the cloud. Cc: Arnout Vandecappelle <arnout@mind.be> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> [Arnout: rename multiplier to timeout_multiplier everywhere] Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
* testing/infra/emulator: remove qemu warnings about audioRicardo Martincoski2017-07-311-1/+2
| | | | | | | | | | | | | | | | | The default audio backend for qemu is configured at compile time. It generates annoying warning messages to qemu's stderr when running our tests, like these: pulseaudio: set_sink_input_volume() failed pulseaudio: Reason: Invalid argument pulseaudio: set_sink_input_mute() failed pulseaudio: Reason: Invalid argument Explicitly set the audio backend to "none" at runtime to remove those messages from our logs. There is no command line argument for this, so use an environment variable when starting qemu. Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
* testing/infra/emulator: allow to specify pexpect timeoutAndrey Smirnov2017-07-221-3/+3
| | | | | | | | | | | Some commands take more than 5 seconds to complete under QEMU, so add provisions to allow individual unit-test to specify different duration to avoid false negative test failures. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Reviewed-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Tested-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
* support/testing: large timeout for login promptRicardo Martincoski2017-07-011-1/+3
| | | | | | | | | | | When running multiple instances of emulator in parallel, the login prompt can take some time to appear. Use a large timeout when waiting for the prompt to avoid random failures. Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
* support/testing: fix code style in emulatorRicardo Martincoski2017-07-011-1/+1
| | | | | | | | Remove unused import. Use 2 empty lines before a class. Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
* support/testing: use pexpect.expect directlyRicardo Martincoski2017-07-011-22/+13
| | | | | | | | When using pexpect there is no need for a helper function. Just use expect() directly everywhere. Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
* support/testing: use pexpect.sendline directlyRicardo Martincoski2017-07-011-7/+4
| | | | | | | | When using pexpect there is no need for a helper function. Just use sendline() directly everywhere. Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
* support/testing: let pexpect write stdout to logRicardo Martincoski2017-07-011-1/+2
| | | | | | | | | | | | | | | When the parameter logfile is passed to spawn(), pexpect sends both stdin and stdout to the logfile and it creates a double echo effect. One way to avoid the double echo in the logfile would be to disable the echo on the terminal just after login ("stty -echo"), but double echo of user and password would remain. Instead of that, send only the stdout to the logfile using the logfile_read property. Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
* support/testing: use qemu stdio in emulatorRicardo Martincoski2017-07-011-16/+8
| | | | | | | | | | | | | Instead of redirecting qemu serial to telnet, redirect it to stdio. It allows to run testcases in parallel without random failing caused by two emulators trying to use the same telnet port (1234). 'qemu -serial stdio' returns some extra <CR> characters, so remove them from the log. Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
* support/testing: use pexpect in emulatorRicardo Martincoski2017-07-011-15/+13
| | | | | | | | | | Replace subprocess + telnetlib with pexpect. Use the telnet installed on the host machine instead of telnetlib, while the serial from qemu is not yet redirected to stdio. Signed-off-by: Ricardo Martincoski <ricardo.martincoski@gmail.com> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
* support/testing: simplify logging by keeping the log file openLuca Ceresoli2017-05-171-10/+5
| | | | | | | | | | | | | | | We currently call infra.smart_open() to open log files each time we need to write to them. Opening the file once in the constructor of Builder and Emulator and writing to it whenever needed is simpler and slightly more efficient. Remove smart_open and instead create a new open_log_file() function which just opens the logfile. Also let it compute the filename, in order to simplify even further the Builder and Emulator code. Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
* support/testing: core testing infrastructureThomas Petazzoni2017-05-071-0/+135
This commit adds the core of a new testing infrastructure that allows to perform runtime testing of Buildroot generated systems. This infrastructure uses the Python unittest logic as its foundation. This core infrastructure commit includes the following aspects: - A base test class, called BRTest, defined in support/testing/infra/basetest.py. This base test class inherited from the Python provided unittest.TestCase, and must be subclassed by all Buildroot test cases. Its main purpose is to provide the Python unittest setUp() and tearDown() methods. In our case, setUp() takes care of building the Buildroot system described in the test case, and instantiate the Emulator object in case runtime testing is needed. The tearDown() method simply cleans things up (stop the emulator, remove the output directory). - A Builder class, defined in support/testing/infra/builder.py, simply responsible for building the Buildroot system in each test case. - An Emulator class, defined in support/testing/infra/emulator.py, responsible for running the generated system under Qemu, allowing each test case to run arbitrary commands inside the emulated system. - A run-tests script, which is the entry point to start the tests. Even though I wrote the original version of this small infrastructure, a huge amount of rework and improvement has been done by Maxime Hadjinlian, and squashed into this patch. So many thanks to Maxime for cleaning up and improving my Python code! Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
OpenPOWER on IntegriCloud