From 6bc9db9f9f6944f86f1337a9a4f1e232678afc7b Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 23 Mar 2010 11:12:48 +0100 Subject: [PATCH] Add mutex test --- test/.gitignore | 3 ++- test/Makefile.am | 6 ++++-- test/test_mutex.c | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 test/test_mutex.c diff --git a/test/.gitignore b/test/.gitignore index 6c57ec2..90d4151 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -33,9 +33,10 @@ test_xml_include test_oid test_file_glob test_log_thread +test_mutex *.log *.o *~ *.diff *.hex* -*.revert* \ No newline at end of file +*.revert* diff --git a/test/Makefile.am b/test/Makefile.am index 061d36a..2723753 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -2,7 +2,7 @@ ## 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 \ @@ -47,7 +47,8 @@ test_odrcodec.c test_odrcodec.h: tstodr.asn $(YAZCOMP) 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) @@ -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_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 diff --git a/test/test_mutex.c b/test/test_mutex.c new file mode 100644 index 0000000..66d6481 --- /dev/null +++ b/test/test_mutex.c @@ -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 +#include + +#include +#include +#include + +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 + */ + -- 1.7.10.4