[PATCH xorg-gtest] Expand on the default 'failed to open connection to display' error

Daniel Stone daniel at fooishbar.org
Mon Nov 5 21:28:04 PST 2012


Well, I've never used stringstream, so:

Acked-by: Daniel Stone <daniel at fooishbar.org>


On 6 November 2012 12:28, Peter Hutterer <peter.hutterer at who-t.net> wrote:

> Virtually everyone trying the tests the first time will run into this issue
> since we cannot check if the ABI for dummy and whatever else is needed
> actually matches the server (well, we have a test for that, but unless you
> run that one first...)
>
> So be at least more verbose about the potential reasons and provide some
> basic debugging help.
>
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  src/test.cpp | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/src/test.cpp b/src/test.cpp
> index c7b69bc..a484787 100644
> --- a/src/test.cpp
> +++ b/src/test.cpp
> @@ -50,8 +50,15 @@ void xorg::testing::Test::SetUp() {
>      dpy = d_->display_string.c_str();
>
>    d_->display = XOpenDisplay(dpy);
> -  if (!d_->display)
> -    throw std::runtime_error("Failed to open connection to display");
> +  if (!d_->display) {
> +    std::stringstream ss;
> +    ss << "Failed to open connection to display";
> +    if (dpy != NULL) ss << " " << dpy;
> +    ss << ".\nThis usually means that your X server did not start
> properly.\n";
> +    ss << "Check the log file, or set XORG_GTEST_CHILD_STDOUT to see the
> server's\n"
> +          "error messages when starting.";
> +    throw std::runtime_error(ss.str());
> +  }
>  }
>
>  void xorg::testing::Test::TearDown() {
> --
> 1.7.11.7
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.x.org/archives/xorg-devel/attachments/20121106/ededc582/attachment-0001.html>


More information about the xorg-devel mailing list