66d648168a1ce3105a27f88252df5e2d54b93197
[yaz-moved-to-github.git] / test / test_mutex.c
1 /* This file is part of the YAZ toolkit.
2  * Copyright (C) 1995-2010 Index Data
3  * See the file LICENSE for details.
4  */
5
6 #include <stdlib.h>
7 #include <stdio.h>
8
9 #include <yaz/mutex.h>
10 #include <yaz/test.h>
11 #include <yaz/log.h>
12
13 static void tst(void)
14 {
15     YAZ_MUTEX p = 0;
16
17     yaz_mutex_create(&p);
18     YAZ_CHECK(p);
19     yaz_mutex_enter(p);
20     yaz_mutex_leave(p);
21     yaz_mutex_destroy(&p);
22     YAZ_CHECK(p == 0);
23
24     yaz_mutex_create(&p);
25     YAZ_CHECK(p);
26     yaz_mutex_set_name(p, YLOG_LOG, "mymutex");
27     yaz_mutex_enter(p);
28     yaz_mutex_leave(p);
29     yaz_mutex_destroy(&p);
30     YAZ_CHECK(p == 0);
31 }
32
33 int main (int argc, char **argv)
34 {
35     YAZ_CHECK_INIT(argc, argv);
36     YAZ_CHECK_LOG();
37     tst();
38     YAZ_CHECK_TERM;
39 }
40
41 /*
42  * Local variables:
43  * c-basic-offset: 4
44  * c-file-style: "Stroustrup"
45  * indent-tabs-mode: nil
46  * End:
47  * vim: shiftwidth=4 tabstop=8 expandtab
48  */
49