From cdc4ddb67d385d188b23c3b9da245d4501264558 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 4 Apr 2006 00:03:27 +0000 Subject: [PATCH] Added test which reproduces the error with shadow files being deleted "too early. --- test/api/Makefile.am | 5 ++- test/api/t15.c | 119 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 122 insertions(+), 2 deletions(-) create mode 100644 test/api/t15.c diff --git a/test/api/Makefile.am b/test/api/Makefile.am index 0e63ebe..bfe158c 100644 --- a/test/api/Makefile.am +++ b/test/api/Makefile.am @@ -1,9 +1,9 @@ -# $Id: Makefile.am,v 1.32 2006-02-21 15:23:11 adam Exp $ +# $Id: Makefile.am,v 1.33 2006-04-04 00:03:27 adam Exp $ noinst_PROGRAMS = testclient testclient_SOURCES = testclient.c -simpletests = t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 +simpletests = t0 t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t13 t14 t15 safaritests = safari1 check_PROGRAMS = $(simpletests) $(safaritests) TESTS = $(check_PROGRAMS) @@ -29,6 +29,7 @@ t11_SOURCES = t11.c t12_SOURCES = t12.c t13_SOURCES = t13.c t14_SOURCES = t14.c +t15_SOURCES = t15.c safari1_SOURCES = safari1.c testlib.c diff --git a/test/api/t15.c b/test/api/t15.c new file mode 100644 index 0000000..48e9573 --- /dev/null +++ b/test/api/t15.c @@ -0,0 +1,119 @@ +/* $Id: t15.c,v 1.1 2006-04-04 00:03:27 adam Exp $ + Copyright (C) 2004-2005 + Index Data ApS + +This file is part of the Zebra server. + +Zebra is free software; you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free +Software Foundation; either version 2, or (at your option) any later +version. + +Zebra 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. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License +along with Zebra; see the file LICENSE.zebra. If not, write to the +Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA +02111-1307, USA. +*/ + +#include +#if HAVE_UNISTD_H +#include +#endif +#if HAVE_SYS_WAIT_H +#include +#endif + +#include "testlib.h" + +static void update_process(ZebraService zs, int iter) +{ + int i; + for (i = 0; i= hits_max); + if (hits < hits_max) + printf("hits=%lld hits_max=%lld\n", hits, hits_max); + hits_max = hits; + zebra_close(zh); + } +} + +static pid_t fork_service(ZebraService zs, int iter, + void (*f)(ZebraService zs, int iter)) +{ + pid_t pid = fork(); + + YAZ_CHECK(pid != -1); + if (pid) + return pid; + + (*f)(zs, iter); + YAZ_CHECK_TERM; +} + +static void tst(int argc, char **argv) +{ + ZebraService zs = tl_start_up("zebra15.cfg", argc, argv); + + ZebraHandle zh = zebra_open(zs, 0); + + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); + + zebra_init(zh); + + YAZ_CHECK(zebra_create_database (zh, "Default") == ZEBRA_OK); + YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK); + zebra_close(zh); + + update_process(zs, 1); + +#if HAVE_SYS_WAIT_H +#if HAVE_UNISTD_H + if (1) + { + int status[3]; + pid_t pids[3]; + + pids[0] = fork_service(zs, 200, search_process); + pids[1] = fork_service(zs, 20, update_process); + pids[2] = fork_service(zs, 20, update_process); + waitpid(pids[0], &status[0], 0); + YAZ_CHECK(status[0] == 0); + waitpid(pids[1], &status[1], 0); + YAZ_CHECK(status[1] == 0); + waitpid(pids[2], &status[2], 0); + YAZ_CHECK(status[2] == 0); + } +#endif +#endif + +} + +TL_MAIN -- 1.7.10.4