ROX-31266: Implement tests with valid and invalid utf 8 strings#251
ROX-31266: Implement tests with valid and invalid utf 8 strings#251JoukoVirtanen wants to merge 10 commits intomainfrom
Conversation
Molter73
left a comment
There was a problem hiding this comment.
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.
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?
…s replaced when comparing to the result
| # 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.
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.
| 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.
Similar to my previous comment but with a filename_decode method.
| ]; | ||
|
|
||
| for (bytes, description) in tests { | ||
| let arr = bytes_to_c_char_array::<256>(bytes); |
There was a problem hiding this comment.
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.
Co-authored-by: Mauro Ezequiel Moltrasio <mmoltras@redhat.com>
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