Index: ossp-pkg/sio/sio_test.c RCS File: /v/ossp/cvs/ossp-pkg/sio/sio_test.c,v rcsdiff -q -kk '-r1.12' '-r1.13' -u '/v/ossp/cvs/ossp-pkg/sio/sio_test.c,v' 2>/dev/null --- sio_test.c 2003/01/30 16:38:32 1.12 +++ sio_test.c 2003/02/03 17:19:11 1.13 @@ -204,7 +204,7 @@ }); if (rc != SIO_OK) return; EVAL0("sio_configure_stage(sios_buffer)", { - rc = sio_configure_stage(sio, sios_buffer, "outputsize", &buflen); + rc = sio_configure_stage(sio, sios_buffer, "outputsize", &bufsize); }); if (rc != SIO_OK) return; EVAL0("sio_configure_stage(sios_buffer, inputsize)", { @@ -1052,6 +1052,176 @@ #if ENABLE_ZLIB TS_TEST(test_sio_zlib) { + sio_rc_t rc; + sio_t *sio; + sio_stage_t *sios_zlib, *sios_fd; + size_t bufsize = 1000; /* input/output buffer size */ + int zoutlevel = 9; /* compress best on output */ + int zinlevel = -1; /* decompress input */ + size_t buflen = 81; /* fd input buffer size */ + int fd; + int i,wcount = 100; + char S[] = "Hello world\n"; + char buf[sizeof(S)]; + size_t actual, len = strlen(S); + char tempfile[] = "./sio_test_tmpfile.XXXXXX"; + int do_unlink = 0; + + EVAL0("sio_create", { + rc = sio_create(&sio); + }); + if (rc != SIO_OK) return; + EVAL0("sio_create_stage(&sios_fd)", { + rc = sio_create_stage(sio, &sio_module_fd, &sios_fd); + }); + if (rc != SIO_OK) return; + EVAL0("sio_create_stage(&sios_zlib)", { + rc = sio_create_stage(sio, &sio_module_zlib, &sios_zlib); + }); + if (rc != SIO_OK) return; + + EVAL0("sio_configure_stage(sios_fd, buflen)", { + rc = sio_configure_stage(sio, sios_fd, "buflen", &buflen); + }); + if (rc != SIO_OK) return; + EVAL0("sio_configure_stage(sios_zlib)", { + rc = sio_configure_stage(sio, sios_zlib, "outputsize", &bufsize); + }); + if (rc != SIO_OK) return; + EVAL0("sio_configure_stage(sios_zlib, inputsize)", { + rc = sio_configure_stage(sio, sios_zlib, "inputsize", &bufsize); + }); + if (rc != SIO_OK) return; + EVAL0("sio_configure_stage(sios_zlib, outputlevel)", { + rc = sio_configure_stage(sio, sios_zlib, "outputlevel", &zoutlevel); + }); + if (rc != SIO_OK) return; + EVAL0("sio_configure_stage(sios_zlib, inputlevel)", { + rc = sio_configure_stage(sio, sios_zlib, "inputlevel", &zinlevel); + }); + if (rc != SIO_OK) return; + + /* + * WRITE phase + */ + + mktemp(tempfile); + fd = open(tempfile, O_CREAT|O_EXCL|O_WRONLY, 0600); + if (fd < 0) { + ts_test_fail(TS_CTX, "cannot create temporary file \"%s\" (%s)\n", + tempfile, strerror(errno)); + } else { + do_unlink = 1; + EVAL0("sio_configure_stage(sios_fd, fd)", { + rc = sio_configure_stage(sio, sios_fd, "fd", &fd); + }); + if (rc != SIO_OK) goto badwrite; + EVAL0("sio_attach(sios_fd)", { + rc = sio_attach(sio, sios_fd, SIO_MODE_READWRITE); + }); + if (rc != SIO_OK) goto badwrite; + EVAL0("sio_attach(sios_zlib)", { + rc = sio_attach(sio, sios_zlib, SIO_MODE_READWRITE); + }); + if (rc != SIO_OK) goto badwrite2; + + for (i=0; i