How to check if a file exists from a test?

Did you know that you can check inside your Specman code if a particular file exists in your project?

Before using file.open() it is a good practice to use file.files_exists(). It ensures that the file exists and it clarifies the debugging process in case there is a problem with opening a file.

Imagine you are using a file inside your code and something goes wrong in your test. You then doubt if the file is good, or if you are loading it from the right location.

This is when file.files_exists() comes in handy, because it can, for example, prompt an error message saying that the file is missing and stop the test right there.

Vtool var file_found

You can even add more flexibility by using a dynamic user value grabbed from $USER with the command get_symbol(). This allows other users to run the same test in their own environments if the paths to the file are the same.
That would then look something like this:

Vtool var user

Contact Us

Please, enter your details below. We will get back to you as fast as we can.

This website uses cookies to ensure you get the best experience on our website.

Get Cogita

Please, enter your details below. We will get back to you as fast as we can.

Thank you!

We will get in touch soon.

Get a Quote

Please, enter your details below. We will get back to you as fast as we can.