This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 14/25] [RFC] GDBserver self test


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]