Extending Loadrunner Scripts with C – Function Library #1.1

Actually, this is more like 1.1. In as much as it ties into the previous post. I was blogging about building audit logs and data files via an “audit” script. That’s what I call them, not sure if there’s a full blown technical name but I use them to verify, validate and build data to be used in actual test scripts.
So let’s suppose you have an array of data you’ve captured with web_reg_save_param (x,y,z,"ord=all",last); this is how to handle that code into an audit log.


// write file header once


return 0;
The function as defined in the previous post.
int WriteToOutputFile(char * string)

char *filename = “c:\\gemalto_audit.txt”;
long file_streamer;

if ((file_streamer = fopen(filename, “a+”)) == NULL)
//open file in append mode
lr_error_message (“Cannot open %s”, filename);
return -1;

fprintf (file_streamer, “%s\n”, string);
return 0;

And finally, the function in use…

char szParamName1[128];
char szParamName2[128];
char szParamName3[128];
// get number of matches from ord=all

nCount = atoi(lr_eval_string("{available_cards_psn_count}"));

//"available_cards_count" = 22 - boundaries are insufficiently unique
//"available_cards_psn_count" = 11
//"available_cards_status_count" = 22 - boundaries are insufficiently unique

for (i=1; i<=nCount; i++ )
j = i * 2;
sprintf(szParamName1, "{available_cards_%d}", j);
sprintf(szParamName2, "{available_cards_psn_%d}", i);
sprintf(szParamName3, "{available_cards_status_%d}", j);

I find more often than anything else, capturing the data is easy enough, but getting at that data in a structured way in order to use it effectively at a later point can be painful. The above is a real-life example – Developers implementing the content management inconsistently meant that there was nothing uniquely identifying 2 of the fields I needed. If I tightened the left boundary or the right boundary, elements were missed.
I’m not criticizing developers per se, they can’t really be expected to think about a performance tester a year down the life-cycle of the project looking at source-code structure.
The workable solution was to capture the 11 values I needed for one element, the 22 value-pairs for the other elements, and just skip every other element in 2 of the arrays. Inelegant perhaps, it works though and I built that today so it may become beatified over time.

Loadrunner with Excel, DLLs and Exe’s, also a Little bit of test stubbing

So, I’ve spent the last couple of weeks trying in vain to make Loadrunner interact with OpenSSL.
I managed to get the DLL declared, and recognised and was able to turn 50% of the existing VBA code into operational C.
This took a long time because partly my knowledge of the process is not where it should be, but then I reached a point where the VBA passes a byte array as an input to a function.
My Loadrunner doesn’t recognise bytes, just about understands arrays and certainly wasn’t about to do this.

So… I figured well, it’s in excel anyway lets just have LR launch the excel process, grab the data it needs and get out again. TOO SLOW. As I knew it would be.

So now I’m rebuilding it as a standalone VB app. I have no idea if this will work, let alone if it will work quickly but I’m running out of ideas so here we are.

Ultimately, this is stage 2 of an interaction upon a webservice, whereby the user (actually the users phone) says HELLO, and then performs a LOGIN.

HELLO or MobileHello to give it the full name of the webservice is just a call to a server and an xml response. Loadrunner can fire the url at the server and read the response.
Bits of that response, session identifiers essentially, are reused in the LOGIN with encryption based upon public and private keys and certificates.

My task is to emulate MobileLogin following a successful HELLO, I’ve captured the values and now I need LR to fire against a VB executable with the parameters it has captured, perform the encryption and derive the next url. It then needs to fire against that url to exercise the server. I’ll make it work, but this has proven to be one of the more difficult tasks I’ve dealt with.

still procrastinating?

Actually no. I’m working out of Brussels, Belgium. And I’ve found my internet access outside office hours to be incredibly flaky. I’ll find a better hotel or buy a damn router myself if it continues like this.

I have so much to do and weirdly am being prevented from doing it by internet speeds beneath 56k modem equivalents. This is extremely annoying but add on the current hotels scheme whereby you may have ONLY one active connection.

As a techie, I have 2 smart-phones (1 UK, 1 Belgian Burner), A kindle, 2 Laptops and anĀ iPod. (The sheer weight of chargers I waddle around with is ludicrous). One active connection is for Luddites. I’d kind of expect this kind of thing in a (let’s say) less technical nation, but Belgium is central europe, the home of the EU and Nato, hardly a country stuck in the dark ages.

Also, and this is merely by way of an excuse, they have beer. Lots of beer. So, I’ll be back, updating as and when, once my connection is sorted. I do have a deliverable created. And some loadrunner tricks to update – one of my Belgian projects is to recreate a visual basic program in C. Lots of string manipulations. Ultimately it failed, as Loadrunner won’t create the byte array OpenSSL needs as an input. I may be able to fix that with a header file or I may go a different route. That’s Mondays job.

Oh, yeah, the deliverable is a data-generator which reads/ writes a dat file for a loadrunner script.