Index: ossp-pkg/sio/Makefile.in RCS File: /v/ossp/cvs/ossp-pkg/sio/Makefile.in,v rcsdiff -q -kk '-r1.3' '-r1.4' -u '/v/ossp/cvs/ossp-pkg/sio/Makefile.in,v' 2>/dev/null --- Makefile.in 2003/01/06 19:04:56 1.3 +++ Makefile.in 2003/01/20 19:13:39 1.4 @@ -51,7 +51,7 @@ POD2MAN = pod2man LIB_NAME = libsio.la -LIB_OBJS = sio.lo sio_bio.lo sio_buffer.lo sio_hello.lo sio_null.lo sio_sa.lo sio_sillymux.lo sio_sio.lo sio_zlib.lo +LIB_OBJS = sio.lo sio_bio.lo sio_buffer.lo sio_hello.lo sio_null.lo sio_hole.lo sio_fd.lo sio_sa.lo sio_sillymux.lo sio_sio.lo sio_zlib.lo LIB_DEPS = @LIB_DEPS@ MAN_NAME = sio.3 Index: ossp-pkg/sio/sio_test.c RCS File: /v/ossp/cvs/ossp-pkg/sio/sio_test.c,v rcsdiff -q -kk '-r1.7' '-r1.8' -u '/v/ossp/cvs/ossp-pkg/sio/sio_test.c,v' 2>/dev/null --- sio_test.c 2003/01/20 15:34:13 1.7 +++ sio_test.c 2003/01/20 19:13:39 1.8 @@ -25,167 +25,352 @@ ** OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF ** SUCH DAMAGE. ** -** sio_test.c: test suite +** sio_test.c: stream I/O library test suite */ #ifdef HAVE_CONFIG_H #include "config.h" #endif -#ifndef ENABLE_BIO -#error Test requires BIO + SSL -#endif - #include +#include +#include +#include +#include +#include "ts.h" #include "al.h" #include "sio.h" -#include "sa.h" - +#if ENABLE_BIO #include #include extern BIO_METHOD *BIO_s_socket(); - extern sio_module_t sio_module_bio; -extern sio_module_t sio_module_hello; -extern sio_module_t sio_module_buffer; -#ifndef SINK -extern sio_module_t sio_module_sa; #endif -#define e(f) rc = f; printf("%s = %s\n",#f, sio_error(rc)); fflush(stdout); -#define s(f) src = f; printf("%s = %s\n",#f, sa_error(src)); fflush(stdout); -#define n(f) rn = f; printf("%s = %d\n",#f, rn); fflush(stdout); -#define p(f) rp = f; printf("%s = %p\n",#f, rp); fflush(stdout); - -int main(int argc, char *argv[]) -{ - int rn; - void *rp; - sio_rc_t rc; - sio_t *sio; -#ifndef SINK - sio_stage_t *sios_sa; +#if ENABLE_SA +#include "sa.h" +extern sio_module_t sio_module_sa; #endif - sio_stage_t *sios_bio, *sios_hello, *sios_buffer; - sa_rc_t src; - sa_addr_t *saa; - sa_t *msa, *sa; - char *uri; - - int fd; - SSL_CTX *ctx; -#ifdef SINK - BIO *bio; -#endif - BIO *sbio; +extern sio_module_t sio_module_null; +extern sio_module_t sio_module_hole; +extern sio_module_t sio_module_buffer; +extern sio_module_t sio_module_zlib; +extern sio_module_t sio_module_sio; +extern sio_module_t sio_module_fd; +extern sio_module_t sio_module_hello; +extern sio_module_t sio_module_sillymux; - char buf[] = "Hello world\n"; - size_t actual; - size_t buflen; - int no = 0; - int yes = 1; +#define EVAL(name,rc,rc0,block) \ + ts_test_check(TS_CTX, name); \ + block \ + if (rc != rc0) \ + ts_test_fail(TS_CTX, "%s -> %d[%s] (expected %d[%s])\n", \ + rc, sio_error(rc), rc0, sio_error(rc0)) - s(sa_create(&msa)); - s(sa_option(msa, SA_OPTION_REUSEADDR, 1)); +#define EVAL0(name,block) EVAL(name,rc,SIO_OK,block) - s(sa_addr_create(&saa)); - uri = "inet://localhost:25001#tcp"; - s(sa_addr_u2a(saa, uri)); - s(sa_bind(msa,saa)); - s(sa_addr_destroy(saa)); - uri = NULL; +sio_rc_t readloop(sio_t *sio, char *buf, size_t len, size_t *actualp) +{ + sio_rc_t rc; + size_t actual, total = 0; - ERR_load_BIO_strings(); - OpenSSL_add_ssl_algorithms(); - ctx = SSL_CTX_new(SSLv23_server_method()); + while (len > 0) { + rc = sio_read(sio, buf, len, &actual); + if (rc != SIO_OK) + break; + buf += actual; + total += actual; + len -= actual; + } - if (!SSL_CTX_use_certificate_file(ctx, "/u/mlelstv/ssl/server.crt", SSL_FILETYPE_PEM)) - exit(98); - if (!SSL_CTX_use_PrivateKey_file(ctx, "/u/mlelstv/ssl/server.key", SSL_FILETYPE_PEM)) - exit(99); + *actualp = total; + return rc; +} - e(sio_create(&sio)); - e(sio_create_stage(sio, &sio_module_bio, &sios_bio)); - e(sio_create_stage(sio, &sio_module_hello, &sios_hello)); - e(sio_create_stage(sio, &sio_module_buffer, &sios_buffer)); -#ifndef SINK - e(sio_create_stage(sio, &sio_module_sa, &sios_sa)); -#endif +TS_TEST(test_sio_buffer) +{ + sio_rc_t rc; + sio_t *sio; + sio_stage_t *sios_buffer, *sios_hole; + size_t bufsize = 1000; /* output/input buffer size */ + int i,wcount = 100; + char S[] = "Hello world\n"; + size_t actual, len = strlen(S); + + EVAL0("sio_create", { + rc = sio_create(&sio); + }); + if (rc != SIO_OK) return; + EVAL0("sio_create_stage(&sios_hole)", { + rc = sio_create_stage(sio, &sio_module_hole, &sios_hole); + }); + if (rc != SIO_OK) return; + EVAL0("sio_create_stage(&sios_buffer)", { + rc = sio_create_stage(sio, &sio_module_buffer, &sios_buffer); + }); + if (rc != SIO_OK) return; + + EVAL0("sio_configure_stage(sios_buffer, outputsize)", { + rc = sio_configure_stage(sio, sios_buffer, "outputsize", &bufsize); + }); + if (rc != SIO_OK) return; + + EVAL0("sio_attach(sios_hole)", { + rc = sio_attach(sio, sios_hole, SIO_MODE_WRITE); + }); + if (rc != SIO_OK) return; + EVAL0("sio_attach(sios_buffer)", { + rc = sio_attach(sio, sios_buffer, SIO_MODE_WRITE); + }); + if (rc != SIO_OK) return; + + for (i=0; i