|
Okay, this is a bit of a tease because I haven’t actually written this function, but it would be nice if someone out there would (maybe it will be me when I get some more free time).
web_reg_save_param() is a useful little function for easily extracting text from the last HTTP response received by the virtual user. You specify left and right boundaries, the occurrence of the text you want to find and a large number of other options which, admittedly, don’t give you the power of regular expressions but are a lot easier to use.
The only problem is that once you’ve got a piece of text from the web page (or some other source), you can’t use this function to help with further manipulations of the text. The closest equivalent function is lr_save_searched_string(), which is useful, but only allows you to specify a left boundary and the number of characters to save. To get the equivalent of web_reg_save_param() requires writing string manipulation code using the standard C libraries which, we all know, some people find a little difficult.
It would be nice to have a function that was the equivalent of web_reg_save_param(), but that you could pass an arbitrary string to. Various people have written functions that implement a small sub-set of the required functionality (like returning text between boundaries), but I have never seen anything which is even close being feature-complete; besides, code in Mercury’s User Contributed Knowledge Base is notoriously buggy.
A good implementation of this function - let’s call it lr_reg_save_param() - might have the following attributes…
Would accept the same arguments as web_reg_save_param(), except with an additional argument for the input string.
int lr_reg_save_param (char* InputString, const char *ParamName, <list of Attributes>, LAST);
Would work in exactly the same way as web_reg_save_param() - I don’t want to have to learn how to use another function.
Would be threadsafe - users shouldn’t have to chase down this type of bug.
Would not create any LoadRunner parameters except for the parameter name specified - this prevents any problems when users inadvertently have a parameter name that is the same as one that is used internally by the function.
Would be well-tested and bug-free.
原文出处:http://www.myloadtest.com/a-usef ... r-function-library/ |
|