[Cbe-oss-dev] [PATCH 4/5] libspe2: Check all PS areas of direct access

Kazunori Asayama asayama at sm.sony.co.jp
Thu Apr 24 22:42:35 EST 2008


This patch modify the test of the PS area mapping function to check
all defined areas.

Signed-off-by: Kazunori Asayama <asayama at sm.sony.co.jp>
---
 tests/common/ppu_libspe2_test.h        |    1 
 tests/common/ppu_result.c              |   18 ++++++++++++++
 tests/libspe2.run/test_direct_access.c |   42 ++++++++++++++++++++++-----------
 3 files changed, 47 insertions(+), 14 deletions(-)

Index: b/tests/common/ppu_libspe2_test.h
===================================================================
--- a/tests/common/ppu_libspe2_test.h	2008-04-21 11:38:40.000000000 +0900
+++ b/tests/common/ppu_libspe2_test.h	2008-04-21 12:49:54.000000000 +0900
@@ -88,6 +88,7 @@ extern const char *proxy_dma_behavior_sy
 extern const char *stop_reason_symbol(unsigned int reason);
 extern const char *runtime_error_symbol(unsigned int error);
 extern const char *runtime_exception_symbol(unsigned int exception);
+extern const char *ps_area_symbol(enum ps_area ps);
 
 
 /*** file operations ***/
Index: b/tests/common/ppu_result.c
===================================================================
--- a/tests/common/ppu_result.c	2008-04-21 11:38:40.000000000 +0900
+++ b/tests/common/ppu_result.c	2008-04-21 12:49:54.000000000 +0900
@@ -211,3 +211,21 @@ const char *runtime_exception_symbol(uns
     return "unknown";
   }
 }
+
+const char *ps_area_symbol(enum ps_area ps)
+{
+  switch (ps) {
+  case SPE_MSSYNC_AREA:
+    return "SPE_MSSYNC_AREA";
+  case SPE_MFC_COMMAND_AREA:
+    return "SPE_MFC_COMMAND_AREA";
+  case SPE_CONTROL_AREA:
+    return "SPE_CONTROL_AREA";
+  case SPE_SIG_NOTIFY_1_AREA:
+    return "SPE_SIG_NOTIFY_1_AREA";
+  case SPE_SIG_NOTIFY_2_AREA:
+    return "SPE_SIG_NOTIFY_2_AREA";
+  default:
+    return "unknown";
+  }
+}
Index: b/tests/libspe2.run/test_direct_access.c
===================================================================
--- a/tests/libspe2.run/test_direct_access.c	2008-04-21 11:38:36.000000000 +0900
+++ b/tests/libspe2.run/test_direct_access.c	2008-04-21 19:30:18.000000000 +0900
@@ -32,6 +32,14 @@ static int test(int argc, char **argv)
   spe_context_ptr_t spe;
   int ret;
   void *ptr;
+  int i;
+  const enum ps_area ps_areas[] = {
+    SPE_MSSYNC_AREA,
+    SPE_MFC_COMMAND_AREA,
+    SPE_CONTROL_AREA,
+    SPE_SIG_NOTIFY_1_AREA,
+    SPE_SIG_NOTIFY_2_AREA,
+  };
 
   /* error (NULL as SPE context) */
   ret = spe_ls_size_get(NULL);
@@ -88,12 +96,15 @@ static int test(int argc, char **argv)
   }
   tprintf("LS area: %p\n", ptr);
 
-  ptr = spe_ps_area_get(spe, SPE_MFC_COMMAND_AREA);
-  if (!ptr) {
-    perror("spe_ps_area_get");
-    fatal();
+  for (i = 0; i < sizeof(ps_areas) / sizeof(ps_areas[0]); i++) {
+    ptr = spe_ps_area_get(spe, ps_areas[i]);
+    if (!ptr) {
+      eprintf("spe_ps_area_get(%p, %s): %s\n",
+	      spe, ps_area_symbol(ps_areas[i]), strerror(errno));
+      fatal();
+    }
+    tprintf("PS area (%s): %p\n", ps_area_symbol(ps_areas[i]), ptr);
   }
-  tprintf("PS area (SPE_MFC_COMMAND_AREA): %p\n", ptr);
 
   /* error (Invalid PS area) */
   ptr = spe_ps_area_get(spe, -1);
@@ -121,15 +132,18 @@ static int test(int argc, char **argv)
     fatal();
   }
 
-  ptr = spe_ps_area_get(spe, SPE_MFC_COMMAND_AREA);
-  if (ptr) {
-    eprintf("spe_ps_area_get: Unexpected success.\n");
-    fatal();
-  }
-  if (errno != EACCES) {
-    eprintf("spe_ps_area_get: Unexpected errno: %d (%s)\n",
-	    errno, strerror(errno));
-    failed();
+  for (i = 0; i < sizeof(ps_areas) / sizeof(ps_areas[0]); i++) {
+    ptr = spe_ps_area_get(spe, ps_areas[i]);
+    if (ptr) {
+      eprintf("spe_ps_area_get(%p, %s): Unexpected success.\n",
+	      spe, ps_area_symbol(ps_areas[i]));
+      fatal();
+    }
+    if (errno != EACCES) {
+      eprintf("spe_ps_area_get(%p, %s): Unexpected errno: %d (%s)\n",
+	      spe, ps_area_symbol(ps_areas[i]), errno, strerror(errno));
+      failed();
+    }
   }
 
   ret = spe_context_destroy(spe);




More information about the cbe-oss-dev mailing list