vector.com|Contact
Search tips

apple banana
Find rows that contain at least one of the two words.

+apple +juice
Find rows that contain both words.

+apple macintosh
Find rows that contain the word 'apple', but rank rows higher if they also contain 'macintosh'.

+apple -macintosh
Find rows that contain the word 'apple' but not 'macintosh'.

+apple ~macintosh
Find rows that contain the word 'apple', but if the row also contains the word 'macintosh', rate it lower than if row does not. This is "softer" than a search for '+apple -macintosh', for which the presence of 'macintosh' causes the row not to be returned at all.

+apple +(>turnover >strudel)
Find rows that contain the words 'apple' and 'turnover', or 'apple' and 'strudel' (in any order), but rank 'apple turnover' higher than 'apple strudel'.

apple*
Find rows that contain words such as 'apple', 'apples', 'applesauce', or 'applet'.

"some words"
Find rows that contain the exact phrase 'some words' (for example, rows that contain 'some words of wisdom' but not "some noise words").

By continuing to use this site you agree to the use of cookies. For more information and to find out how to change this click here. Accept Cookies
Please enable cookies in your browser for this website.
Search:
Advanced search

Accessing Third Parameter of a Variadic ioctl Stubbed Function

Last updated: 2019-10-24
Question:
How to access the 3rd parameter of a variadic ioctl stubbed function?
Answer:

For example, let's assume that your ioctl is declared as:
 

  int ioctl(int fd, int function, ...);
 

If your ioctl() has different parameter names, substitute those names instead in the description/code that follows.
 

Because ioctl() is a variadic function, VectorCAST does not provide direct access to the unnamed parameters via the parameter tree. Instead you can use user code to access the third parameter.
 

The user code will need to use the the macros in stdarg.h to manipulate the unnamed parameter. So the first step is to #include that header. You can also add a global variable to be used to store the parameter.

  • open your environment in the VectorCAST GUI
  • go to Environment | User Code | Edit
  • expand the Unit Appendix User Code section
  • double click the box in the value column next to your UUT
  • you should now be in edit mode. Enter this user code:

#include <stdarg.h>
int vcast_ioctl_capture_3rd_int;

  • click the Test compile icon (has a little red arrow)
  • the compile should succeed -- click OK
  • close the user code tab or mdi window
  • you should be prompted. Choose Save and link and click OK

Now you can add user code to the actual library stub definition to
capture the third parameter:

  • go to Environment | Configure Stubs | Edit
  • find the row for ioctl (probably under ioctl.h)
  • double-click the box under Beginning of stub for the ioctl row
  • you should now be in edit mode. Enter this user code:

va_list ap;
va_start(ap, function);
vcast_ioctl_capture_3rd_int = va_arg(ap, int);
va_end(ap);

  • click the Test compile icon (has a little red arrow)
  • the compile should succeed -- click OK
  • close the user code tab or mdi window
  • you should be prompted. Choose save and link and click OK
     

After making these changes, whenever your function under test calls ioctl, it will call the VectorCAST-generated library stub instead, and that stub will set the global variable vcast_ioctl_capture_3rd_int to the integer passed as the 3rd parameter to ioctl(). You can then use regular parameter user code for the ioctl() function to modify the pointer stored in that int.
 

  • create a test case
  • find ioctl in the Stubbed Subprograms section of the parameter tree
  • double-click on return for ioctl
  • go to the User Code tab
  • paste this code into the Input User Code section:

int* ptrBytesAvailable = (int*)vcast_ioctl_capture_3rd_int;
*ptrBytesAvailable = 1234;

  • click Test Compile Input
  • the test compile should succeed
  • click OK to close the Properties/User Code dialog
     

You can now execute the test case, and when ioctl is called, your parameter user code will put 1234 at the address pointed to by the 3rd parameter.
 

 
Article Options
2019-10-24
Views: 11