From 3810d3b956e99bd59c04ad152c59dc774a5aa11f Mon Sep 17 00:00:00 2001
From: Fons Rademakers <Fons.Rademakers@cern.ch>
Date: Sat, 10 Dec 2011 15:56:49 +0000
Subject: [PATCH] From Gerri: Add support for a command line test run of
 'proofserv'. This is useful to test that the environment is setup correctly.

git-svn-id: http://root.cern.ch/svn/root/trunk@42458 27541ba8-7e3a-0410-8455-c3a389f83636
---
 main/src/pmain.cxx             | 15 ++++++++-------
 proof/proof/src/TProofServ.cxx | 17 ++++++++++++++++-
 2 files changed, 24 insertions(+), 8 deletions(-)

diff --git a/main/src/pmain.cxx b/main/src/pmain.cxx
index 460788c9784..c94f0f86692 100644
--- a/main/src/pmain.cxx
+++ b/main/src/pmain.cxx
@@ -284,16 +284,17 @@ int main(int argc, char **argv)
    // Enable autoloading
    gInterpreter->EnableAutoLoading();
 
-   TString getter("GetTProofServ");
-   TString prooflib = "libProof";
+   TString getter("GetTXProofServ");
+   TString prooflib = "libProofx";
    if (argc > 2) {
       if (!strcmp(argv[2], "lite")) {
-         // Lite version for local processing
+         // Lite version for local processing: this is in libProof and has its own getter
+         prooflib = "libProof";
          getter = "GetTProofServLite";
-      } else if (!strcmp(argv[2], "xpd")) {
-         // XPD: additionally load the appropriate library
-         prooflib = "libProofx";
-         getter = "GetTXProofServ";
+      } else if (strcmp(argv[2], "xpd")) {
+         // Not XPD: set the appropriate names for library and getter
+         prooflib = "libProof";
+         getter = "GetTProofServ";
       }
    }
    char *p = 0;
diff --git a/proof/proof/src/TProofServ.cxx b/proof/proof/src/TProofServ.cxx
index 86eb21dae8e..1e14314f00f 100644
--- a/proof/proof/src/TProofServ.cxx
+++ b/proof/proof/src/TProofServ.cxx
@@ -534,6 +534,13 @@ TProofServ::TProofServ(Int_t *argc, char **argv, FILE *flog)
    // Actual server creation work is done in CreateServer() to allow
    // overloading.
 
+   // If test and tty, we are done
+   Bool_t xtest = (argc && *argc == 1) ? kTRUE : kFALSE;
+   if (xtest) {
+      Printf("proofserv: command line testing: OK");
+      exit(0);
+   }
+
    // Read session specific rootrc file
    TString rcfile = gSystem->Getenv("ROOTRCFILE") ? gSystem->Getenv("ROOTRCFILE")
                                                   : "session.rootrc";
@@ -1260,6 +1267,14 @@ void TProofServ::GetOptions(Int_t *argc, char **argv)
    // Get and handle command line options. Fixed format:
    // "proofserv"|"proofslave" <confdir>
 
+   Bool_t xtest = (argc && *argc > 3 && !strcmp(argv[3], "test")) ? kTRUE : kFALSE;
+
+   // If test and tty
+   if (xtest && !(isatty(0) == 0 || isatty(1) == 0)) {
+      Printf("proofserv: command line testing: OK");
+      exit(0);
+   }
+
    if (*argc <= 1) {
       Fatal("GetOptions", "Must be started from proofd with arguments");
       exit(1);
@@ -5827,7 +5842,7 @@ void TProofServ::ErrorHandler(Int_t level, Bool_t abort, const char *location,
 
       if (gProofServ != 0 && !recursive) {
          recursive = kTRUE;
-         gProofServ->GetSocket()->Send(kPROOF_FATAL);
+         if (gProofServ->GetSocket()) gProofServ->GetSocket()->Send(kPROOF_FATAL);
          recursive = kFALSE;
       }
 
-- 
GitLab