1 /* $Id: t15.c,v 1.4 2006-05-10 08:13:35 adam Exp $
2 Copyright (C) 2004-2005
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 Zebra; see the file LICENSE.zebra. If not, write to the
19 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
27 #include <sys/types.h>
38 static void update_process(ZebraService zs, int iter)
41 for (i = 0; i<iter; i++)
43 const char *rec = "<gils><title>some</title></gils>";
44 ZebraHandle zh = zebra_open(zs, 0);
45 // printf("update_record i=%d\n", i);
46 zebra_add_record(zh, rec, strlen(rec));
47 if ((i % 30) == 0 || i == iter-1)
53 static void search_process(ZebraService zs, int iter)
57 for (i = 0; i<iter; i++)
59 ZebraHandle zh = zebra_open(zs, 0);
61 ZEBRA_RES res = zebra_search_PQF(zh, "@attr 1=4 some", "default",
63 YAZ_CHECK(res == ZEBRA_OK);
65 YAZ_CHECK(hits >= hits_max);
67 printf("hits=%lld hits_max=%lld\n", hits, hits_max);
73 static pid_t fork_service(ZebraService zs, int iter,
74 void (*f)(ZebraService zs, int iter))
86 static void tst(int argc, char **argv)
91 mkdir("register", 0775);
92 mkdir("shadow", 0775);
94 zs = tl_start_up("zebra15.cfg", argc, argv);
97 zh = zebra_open(zs, 0);
100 YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
104 YAZ_CHECK(zebra_create_database (zh, "Default") == ZEBRA_OK);
105 YAZ_CHECK(zebra_select_database(zh, "Default") == ZEBRA_OK);
108 update_process(zs, 1);
117 pids[0] = fork_service(zs, 200, search_process);
118 pids[1] = fork_service(zs, 20, update_process);
119 pids[2] = fork_service(zs, 20, update_process);
120 waitpid(pids[0], &status[0], 0);
121 YAZ_CHECK(status[0] == 0);
122 waitpid(pids[1], &status[1], 0);
123 YAZ_CHECK(status[1] == 0);
124 waitpid(pids[2], &status[2], 0);
125 YAZ_CHECK(status[2] == 0);
136 * indent-tabs-mode: nil
138 * vim: shiftwidth=4 tabstop=8 expandtab