Y-lib
Loadrunner libraries
|
This file contains loadrunner parameter array helper functions. More...
Go to the source code of this file.
Macros | |
#define | y_array_count(param_array) lr_paramarr_len(param_array) |
Determine the number of elements in the target parameter array. More... | |
#define | y_array_get(source_param_array, param_array_index) lr_paramarr_idx(source_param_array, param_array_index) |
Fetch the content of a specific element from a parameter list based on index. More... | |
Functions | |
char * | y_array_get_no_zeroes (const char *source_param_array, const int param_array_index) |
Get the content the nth member of target parameter array, but without embedded zeroes. More... | |
void | y_array_save (const char *value, const char *source_param_array, const int param_array_index) |
Save a string value into an array at a specified position. More... | |
void | y_array_save_count (const int count, const char *source_param_array) |
void | y_array_add (const char *source_param_array, const char *value) |
void | y_array_concat (const char *source_param_array_first, const char *source_param_array_second, const char *result_array) |
Concatenate two arrays together and save the result into a third array. More... | |
char * | y_array_get_random (const char *source_param_array) |
Get a random element from a parameter list. More... | |
char * | y_array_get_random_no_zeroes (const char *source_param_array) |
Get a random element from a parameter list without embedded zeroes. More... | |
int | y_array_pick_random (const char *source_param_array) |
Choose an element at random from a saved parameter list and store it in a parameter with the same name. More... | |
void | y_array_dump (const char *source_param_array) |
Dump the contents of a list of saved parameters to standard output (the run log) More... | |
void | y_array_save_param_list (const char *sourceParam, const char *LB, const char *RB, const char *result_array) |
Create a parameter list from a single parameter value. More... | |
void | y_array_grep (const char *source_param_array, const char *search, const char *result_array) |
Search a parameter array for a specific text and build a new array containing only parameters containing that text. More... | |
void | y_array_filter (const char *source_param_array, const char *search, const char *result_array) |
Search a parameter array for a specific string and and build a new result array containing only parameters NOT containing the string. More... | |
int | y_array_merge (const char *param_array_left, const char *param_array_right, const char *separator, const char *result_array) |
void | y_array_split (const char *source_param_array, const char *separator, const char *param_array_left, const char *param_array_right) |
void | y_array_shuffle (char *source_param_array, char *result_array) |
Variables | |
int | _y_random_array_index = 0 |
This file contains loadrunner parameter array helper functions.
This file provides functions that make using and manipulating loadrunner parameter arrays easier. A parameter array is a set of loadrunner parameters that is usually created by web_reg_save_param() with the "Ord=All" argument. These parameters all use the same name, postfixed with a number to indicate the index into the array.
Definition in file y_param_array.c.
#define y_array_count | ( | param_array | ) | lr_paramarr_len(param_array) |
Determine the number of elements in the target parameter array.
[in] | param_array | The name of the parameter array. |
Example:
Definition at line 80 of file y_param_array.c.
#define y_array_get | ( | source_param_array, | |
param_array_index | |||
) | lr_paramarr_idx(source_param_array, param_array_index) |
Fetch the content of a specific element from a parameter list based on index.
[in] | source_param_array | The name of the parameter array. |
[in] | param_array_index | The index of the chosen element. |
Example:
Definition at line 134 of file y_param_array.c.
void y_array_add | ( | const char * | source_param_array, |
const char * | value | ||
) |
Add a new element to the end of the target parameter array.
[in] | source_param_array | The target array to resize. If this array does not exist, a new one will be created. |
[in] | value | the value to add. |
Example:
Definition at line 282 of file y_param_array.c.
void y_array_concat | ( | const char * | source_param_array_first, |
const char * | source_param_array_second, | ||
const char * | result_array | ||
) |
Concatenate two arrays together and save the result into a third array.
Example:
Definition at line 305 of file y_param_array.c.
void y_array_dump | ( | const char * | source_param_array | ) |
Dump the contents of a list of saved parameters to standard output (the run log)
[in] | source_param_array | The name of the array to log. |
Example:
Definition at line 431 of file y_param_array.c.
void y_array_filter | ( | const char * | source_param_array, |
const char * | search, | ||
const char * | result_array | ||
) |
Search a parameter array for a specific string and and build a new result array containing only parameters NOT containing the string.
As y_array_grep(), but reversed.
[in] | source_param_array | The name of the array to be searched. |
[in] | search | The string to search for. |
[in] | result_array | The name of the array to hold the resulting values. Can be the same as the original parameter array. |
Example:
Definition at line 562 of file y_param_array.c.
char* y_array_get_no_zeroes | ( | const char * | source_param_array, |
const int | param_array_index | ||
) |
Get the content the nth member of target parameter array, but without embedded zeroes.
As y_array_get(), but it filters embedded zeroes from the input, replacing them with a single space: ' '. It's not ideal, but better than having your script break on this particular type of broken web page.
[in] | source_param_array | The name of the parameter array to get an element from. |
[in] | param_array_index | The index number of the element to fetch. |
Example:
Definition at line 180 of file y_param_array.c.
char* y_array_get_random | ( | const char * | source_param_array | ) |
Get a random element from a parameter list.
Fetch the contents of a random element in a parameter array. As lr_paramarr_random(), but stores the rolled index number internally.
[in] | source_param_array | The name of the parameter array to fetch a random value from. |
Definition at line 351 of file y_param_array.c.
char* y_array_get_random_no_zeroes | ( | const char * | source_param_array | ) |
Get a random element from a parameter list without embedded zeroes.
Fetch the contents of a random element in a parameter array, filtering out any embedded zeroes. Stores the rolled index number internally.
[in] | source_param_array | The name of the parameter array to fetch a random value from. |
Definition at line 378 of file y_param_array.c.
void y_array_grep | ( | const char * | source_param_array, |
const char * | search, | ||
const char * | result_array | ||
) |
Search a parameter array for a specific text and build a new array containing only parameters containing that text.
Let's just call it 'grep'. :)
[in] | source_param_array | The name of the array to be searched. |
[in] | search | The string to search for. |
[in] | result_array | The name of the array to hold the resulting values. Can be the same as the original parameter array. |
Example:
Definition at line 525 of file y_param_array.c.
int y_array_merge | ( | const char * | param_array_left, |
const char * | param_array_right, | ||
const char * | separator, | ||
const char * | result_array | ||
) |
Merge two parameter arrays into a single array.
The resulting list contains each item from the left array appended to the item with the same index in the right array, with an optional glue separator in the middle for convenient re-splitting later.
This thing is mostly created to facilitate situations where you have two lists of parameters that contain data that is related to each other. Example: Hyperlinks consist of a hyperlink and a title, and each of these is captured seperately. Since the entries in these lists are closely correlated picking one involves correlating entries in the hyperlink list with the entries in the title list.
With this function you can just glue the two lists together based on their index and continue processing from there.
[in] | param_array_left | The parameter array to use for the lefthand side of the concatenations. |
[in] | param_array_right | The parameter array to use for the righthand side of the concatenations. |
[in] | separator | A fixed string to be used as a seperator between the two values. |
[in] | result_array | The name of the array to hold the resulting values. Can be the same as either the left or the righthand parameter array. |
Example:
Definition at line 612 of file y_param_array.c.
int y_array_pick_random | ( | const char * | source_param_array | ) |
Choose an element at random from a saved parameter list and store it in a parameter with the same name.
Fetch the contents of a random element in a parameter array, filtering out any embedded zeroes, and saves it as a parameter with the same name.
[in] | source_param_array | The name of the parameter array to fetch a random value from. |
Definition at line 402 of file y_param_array.c.
void y_array_save | ( | const char * | value, |
const char * | source_param_array, | ||
const int | param_array_index | ||
) |
Save a string value into an array at a specified position.
This does not update the size of the array.
[in] | value | The value to store |
[in] | source_param_array | The name of the array to store the value in |
[in] | param_array_index | The index of the element to be updated. |
Example:
Definition at line 217 of file y_param_array.c.
void y_array_save_count | ( | const int | count, |
const char * | source_param_array | ||
) |
Change the size of the target parameter array.
Updates the _count field of the chosen parameter array, changing the reported size of the array.
[in] | count | The new size of the array. |
[in] | source_param_array | The target array to resize. |
Definition at line 246 of file y_param_array.c.
void y_array_save_param_list | ( | const char * | sourceParam, |
const char * | LB, | ||
const char * | RB, | ||
const char * | result_array | ||
) |
Create a parameter list from a single parameter value.
As if using web_reg_save_param() with "Ord=All" as an option, but for already saved parameters instead of web requests. This is especially useful when there is a need to save lists of parameters from sections of the application output instead of the entire thing.
For example, HTML dropdown boxes look like this:
These cannot be correlated using just <option>
and </option>
as the left and right boundaries if there is more than one dropdown box on a page. Using this function you can save the HTML for the entire dropdown box in a parameter instead, then have the options saved as a parameter list afterwards.
[in] | sourceParam | The name of a single parameter containing a list of elements. See dropdown example, above. |
[in] | LB | The left boundary of the values you wish to save into a list. Example: <option> |
[in] | RB | The right boundary of the values you wish to save into a list. Example: </option> |
[in] | result_array | The name of the parameter array to save the values into. |
Example:
Definition at line 482 of file y_param_array.c.
void y_array_shuffle | ( | char * | source_param_array, |
char * | result_array | ||
) |
Shuffle a parameter array and store the result in a new array of parameters.
[in] | source_param_array | The name of the array holding the values to be shuffled. |
[in] | result_array | The parameter array holding the shuffled result. This array must NOT have the same name as the original array. |
Example:
Definition at line 715 of file y_param_array.c.
void y_array_split | ( | const char * | source_param_array, |
const char * | separator, | ||
const char * | param_array_left, | ||
const char * | param_array_right | ||
) |
Split an input array vertically into two new arrays, based on a search parameter.
This is the reverse of y_array_merge(). It will examine each parameter in turn and save each value into two separate parameter lists.
[in] | source_param_array | The name of the array holding the values to be split. |
[in] | separator | A fixed string to be used as a seperator between the two values. |
[in] | param_array_left | The parameter array to use for the lefthand side of the concatenations. Can be the same as the input array. |
[in] | param_array_right | The parameter array to use for the righthand side of the concatenations. Can also be the same as the input array. |
Definition at line 662 of file y_param_array.c.
int _y_random_array_index = 0 |
Definition at line 45 of file y_param_array.c.