Commit Graph

83 Commits

Author SHA1 Message Date
Randy Witt d893a2503d runqemu: Add a tcpserial option
The option was added so that the qemurunner could start a second tcp
serial port without adding machine conditional logic to qemurunner.

The issue that made this necessary was that when "virt" is passed to
qemu-system-aarch64, the normal mechanism for specifying a tcp serial
port does not work. This is because the hardware for the "virt" machine
is hardcoded in the device tree blob and the addition devices must be
virtio devices.

So runqemu can specify virtio for qemuarm64 whereas it seems all other
qemu machines work with the "-serial tcp*" option.

(From OE-Core rev: 849d65d55e4df5fa443b2cb7b4cee23913fc9d5a)

Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-08-24 23:47:07 +01:00
Randy Witt fd164dcc31 qemurunner: Use two serial ports and log console with a thread
qemu can freeze and stop responding if the socket buffer connected to a tcp
serial connection fills up. This happens of course when the reader of
the serial data doesn't actually read it.

This happened in the qemurunner code, because after checking for the
"login:" sentinel, data was never again read from the serial connection.

This patch solves the potential freeze by adding a thread to continuously
read the data from the console and log it. So it also will give a full log
of the console, rather than just up to the login prompt.

To simplify this patch, another serial port was also added to use for the
sole purpose of watching for the sentinel as well as being the interactive
serial port. This will also prevent the possibility of lots of debug
data on the console preventing the sentinel value from being seen due to
interleaved text.

(From OE-Core rev: 2da3fee6b6d9f4dd4c4cb529f4ba393c20aa0f13)

Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-08-24 23:47:07 +01:00
Randy Witt 8d05d8a0c4 qemurunner: Make create_socket() return data and use exceptions
So that create_socket() can be called more than once to create sockets,
it now returns the socket and port rather than setting class variables
directly.

create_socket() now only uses exceptions for errors, not the return
value from the function.

(From OE-Core rev: b46d83a848cf23c7f639a6ebafbd0f2c1413584a)

Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-08-24 23:47:06 +01:00
Randy Witt 62585cff0d qemurunner.py: Move some class variables that should only be local
The bootlog and qemusock variables were set in the class as part of the
create_socket() routine. However those variables are never used outside
of the same function and thus serve no purpose as class variables.

This initializes those variables near where they are used.

(From OE-Core rev: 829a6e521f15bae93d5f1a02dc67bc56a8c606c8)

Signed-off-by: Randy Witt <randy.e.witt@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-08-24 23:47:06 +01:00
Mariano Lopez 51d8e8fb37 qemurunner.py: Performance improvements in run_serial
This allow to search for the prompt after a command is
run so it can avoid waiting for the timeout.

Also corrected identation issues

[YOCTO #8118]

(From OE-Core rev: 600f35c0873a61f8cd02c0e5cc1495ce7785ea89)

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-08-16 09:25:00 +01:00
Mariano Lopez c0c463be28 qemurunner.py: Added raw mode in run_serial
Raw mode allows to send the command without sending
'echo $?' for validation; Also this doesn't remove the
command or the prompt from the output returned. In raw
mode validation is done if there is output.

This raw mode would be useful for validate the prompt
when a user logs in.

[YOCTO #8118]

(From OE-Core rev: b8ead7c0929c4096e50b481a608f5d0c09eab29d)

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-08-16 09:24:59 +01:00
Mariano Lopez a5bfa110f6 qemurunner.py: Added login to start method
This adds the automatic login after the target
finished booting. If the automatic login fails
it won't stop the target or any test, it would
only send a log to the file.

[YOCTO #8118]

(From OE-Core rev: cc2b1c28801399c6b525248fa0dabf7c42afc714)

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-08-16 09:24:59 +01:00
Mariano Lopez 78e1c4f146 qemurunner.py: Add method run_serial
The only need for the console before this patch was
to check if the target has booted. This allows to send
commands to the terminal.

This new method is based on the method with the same name
of the QemuTinyRunner class. The difference here is it will
remove the command and the prompt. The other diference is
it will send an echo $? to check if the last command was
successful.

[YOCTO #8118]

(From OE-Core rev: a82711fe4520538a732a16795d50573b6f1d4463)

Signed-off-by: Mariano Lopez <mariano.lopez@linux.intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-08-16 09:24:59 +01:00
Richard Purdie 37e78463e5 oeqa/qemurunner: Improve runqemu log output debug
If runqemu fails, ensure the log output is shown as its invaluable
to aid debugging. Its slightly convoluted since we need to ensure
we don't block on reading the pipe which may still be executing
hence the need for nonblocking IO.

(From OE-Core rev: 0e0fa1461863ec586b4f028dfd7d641f091ea928)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-08-09 00:13:58 -07:00
Alejandro Hernandez 0658434ee3 qemurunner: Improves checking for server and target IPs on qemus parameters
Fixes OS hanging infinitely waiting for qemus process to release bitbake.lock

(From OE-Core rev: d168bf34c553dbe5de7511e158cd83869d7a88bc)

Signed-off-by: Alejandro Hernandez <alejandro.hernandez@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-08-09 00:13:56 -07:00
Richard Purdie ae344c188d oeqa/qemurunner: Fix AttributeError: QemuRunner instance has no attribute 'server_socket'
If start() returns False due to create_socker() failing, stop() may still get
called and currently this gives a track back since server_socket doesn't exist.

Avoid this.

(From OE-Core rev: 26fb69ec663afd05134822dc5e48fc8928ea5bf1)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-27 23:29:15 +01:00
Richard Purdie f4f72b15ad qemurunner: Show last 25 line of log, not 5
For debugging purposes, 5 lines often isn't useful as it doesn't even
cover a full backtrace. Show 25 instead.

(From OE-Core rev: 5b3ff562b2c56df301fc402c8b84420d8d4e5705)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-27 23:29:15 +01:00
Paul Eggleton a6eb5ec327 oeqa/utils/qemurunner: fix error handling if runqemu exits with an error
* Don't wait for QEMU to start if it's never going to (because runqemu
  exited with an error)
* Don't error out if killing the process fails with "no such process"
  (we don't care if it's already dead)

(From OE-Core rev: 1789b89de6c4642464abadd9f8a4746385e6b4a7)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-27 23:29:14 +01:00
Paul Eggleton 7f9b42a90f oeqa/utils/qemurunner: avoid blocking on stty when running under oe-selftest
runqemu-internal runs stty to return the terminal to its previous state
in case QEMU hasn't done that properly (which it at least used to do
when it crashed). For some reason I have yet to determine, stty blocks
(on tcsetattr() according to gdb) when run within QemuRunner() under
oe-selftest, with the result that we always wait until the timeout and
then we kill the script, which adds an extra delay after QEMU is
stopped. Naturally you would assume that this is something to do with
the nature of the terminal under which it is being run; however no
amount of playing around with stdin/stdout/stderr seemed to fix the
issue, apart from passing in subprocess.PIPE as stdin which makes stty
error out with "stty: standard input: Inappropriate ioctl for device". I
was also unable to come up with a reliable test for the terminal which
we could use inside runqemu-internal to avoid calling stty. For now, go
with the stdin=subprocess.PIPE workaround to at least avoid the delay
with minimal ill effect.

(From OE-Core rev: a058d07cd7251749fa9c1c8eca3caa80144664fe)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-27 23:29:14 +01:00
Paul Eggleton 4855ec380f oeqa/utils/qemurunner: fix logging
OE-Core commit 519e381278d40bdac79add340e4c0460a9f97e17 unfortunately
broke logging in two different ways:

1) it prevented logging to the task log from working within bitbake
   -c testimage. This is due to the logger object being set up too early
   which interferes with BitBake's own logging. If we prefix the name
   with "BitBake." everything works (and we don't need to set the
   logging level).

2) Additionally because it called the log functions on the logging
   module and not the logger object it set up, this caused the
   oe-selftest logging to start printing everything from that point
   forward.

Fix these two issues and return us to the desired behaviour for
do_testimage.

(From OE-Core rev: 429b1971be06d5146bb1c14f4697966cddab3b33)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-27 23:29:14 +01:00
Ross Burton 9a539cbc19 oeqa/qemurunner: don't assume hostname starts with qemu
It's possible to customise the hostname trivially so don't assume that the
hostname hasn't been configured.

(From OE-Core rev: faf85728ed9a5a3af336f243f6f3567c773159cf)

Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-25 14:41:42 +01:00
Ross Burton 1b17b58c51 oeqa/QemuRunner: don't use bb for logging
Instead of using bb.note() etc for logging use logging.Logger directly, allowing
the use of QemuRunner outside of bitbake.

Also clean up the logging/errors by moving create_socket() out of
__init__()/restart() and into start().

(From OE-Core rev: 519e381278d40bdac79add340e4c0460a9f97e17)

Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2015-07-23 08:48:40 +01:00
Stefan Stanacar cdf4473332 oeqa/utils/qemurunner: search for login string in the entire boot log
If some service is to spammy we might miss the login, so search
in the entire log instead of just the last few lines.
Use qemu in regex too (to avoid a login string from some service).

(From OE-Core rev: 1117d25fdfabbf1afdc7030e05efc6a32df871e3)

Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-03-11 08:11:41 -07:00
Stefan Stanacar 678cca4421 oeqa/utils/qemurunner: use the right kill call so we don't send SIGTERM to bitbake-worker
After recent bitbake-worker changes [1] this was killing the bitbake-worker,
which isn't what we want and kill(-pid) was the wrong call anyway.

runqemu.pid is the right PGID as the process was started with preexec_fn=setpgrp
(so no need to do os.getpgid(self.runqemu.pid))

[1] http://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?id=15688798520896690561824b2fdc227c8a365c82

(From OE-Core rev: f4bf21b40ec6fa07c4a7bb450e3cfae12128dc2c)

Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2014-03-11 08:11:40 -07:00
Stefan Stanacar b4d9b4208b testimage: use the new targetcontrol.py module for running tests
This patch makes the necessary changes for using the targetcontrol.py module
so that one can run the same tests on a qemu instance or a remote machine
based on the value of TEST_TARGET variable: "qemu" or "simpleremote".
The default value is "qemu" which starts a qemu instance and it's the
with what we currently have.

With "simpleremote", the remote machine must be up with network and ssh
and you need to set TEST_TARGET_IP with the IP address of the remote machine
(it can still be a qemu instance that was manually started).

Basically testimage.bbclass now does something along the lines of:
 - load tests -> deploy (prepare) / start target -> run tests.
There were a couple of changes necessary for tests and
also some cleanups/renames that were needed to adjust this change. (use
ip everywhere when refering to target and server_ip when refering to host/build machine)
Also two unnecessary and unsed methods were dropped from sshcontrol.

[ YOCTO #5554 ]

(From OE-Core rev: a7820350fa3271d78ed7476e02f4aef593be1125)

Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-12-03 17:45:51 +00:00
Ross Burton 4a224d31c8 qemurunner: disable grabs in automated testing
Use the new QEMU_DONT_GRAB environment variable to disable grabs,
finally/hopefully solving the random hangs that the autobuilder has been hitting
for a while.

[ YOCTO #5131 ]

(From OE-Core rev: 32f9575a565f350649264c11eceba8311584b0fd)

Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-18 17:52:04 +01:00
Paul Eggleton 6670be71f7 bitbake.conf: include machine name in DEPLOY_DIR_IMAGE
This allows a clean seperation between image outputs from different
machines, and makes it possible to have convenience symlinks to make
the output ready to deploy.

This did require some surgery in runqemu; if explicit paths to the image
and kernel are not supplied then DEPLOY_DIR_IMAGE needs to be determined
from bitbake or set in the environment. However the script does try to
avoid requiring it unless it really is needed. Corresponding changes
were made in the automated testing code as well.

Based on an RFC patch by Koen Kooi <koen@dominion.thruhere.net>

(From OE-Core rev: 7e90261aec61f79680b5eaeaf5b18c7b795412a4)

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-14 08:21:00 +01:00
Richard Purdie 9b84fc7cc2 lib/oeqa/qemurunner: Use a timeout in select() call
A 0 value to select.select() immediately returns with no timeout. This was
pegging the cpu at 100% for the python process which was bad and may be
contributing to some of the timeout problems.

Profile from -P of a core-image-minimal before:

    97526792 function calls (97525652 primitive calls) in 45.189 seconds

and after:

       50204 function calls (49064 primitive calls) in 17.318 seconds

Saving 97.5 million function calls has to be good :)

(From OE-Core rev: c0551436974d179df23418567f18a082830380f6)

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-09-06 23:04:51 +01:00
Stefan Stanacar 249dc825a0 lib/oeqa/utils: qemurunner: fix when runqemu errors out
When qemu doesn't start or runqemu errors out
(some wrong option passed or sudo needs a password for setting tap) we
want to display the output but oe-core commit 9de7fe11967576f4a8b24e653c6b9a02e5f6d85b/
poky commit 51588936d4
changed the kill method and broke this code, so let's fix it.

(From OE-Core rev: 923d4bd548911caa0b419c10905895af1e8e7026)

Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-30 16:23:47 +01:00
Stefan Stanacar 51588936d4 lib/oeqa: make it possible to restart the target
Tweak QemuRunner so we can actually restart the
qemu target in a test (if we want more memory for example).
Also add a restart method to the base test class so that tests
can use it.

(From OE-Core rev: 9de7fe11967576f4a8b24e653c6b9a02e5f6d85b)

Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-26 11:47:21 +01:00
Mihai Lindner a9dab56e5d lib/oeqa/utils: qemurunner: save host IP address
Save host IP address to host_ip.
Read /proc/PID/cmdline on host to look for IPs of target and host;
instead of running 'ps'.
Also removed some extra empty lines from file.

(From OE-Core rev: 1fcf10db10fa36430e37c95c9fee27197e73f7a5)

Signed-off-by: Mihai Lindner <mihaix.lindner@linux.intel.com>
Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-26 11:47:21 +01:00
Stefan Stanacar 0ba78c1162 oeqa/utils/qemurunner: get ip old fashioned way and use tcp serial console
The way we read data from the serial console was unreliable and blocking (AutoBuilder
seems to hit that often), so change the serial console type from unix socket to tcp
and reverse the connection - don't let qemu act as server (wait for a connection).
So now the serial console is used to save the boot log and make sure that we reached
the login prompt. Until a better way is found this should solve some of the AutoBuilder
failures (one being YB#4904).

Also we need to use the same method as the old qemuimagetest to get the ip
(from the qemu process arguments), because that it's more reliable.
The first version used here was to log into the target and use the output of
"ip addr show eth0" but then systemd decides that it should rename interfaces,
so that was changed to get the ip of the interface that has the default gw,
but if there is no default gw we'll get the loopback ip and we end up trying to
ssh into the host machine (some recent AutoBuilder runs showed that).

Changed in V2:
 - use -ww for ps, as output might get truncated

(From OE-Core rev: 55e78185110937b7e2b143cf1020426d8df58b72)

Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-13 23:05:59 +01:00
Stefan Stanacar 76f8dfe2ad oeqa/utils/qemurunner: fix wrong var in message
If nothing matches we should print the text not
the match, else we get a nice traceback.

Changed in V2:
 - commit message

(From OE-Core rev: 601738fee3e9b7909b63714ca725576c10eec1e3)

Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-06 12:39:57 +01:00
Stefan Stanacar 26d67b98f8 oeqa/utils/qemurunner: tweak console bootparam and ip command
Sync serial baud rate with default inittab which should
help with apparent boot fails. Also keep a console on tty1.

Also we shouldn't assume eth0 it the right interface.
(systemd images can rename interfaces to something else).

(From OE-Core rev: d5620c0b6782b88f3e6de97b1ddadcf21207fc57)

Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-03 10:33:02 +01:00
Stefan Stanacar fce0c9906f oeqa/utils/qemurunner: add comment and header
One of the files was missing comment/header, unlike the others.

(From OE-Core rev: 054dba3b7b96349e1e20e3a58acd98bb68ab2536)

Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-08-03 10:33:02 +01:00
Stefan Stanacar 655da29dac classes/testimage.bbclass: use a copy of rootfs for tests
Make a copy of the rootfs and test that.
We can now drop the snapshot option.

(From OE-Core rev: ba58f1fe8fb7a0e3ff9320dfc108235d484da6a1)

Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-07-16 10:04:16 +01:00
Stefan Stanacar 9c4a02b6c6 testimage.bbclass, lib/oeqa/utils/qemurunner.py: make boot timeout configurable and increase it
On a loaded host (such as an AB setup where multiple builds run)
the 200 seconds timeout might not be enough to reach the login prompt.
Also make it configurable so we can set it from local.conf/auto.conf

(From OE-Core rev: e828571683333e6f18ed56a84e114b5e54975bc7)

Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Saul Wold <sgw@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-07-16 10:04:15 +01:00
Radu Moisan 88a6eb8027 lib/oeqa/utils/qemurunner.py: class to handle qemu instance
Handles qemu instances (launch, kill, restart, serial connection, logging)
Launch is blocking until login prompt and returns to the task. A qemu
serial connection is used to save the boot log and get the ip from the image.
Changed runqemu script not to error out when using custom serial option.

(From OE-Core rev: ee7d64dfcc02ba8f568b17d181e0a58d3c810076)

Signed-off-by: Radu Moisan <radu.moisan@intel.com>
Signed-off-by: Stefan Stanacar <stefanx.stanacar@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
2013-07-09 10:53:45 +01:00