Our legacy site: www.webwob.com   

VUgen scripting methods (page 2)

This page will cover more LoadRunner scripting methods, following on from the legacy site pages.

     LoadRunner CI/CD      *_LR_CI_*      LR_CI_+      Email_out      Email_in      Cookies 1      TUTORIAL      sprintf      debug      VUgen      Kill -9      disk space      AWS S3      dig (DNS++)      substitute      curl with timings      LR_Jenkins_graphs     

Example 1: watch out using sprintf - use strcpy preferably

VuGen code snippet and results obtained:

See what happens to this below: 'One%20Born%20Every%20' with sprintf

vugen code:

        lr_message("sprintf line: %s",line);
        lr_message("strcpy line: %s",line);

Starting action Action.
Time in seconds since 1/1/70: 1481829714
Formatted time and date: Thu Dec 15 19:21:54 2016
iteration: 0
[2016-11-22T06:25:19+00:00] [1479795919.010] m.m.m.m m.m.m.mcomma x.x.x.xcomma y.y.y.y z.z.z.z - - "GET /pmlsd/search/od/One%20Born%20Every%20Minute.atom?platform=ios& HTTP/1.1" 200 1443 "-"
sprintf line: [2016-11-22T06:25:19+00:00] [1479795919.010] m.m.m.m m.m.m.mcomma x.x.x.xcomma y.y.y.y z.z.z.z - - "GET /pmlsd/search/od/OneBorn 1.489641E-310veryMinute.atom?platform=ios& HTTP/1.1" 200 1443 "-"

strcpy line: [2016-11-22T06:25:19+00:00] [1479795919.010] m.m.m.m m.m.m.mcomma x.x.x.xcomma y.y.y.y z.z.z.z - - "GET /pmlsd/search/od/One%20Born%20Every%20Minute.atom?platform=ios& HTTP/1.1" 200 1443 "-"

Action.c(66): The string "[" was found at position 1
Action.c(70): The string(2) "[" was found at position 29
Action.c(77): The string(3) "." was found at position 40


Example 2 - see screenshot. Switch out sprintf for strcpy and strcat

VuGen code snippet and errors avoided

See the screenshot below for the errors - the problem was the use of sprintf in LRv12.53 was causing vusers to hang on closedown. So the scenario would not cleanly exit and several users were left in a state of 'Gradually Exiting'.

vugen code:

  char output[56]; //(addditional variable needed for integers)
       //sprintf(param_buf, "output_%d", i);
      strcpy(param_buf, "output_");
      strcat(param_buf, output);
      lr_output_message("PARAM_BUF IS: %s",param_buf);
  vuser_init.c(107): PARAM_BUF IS: output_1
  vuser_init.c(107): PARAM_BUF IS: output_2
  vuser_init.c(107): PARAM_BUF IS: output_14
  New example with proper data fields included:       
      //sprintf(strtemp,"DATA: nextpage: %s, strtemp1: %s, newEndPoint %s",nextPage,strtemp1,newEndPoint);
      strcpy(strtemp,"DATA: nextpage: ");
      strcat(strtemp,", strtemp1: ");
      strcat(strtemp,", newEndPoint: ");

LR Contorller issues