[PATCH xorg-gtest 08/16] xserver: return used display number from Start()

Chase Douglas chase.douglas at canonical.com
Tue Jul 3 10:43:29 PDT 2012


On 07/02/2012 11:44 PM, Peter Hutterer wrote:
> Doesn't do much yet, but once we support -displayfd we can hook it up here.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>   include/xorg/gtest/xorg-gtest-xserver.h |    7 +++++--
>   src/xserver.cpp                         |    9 ++++++---
>   2 files changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/include/xorg/gtest/xorg-gtest-xserver.h b/include/xorg/gtest/xorg-gtest-xserver.h
> index 33331cd..5cab01b 100644
> --- a/include/xorg/gtest/xorg-gtest-xserver.h
> +++ b/include/xorg/gtest/xorg-gtest-xserver.h
> @@ -48,13 +48,16 @@ class XServer : public xorg::testing::Process {
>
>       /**
>        * Start a new server, using the default binary
> +     *
> +     * @return The display number this server is running on
>        */
> -    void Start(void);
> +    unsigned int Start(void);
>       /**
>        * Start a new server
>        * @param [in] program Path to the XServer binary
> +     * @return The display number this server is running on
>        */
> -    void Start(std::string &program);
> +    unsigned int Start(std::string &program);

I would rather we separate the starting from the getting of the display 
number. Basically, it's not obvious that you have to get the return 
value of Start() to determine the display number unless you look at the 
documentation. Can we add a getter method instead? It also would allow 
getting the display number after the server has already been started.

>
>       /**
>        * Terminates this server process. Will signal the server to terminate
> diff --git a/src/xserver.cpp b/src/xserver.cpp
> index 160eadc..f5fd245 100644
> --- a/src/xserver.cpp
> +++ b/src/xserver.cpp
> @@ -289,11 +289,11 @@ void xorg::testing::XServer::TestStartup(void) {
>
>   }
>
> -void xorg::testing::XServer::Start(void) {
> -  Start(d_->path_to_server);
> +unsigned int xorg::testing::XServer::Start(void) {
> +  return Start(d_->path_to_server);
>   }
>
> -void xorg::testing::XServer::Start(std::string &program) {
> +unsigned int xorg::testing::XServer::Start(std::string &program) {
>     TestStartup();
>     Process::Start(program, program.c_str(),
>                    GetDisplayString(),
> @@ -301,6 +301,9 @@ void xorg::testing::XServer::Start(std::string &program) {
>                    "-logfile", d_->path_to_logfile.c_str(),
>                    "-config", d_->path_to_conf.c_str(),
>                    NULL);
> +
> +  /* FIXME: use -displayfd here once the released servers support it */
> +  return d_->display_number;
>   }
>
>   bool xorg::testing::XServer::Terminate(void) {
>



More information about the xorg-devel mailing list