-
Notifications
You must be signed in to change notification settings - Fork 2
ROX-31266: Implement tests with valid and invalid utf 8 strings #251
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
base: main
Are you sure you want to change the base?
ROX-31266: Implement tests with valid and invalid utf 8 strings #251
Conversation
Molter73
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still need to go through the rust unit tests, my first impression is that they are quite convoluted for testing some functions that are relatively simple and straightforward. The integration tests provide a lot more value because they are testing not just those functions but also the BPF programs and the rest of the userspace logic, I would focus on those.
tests/test_file_open.py
Outdated
| ['0.txt', '1.txt', '2.txt'], | ||
| ['café.txt', 'файл.txt', '测试.txt'], | ||
| ]) | ||
| def test_multiple(fact, monitored_dir, server, filenames): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if there is much value in this change. This test is checking that multiple events are captured, so the actual paths used are not that important. Maybe we want to rollback this part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted
tests/test_path_unlink.py
Outdated
| # Handle bytes filenames by converting monitored_dir to bytes | ||
| if isinstance(filename, bytes): | ||
| test_file = os.path.join(os.fsencode(monitored_dir), filename) | ||
| else: | ||
| test_file = os.path.join(monitored_dir, filename) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This block is used on all 4 tests, could we move it to a separate method called something like filename_encode? You could put it in conftest.py or a new filename_utils.py file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
tests/test_path_unlink.py
Outdated
| if isinstance(test_file, bytes): | ||
| test_file_str = test_file.decode('utf-8', errors='replace') | ||
| else: | ||
| test_file_str = test_file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to my previous comment but with a filename_decode method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
fact/src/event/mod.rs
Outdated
| ]; | ||
|
|
||
| for (bytes, description) in tests { | ||
| let arr = bytes_to_c_char_array::<256>(bytes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are some of these templates 256 bytes but others 4096? The 4K one makes more sense since we are dealing mostly with paths, so I don't really get why we event need a template.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have replaced all of these with <{ PATH_MAX as usize }>.
…s replaced when comparing to the result
Co-authored-by: Mauro Ezequiel Moltrasio <mmoltras@redhat.com>
35fbb9e to
79f1728
Compare
Description
Parameterized the filename in the existing
test_openandtest_multipletests. The input file names include regular ASCII, accents, Cyrillic, Chinese, and emoji.Unit tests were also added for
slice_to_string,sanitize_d_path, and creation of processes with valid ASCII, Cyrillic, Chinese, Japanese, Arabic, emoji, and invalid UTF-8.Checklist
Automated testing
If any of these don't apply, please comment below.
Testing Performed
CI is sufficient