1 /* This file is part of the yazpp toolkit.
2 * Copyright (C) 1998-2009 Index Data and Mike Taylor
3 * See the file LICENSE for details.
9 #include <yaz/comstack.h>
10 #include <yaz/options.h>
11 #include <yaz/otherinfo.h>
12 #include <yaz/charneg.h>
17 Zlint_test::~Zlint_test()
25 Zlint_t(Zlint_test *t);
30 int m_test_number_sequence;
35 Zlint::Zlint(IPDU_Observable *the_PDU_Observable) :
36 Z_Assoc(the_PDU_Observable)
39 m_PDU_Observable = the_PDU_Observable;
58 void Zlint::set_host(const char *cp)
66 cs_get_host_args(m_host, &basep);
67 if (!basep || !*basep)
70 m_database = xstrdup(basep);
73 void Zlint::timeoutNotify()
77 if (m_cur_test->m_t->recv_fail(this, 2) != TEST_FINISHED)
88 void Zlint::failNotify()
92 if (m_cur_test->m_t->recv_fail(this, 1) != TEST_FINISHED)
103 void Zlint::connectNotify()
107 if (m_cur_test->m_t->init(this) != TEST_FINISHED)
113 void Zlint::recv_GDU(Z_GDU *gdu, int len)
117 int r = m_cur_test->m_t->recv_gdu(this, gdu);
118 if (r == TEST_CONTINUE)
120 if (r == TEST_REOPEN)
131 void Zlint::close_goto_next()
135 m_cur_test = m_cur_test->m_next;
141 IPDU_Observer *Zlint::sessionNotify(
142 IPDU_Observable *the_PDU_Observable, int fd)
147 Z_ReferenceId *Zlint::mk_refid(const char *buf, int len)
150 (Z_ReferenceId *) odr_malloc(odr_encode(), sizeof(*id));
151 id->size = id->len = len;
152 id->buf = (unsigned char*) odr_malloc(odr_encode(), len);
153 memcpy(id->buf, buf, len);
157 int Zlint::initResponseGetVersion(Z_InitResponse *init)
162 for (i = 0; i<12; i++)
163 if (ODR_MASK_GET(init->protocolVersion, no))
172 void Zlint::add_test(Zlint_test *t)
174 Zlint_t **d = &m_tests;
179 m_cur_test = m_tests;
182 void Zlint::msg_check_for(const char *fmt, ...)
184 m_cur_test->m_test_ok = 0;
185 m_cur_test->m_test_number_sequence++;
186 m_cur_test->m_test_reported = 0;
191 vsnprintf(buf, sizeof(buf), fmt, ap);
192 printf ("Checking %s .. ", buf);
196 void Zlint::msg_check_info(const char *fmt, ...)
201 vsnprintf(buf, sizeof(buf), fmt, ap);
202 printf (" %s\n", buf);
206 void Zlint::msg_check_ok()
208 if (!m_cur_test->m_test_reported)
210 m_cur_test->m_test_ok = 1;
211 m_cur_test->m_test_reported = 1;
216 void Zlint::msg_check_fail(const char *fmt, ...)
218 if (!m_cur_test->m_test_reported)
220 m_cur_test->m_test_ok = 0;
221 m_cur_test->m_test_reported = 1;
227 vsnprintf(buf, sizeof(buf), fmt, ap);
228 printf (" %s\n", buf);
232 void Zlint::msg_check_notapp()
234 if (!m_cur_test->m_test_reported)
236 m_cur_test->m_test_ok = 2;
237 m_cur_test->m_test_reported = 1;
238 printf ("Unsupported\n");
242 void Zlint::getDatabase(char ***db, int *num)
244 *db = (char**) odr_malloc(odr_encode(), 2*sizeof(char *));
245 (*db)[0] = m_database;
250 Zlint_t::Zlint_t(Zlint_test *t)
252 m_test_number_sequence = 0;
264 Zlint_code Zlint_test_simple::recv_fail(Zlint *z, int reason)
266 z->msg_check_fail("target closed connection");
267 return TEST_FINISHED;
272 * indent-tabs-mode: nil
274 * vim: shiftwidth=4 tabstop=8 expandtab