Skip to content

Commit

Permalink
Remove require_tiledb_ok for File I/O test case
Browse files Browse the repository at this point in the history
  • Loading branch information
bekadavis9 authored and KiterLuc committed Feb 28, 2024
1 parent 4d2a9da commit be684ff
Showing 1 changed file with 24 additions and 25 deletions.
49 changes: 24 additions & 25 deletions test/src/unit-vfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -512,17 +512,17 @@ TEST_CASE("VFS: File I/O", "[vfs][uri][file_io]") {
// Set up
bool exists = false;
if (path.is_gcs() || path.is_s3() || path.is_azure()) {
require_tiledb_ok(vfs.is_bucket(path, &exists));
REQUIRE(vfs.is_bucket(path, &exists).ok());
if (exists) {
require_tiledb_ok(vfs.remove_bucket(path));
REQUIRE(vfs.remove_bucket(path).ok());
}
require_tiledb_ok(vfs.create_bucket(path));
REQUIRE(vfs.create_bucket(path).ok());
} else {
require_tiledb_ok(vfs.is_dir(path, &exists));
REQUIRE(vfs.is_dir(path, &exists).ok());
if (exists) {
require_tiledb_ok(vfs.remove_dir(path));
REQUIRE(vfs.remove_dir(path).ok());
}
require_tiledb_ok(vfs.create_dir(path));
REQUIRE(vfs.create_dir(path).ok());
}

// Prepare buffers
Expand All @@ -537,41 +537,40 @@ TEST_CASE("VFS: File I/O", "[vfs][uri][file_io]") {

// Write to two files
URI largefile = URI(path.to_string() + "largefile");
require_tiledb_ok(vfs.write(largefile, write_buffer, buffer_size));
require_tiledb_ok(
vfs.write(URI(largefile), write_buffer_small, buffer_size_small));
REQUIRE(vfs.write(largefile, write_buffer, buffer_size).ok());
REQUIRE(
vfs.write(URI(largefile), write_buffer_small, buffer_size_small).ok());
URI smallfile = URI(path.to_string() + "smallfile");
require_tiledb_ok(
vfs.write(smallfile, write_buffer_small, buffer_size_small));
REQUIRE(vfs.write(smallfile, write_buffer_small, buffer_size_small).ok());

// On non-local and hdfs systems, before flushing, the files do not exist
if (!(path.is_file() || path.is_hdfs())) {
require_tiledb_ok(vfs.is_file(largefile, &exists));
REQUIRE(vfs.is_file(largefile, &exists).ok());
CHECK(!exists);
require_tiledb_ok(vfs.is_file(smallfile, &exists));
REQUIRE(vfs.is_file(smallfile, &exists).ok());
CHECK(!exists);

// Flush the files
require_tiledb_ok(vfs.close_file(largefile));
require_tiledb_ok(vfs.close_file(smallfile));
REQUIRE(vfs.close_file(largefile).ok());
REQUIRE(vfs.close_file(smallfile).ok());
}

// After flushing, the files exist
require_tiledb_ok(vfs.is_file(largefile, &exists));
REQUIRE(vfs.is_file(largefile, &exists).ok());
CHECK(exists);
require_tiledb_ok(vfs.is_file(smallfile, &exists));
REQUIRE(vfs.is_file(smallfile, &exists).ok());
CHECK(exists);

// Get file sizes
uint64_t nbytes = 0;
require_tiledb_ok(vfs.file_size(largefile, &nbytes));
REQUIRE(vfs.file_size(largefile, &nbytes).ok());
CHECK(nbytes == (buffer_size + buffer_size_small));
require_tiledb_ok(vfs.file_size(smallfile, &nbytes));
REQUIRE(vfs.file_size(smallfile, &nbytes).ok());
CHECK(nbytes == buffer_size_small);

// Read from the beginning
auto read_buffer = new char[26];
require_tiledb_ok(vfs.read(largefile, 0, read_buffer, 26));
REQUIRE(vfs.read(largefile, 0, read_buffer, 26).ok());
bool allok = true;
for (int i = 0; i < 26; i++) {
if (read_buffer[i] != static_cast<char>('a' + i)) {
Expand All @@ -582,7 +581,7 @@ TEST_CASE("VFS: File I/O", "[vfs][uri][file_io]") {
CHECK(allok);

// Read from a different offset
require_tiledb_ok(vfs.read(largefile, 11, read_buffer, 26));
REQUIRE(vfs.read(largefile, 11, read_buffer, 26).ok());
allok = true;
for (int i = 0; i < 26; i++) {
if (read_buffer[i] != static_cast<char>('a' + (i + 11) % 26)) {
Expand All @@ -594,12 +593,12 @@ TEST_CASE("VFS: File I/O", "[vfs][uri][file_io]") {

// Clean up
if (path.is_gcs() || path.is_s3() || path.is_azure()) {
require_tiledb_ok(vfs.remove_bucket(path));
require_tiledb_ok(vfs.is_bucket(path, &exists));
REQUIRE(vfs.remove_bucket(path).ok());
REQUIRE(vfs.is_bucket(path, &exists).ok());
REQUIRE(!exists);
} else {
require_tiledb_ok(vfs.remove_dir(path));
require_tiledb_ok(vfs.is_dir(path, &exists));
REQUIRE(vfs.remove_dir(path).ok());
REQUIRE(vfs.is_dir(path, &exists).ok());
REQUIRE(!exists);
}
}
Expand Down

0 comments on commit be684ff

Please sign in to comment.