[PATCH xorg-gtest 1/3] Added --xorg-logfile option.

walter harms wharms at bfs.de
Mon Jan 30 09:43:11 PST 2012



Am 30.01.2012 18:32, schrieb Daniel d'Andrada:
> And by default point to a location that doesn't require root privileges
> to be used. This is an enabler to make it possible to run Xorg without
> being root.
> 
> Signed-off-by: Daniel d'Andrada <daniel.dandrada at canonical.com>
> 
> diff --git a/include/xorg/gtest/environment.h
> b/include/xorg/gtest/environment.h
> index fd550e7..65a28d5 100644
> --- a/include/xorg/gtest/environment.h
> +++ b/include/xorg/gtest/environment.h
> @@ -48,11 +48,13 @@ namespace testing {
>   * with the overall testing framework like
>   * @code
>   * std::string xorg_conf_path("conf/dummy.conf");
> + * std::string xorg_logfile_path("./MyXorg.log");

Do you realy want all the log crap in you $HOME instead a nice subdir
where you can kill them all at once ?

It has nothing to do being root or not

re,
 wh


>   * int xorg_display = 133;
>   * std::string server("Xorg");
>   *
>   * xorg::testing::Environment* environment = new
> xorg::testing::Environment(
>   *       xorg_conf_path,
> + *       xorg_logfile_path,
>   *       server,
>   *       xorg_display);
>   * testing::AddGlobalTestEnvironment(environment);
> @@ -64,10 +66,12 @@ class Environment : public ::testing::Environment {
>    /**
>     * Constructs an object to provide a global X server dummy environment.
>     * @param path_to_conf Path to xserver configuration.
> +   * @param path_to_logfile Path to xserver logfile.
>     * @param path_to_server Path to xserver executable.
>     * @param display Display port of dummy xserver instance.
>     */
>    Environment(const std::string& path_to_conf,
> +              const std::string& path_to_logfile = "/tmp/Xorg.GTest.log",
>                const std::string& path_to_server = "Xorg", int display =
> 133);
> 
>    virtual ~Environment();
> diff --git a/src/environment.cpp b/src/environment.cpp
> index b00eaf9..62bd551 100644
> --- a/src/environment.cpp
> +++ b/src/environment.cpp
> @@ -35,20 +35,24 @@
>  #include <X11/Xlib.h>
> 
>  struct xorg::testing::Environment::Private {
> -  Private(const std::string& conf, const std::string& server, int
> display_num)
> -      : path_to_conf(conf), path_to_server(server), display(display_num) {
> +  Private(const std::string& conf, const std::string& logfile,
> +          const std::string& server, int display_num)
> +      : path_to_conf(conf), path_to_logfile(logfile),
> path_to_server(server),
> +        display(display_num) {
>    }
> 
>    const std::string path_to_conf;
> +  const std::string path_to_logfile;
>    const std::string path_to_server;
>    const int display;
>    Process process;
>  };
> 
>  xorg::testing::Environment::Environment(const std::string& path_to_conf,
> +                                        const std::string&
> path_to_logfile,
>                                          const std::string& path_to_server,
>                                          int display)
> -    : d_(new Private(path_to_conf, path_to_server, display)) {
> +    : d_(new Private(path_to_conf, path_to_logfile, path_to_server,
> display)) {
>  }
> 
>  xorg::testing::Environment::~Environment() {}
> @@ -58,7 +62,10 @@ void xorg::testing::Environment::SetUp() {
>    snprintf(display_string, 6, ":%d", d_->display);
> 
>    d_->process.Start(d_->path_to_server, d_->path_to_server.c_str(),
> -                    display_string, "-config",
> d_->path_to_conf.c_str(), NULL);
> +                    display_string,
> +                    "-logfile", d_->path_to_logfile.c_str(),
> +                    "-config", d_->path_to_conf.c_str(),
> +                    NULL);
> 
>    Process::SetEnv("DISPLAY", display_string, true);
> 
> diff --git a/src/main.cpp b/src/main.cpp
> index 331aa28..eb6e728 100644
> --- a/src/main.cpp
> +++ b/src/main.cpp
> @@ -25,12 +25,15 @@
> 
>  #include "xorg/gtest/environment.h"
> 
> +#define DEFAULT_XORG_LOGFILE "/tmp/Xorg.GTest.log"
> +
>  namespace {
> 
>  int help = false;
>  int no_dummy_server = false;
>  int xorg_conf = false;
>  int xorg_display_opt = false;
> +int xorg_logfile = false;
>  int server = false;
> 
>  const struct option longopts[] = {
> @@ -38,6 +41,7 @@ const struct option longopts[] = {
>    { "no-dummy-server", no_argument, &no_dummy_server, true, },
>    { "xorg-conf", required_argument, &xorg_conf, true, },
>    { "xorg-display", required_argument, &xorg_display_opt, true, },
> +  { "xorg-logfile", required_argument, &xorg_logfile, true, },
>    { "server", required_argument, &server, true, },
>    { NULL, 0, NULL, 0 }
>  };
> @@ -48,6 +52,8 @@ int main(int argc, char *argv[]) {
>    /* Default Xorg dummy conf path. */
>    std::string xorg_conf_path(DUMMY_CONF_PATH);
> 
> +  std::string xorg_logfile_path(DEFAULT_XORG_LOGFILE);
> +
>    /* Default X display */
>    int xorg_display = 133;
> 
> @@ -80,6 +86,10 @@ int main(int argc, char *argv[]) {
>          break;
> 
>        case 4:
> +        xorg_logfile_path = optarg;
> +        break;
> +
> +      case 5:
>          server = optarg;
>          break;
> 
> @@ -95,12 +105,15 @@ int main(int argc, char *argv[]) {
>      std::cout << "    --xorg-conf: Path to xorg dummy configuration
> file\n";
>      std::cout << "    --server: Path to X server executable\n";
>      std::cout << "    --xorg-display: xorg dummy display port\n";
> +    std::cout << "    --xorg-logfile: xorg logfile filename. See
> -logfile in \"man Xorg\".\n"
> +                 "                    Its default value is
> "DEFAULT_XORG_LOGFILE".\n";
>      exit(-1);
>    }
> 
>    if (!no_dummy_server) {
>      xorg::testing::Environment* environment = new
> xorg::testing::Environment(
>          xorg_conf_path,
> +        xorg_logfile_path,
>          server,
>          xorg_display);
>      testing::AddGlobalTestEnvironment(environment);
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: http://lists.x.org/mailman/listinfo/xorg-devel
> 


More information about the xorg-devel mailing list