Add mutex test
authorAdam Dickmeiss <adam@indexdata.dk>
Tue, 23 Mar 2010 10:12:48 +0000 (11:12 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Tue, 23 Mar 2010 10:12:48 +0000 (11:12 +0100)
test/.gitignore
test/Makefile.am
test/test_mutex.c [new file with mode: 0644]

index 6c57ec2..90d4151 100644 (file)
@@ -33,9 +33,10 @@ test_xml_include
 test_oid
 test_file_glob
 test_log_thread
 test_oid
 test_file_glob
 test_log_thread
+test_mutex
 *.log
 *.o
 *~
 *.diff
 *.hex*
 *.log
 *.o
 *~
 *.diff
 *.hex*
-*.revert*
\ No newline at end of file
+*.revert*
index 061d36a..2723753 100644 (file)
@@ -2,7 +2,7 @@
 ## Copyright (C) 1995-2010 Index Data
 
 check_PROGRAMS = test_xmalloc test_iconv test_nmem test_matchstr test_wrbuf \
 ## Copyright (C) 1995-2010 Index Data
 
 check_PROGRAMS = test_xmalloc test_iconv test_nmem test_matchstr test_wrbuf \
- test_odr test_ccl test_log \
+ test_odr test_ccl test_log test_mutex \
  test_soap1 test_soap2 test_odrstack test_log_thread test_xmlquery test_pquery \
  test_comstack test_filepath test_record_conv test_retrieval test_tpath \
  test_timing test_query_charset test_oid test_icu test_match_glob \
  test_soap1 test_soap2 test_odrstack test_log_thread test_xmlquery test_pquery \
  test_comstack test_filepath test_record_conv test_retrieval test_tpath \
  test_timing test_query_charset test_oid test_icu test_match_glob \
@@ -47,7 +47,8 @@ test_odrcodec.c test_odrcodec.h: tstodr.asn $(YAZCOMP)
        cd $(srcdir); $(YAZCOMP) tstodr.asn
 
 LDADD = ../src/libyaz.la
        cd $(srcdir); $(YAZCOMP) tstodr.asn
 
 LDADD = ../src/libyaz.la
-test_icu_LDADD = ../src/libyaz_icu.la $(ICU_LIBS)
+test_icu_LDADD = ../src/libyaz_icu.la ../src/libyaz.la $(ICU_LIBS)
+test_mutex_LDADD = ../src/libyaz_server.la ../src/libyaz.la $(PTHREAD_LIBS)
 AM_CFLAGS = $(PTHREAD_CFLAGS)
 
 
 AM_CFLAGS = $(PTHREAD_CFLAGS)
 
 
@@ -62,6 +63,7 @@ test_odr_SOURCES = test_odrcodec.c test_odrcodec.h test_odr.c
 test_odrstack_SOURCES = test_odrstack.c
 test_ccl_SOURCES = test_ccl.c
 test_log_SOURCES = test_log.c
 test_odrstack_SOURCES = test_odrstack.c
 test_ccl_SOURCES = test_ccl.c
 test_log_SOURCES = test_log.c
+test_mutex_SOURCES = test_mutex.c
 test_soap1_SOURCES = test_soap1.c
 test_soap2_SOURCES = test_soap2.c
 test_log_thread_SOURCES = test_log_thread.c
 test_soap1_SOURCES = test_soap1.c
 test_soap2_SOURCES = test_soap2.c
 test_log_thread_SOURCES = test_log_thread.c
diff --git a/test/test_mutex.c b/test/test_mutex.c
new file mode 100644 (file)
index 0000000..66d6481
--- /dev/null
@@ -0,0 +1,49 @@
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2010 Index Data
+ * See the file LICENSE for details.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <yaz/mutex.h>
+#include <yaz/test.h>
+#include <yaz/log.h>
+
+static void tst(void)
+{
+    YAZ_MUTEX p = 0;
+
+    yaz_mutex_create(&p);
+    YAZ_CHECK(p);
+    yaz_mutex_enter(p);
+    yaz_mutex_leave(p);
+    yaz_mutex_destroy(&p);
+    YAZ_CHECK(p == 0);
+
+    yaz_mutex_create(&p);
+    YAZ_CHECK(p);
+    yaz_mutex_set_name(p, YLOG_LOG, "mymutex");
+    yaz_mutex_enter(p);
+    yaz_mutex_leave(p);
+    yaz_mutex_destroy(&p);
+    YAZ_CHECK(p == 0);
+}
+
+int main (int argc, char **argv)
+{
+    YAZ_CHECK_INIT(argc, argv);
+    YAZ_CHECK_LOG();
+    tst();
+    YAZ_CHECK_TERM;
+}
+
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+