-
Notifications
You must be signed in to change notification settings - Fork 171
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
StringEnumColumn testing #2780
StringEnumColumn testing #2780
Conversation
Please check your coverage here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/1/Diff_Coverage |
Check the performance result here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/1/Performance_Report |
Check the performance result here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/2/Performance_Report |
Please check your coverage here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/2/Diff_Coverage |
Please check your coverage here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/3/Diff_Coverage |
Check the performance result here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/3/Performance_Report |
I've cherry-picked from #2778 because that needs to go into master, otherwise CI fails this PR. |
src/realm/column_string_enum.cpp
Outdated
@@ -162,6 +162,39 @@ void StringEnumColumn::do_move_last_over(size_t row_ndx, size_t last_row_ndx) | |||
move_last_over_without_updating_index(row_ndx, last_row_ndx); // Throws | |||
} | |||
|
|||
void StringEnumColumn::swap_rows(size_t row_ndx_1, size_t row_ndx_2) | |||
{ | |||
REALM_ASSERT_3(row_ndx_1, <=, size()); |
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.
Shouldn't this be <
instead of <=
?
src/realm/column_string_enum.cpp
Outdated
set(row_ndx_2, realm::null()); | ||
} | ||
else { | ||
StringData copy{buffer_1.data(), buffer_1.size()}; |
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.
You can just swap the integers with IntegerColumn::get() / IntegerColumn::set() instead of copying payload
test/fuzz_group.cpp
Outdated
@@ -207,7 +207,7 @@ Mixed construct_mixed(State& s, util::Optional<std::ostream&> log, std::string& | |||
} | |||
case 5: { | |||
size_t rand_char = get_next(s); | |||
size_t blob_size = get_int64(s) % ArrayBlob::max_binary_size; | |||
size_t blob_size = static_cast<uint64_t>(get_int64(s)) % ArrayBlob::max_binary_size; |
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.
You should do % (ArrayBlob::max_binary_size + 1)
to be able to also trigger the maximum blob size, which is an important edge case
71dd478
to
e41fc1a
Compare
Check the performance result here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/5/Performance_Report |
Please check your coverage here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/5/Diff_Coverage |
Please check your coverage here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/6/Diff_Coverage |
Check the performance result here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/6/Performance_Report |
@finnschiermer @rrrlasse I've been running the fuzz tests on this branch for several days without finding any new crashes. I believe the
|
Looks like I was a bit too hasty there, at the 10 million execution point AFL found some crashes in |
The fuzzer also found that |
Please check your coverage here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/8/Diff_Coverage |
Check the performance result here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/8/Performance_Report |
ef46b28
to
2c9c41c
Compare
Please check your coverage here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/9/Diff_Coverage |
Check the performance result here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/9/Performance_Report |
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.
Very nice.
} | ||
|
||
// Update search index | ||
// (it is important here that we do it before actually setting |
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.
👍
@rrrlasse did you get a chance to look at the changes here or is it good to go? |
@rrrlasse bump for review |
Please check your coverage here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/10/Diff_Coverage |
Check the performance result here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/10/Performance_Report |
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.
See comments
{ | ||
REALM_ASSERT_3(row_ndx_1, <, size()); | ||
REALM_ASSERT_3(row_ndx_2, <, size()); | ||
REALM_ASSERT_DEBUG(row_ndx_1 != row_ndx_2); |
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.
Do all other column types use != also?
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.
Yes other columns have the same asserts, in particular StringColumn
.
test/fuzz_group.cpp
Outdated
@@ -678,7 +678,7 @@ void parse_and_apply_instructions(std::string& in, const std::string& path, util | |||
bool insert_big_blob = get_next(s) % 2 == 0; | |||
if (insert_big_blob) { | |||
size_t rand_char = get_next(s); | |||
size_t blob_size = get_next(s) + ArrayBlob::max_binary_size; | |||
size_t blob_size = get_next(s) + (ArrayBlob::max_binary_size + 1); |
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.
Shouldn't this be static_cast<uint64_t>(get_int64(s)) % (ArrayBlob::max_binary_size + 1);
? Or better yet, is there a reason for not reusing the existing generator in construct_mixed()
?
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.
Good idea, updated to share the correct ™ binary creation code in a function.
Please check your coverage here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/11/Diff_Coverage |
Check the performance result here: https://ci.realm.io/job/realm/job/realm-core/job/PR-2780/11/Performance_Report |
There was one bug introduced when the
swap_row
instruction was implemented:StringEnumColumn
was forgotten so the defaultColumn
implementation is called. What ends up happening is we set aStringData
payload into anIntegerColumn
type bp-tree. The fix is simply implementingStringEnumColumn::swap_rows()
just likeStringColumn
does it. This fixes #2766 (and adds the test there).The rest of the changes increase coverage of the
StringEnumColumn
type by making use of theTEST_TYPES
macro and some custom test structs implemented intest/test_string_types.hpp
. I found that I couldn't see the test headers in the generated Xcode project, so I added them to the project via theCMakeLists.txt
config.The increased number of tests increased the test time too much, so I reduced the number of iterations in the biggest offender
StringIndex_Insensitive_Fuzz
.Before:
After: