1 /* This file is part of the yazpp toolkit.
2 * Copyright (C) 1998-2013 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>
21 Zlint_test::~Zlint_test()
29 Zlint_t(Zlint_test *t);
34 int m_test_number_sequence;
39 Zlint::Zlint(IPDU_Observable *the_PDU_Observable) :
40 Z_Assoc(the_PDU_Observable)
43 m_PDU_Observable = the_PDU_Observable;
62 void Zlint::set_host(const char *cp)
70 cs_get_host_args(m_host, &basep);
71 if (!basep || !*basep)
74 m_database = xstrdup(basep);
77 void Zlint::timeoutNotify()
81 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)
105 void Zlint::connectNotify()
109 if (m_cur_test->m_t->init(this) != TEST_FINISHED)
115 void Zlint::recv_GDU(Z_GDU *gdu, int len)
119 int r = m_cur_test->m_t->recv_gdu(this, gdu);
120 if (r == TEST_CONTINUE)
122 if (r == TEST_REOPEN)
132 void Zlint::close_goto_next()
135 m_cur_test = m_cur_test->m_next;
145 IPDU_Observer *Zlint::sessionNotify(
146 IPDU_Observable *the_PDU_Observable, int fd)
151 Z_ReferenceId *Zlint::mk_refid(const char *buf, int len)
153 return odr_create_Odr_oct(odr_encode(), buf, len);
156 int Zlint::initResponseGetVersion(Z_InitResponse *init)
160 for (i = 0; i<12; i++)
161 if (ODR_MASK_GET(init->protocolVersion, no))
168 void Zlint::add_test(Zlint_test *t)
170 Zlint_t **d = &m_tests;
175 m_cur_test = m_tests;
178 void Zlint::msg_check_for(const char *fmt, ...)
180 m_cur_test->m_test_ok = 0;
181 m_cur_test->m_test_number_sequence++;
182 m_cur_test->m_test_reported = 0;
187 vsnprintf(buf, sizeof(buf), fmt, ap);
188 printf ("Checking %s .. ", buf);
192 void Zlint::msg_check_info(const char *fmt, ...)
197 vsnprintf(buf, sizeof(buf), fmt, ap);
198 printf (" %s\n", buf);
202 void Zlint::msg_check_ok()
204 if (!m_cur_test->m_test_reported)
206 m_cur_test->m_test_ok = 1;
207 m_cur_test->m_test_reported = 1;
212 void Zlint::msg_check_fail(const char *fmt, ...)
214 if (!m_cur_test->m_test_reported)
216 m_cur_test->m_test_ok = 0;
217 m_cur_test->m_test_reported = 1;
223 vsnprintf(buf, sizeof(buf), fmt, ap);
224 printf (" %s\n", buf);
228 void Zlint::msg_check_notapp()
230 if (!m_cur_test->m_test_reported)
232 m_cur_test->m_test_ok = 2;
233 m_cur_test->m_test_reported = 1;
234 printf ("Unsupported\n");
238 void Zlint::getDatabase(char ***db, int *num)
240 *db = (char**) odr_malloc(odr_encode(), 2*sizeof(char *));
241 (*db)[0] = m_database;
246 Zlint_t::Zlint_t(Zlint_test *t)
248 m_test_number_sequence = 0;
260 Zlint_code Zlint_test_simple::recv_fail(Zlint *z, int reason)
262 z->msg_check_fail("target closed connection");
263 return TEST_FINISHED;
268 * c-file-style: "Stroustrup"
269 * indent-tabs-mode: nil
271 * vim: shiftwidth=4 tabstop=8 expandtab