libs/gst/check/gstcheck.*: factor out the method from tests that checks size of struc...
authorThomas Vander Stichele <thomas@apestaart.org>
Tue, 6 Jun 2006 13:48:20 +0000 (13:48 +0000)
committerThomas Vander Stichele <thomas@apestaart.org>
Tue, 6 Jun 2006 13:48:20 +0000 (13:48 +0000)
Original commit message from CVS:
* libs/gst/check/gstcheck.c: (gst_check_abi_list):
* libs/gst/check/gstcheck.h:
factor out the method from tests that checks size of structures,
and add code to generate the header containing these sizes
* tests/check/gst/gstabi.c: (GST_START_TEST):
* tests/check/gst/struct_i386.h:
* tests/check/libs/libsabi.c: (GST_START_TEST):
* tests/check/libs/struct_i386.h:
use it

ChangeLog
libs/gst/check/gstcheck.c
libs/gst/check/gstcheck.h
tests/check/gst/gstabi.c
tests/check/gst/struct_i386.h
tests/check/libs/libsabi.c
tests/check/libs/struct_i386.h

index 3e8cb0b..6d522d0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2006-06-06  Thomas Vander Stichele  <thomas at apestaart dot org>
+
+       * libs/gst/check/gstcheck.c: (gst_check_abi_list):
+       * libs/gst/check/gstcheck.h:
+         factor out the method from tests that checks size of structures,
+         and add code to generate the header containing these sizes
+       * tests/check/gst/gstabi.c: (GST_START_TEST):
+       * tests/check/gst/struct_i386.h:
+       * tests/check/libs/libsabi.c: (GST_START_TEST):
+       * tests/check/libs/struct_i386.h:
+         use it
+
 2006-06-06  Michael Smith  <msmith@fluendo.com>
 
        * gst/gstsegment.h:
index 20ddc42..1b34ae6 100644 (file)
@@ -259,3 +259,36 @@ gst_check_teardown_sink_pad (GstElement * element)
   gst_object_unref (sinkpad);
   gst_object_unref (sinkpad);
 }
+
+void
+gst_check_abi_list (GstCheckABIStruct list[], gboolean have_abi_sizes)
+{
+  if (have_abi_sizes) {
+    gboolean ok = TRUE;
+    gint i;
+
+    for (i = 0; list[i].name; i++) {
+      if (list[i].size != list[i].abi_size) {
+        ok = FALSE;
+        g_print ("sizeof(%s) is %d, expected %d\n",
+            list[i].name, list[i].size, list[i].abi_size);
+      }
+    }
+    fail_unless (ok, "failed ABI check");
+  } else {
+    if (g_getenv ("GST_ABI")) {
+      gint i;
+
+      g_print ("GstCheckABIStruct list[] = {\n");
+      for (i = 0; list[i].name; i++) {
+        g_print ("  {\"%s\", sizeof (%s), %d},\n", list[i].name, list[i].name,
+            list[i].size);
+      }
+      g_print ("  {NULL, 0, 0}\n");
+      g_print ("}\n");
+    } else {
+      g_print ("No structure size list was generated for this architecture.\n");
+      g_print ("Run with GST_ABI environment variable set to output header.\n");
+    }
+  }
+}
index 75dbae3..d50a27e 100644 (file)
@@ -50,6 +50,14 @@ GList * buffers;
 GMutex *check_mutex;
 GCond *check_cond;
 
+typedef struct
+{
+  char *name;
+  int size;
+  int abi_size;
+}
+GstCheckABIStruct;
+
 void gst_check_init (int *argc, char **argv[]);
 
 GstFlowReturn gst_check_chain_func (GstPad *pad, GstBuffer *buffer);
@@ -64,6 +72,8 @@ void gst_check_teardown_src_pad (GstElement *element);
 GstPad * gst_check_setup_sink_pad (GstElement *element,
     GstStaticPadTemplate *template, GstCaps *caps);
 void gst_check_teardown_sink_pad (GstElement *element);
+void gst_check_abi_list (GstCheckABIStruct list[], gboolean have_abi_sizes);
+
 
 
 #define fail_unless_message_error(msg, domain, code)           \
index 320adf6..14232ee 100644 (file)
 #include <config.h>
 #include <gst/check/gstcheck.h>
 
-typedef struct
-{
-  char *name;
-  int size;
-  int abi_size;
-}
-Struct;
-
 #ifdef HAVE_CPU_I386
 #include "struct_i386.h"
-#define HAVE_ABI_SIZES
+#define HAVE_ABI_SIZES TRUE
+#else
+#ifdef HAVE_CPU_X86_64
+#include "struct_x86_64.h"
 #else
 /* in case someone wants to generate a new arch */
 #include "struct_i386.h"
+#define HAVE_ABI_SIZES FALSE
+#endif
 #endif
-
 
 GST_START_TEST (test_ABI)
 {
-#ifdef HAVE_ABI_SIZES
-  gboolean ok = TRUE;
-  gint i;
-
-  for (i = 0; list[i].name; i++) {
-    if (list[i].size != list[i].abi_size) {
-      ok = FALSE;
-      g_print ("sizeof(%s) is %d, expected %d\n",
-          list[i].name, list[i].size, list[i].abi_size);
-    }
-  }
-  fail_unless (ok, "failed ABI check");
-#else
-  g_print ("No structure size list was generated for this architecture\n");
-  g_print ("ignoring\n");
-#endif
+  gst_check_abi_list (list, HAVE_ABI_SIZES);
 }
 
 GST_END_TEST;
index 245c66e..f77f9cd 100644 (file)
@@ -1,4 +1,4 @@
-Struct list[] = {
+GstCheckABIStruct list[] = {
  {"GstBin", sizeof (GstBin), 184},
  {"GstBinClass", sizeof(GstBinClass), 288},
  {"GstBuffer", sizeof(GstBuffer), 80},
index b6bd374..b090ee9 100644 (file)
 #include <gst/net/gstnettimepacket.h>
 #include <gst/net/gstnettimeprovider.h>
 
-
-typedef struct
-{
-  char *name;
-  int size;
-  int abi_size;
-}
-Struct;
-
 #ifdef HAVE_CPU_I386
 #include "struct_i386.h"
-#define HAVE_ABI_SIZES
+#define HAVE_ABI_SIZES TRUE
 #else
 /* in case someone wants to generate a new arch */
 #include "struct_i386.h"
+#define HAVE_ABI_SIZES FALSE
 #endif
 
 
 GST_START_TEST (test_ABI)
 {
-#ifdef HAVE_ABI_SIZES
-  gboolean ok = TRUE;
-  gint i;
-
-  for (i = 0; list[i].name; i++) {
-    if (list[i].size != list[i].abi_size) {
-      ok = FALSE;
-      g_print ("sizeof(%s) is %d, expected %d\n",
-          list[i].name, list[i].size, list[i].abi_size);
-    }
-  }
-  fail_unless (ok, "failed ABI check");
-#else
-  g_print ("No structure size list was generated for this architecture\n");
-  g_print ("ignoring\n");
-#endif
+  gst_check_abi_list (list, HAVE_ABI_SIZES);
 }
 
 GST_END_TEST;
index 6844fb7..94a30ee 100644 (file)
@@ -1,4 +1,4 @@
-Struct list[] = {
+GstCheckABIStruct list[] = {
  {"GstAdapter", sizeof(GstAdapter), 52},
  {"GstAdapterClass", sizeof(GstAdapterClass), 84},
  {"GstBaseSink", sizeof(GstBaseSink), 384},