This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH 14/25] [RFC] GDBserver self test
- From: Pedro Alves <palves at redhat dot com>
- To: Yao Qi <qiyaoltc at gmail dot com>, gdb-patches at sourceware dot org
- Date: Wed, 28 Jun 2017 18:08:55 +0100
- Subject: Re: [PATCH 14/25] [RFC] GDBserver self test
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com BB10261B92
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com BB10261B92
- References: <1497256916-4958-1-git-send-email-yao.qi@linaro.org> <1497256916-4958-15-git-send-email-yao.qi@linaro.org>
On 06/12/2017 09:41 AM, Yao Qi wrote:
> This patch uses GDB self test in GDBserver. The self tests are run if
> GDBserver is started with option --self-test.
The name of the corresponding gdb command is "maint selftest",
i.e., no hyphen. If wonder if we should be consistent.
>
> gdb/gdbserver:
>
> 2017-05-26 Yao Qi <yao.qi@linaro.org>
>
> * configure.ac: AC_DEFINE GDB_SELF_TEST if $development.
> * configure, config.in: Re-generated.
> * server.c: Include sefltest.h and selftest.c.
> (captured_main): Handle option --self-test.
> gdb:
>
> 2017-05-26 Yao Qi <yao.qi@linaro.org>
>
> * selftest.c: Adjust it for GDBserver.
>
> gdb/testsuite:
>
> 2017-05-26 Yao Qi <yao.qi@linaro.org>
>
> * gdb.server/unittest.exp: New.
I like the idea of running unit tests in gdbserver
(and we briefly discussed it when we introduced selftest-arch.c
IIRC).
But I don't know whether you're proposing the patch as
is, or whether it's really just for comments on the idea.
I say this because there are several hacks in the patch
that ideally we'd avoid.
> +#include "../selftest.h"
> +#include "../selftest.c"
E.g., we should really move these to common/ and void
the #ifdefery within them.
> +global server_spawn_id
> +
> +set gdbserver [find_gdbserver]
> +set gdbserver_command "$gdbserver --self-test"
> +
> +set server_spawn_id [remote_spawn target $gdbserver_command]
> +
> +gdb_expect {
> + -i $server_spawn_id
> + -re "Ran $decimal unit tests, 0 failed" {
> + pass "unit tests"
> + }
> + -re "Ran $decimal unit tests, $decimal failed" {
> + fail "unit tests"
> + }
Shouldn't this have a "default" case that fails instead
of only handling one specific failure mode?
Thanks,
Pedro Alves