• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

LogAccessTest.cc

Go to the documentation of this file.
00001 /** @file
00002 
00003   A brief file description
00004 
00005   @section license License
00006 
00007   Licensed to the Apache Software Foundation (ASF) under one
00008   or more contributor license agreements.  See the NOTICE file
00009   distributed with this work for additional information
00010   regarding copyright ownership.  The ASF licenses this file
00011   to you under the Apache License, Version 2.0 (the
00012   "License"); you may not use this file except in compliance
00013   with the License.  You may obtain a copy of the License at
00014 
00015       http://www.apache.org/licenses/LICENSE-2.0
00016 
00017   Unless required by applicable law or agreed to in writing, software
00018   distributed under the License is distributed on an "AS IS" BASIS,
00019   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00020   See the License for the specific language governing permissions and
00021   limitations under the License.
00022  */
00023 
00024 /***************************************************************************
00025  LogAccessTest.cc
00026 
00027 
00028  ***************************************************************************/
00029 
00030 /*-------------------------------------------------------------------------
00031   Ok, the name of the game here is to generate 'random' data, with strings
00032   of varying length, so that we can use these accessor objects to test the
00033   hell out the logging system without relying on the rest of the proxy to
00034   provide the data.
00035 
00036   We'll use the random(3) number generator, which returns pseudo-random
00037   numbers in the range from 0 to (2^31)-1.  The period is 16^((2^31)-1).
00038   srandom(3) is used to seed the random number generator.
00039   -------------------------------------------------------------------------*/
00040 
00041 #include <assert.h>
00042 #include <stdio.h>
00043 #include "LogAccessTest.h"
00044 
00045 /*-------------------------------------------------------------------------
00046   -------------------------------------------------------------------------*/
00047 
00048 LogAccessTest::LogAccessTest()
00049 {
00050 }
00051 
00052 /*-------------------------------------------------------------------------
00053   -------------------------------------------------------------------------*/
00054 
00055 LogAccessTest::~LogAccessTest()
00056 {
00057 }
00058 
00059 /*-------------------------------------------------------------------------
00060   The marshalling routines ...
00061   -------------------------------------------------------------------------*/
00062 
00063 /*-------------------------------------------------------------------------
00064   -------------------------------------------------------------------------*/
00065 
00066 int
00067 LogAccessTest::marshal_client_host_ip(char *buf)
00068 {
00069   IpEndpoint lo;
00070   ats_ip4_set(&lo, INADDR_LOOPBACK);
00071   return marshal_ip(buf, &lo.sa);
00072 }
00073 
00074 /*-------------------------------------------------------------------------
00075   -------------------------------------------------------------------------*/
00076 
00077 int
00078 LogAccessTest::marshal_client_auth_user_name(char *buf)
00079 {
00080   static char const* str = "major tom";
00081   int len = LogAccess::strlen(str);
00082   if (buf) {
00083     marshal_str(buf, str, len);
00084   }
00085   return len;
00086 }
00087 
00088 /*-------------------------------------------------------------------------
00089   -------------------------------------------------------------------------*/
00090 
00091 int
00092 LogAccessTest::marshal_client_req_text(char *buf)
00093 {
00094   static char const* str = "GET http://www.foobar.com/ HTTP/1.0";
00095   int len = LogAccess::strlen(str);
00096   if (buf) {
00097     marshal_str(buf, str, len);
00098   }
00099   return len;
00100 }
00101 
00102 /*-------------------------------------------------------------------------
00103   -------------------------------------------------------------------------*/
00104 
00105 int
00106 LogAccessTest::marshal_client_req_http_method(char *buf)
00107 {
00108   if (buf) {
00109     int64_t val = 1;
00110     marshal_int(buf, val);
00111   }
00112   return sizeof(int64_t);
00113 }
00114 
00115 /*-------------------------------------------------------------------------
00116   -------------------------------------------------------------------------*/
00117 
00118 int
00119 LogAccessTest::marshal_client_req_url(char *buf)
00120 {
00121   static char const* str = "http://www.foobar.com/";
00122   int len = LogAccess::strlen(str);
00123   if (buf) {
00124     marshal_str(buf, str, len);
00125   }
00126   return len;
00127 }
00128 
00129 /*-------------------------------------------------------------------------
00130   -------------------------------------------------------------------------*/
00131 
00132 int
00133 LogAccessTest::marshal_client_req_http_version(char *buf)
00134 {
00135   if (buf) {
00136     int64_t val = 2;
00137     marshal_int(buf, val);
00138   }
00139   return sizeof(int64_t);
00140 }
00141 
00142 /*-------------------------------------------------------------------------
00143   -------------------------------------------------------------------------*/
00144 
00145 int
00146 LogAccessTest::marshal_client_req_header_len(char *buf)
00147 {
00148   if (buf) {
00149     int64_t val = 3;
00150     marshal_int(buf, val);
00151   }
00152   return sizeof(int64_t);
00153 }
00154 
00155 /*-------------------------------------------------------------------------
00156   -------------------------------------------------------------------------*/
00157 
00158 int
00159 LogAccessTest::marshal_client_req_body_len(char *buf)
00160 {
00161   if (buf) {
00162     int64_t val = 4;
00163     marshal_int(buf, val);
00164   }
00165   return sizeof(int64_t);
00166 }
00167 
00168 /*-------------------------------------------------------------------------
00169   -------------------------------------------------------------------------*/
00170 
00171 int
00172 LogAccessTest::marshal_client_finish_status_code(char *buf)
00173 {
00174   if (buf) {
00175     int64_t val = 5;
00176     marshal_int(buf, val);
00177   }
00178   return sizeof(int64_t);
00179 }
00180 
00181 /*-------------------------------------------------------------------------
00182   -------------------------------------------------------------------------*/
00183 
00184 int
00185 LogAccessTest::marshal_proxy_resp_content_type(char *buf)
00186 {
00187   static char const* str = "text/html";
00188   int len = LogAccess::strlen(str);
00189   if (buf) {
00190     marshal_str(buf, str, len);
00191   }
00192   return len;
00193 }
00194 
00195 /*-------------------------------------------------------------------------
00196   -------------------------------------------------------------------------*/
00197 
00198 int
00199 LogAccessTest::marshal_proxy_resp_squid_len(char *buf)
00200 {
00201   if (buf) {
00202     int64_t val = 100;
00203     marshal_int(buf, val);
00204   }
00205   return sizeof(int64_t);
00206 }
00207 
00208 /*-------------------------------------------------------------------------
00209   -------------------------------------------------------------------------*/
00210 
00211 int
00212 LogAccessTest::marshal_proxy_resp_content_len(char *buf)
00213 {
00214   if (buf) {
00215     int64_t val = 6;
00216     marshal_int(buf, val);
00217   }
00218   return sizeof(int64_t);
00219 }
00220 
00221 /*-------------------------------------------------------------------------
00222   -------------------------------------------------------------------------*/
00223 
00224 int
00225 LogAccessTest::marshal_proxy_resp_status_code(char *buf)
00226 {
00227   if (buf) {
00228     int64_t val = 7;
00229     marshal_int(buf, val);
00230   }
00231   return sizeof(int64_t);
00232 }
00233 
00234 /*-------------------------------------------------------------------------
00235   -------------------------------------------------------------------------*/
00236 
00237 int
00238 LogAccessTest::marshal_proxy_resp_header_len(char *buf)
00239 {
00240   if (buf) {
00241     int64_t val = 8;
00242     marshal_int(buf, val);
00243   }
00244   return sizeof(int64_t);
00245 }
00246 
00247 /*-------------------------------------------------------------------------
00248   -------------------------------------------------------------------------*/
00249 
00250 int
00251 LogAccessTest::marshal_proxy_finish_status_code(char *buf)
00252 {
00253   if (buf) {
00254     int64_t val = 9;
00255     marshal_int(buf, val);
00256   }
00257   return sizeof(int64_t);
00258 }
00259 
00260 /*-------------------------------------------------------------------------
00261   -------------------------------------------------------------------------*/
00262 
00263 int
00264 LogAccessTest::marshal_cache_result_code(char *buf)
00265 {
00266   if (buf) {
00267     int64_t val = 10;
00268     marshal_int(buf, val);
00269   }
00270   return sizeof(int64_t);
00271 }
00272 
00273 /*-------------------------------------------------------------------------
00274   -------------------------------------------------------------------------*/
00275 
00276 int
00277 LogAccessTest::marshal_proxy_req_header_len(char *buf)
00278 {
00279   if (buf) {
00280     int64_t val = 11;
00281     marshal_int(buf, val);
00282   }
00283   return sizeof(int64_t);
00284 }
00285 
00286 /*-------------------------------------------------------------------------
00287   -------------------------------------------------------------------------*/
00288 
00289 int
00290 LogAccessTest::marshal_proxy_req_body_len(char *buf)
00291 {
00292   if (buf) {
00293     int64_t val = 12;
00294     marshal_int(buf, val);
00295   }
00296   return sizeof(int64_t);
00297 }
00298 
00299 /*-------------------------------------------------------------------------
00300   -------------------------------------------------------------------------*/
00301 
00302 int
00303 LogAccessTest::marshal_proxy_hierarchy_route(char *buf)
00304 {
00305   if (buf) {
00306     int64_t val = 13;
00307     marshal_int(buf, val);
00308   }
00309   return sizeof(int64_t);
00310 }
00311 
00312 /*-------------------------------------------------------------------------
00313   -------------------------------------------------------------------------*/
00314 
00315 int
00316 LogAccessTest::marshal_server_host_ip(char *buf)
00317 {
00318   IpEndpoint lo;
00319   ats_ip4_set(&lo, INADDR_LOOPBACK);
00320   return marshal_ip(buf, &lo.sa);
00321 }
00322 
00323 /*-------------------------------------------------------------------------
00324   -------------------------------------------------------------------------*/
00325 
00326 int
00327 LogAccessTest::marshal_server_host_name(char *buf)
00328 {
00329   static char const* str = "www.foobar.com";
00330   int len = LogAccess::strlen(str);
00331   if (buf) {
00332     marshal_str(buf, str, len);
00333   }
00334   return len;
00335 }
00336 
00337 /*-------------------------------------------------------------------------
00338   -------------------------------------------------------------------------*/
00339 
00340 int
00341 LogAccessTest::marshal_server_resp_status_code(char *buf)
00342 {
00343   if (buf) {
00344     int64_t val = 15;
00345     marshal_int(buf, val);
00346   }
00347   return sizeof(int64_t);
00348 }
00349 
00350 /*-------------------------------------------------------------------------
00351   -------------------------------------------------------------------------*/
00352 
00353 int
00354 LogAccessTest::marshal_server_resp_content_len(char *buf)
00355 {
00356   if (buf) {
00357     int64_t val = 16;
00358     marshal_int(buf, val);
00359   }
00360   return sizeof(int64_t);
00361 }
00362 
00363 /*-------------------------------------------------------------------------
00364   -------------------------------------------------------------------------*/
00365 
00366 int
00367 LogAccessTest::marshal_server_resp_header_len(char *buf)
00368 {
00369   if (buf) {
00370     int64_t val = 17;
00371     marshal_int(buf, val);
00372   }
00373   return sizeof(int64_t);
00374 }
00375 
00376 /*-------------------------------------------------------------------------
00377   -------------------------------------------------------------------------*/
00378 
00379 int
00380 LogAccessTest::marshal_transfer_time_ms(char *buf)
00381 {
00382   if (buf) {
00383     int64_t val = 18;
00384     marshal_int(buf, val);
00385   }
00386   return sizeof(int64_t);
00387 }
00388 
00389 /*-------------------------------------------------------------------------
00390   -------------------------------------------------------------------------*/
00391 
00392 int
00393 LogAccessTest::marshal_http_header_field(char *header_symbol, char *field, char *buf)
00394 {
00395   return 0;                     // STUB
00396 }

Generated by  doxygen 1.7.1