Skip to content

Added some more vmm unit tests #367

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

andreeaflorescu
Copy link
Member

  • Added unit tests tests for put_block_device and put_net_device.
  • Removed the helper functions for creating and deleting files in unit tests. Used tempfile crate instead because it handles this automatically.

rx_rate_limiter: None,
tx_rate_limiter: None,
};
match vmm.put_net_device(network_interface) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this really work? I remember there was a problem with updating network interfaces because of it attempts to take() the tap again.

Copy link
Member Author

@andreeaflorescu andreeaflorescu Jun 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Depends what you update. If you have no mac address initially, the update will work.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The update issue is addressed by #370 (which is currently failing tests because I created the PR from the wrong branch and will be corrected shortly).

acatangiu
acatangiu previously approved these changes Jun 21, 2018
// clean up before the assert!s to make sure the temp files are deleted
delete_dummy_path(dummy_filename);
assert!(ret.is_ok());
assert_eq!(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not assert!(block_devices_configs.add(dummy_block_device.clone()).is_ok()) ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a miss on my side. I will change it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's still assert_eq!, it should be assert!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed it. take a look.

let ret = block_devices_configs.add(dummy_block_device.clone());
delete_dummy_path(dummy_filename);
assert!(ret.is_ok());
assert!(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This asserts on is_ok (and not on _eq(Ok())), please change the previous one to do the same.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do.

alxiord
alxiord previously approved these changes Jun 22, 2018
acatangiu
acatangiu previously approved these changes Jun 22, 2018
Added unit tests for put_block_device and put_net_device.
Added a new crate tempfile for testing the block device
with temporary files that are deleted when the object gets
out of scope.

Signed-off-by: Andreea Florescu <[email protected]>
acatangiu
acatangiu previously approved these changes Jun 25, 2018
alxiord
alxiord previously approved these changes Jun 25, 2018
Temfiles are automatically deleted when the object used to
create the file gets out of scope. Removed the helpers for
creating and deleting files and use named temporary files.

Signed-off-by: Andreea Florescu <[email protected]>
@andreeaflorescu andreeaflorescu merged commit 513a99a into firecracker-microvm:master Jun 25, 2018
@andreeaflorescu andreeaflorescu deleted the vmm_unittests branch June 25, 2018 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants