mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-09 12:25:48 +01:00
Add headers
This commit is contained in:
parent
d4d203e3cb
commit
4f3026ea23
@ -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>
|
#include <glib.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -8,6 +30,8 @@ test_mutex1 (void)
|
|||||||
g_mutex_init (&mutex);
|
g_mutex_init (&mutex);
|
||||||
g_mutex_lock (&mutex);
|
g_mutex_lock (&mutex);
|
||||||
g_mutex_unlock (&mutex);
|
g_mutex_unlock (&mutex);
|
||||||
|
g_mutex_lock (&mutex);
|
||||||
|
g_mutex_unlock (&mutex);
|
||||||
g_mutex_clear (&mutex);
|
g_mutex_clear (&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,6 +40,8 @@ test_mutex2 (void)
|
|||||||
{
|
{
|
||||||
GMutex mutex = G_MUTEX_INIT;
|
GMutex mutex = G_MUTEX_INIT;
|
||||||
|
|
||||||
|
g_mutex_lock (&mutex);
|
||||||
|
g_mutex_unlock (&mutex);
|
||||||
g_mutex_lock (&mutex);
|
g_mutex_lock (&mutex);
|
||||||
g_mutex_unlock (&mutex);
|
g_mutex_unlock (&mutex);
|
||||||
g_mutex_clear (&mutex);
|
g_mutex_clear (&mutex);
|
||||||
@ -29,6 +55,8 @@ test_mutex3 (void)
|
|||||||
mutex = g_mutex_new ();
|
mutex = g_mutex_new ();
|
||||||
g_mutex_lock (mutex);
|
g_mutex_lock (mutex);
|
||||||
g_mutex_unlock (mutex);
|
g_mutex_unlock (mutex);
|
||||||
|
g_mutex_lock (mutex);
|
||||||
|
g_mutex_unlock (mutex);
|
||||||
g_mutex_free (mutex);
|
g_mutex_free (mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,8 +69,9 @@ test_mutex4 (void)
|
|||||||
ret = g_mutex_trylock (&mutex);
|
ret = g_mutex_trylock (&mutex);
|
||||||
g_assert (ret);
|
g_assert (ret);
|
||||||
|
|
||||||
ret = g_mutex_trylock (&mutex);
|
|
||||||
/* no guarantees that mutex is recursive, so could return 0 or 1 */
|
/* 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_unlock (&mutex);
|
||||||
g_mutex_clear (&mutex);
|
g_mutex_clear (&mutex);
|
||||||
|
@ -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>
|
#include <glib.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -8,6 +30,8 @@ test_rec_mutex1 (void)
|
|||||||
g_rec_mutex_init (&mutex);
|
g_rec_mutex_init (&mutex);
|
||||||
g_rec_mutex_lock (&mutex);
|
g_rec_mutex_lock (&mutex);
|
||||||
g_rec_mutex_unlock (&mutex);
|
g_rec_mutex_unlock (&mutex);
|
||||||
|
g_rec_mutex_lock (&mutex);
|
||||||
|
g_rec_mutex_unlock (&mutex);
|
||||||
g_rec_mutex_clear (&mutex);
|
g_rec_mutex_clear (&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,6 +40,8 @@ test_rec_mutex2 (void)
|
|||||||
{
|
{
|
||||||
GRecMutex mutex = G_REC_MUTEX_INIT;
|
GRecMutex mutex = G_REC_MUTEX_INIT;
|
||||||
|
|
||||||
|
g_rec_mutex_lock (&mutex);
|
||||||
|
g_rec_mutex_unlock (&mutex);
|
||||||
g_rec_mutex_lock (&mutex);
|
g_rec_mutex_lock (&mutex);
|
||||||
g_rec_mutex_unlock (&mutex);
|
g_rec_mutex_unlock (&mutex);
|
||||||
g_rec_mutex_clear (&mutex);
|
g_rec_mutex_clear (&mutex);
|
||||||
@ -34,7 +60,7 @@ test_rec_mutex3 (void)
|
|||||||
g_assert (ret);
|
g_assert (ret);
|
||||||
|
|
||||||
g_rec_mutex_unlock (&mutex);
|
g_rec_mutex_unlock (&mutex);
|
||||||
g_rec_mutex_clear (&mutex);
|
g_rec_mutex_unlock (&mutex);
|
||||||
g_rec_mutex_clear (&mutex);
|
g_rec_mutex_clear (&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user