1 /* $Id: t15.c,v 1.12 2007-01-15 15:10:20 adam Exp $
2 Copyright (C) 2004-2007
5 This file is part of the Zebra server.
7 Zebra is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 2, or (at your option) any later
12 Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
27 #include <sys/types.h>
35 #if HAVE_SYS_UTSNAME_H
36 #include <sys/utsname.h>
43 static void update_process(ZebraService zs, int iter)
46 for (i = 0; i<iter; i++)
48 const char *rec = "<gils><title>some</title></gils>";
49 ZebraHandle zh = zebra_open(zs, 0);
50 zebra_add_record(zh, rec, strlen(rec));
51 if ((i % 30) == 0 || i == iter-1)
57 static void search_process(ZebraService zs, int iter)
61 for (i = 0; i<iter; i++)
63 ZebraHandle zh = zebra_open(zs, 0);
65 ZEBRA_RES res = zebra_search_PQF(zh, "@attr 1=4 some", "default",
67 YAZ_CHECK(res == ZEBRA_OK);
69 YAZ_CHECK(hits >= hits_max);
71 printf("i=%d hits=%lld hits_max=%lld\n", i, hits, hits_max);
77 static pid_t fork_service(ZebraService zs, int iter,
78 void (*f)(ZebraService zs, int iter))
90 static void tst(int argc, char **argv)
95 mkdir("register", 0775);
96 mkdir("shadow", 0775);
98 zs = tl_start_up("zebra15.cfg", argc, argv);
101 zh = zebra_open(zs, 0);
104 YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
108 YAZ_CHECK(zebra_create_database (zh, "Default") == ZEBRA_OK);
109 YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
112 update_process(zs, 1);
116 #if HAVE_SYS_UTSNAME_H
120 int tst_with_fork = 1;
125 if (!strcmp(s.sysname, "FreeBSD"))
128 yaz_log(YLOG_LOG, "s.sysname=%s tst_with_fork=%d", s.sysname,
132 pids[0] = fork_service(zs, 200, search_process);
133 pids[1] = fork_service(zs, 20, update_process);
134 pids[2] = fork_service(zs, 20, update_process);
135 waitpid(pids[0], &status[0], 0);
136 YAZ_CHECK(status[0] == 0);
137 waitpid(pids[1], &status[1], 0);
138 YAZ_CHECK(status[1] == 0);
139 waitpid(pids[2], &status[2], 0);
140 YAZ_CHECK(status[2] == 0);
146 YAZ_CHECK(tl_close_down(0, zs));
153 * indent-tabs-mode: nil
155 * vim: shiftwidth=4 tabstop=8 expandtab