Add headers
authorMatthias Clasen <mclasen@redhat.com>
Fri, 23 Sep 2011 02:44:53 +0000 (22:44 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 23 Sep 2011 02:45:47 +0000 (22:45 -0400)
glib/tests/mutex.c
glib/tests/rec-mutex.c

index 27fe4e7..2951d03 100644 (file)
@@ -1,3 +1,25 @@
+/* Unit tests for GMutex
+ * Copyright (C) 2011 Red Hat, Inc
+ * Author: Matthias Clasen
+ *
+ * This work is provided "as is"; redistribution and modification
+ * in whole or in part, in any medium, physical or electronic is
+ * permitted without restriction.
+ *
+ * This work is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * In no event shall the authors or contributors be liable for any
+ * direct, indirect, incidental, special, exemplary, or consequential
+ * damages (including, but not limited to, procurement of substitute
+ * goods or services; loss of use, data, or profits; or business
+ * interruption) however caused and on any theory of liability, whether
+ * in contract, strict liability, or tort (including negligence or
+ * otherwise) arising in any way out of the use of this software, even
+ * if advised of the possibility of such damage.
+ */
+
 #include <glib.h>
 
 static void
@@ -8,6 +30,8 @@ test_mutex1 (void)
   g_mutex_init (&mutex);
   g_mutex_lock (&mutex);
   g_mutex_unlock (&mutex);
+  g_mutex_lock (&mutex);
+  g_mutex_unlock (&mutex);
   g_mutex_clear (&mutex);
 }
 
@@ -18,6 +42,8 @@ test_mutex2 (void)
 
   g_mutex_lock (&mutex);
   g_mutex_unlock (&mutex);
+  g_mutex_lock (&mutex);
+  g_mutex_unlock (&mutex);
   g_mutex_clear (&mutex);
 }
 
@@ -29,6 +55,8 @@ test_mutex3 (void)
   mutex = g_mutex_new ();
   g_mutex_lock (mutex);
   g_mutex_unlock (mutex);
+  g_mutex_lock (mutex);
+  g_mutex_unlock (mutex);
   g_mutex_free (mutex);
 }
 
@@ -41,8 +69,9 @@ test_mutex4 (void)
   ret = g_mutex_trylock (&mutex);
   g_assert (ret);
 
-  ret = g_mutex_trylock (&mutex);
   /* no guarantees that mutex is recursive, so could return 0 or 1 */
+  if (g_mutex_trylock (&mutex))
+    g_mutex_unlock (&mutex);
 
   g_mutex_unlock (&mutex);
   g_mutex_clear (&mutex);
index 2b82ceb..e416d31 100644 (file)
@@ -1,3 +1,25 @@
+/* Unit tests for GRecMutex
+ * Copyright (C) 2011 Red Hat, Inc
+ * Author: Matthias Clasen
+ *
+ * This work is provided "as is"; redistribution and modification
+ * in whole or in part, in any medium, physical or electronic is
+ * permitted without restriction.
+ *
+ * This work is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * In no event shall the authors or contributors be liable for any
+ * direct, indirect, incidental, special, exemplary, or consequential
+ * damages (including, but not limited to, procurement of substitute
+ * goods or services; loss of use, data, or profits; or business
+ * interruption) however caused and on any theory of liability, whether
+ * in contract, strict liability, or tort (including negligence or
+ * otherwise) arising in any way out of the use of this software, even
+ * if advised of the possibility of such damage.
+ */
+
 #include <glib.h>
 
 static void
@@ -8,6 +30,8 @@ test_rec_mutex1 (void)
   g_rec_mutex_init (&mutex);
   g_rec_mutex_lock (&mutex);
   g_rec_mutex_unlock (&mutex);
+  g_rec_mutex_lock (&mutex);
+  g_rec_mutex_unlock (&mutex);
   g_rec_mutex_clear (&mutex);
 }
 
@@ -18,6 +42,8 @@ test_rec_mutex2 (void)
 
   g_rec_mutex_lock (&mutex);
   g_rec_mutex_unlock (&mutex);
+  g_rec_mutex_lock (&mutex);
+  g_rec_mutex_unlock (&mutex);
   g_rec_mutex_clear (&mutex);
 }
 
@@ -34,7 +60,7 @@ test_rec_mutex3 (void)
   g_assert (ret);
 
   g_rec_mutex_unlock (&mutex);
-  g_rec_mutex_clear (&mutex);
+  g_rec_mutex_unlock (&mutex);
   g_rec_mutex_clear (&mutex);
 }