Add one call to yaz_mutex_destroy in test
[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     yaz_mutex_destroy(&p); /* OK to "destroy" NULL handle */
33 }
34
35 int main (int argc, char **argv)
36 {
37     YAZ_CHECK_INIT(argc, argv);
38     YAZ_CHECK_LOG();
39     tst();
40     YAZ_CHECK_TERM;
41 }
42
43 /*
44  * Local variables:
45  * c-basic-offset: 4
46  * c-file-style: "Stroustrup"
47  * indent-tabs-mode: nil
48  * End:
49  * vim: shiftwidth=4 tabstop=8 expandtab
50  */
51