Index: ossp-pkg/sio/sio_test.c RCS File: /v/ossp/cvs/ossp-pkg/sio/sio_test.c,v rcsdiff -q -kk '-r1.13' '-r1.14' -u '/v/ossp/cvs/ossp-pkg/sio/sio_test.c,v' 2>/dev/null --- sio_test.c 2003/02/03 17:19:11 1.13 +++ sio_test.c 2003/02/04 15:07:21 1.14 @@ -69,14 +69,15 @@ extern sio_module_t sio_module_sillymux; -#define EVAL(name,rc,rc0,block) \ +#define EVAL(name,rc,rc0,block,errf) \ ts_test_check(TS_CTX, name); \ block \ if (rc != rc0) \ ts_test_fail(TS_CTX, "%s -> %d[%s] (expected %d[%s])\n", \ - name, rc, sio_error(rc), rc0, sio_error(rc0)) + name, rc, errf(rc), rc0, errf(rc0)) -#define EVAL0(name,block) EVAL(name,rc,SIO_OK,block) +#define EVAL0(name,block) EVAL(name,rc,SIO_OK,block,sio_error) +#define EVALS(name,block) EVAL(name,rc,SA_OK,block,sa_error) static sio_rc_t sreadloop(sio_t *, char *, size_t, size_t *); static int test_sio_pipe_read(ts_test_t *, int, int); @@ -572,6 +573,9 @@ if (child == 0) { int result; + + sleep(1); + close(pd[1]); result = test_sio_pipe_write(NULL, pd[0], wcount); close(pd[0]); @@ -1032,6 +1036,9 @@ if (child == 0) { int result; + + sleep(1); + close(pd[1]); result = test_sio_hello_client(NULL, pd[0]); close(pd[0]); @@ -1226,9 +1233,321 @@ #endif #if ENABLE_SA +static +int test_sio_sa_read(ts_test_t *_t, sa_t *sa, int wcount) +{ + int error = 0, result = -1; + sio_rc_t rc; + sio_t *sio; + sio_stage_t *sios_buffer, *sios_sa; + size_t bufsize = 987; /* output buffer size */ + size_t buflen = 64; /* sa input buffer size */ + int i; + char S[] = "Hello world\n"; + char buf[sizeof(S)]; + size_t actual, len = strlen(S); + + EVAL0("sio_create", { + rc = sio_create(&sio); + }); + if (rc != SIO_OK) return -1; + EVAL0("sio_create_stage(&sios_sa)", { + rc = sio_create_stage(sio, &sio_module_sa, &sios_sa); + }); + if (rc != SIO_OK) return -1; + EVAL0("sio_create_stage(&sios_buffer)", { + rc = sio_create_stage(sio, &sio_module_buffer, &sios_buffer); + }); + if (rc != SIO_OK) return -1; + + EVAL0("sio_configure_stage(sios_sa, buflen)", { + rc = sio_configure_stage(sio, sios_sa, "buflen", &buflen); + }); + if (rc != SIO_OK) return -1; + EVAL0("sio_configure_stage(sios_buffer)", { + rc = sio_configure_stage(sio, sios_buffer, "outputsize", &buflen); + }); + if (rc != SIO_OK) return -1; + EVAL0("sio_configure_stage(sios_buffer, inputsize)", { + rc = sio_configure_stage(sio, sios_buffer, "inputsize", &bufsize); + }); + if (rc != SIO_OK) return -1; + + EVAL0("sio_configure_stage(sios_sa, sa)", { + rc = sio_configure_stage(sio, sios_sa, "sa", sa); + }); + if (rc != SIO_OK) goto badread; + + EVAL0("sio_attach(sios_sa)", { + rc = sio_attach(sio, sios_sa, SIO_MODE_READWRITE); + }); + if (rc != SIO_OK) goto badread; + EVAL0("sio_attach(sios_buffer)", { + rc = sio_attach(sio, sios_buffer, SIO_MODE_READWRITE); + }); + if (rc != SIO_OK) goto badread2; + + for (i=0; i