Add headers

This commit is contained in:
Matthias Clasen 2011-09-22 22:44:53 -04:00
parent d4d203e3cb
commit 4f3026ea23
2 changed files with 57 additions and 2 deletions

View 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);
}
@ -16,6 +40,8 @@ test_mutex2 (void)
{
GMutex mutex = G_MUTEX_INIT;
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);

View 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);
}
@ -16,6 +40,8 @@ test_rec_mutex2 (void)
{
GRecMutex mutex = G_REC_MUTEX_INIT;
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);
}