httpd-test-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From do...@apache.org
Subject cvs commit: httpd-test/perl-framework/t/apache passbrigade.t
Date Tue, 20 Nov 2001 22:52:23 GMT
dougm       01/11/20 14:52:23

  Added:       perl-framework/c-modules/test_pass_brigade .cvsignore
                        mod_test_pass_brigade.c
               perl-framework/t/apache passbrigade.t
  Log:
  adding a test for ap_pass_brigade
  
  Revision  Changes    Path
  1.1                  httpd-test/perl-framework/c-modules/test_pass_brigade/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  Makefile
  .libs
  *.lo
  *.slo
  *.la
  
  
  
  1.1                  httpd-test/perl-framework/c-modules/test_pass_brigade/mod_test_pass_brigade.c
  
  Index: mod_test_pass_brigade.c
  ===================================================================
  #define HTTPD_TEST_REQUIRE_APACHE 2
  
  #if CONFIG_FOR_HTTPD_TEST
  
  <Location /test_pass_brigade>
     SetHandler test_pass_brigade
  </Location>
  
  #endif
  
  #define APACHE_HTTPD_TEST_HANDLER test_pass_brigade_handler
  
  #include "apache_httpd_test.h"
  
  #include "apr_buckets.h"
  
  /*
   * mainly for testing / researching core_output_filter buffering
   */
  
  static int test_pass_brigade_handler(request_rec *r)
  {
      const char *args = r->args;
      long total=0, remaining=1;
      char *buff, *endptr;
      int buff_size = 8192;
  
      if (strcmp(r->handler, "test_pass_brigade")) {
          return DECLINED;
      }
      if (r->method_number != M_GET) {
          return DECLINED;
      }
  
      if (args) {
          buff_size = strtol(args, &endptr, 0);
  
          if (endptr && *endptr == ',') {
              ++endptr;
              remaining = strtol(endptr, &endptr, 0);
          }
      }
  
      fprintf(stderr, "[mod_test_pass_brigade] "
              "going to echo %ld bytes with buffer size=%d\n",
              remaining, buff_size);
  
      buff = malloc(buff_size);
      memset(buff, 'a', buff_size);
  
      while (total < remaining) {
          int left = (remaining - total);
          int len = left <= buff_size ? left : buff_size;
          apr_bucket_brigade *bb = apr_brigade_create(r->pool);
          apr_bucket *bucket = apr_bucket_heap_create(buff, len, 1);
          apr_status_t status;
  
          APR_BRIGADE_INSERT_TAIL(bb, bucket);
  
          status = ap_pass_brigade(r->output_filters->next, bb);
  
          if (status != APR_SUCCESS) {
              apr_brigade_destroy(bb);
              ap_log_error(APLOG_MARK, APLOG_ERR|APLOG_NOERRNO,
                           status, r->server,
                           "[mod_test_pass_brigade] ap_pass_brigade failed");
              free(buff);
              return HTTP_INTERNAL_SERVER_ERROR;
          }
  
          total += len;
  
          fprintf(stderr, "[mod_test_pass_brigade] wrote %d of %d bytes\n",
                  len, len);
      }
      
      fprintf(stderr,
              "[mod_test_pass_brigade] done writing %ld of %ld bytes\n",
              total, remaining);
  
      free(buff);    
      return OK;
  }
  
  APACHE_HTTPD_TEST_MODULE(test_pass_brigade);
  
  
  
  
  1.1                  httpd-test/perl-framework/t/apache/passbrigade.t
  
  Index: passbrigade.t
  ===================================================================
  use strict;
  use warnings FATAL => 'all';
  
  use Apache::Test;
  use Apache::TestRequest;
  
  #1k..9k, 10k..50k, 100k, 300k, 500k, 2Mb, 4Mb, 6Mb, 10Mb
  my @sizes = (1..9, 10..50, 100, 300, 500, 2000, 4000, 6000, 10_000);
  my @buff_sizes = (1024, 8192);
  
  plan tests => @sizes * @buff_sizes, [qw(test_pass_brigade LWP)];
  
  my $location = "/test_pass_brigade";
  
  for my $buff_size (@buff_sizes) {
      for my $size (@sizes) {
          my $length = $size * 1024;
  
          print "getting $length bytes of data\n";
  
          my $str = GET_BODY "$location?$buff_size,$length";
  
          printf "read %d bytes of data\n", length $str;
  
          my $chunk = 'a' x 1024;
          ok $str =~ /^($chunk){$size}$/;
      }
  }
  
  
  
  

Mime
View raw message