From e7e29543ddd6df23faa6e0630e963320eedf4e40 Mon Sep 17 00:00:00 2001
From: madiot <madiot@localhost>
Date: Wed, 27 Jan 2010 09:14:32 +0000
Subject: [PATCH] fix related to code coverage with EMMA - serialize the startDS in the tools function startservers to avoid emma.properties generated file to overwrite each other - skip the kill on OpenDS processes to avoid potential unexpected behaviour with code coverage - generating a new Emma coverage.ec statistics file for each start of any given OpenDS instance

---
 opends/tests/staf-tests/shared/functions/dsadm.xml |   32 +++++++++++++++++++++++++++++++-
 1 files changed, 31 insertions(+), 1 deletions(-)

diff --git a/opends/tests/staf-tests/shared/functions/dsadm.xml b/opends/tests/staf-tests/shared/functions/dsadm.xml
index e0fcf30..900a366 100755
--- a/opends/tests/staf-tests/shared/functions/dsadm.xml
+++ b/opends/tests/staf-tests/shared/functions/dsadm.xml
@@ -304,7 +304,37 @@
       <message>
         '%s %s' % (STAFCmd, STAFCmdParams)
       </message>
-      
+      <!-- configure the coverage dump file -->
+      <script>
+        mylog = "Didn't find the emma.jar file : '%s'\n" % os.path.join(dsPath,'lib','emma.jar')
+        if os.path.exists(os.path.join(dsPath,'lib','emma.jar')):
+          mylog= ''
+          mylog=" ::coverage on\n"
+          coveragePath = os.path.join(LOGS_ROOT,'coverage')
+          if not os.path.exists(coveragePath):
+            os.mkdir(coveragePath)
+            mylog+=" ::mkdir %s on\n" % coveragePath
+            # copying coverage.em in coveragePath
+            import shutil
+            mylog+=" ::copying %s to %s\n" % (os.path.join(dsPath,'coverage.em'),coveragePath)
+            if not os.path.exists(os.path.join(dsPath,'coverage.em')):
+              mylog+= " Didn't find %s to copy to %s\n" % (os.path.join(dsPath,'coverage.em'),coveragePath)
+            else:
+              shutil.copy(os.path.join(dsPath,'coverage.em'),coveragePath)
+          coverageGroupPath=os.path.join(coveragePath,CurrentTestPath['group'])
+          if not os.path.exists(coverageGroupPath):
+            mylog+=" ::mkdir %s on\n" % (coverageGroupPath)
+            os.mkdir(coverageGroupPath)
+          existingECs=[cf for cf in os.listdir(coverageGroupPath) if cf.startswith('coverage') and cf.endswith('.ec')]
+          newCoverageEC=os.path.join(coverageGroupPath,'coverage%s.ec' % len(existingECs))
+          coveragefh = open( '%s/classes/emma.properties' % (dsPath), 'w' )
+          coveragefh.write( 'coverage.out.file=%s\n' % (newCoverageEC) )
+          coveragefh.write( 'verbosity.level=silent\n')
+          coveragefh.write( 'coverage.out.merge=true\n')
+          coveragefh.close()
+          mylog+=" ::writing %s to %s/%s/classes/emma.properties\n" % (newCoverageEC, dsPath,OPENDSNAME)
+      </script>
+      <message>'%s' % mylog</message>
       <call function="'runCommand'">
         { 'location'  : location,
           'command'   : STAFCmd,

--
Gitblit v1.10.0