From d3cad66f902bf6bc44a2cdba54e1ffae7870b4dd Mon Sep 17 00:00:00 2001
From: Jan David Mol <mol@astron.nl>
Date: Thu, 28 Mar 2013 09:16:26 +0000
Subject: [PATCH] Task #4315: Use unique keys in shared memory tests to allow
 them to run in parallel

---
 RTCP/Cobalt/InputProc/test/tBlockReader.cc    |  2 +-
 RTCP/Cobalt/InputProc/test/tBlockReader.sh    |  2 +-
 RTCP/Cobalt/InputProc/test/tPacketWriter.cc   |  2 +-
 RTCP/Cobalt/InputProc/test/tPacketWriter.sh   |  2 +-
 .../Cobalt/InputProc/test/tPacketsToBuffer.cc |  2 +-
 .../Cobalt/InputProc/test/tPacketsToBuffer.sh |  2 +-
 RTCP/Cobalt/InputProc/test/tSampleBuffer.cc   |  2 +-
 RTCP/Cobalt/InputProc/test/tSampleBuffer.sh   |  2 +-
 .../InputProc/test/tSampleBufferSync.cc       |  2 +-
 .../InputProc/test/tSampleBufferSync.sh       |  2 +-
 RTCP/Cobalt/InputProc/test/tSharedMemory.cc   | 20 ++++++++++---------
 RTCP/Cobalt/InputProc/test/tSharedMemory.sh   |  2 +-
 12 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/RTCP/Cobalt/InputProc/test/tBlockReader.cc b/RTCP/Cobalt/InputProc/test/tBlockReader.cc
index eff3e46a2c4..97dd751b0c2 100644
--- a/RTCP/Cobalt/InputProc/test/tBlockReader.cc
+++ b/RTCP/Cobalt/InputProc/test/tBlockReader.cc
@@ -149,7 +149,7 @@ int main()
   alarm(10);
 
   // Use a fixed key, so the test suite knows what to clean
-  settings.dataKey = 0x12345678;
+  settings.dataKey = 0x10000001;
 
   // Limit the array in size to work on systems with only 32MB SHM
   settings.nrBoards = 1;
diff --git a/RTCP/Cobalt/InputProc/test/tBlockReader.sh b/RTCP/Cobalt/InputProc/test/tBlockReader.sh
index e47a565785d..2e4baaa6095 100755
--- a/RTCP/Cobalt/InputProc/test/tBlockReader.sh
+++ b/RTCP/Cobalt/InputProc/test/tBlockReader.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
 # Remove the shared memory region if the test crashes
-trap "ipcrm -M 0x12345678 2>/dev/null || true" EXIT
+trap "ipcrm -M 0x10000001 2>/dev/null || true" EXIT
 
 ./runctest.sh tBlockReader > tBlockReader.log 2>&1
diff --git a/RTCP/Cobalt/InputProc/test/tPacketWriter.cc b/RTCP/Cobalt/InputProc/test/tPacketWriter.cc
index 6a0962cce2d..9f19a71cfbc 100644
--- a/RTCP/Cobalt/InputProc/test/tPacketWriter.cc
+++ b/RTCP/Cobalt/InputProc/test/tPacketWriter.cc
@@ -111,7 +111,7 @@ int main()
   struct BufferSettings settings(stationID, false);
 
   // Use a fixed key, so the test suite knows what to clean
-  settings.dataKey = 0x12345678;
+  settings.dataKey = 0x10000003;
 
   // Limit the array in size to work on systems with only 32MB SHM
   settings.nrBoards = 1;
diff --git a/RTCP/Cobalt/InputProc/test/tPacketWriter.sh b/RTCP/Cobalt/InputProc/test/tPacketWriter.sh
index 71293cb8041..8bdc6b3e7a7 100755
--- a/RTCP/Cobalt/InputProc/test/tPacketWriter.sh
+++ b/RTCP/Cobalt/InputProc/test/tPacketWriter.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
 # Remove the shared memory region if the test crashes
-trap "ipcrm -M 0x12345678 2>/dev/null || true" EXIT
+trap "ipcrm -M 0x10000003 2>/dev/null || true" EXIT
 
 ./runctest.sh tPacketWriter > tPacketWriter.log 2>&1
diff --git a/RTCP/Cobalt/InputProc/test/tPacketsToBuffer.cc b/RTCP/Cobalt/InputProc/test/tPacketsToBuffer.cc
index 5254687cc48..2fcaba5f095 100644
--- a/RTCP/Cobalt/InputProc/test/tPacketsToBuffer.cc
+++ b/RTCP/Cobalt/InputProc/test/tPacketsToBuffer.cc
@@ -72,7 +72,7 @@ int main()
   struct BufferSettings settings(stationID, false);
 
   // Use a fixed key, so the test suite knows what to clean
-  settings.dataKey = 0x12345678;
+  settings.dataKey = 0x10000002;
 
   // Limit the array in size to work on systems with only 32MB SHM
   settings.nrBoards = 1;
diff --git a/RTCP/Cobalt/InputProc/test/tPacketsToBuffer.sh b/RTCP/Cobalt/InputProc/test/tPacketsToBuffer.sh
index cba872813e1..e0a35674e20 100755
--- a/RTCP/Cobalt/InputProc/test/tPacketsToBuffer.sh
+++ b/RTCP/Cobalt/InputProc/test/tPacketsToBuffer.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
 # Remove the shared memory region if the test crashes
-trap "ipcrm -M 0x12345678 2>/dev/null || true" EXIT
+trap "ipcrm -M 0x10000002 2>/dev/null || true" EXIT
 
 ./runctest.sh tPacketsToBuffer > tPacketsToBuffer.log 2>&1
diff --git a/RTCP/Cobalt/InputProc/test/tSampleBuffer.cc b/RTCP/Cobalt/InputProc/test/tSampleBuffer.cc
index 753d5781fb0..ea138714391 100644
--- a/RTCP/Cobalt/InputProc/test/tSampleBuffer.cc
+++ b/RTCP/Cobalt/InputProc/test/tSampleBuffer.cc
@@ -56,7 +56,7 @@ int main()
   struct BufferSettings settings(stationID, false);
 
   // Use a fixed key, so the test suite knows what to clean
-  settings.dataKey = 0x12345678;
+  settings.dataKey = 0x10000004;
 
   // Limit the array in size to work on systems with only 32MB SHM
   settings.nrBoards = 1;
diff --git a/RTCP/Cobalt/InputProc/test/tSampleBuffer.sh b/RTCP/Cobalt/InputProc/test/tSampleBuffer.sh
index 252b72cec1a..9e174f0e5eb 100755
--- a/RTCP/Cobalt/InputProc/test/tSampleBuffer.sh
+++ b/RTCP/Cobalt/InputProc/test/tSampleBuffer.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
 # Remove the shared memory region if the test crashes
-trap "ipcrm -M 0x12345678 2>/dev/null || true" EXIT
+trap "ipcrm -M 0x10000004 2>/dev/null || true" EXIT
 
 ./runctest.sh tSampleBuffer > tSampleBuffer.log 2>&1
diff --git a/RTCP/Cobalt/InputProc/test/tSampleBufferSync.cc b/RTCP/Cobalt/InputProc/test/tSampleBufferSync.cc
index a882e485a03..83941b20371 100644
--- a/RTCP/Cobalt/InputProc/test/tSampleBufferSync.cc
+++ b/RTCP/Cobalt/InputProc/test/tSampleBufferSync.cc
@@ -52,7 +52,7 @@ void initBoard()
   struct BufferSettings settings(stationID, false);
 
   // Use a fixed key, so the test suite knows what to clean
-  settings.dataKey = 0x12345678;
+  settings.dataKey = 0x10000005;
 
   // Limit the array in size to work on systems with only 32MB SHM
   settings.nrBoards = 1;
diff --git a/RTCP/Cobalt/InputProc/test/tSampleBufferSync.sh b/RTCP/Cobalt/InputProc/test/tSampleBufferSync.sh
index 51db7688fdc..e98fb7b06c0 100755
--- a/RTCP/Cobalt/InputProc/test/tSampleBufferSync.sh
+++ b/RTCP/Cobalt/InputProc/test/tSampleBufferSync.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
 # Remove the shared memory region if the test crashes
-trap "ipcrm -M 0x12345678 2>/dev/null || true" EXIT
+trap "ipcrm -M 0x10000005 2>/dev/null || true" EXIT
 
 ./runctest.sh tSampleBufferSync > tSampleBufferSync.log 2>&1
diff --git a/RTCP/Cobalt/InputProc/test/tSharedMemory.cc b/RTCP/Cobalt/InputProc/test/tSharedMemory.cc
index a20e73376ca..98da9f444a2 100644
--- a/RTCP/Cobalt/InputProc/test/tSharedMemory.cc
+++ b/RTCP/Cobalt/InputProc/test/tSharedMemory.cc
@@ -28,6 +28,8 @@
 
 #include <InputProc/Buffer/SharedMemory.h>
 
+#define DATAKEY 0x10000006
+
 using namespace LOFAR;
 using namespace Cobalt;
 
@@ -40,7 +42,7 @@ public:
   {
     sleep(1);
 
-    SharedMemoryArena m( 0x12345678, 1024, SharedMemoryArena::CREATE, 0 );
+    SharedMemoryArena m( DATAKEY, 1024, SharedMemoryArena::CREATE, 0 );
 
     LOG_INFO("Memory area created");
 
@@ -52,7 +54,7 @@ public:
   {
     LOG_INFO("Waiting for memory area");
 
-    SharedMemoryArena m( 0x12345678, 1024, SharedMemoryArena::READ, 2 );
+    SharedMemoryArena m( DATAKEY, 1024, SharedMemoryArena::READ, 2 );
 
     LOG_INFO("Memory area attached");
 
@@ -69,16 +71,16 @@ int main()
   {
     LOG_INFO("Create shared memory region");
 
-    SharedMemoryArena m( 0x12345678, 1024, SharedMemoryArena::CREATE, 0 );
+    SharedMemoryArena m( DATAKEY, 1024, SharedMemoryArena::CREATE, 0 );
   }
 
   /* Create a shared memory region and access it */
   {
     LOG_INFO("Create shared memory region and access it");
 
-    SharedMemoryArena x( 0x12345678, 1024, SharedMemoryArena::CREATE, 0 );
+    SharedMemoryArena x( DATAKEY, 1024, SharedMemoryArena::CREATE, 0 );
 
-    SharedMemoryArena y( 0x12345678, 1024, SharedMemoryArena::READ, 0 );
+    SharedMemoryArena y( DATAKEY, 1024, SharedMemoryArena::READ, 0 );
   }
 
   /* Access a non-existing shared memory region */
@@ -88,7 +90,7 @@ int main()
     bool caught_exception = false;
 
     try {
-      SharedMemoryArena y( 0x12345678, 1024, SharedMemoryArena::READ, 0 );
+      SharedMemoryArena y( DATAKEY, 1024, SharedMemoryArena::READ, 0 );
     } catch(SystemCallException &e) {
       caught_exception = true;
     }
@@ -103,7 +105,7 @@ int main()
     bool caught_exception = false;
 
     try {
-      SharedMemoryArena y( 0x12345678, 1024, SharedMemoryArena::READ, 1 );
+      SharedMemoryArena y( DATAKEY, 1024, SharedMemoryArena::READ, 1 );
     } catch(SharedMemoryArena::TimeOutException &e) {
       caught_exception = true;
     }
@@ -130,9 +132,9 @@ int main()
   {
     LOG_INFO("Checking memory access through SharedStruct");
 
-    SharedStruct<int> writer( 0x12345678, true, 0 );
+    SharedStruct<int> writer( DATAKEY, true, 0 );
 
-    SharedStruct<int> reader( 0x12345678, false, 0 );
+    SharedStruct<int> reader( DATAKEY, false, 0 );
 
     writer.get() = 42;
     ASSERT( reader.get() == 42 );
diff --git a/RTCP/Cobalt/InputProc/test/tSharedMemory.sh b/RTCP/Cobalt/InputProc/test/tSharedMemory.sh
index 3340e3d8843..759873854b7 100755
--- a/RTCP/Cobalt/InputProc/test/tSharedMemory.sh
+++ b/RTCP/Cobalt/InputProc/test/tSharedMemory.sh
@@ -1,6 +1,6 @@
 #!/bin/sh
 
 # Remove the shared memory region if the test crashes
-trap "ipcrm -M 0x12345678 2>/dev/null || true" EXIT
+trap "ipcrm -M 0x10000006 2>/dev/null || true" EXIT
 
 ./runctest.sh tSharedMemory > tSharedMemory.log 2>&1
-- 
GitLab