1 /* This file is part of the yazpp toolkit.
2 * Copyright (C) 1998-2012 Index Data and Mike Taylor
3 * See the file LICENSE for details.
12 #include <yaz/comstack.h>
13 #include <yaz/options.h>
14 #include <yaz/otherinfo.h>
15 #include <yaz/charneg.h>
20 Zlint_test::~Zlint_test()
28 Zlint_t(Zlint_test *t);
33 int m_test_number_sequence;
38 Zlint::Zlint(IPDU_Observable *the_PDU_Observable) :
39 Z_Assoc(the_PDU_Observable)
42 m_PDU_Observable = the_PDU_Observable;
61 void Zlint::set_host(const char *cp)
69 cs_get_host_args(m_host, &basep);
70 if (!basep || !*basep)
73 m_database = xstrdup(basep);
76 void Zlint::timeoutNotify()
80 if (m_cur_test->m_t->recv_fail(this, 2) != TEST_FINISHED)
91 void Zlint::failNotify()
95 if (m_cur_test->m_t->recv_fail(this, 1) != TEST_FINISHED)
106 void Zlint::connectNotify()
110 if (m_cur_test->m_t->init(this) != TEST_FINISHED)
116 void Zlint::recv_GDU(Z_GDU *gdu, int len)
120 int r = m_cur_test->m_t->recv_gdu(this, gdu);
121 if (r == TEST_CONTINUE)
123 if (r == TEST_REOPEN)
134 void Zlint::close_goto_next()
138 m_cur_test = m_cur_test->m_next;
144 IPDU_Observer *Zlint::sessionNotify(
145 IPDU_Observable *the_PDU_Observable, int fd)
150 Z_ReferenceId *Zlint::mk_refid(const char *buf, int len)
153 (Z_ReferenceId *) odr_malloc(odr_encode(), sizeof(*id));
154 id->size = id->len = len;
155 id->buf = (unsigned char*) odr_malloc(odr_encode(), len);
156 memcpy(id->buf, buf, len);
160 int Zlint::initResponseGetVersion(Z_InitResponse *init)
165 for (i = 0; i<12; i++)
166 if (ODR_MASK_GET(init->protocolVersion, no))
175 void Zlint::add_test(Zlint_test *t)
177 Zlint_t **d = &m_tests;
182 m_cur_test = m_tests;
185 void Zlint::msg_check_for(const char *fmt, ...)
187 m_cur_test->m_test_ok = 0;
188 m_cur_test->m_test_number_sequence++;
189 m_cur_test->m_test_reported = 0;
194 vsnprintf(buf, sizeof(buf), fmt, ap);
195 printf ("Checking %s .. ", buf);
199 void Zlint::msg_check_info(const char *fmt, ...)
204 vsnprintf(buf, sizeof(buf), fmt, ap);
205 printf (" %s\n", buf);
209 void Zlint::msg_check_ok()
211 if (!m_cur_test->m_test_reported)
213 m_cur_test->m_test_ok = 1;
214 m_cur_test->m_test_reported = 1;
219 void Zlint::msg_check_fail(const char *fmt, ...)
221 if (!m_cur_test->m_test_reported)
223 m_cur_test->m_test_ok = 0;
224 m_cur_test->m_test_reported = 1;
230 vsnprintf(buf, sizeof(buf), fmt, ap);
231 printf (" %s\n", buf);
235 void Zlint::msg_check_notapp()
237 if (!m_cur_test->m_test_reported)
239 m_cur_test->m_test_ok = 2;
240 m_cur_test->m_test_reported = 1;
241 printf ("Unsupported\n");
245 void Zlint::getDatabase(char ***db, int *num)
247 *db = (char**) odr_malloc(odr_encode(), 2*sizeof(char *));
248 (*db)[0] = m_database;
253 Zlint_t::Zlint_t(Zlint_test *t)
255 m_test_number_sequence = 0;
267 Zlint_code Zlint_test_simple::recv_fail(Zlint *z, int reason)
269 z->msg_check_fail("target closed connection");
270 return TEST_FINISHED;
275 * c-file-style: "Stroustrup"
276 * indent-tabs-mode: nil
278 * vim: shiftwidth=4 tabstop=8 expandtab