-
Notifications
You must be signed in to change notification settings - Fork 185
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression test runner and test for SC-17415
- Loading branch information
Showing
4 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# | ||
# test/regression/CMakeLists.txt | ||
# | ||
# | ||
# The MIT License | ||
# | ||
# Copyright (c) 2022 TileDB, Inc. | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in | ||
# all copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
# THE SOFTWARE. | ||
# | ||
|
||
find_package(Catch_EP REQUIRED) | ||
|
||
set(SOURCES | ||
targets/sc-15387.cc | ||
) | ||
|
||
add_executable(tiledb_regression | ||
EXCLUDE_FROM_ALL | ||
regression.cc | ||
${SOURCES} | ||
) | ||
|
||
if (NOT MSVC) | ||
target_compile_options(tiledb_regression PRIVATE -Wno-deprecated-declarations) | ||
endif() | ||
|
||
target_link_libraries(tiledb_regression | ||
PUBLIC | ||
Catch2::Catch2 | ||
tiledb_shared | ||
) | ||
|
||
target_include_directories(tiledb_regression | ||
PRIVATE | ||
${CMAKE_INSTALL_PREFIX}/include | ||
) | ||
|
||
add_test( | ||
NAME "tiledb_regression" | ||
COMMAND $<TARGET_FILE:tiledb_regression> --durations=yes | ||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#define CATCH_CONFIG_RUNNER | ||
#include <catch.hpp> | ||
|
||
int main(const int argc, char** const argv) { | ||
Catch::Session session; | ||
|
||
int rc = session.applyCommandLine(argc, argv); | ||
if (rc != 0) | ||
return rc; | ||
|
||
session.run(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
#include <tiledb/tiledb> | ||
|
||
#include "catch.hpp" | ||
|
||
#include <chrono> | ||
#include <thread> | ||
|
||
using namespace tiledb; | ||
|
||
namespace { | ||
void create_array(Context& ctx, std::string uri, bool use_two_dims) { | ||
auto dim0 = | ||
Dimension::create(ctx, "__dim_0", TILEDB_STRING_ASCII, nullptr, nullptr); | ||
tiledb::FilterList dim0_filters{ctx}; | ||
dim0_filters.add_filter({ctx, TILEDB_FILTER_RLE}); | ||
dim0.set_filter_list(dim0_filters); | ||
|
||
auto dim1 = | ||
Dimension::create(ctx, "__dim_1", TILEDB_STRING_ASCII, nullptr, nullptr); | ||
|
||
tiledb::Filter dim1_filter(ctx, TILEDB_FILTER_ZSTD); | ||
int level{22}; | ||
dim1_filter.set_option(TILEDB_COMPRESSION_LEVEL, &level); | ||
tiledb::FilterList dim1_filter_list{ctx}; | ||
dim1_filter_list.add_filter(dim1_filter); | ||
dim1.set_filter_list(dim1_filter_list); | ||
|
||
tiledb::FilterList attr_filter_list{ctx}; | ||
attr_filter_list.add_filter({ctx, TILEDB_FILTER_ZSTD}); | ||
|
||
Domain domain{ctx}; | ||
domain.add_dimension(dim0); | ||
if (use_two_dims) { | ||
domain.add_dimension(dim1); | ||
} | ||
|
||
Attribute attr{ctx, "value", TILEDB_FLOAT32, attr_filter_list}; | ||
|
||
tiledb::FilterList offsets_filters{ctx}; | ||
offsets_filters.add_filter({ctx, TILEDB_FILTER_DOUBLE_DELTA}) | ||
.add_filter({ctx, TILEDB_FILTER_BIT_WIDTH_REDUCTION}) | ||
.add_filter({ctx, TILEDB_FILTER_ZSTD}); | ||
|
||
ArraySchema schema{ctx, TILEDB_SPARSE}; | ||
schema.set_allows_dups(true); | ||
schema.set_capacity(100000); | ||
schema.set_cell_order(TILEDB_ROW_MAJOR); | ||
schema.set_tile_order(TILEDB_COL_MAJOR); | ||
schema.set_domain(domain); | ||
schema.add_attribute(attr); | ||
|
||
Array::create(uri, schema); | ||
} | ||
|
||
void write_array(Context& ctx, std::string uri, bool use_two_dims) { | ||
{ | ||
std::vector<char> d0_data{'a', 'b', 'c'}; | ||
std::vector<uint64_t> d0_offsets{0, 1, 2}; | ||
std::vector<char> d1_data{'s', 't', 'u'}; | ||
std::vector<uint64_t> d1_offsets{0, 1, 2}; | ||
std::vector<float> data{4, 5, 6}; | ||
|
||
Array array{ctx, uri, TILEDB_WRITE}; | ||
Query query{ctx, array, TILEDB_WRITE}; | ||
|
||
query.set_layout(TILEDB_UNORDERED) | ||
.set_data_buffer("__dim_0", d0_data) | ||
.set_offsets_buffer("__dim_0", d0_offsets) | ||
.set_data_buffer("value", data); | ||
|
||
if (use_two_dims) { | ||
query.set_data_buffer("__dim_1", d1_data) | ||
.set_offsets_buffer("__dim_1", d1_offsets); | ||
} | ||
|
||
query.submit(); | ||
query.finalize(); | ||
|
||
REQUIRE(query.query_status() == Query::Status::COMPLETE); | ||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); | ||
} | ||
{ | ||
std::vector<char> d0_data{'d', 'e', 'f'}; | ||
std::vector<uint64_t> d0_offsets{0, 1, 2}; | ||
std::vector<char> d1_data{'v', 'w', 'x'}; | ||
std::vector<uint64_t> d1_offsets{0, 1, 2}; | ||
std::vector<float> data{4, 5, 6}; | ||
|
||
Array array{ctx, uri, TILEDB_WRITE}; | ||
Query query{ctx, array, TILEDB_WRITE}; | ||
|
||
query.set_layout(TILEDB_UNORDERED) | ||
.set_data_buffer("__dim_0", d0_data) | ||
.set_offsets_buffer("__dim_0", d0_offsets) | ||
.set_data_buffer("value", data); | ||
|
||
if (use_two_dims) { | ||
query.set_data_buffer("__dim_1", d1_data) | ||
.set_offsets_buffer("__dim_1", d1_offsets); | ||
} | ||
|
||
query.submit(); | ||
query.finalize(); | ||
|
||
REQUIRE(query.query_status() == Query::Status::COMPLETE); | ||
} | ||
} | ||
|
||
}; // anonymous namespace | ||
|
||
TEST_CASE("SC-15387") { | ||
Context ctx; | ||
|
||
std::string uri{"foo1"}; | ||
|
||
auto object = tiledb::Object::object(ctx, uri); | ||
if (object.type() == tiledb::Object::Type::Array) | ||
tiledb::Object::remove(ctx, uri); | ||
|
||
auto use_two_dims = GENERATE(false, true); | ||
|
||
create_array(ctx, uri, use_two_dims); | ||
|
||
write_array(ctx, uri, use_two_dims); | ||
|
||
// use_two_dims | ||
// - false: segfaults if pre-increment used in comparators.h | ||
// - true: expected to segfault before fix | ||
tiledb::Array::consolidate(ctx, uri); | ||
|
||
// tiledb::Object::remove(ctx, uri); | ||
}; |