From cfb3971aed40db5e1e2019061149330b46b1223b Mon Sep 17 00:00:00 2001
From: Atlas-Software Librarian <Atlas-Software.Librarian@cern.ch>
Date: Fri, 8 Apr 2016 17:43:59 +0200
Subject: [PATCH] 'CMakeLists.txt' (ReleaseTests-00-00-02)

---
 ReleaseTests/CMakeLists.txt                   | 14 +++
 ReleaseTests/bin/testSelectionXML.py          | 87 +++++++++++++++++++
 ReleaseTests/cmt/requirements                 | 18 ++++
 .../test/ReleaseTests_TestConfiguration.xml   | 20 +++++
 4 files changed, 139 insertions(+)
 create mode 100644 ReleaseTests/CMakeLists.txt
 create mode 100755 ReleaseTests/bin/testSelectionXML.py
 create mode 100644 ReleaseTests/cmt/requirements
 create mode 100644 ReleaseTests/test/ReleaseTests_TestConfiguration.xml

diff --git a/ReleaseTests/CMakeLists.txt b/ReleaseTests/CMakeLists.txt
new file mode 100644
index 00000000000..47c0786e2d0
--- /dev/null
+++ b/ReleaseTests/CMakeLists.txt
@@ -0,0 +1,14 @@
+################################################################################
+# Package: ReleaseTests
+################################################################################
+
+# Declare the package name:
+atlas_subdir( ReleaseTests )
+
+# Declare the package's dependencies:
+atlas_depends_on_subdirs( PRIVATE
+                          TestPolicy )
+
+# Install files from the package:
+atlas_install_runtime( test/ReleaseTests_TestConfiguration.xml )
+
diff --git a/ReleaseTests/bin/testSelectionXML.py b/ReleaseTests/bin/testSelectionXML.py
new file mode 100755
index 00000000000..8e597f71d0d
--- /dev/null
+++ b/ReleaseTests/bin/testSelectionXML.py
@@ -0,0 +1,87 @@
+#!/usr/bin/env python
+
+# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+
+import os
+import xml.etree.ElementTree as ET
+import re
+import commands
+
+# list = commands.getstatusoutput("cmt show packages /afs/cern.ch/work/s/seuster/sel | gawk '{print $3 \"/\" $1}'")[1].split()
+list = commands.getstatusoutput("cmt show packages | gawk '{print $3 \"/\" $1}'")[1].split()
+# list = os.getenv("CMTPATH").split(':')
+
+# list = ['/afs/cern.ch/atlas/software/builds/nightlies/devval/AtlasAnalysis/rel_2/Reconstruction/egamma/egammaPhysCalib/egammaPhysCalib/selection.xml']
+
+ErrorList = {}
+ErrorContent = {}
+GUIDList = {}
+GUIDListDup = {}
+
+print "Processing these packages:"
+for index, item in enumerate(list):
+    print index, item
+
+for path in list:
+    #print path
+    from os.path import join, getsize
+    for root, dirs, files in os.walk(path):
+        if os.path.exists(root):
+            for name in files:
+                path=join(root, name)
+                if os.path.exists(path) and name=="selection.xml":
+                    #print ("file ", path," size ",getsize(path))
+                    with open(path, 'r') as content_file:
+                        content = content_file.read()
+                    old="different"
+                    while old != content:
+                        old = content
+                        content = re.sub(r"(class +[a-zA-Z]+ *= *\")([a-zA-Z0-9:_* ,&;]+)<([a-zA-Z0-9:_* ,<&;]+)>([a-zA-Z0-9:_* ,>&;]*)", r"\1\2&lt;\3&gt;\4", content)
+                        #print "TEST"
+                        #print
+                        #print content
+
+                    try:
+                        tree = ET.fromstring(content)
+                        #for child in tree:
+                        #    print child.tag, child.attrib
+                        for neighbor in tree.findall('./class'):
+                            guid=neighbor.get("id")
+                            clnm=neighbor.get("name")
+                            #print "id: ",clnm,guid
+                            if guid != None:
+                                if guid in GUIDList:
+                                    print "Duplicate ! ", guid, " found twice !!"
+                                    print " 1. ", GUIDList[guid]
+                                    print " 2. ", path, " (", clnm, ")"
+                                    GUIDListDup[guid]=path + " (" + clnm + ")"
+                                else:
+                                    GUIDList[guid]=path + " (" + clnm + ")"
+
+                    except Exception as e:
+                        #print "ERROR: ", type(e)
+                        #print "ERROR: ", e.args
+                        #print "ERROR: ", content
+                        # ErrorList.append(path)
+                        ErrorList[path]=e.args
+                        ErrorContent[path]=content
+                        pass
+                   
+if len(ErrorList):
+    print "Failed reading these selection.xml files:"
+    for index, item in enumerate(ErrorList):
+        print index, item, ErrorList[item]
+        print "  Error was : ", ErrorList[item]
+        print "  selection.xml was: "
+        print ErrorContent[item]
+else:
+    print "All selection.xml files in all packages were read successfully"
+    
+if len(GUIDListDup):
+    print "Found following Duplicates in selection.xml:"
+    for index, item in enumerate(GUIDListDup):
+        print index, item, GUIDListDup[item]
+        print "                     also declared in ", GUIDList[item]
+        
+import sys
+sys.exit(len(GUIDListDup))
diff --git a/ReleaseTests/cmt/requirements b/ReleaseTests/cmt/requirements
new file mode 100644
index 00000000000..f5d2900b613
--- /dev/null
+++ b/ReleaseTests/cmt/requirements
@@ -0,0 +1,18 @@
+package ReleaseTests
+
+author Rolf Seuster
+
+branches bin
+
+private
+
+use TestPolicy          TestPolicy-*
+
+apply_pattern validate_xml
+
+end_private
+
+macro ReleaseTests_TestConfiguration "../test/ReleaseTests_TestConfiguration.xml"
+
+apply_pattern declare_runtime extras="../test/ReleaseTests_TestConfiguration.xml"
+
diff --git a/ReleaseTests/test/ReleaseTests_TestConfiguration.xml b/ReleaseTests/test/ReleaseTests_TestConfiguration.xml
new file mode 100644
index 00000000000..af325748c54
--- /dev/null
+++ b/ReleaseTests/test/ReleaseTests_TestConfiguration.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<!DOCTYPE unifiedTestConfiguration SYSTEM "http://www.hep.ucl.ac.uk/atlas/AtlasTesting/DTD/unifiedTestConfiguration.dtd">
+
+<unifiedTestConfiguration>
+  
+  <atn>
+    <TEST name="ReleaseTests" type="script" suite="Examples">
+      <options_atn>
+	${ATN_PACKAGE}/bin/testSelectionXML.py
+      </options_atn>
+      <timelimit>60</timelimit>
+      <author>Rolf Seuster</author>
+      <prescript>rm -f $ATN_WORK_AREA/*</prescript>
+      <expectations>
+	<returnValue>0</returnValue>
+      </expectations>
+    </TEST>
+  </atn>
+  
+</unifiedTestConfiguration>
-- 
GitLab