Skip to content

[aws-cpp-sdk-s3-crt]: TransferManager for S3CrtClient #2380

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add DownloadStream tests
  • Loading branch information
grrtrr committed Mar 6, 2023
commit 83e6488d3cadddbbcb853858b93eef0ab3833107
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ DownloadStream::DownloadStream(const Aws::String &dstPath, ErrorCallback ec, boo

// Produce unique temporary-file suffix. Use O_SYNC to ensure data gets written out to disk.
fd_ = ::mkostemp(&dstTempPath_[0], sync_always ? O_SYNC : 0);
std::cerr << "fd " << fd_ << " " << dstTempPath_ <<" " << strerror(errno)<< "\n";
if (fd_ < 0) {
ss << "Failed to create " << dstTempPath_ << ": " << ::strerror(errno);
_error(ss.str());
Expand Down
29 changes: 16 additions & 13 deletions tests/aws-cpp-sdk-transfer-crt-tests/DownloadStreamTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,27 @@ bool StringEndsWith(const Aws::String& str, const Aws::String& suffix) {
// Test fixture to help set up / tear down DownloadStream test cases.
class DownloadStreamtest : public ::testing::Test {
public:
static void SetUpTestCase() {
Aws::FileSystem::DeepDeleteDirectory(GetTestFilesDirectory().c_str());
}
static void TearDownTestCase() {
Aws::FileSystem::DeepDeleteDirectory(GetTestFilesDirectory().c_str());
}

DownloadStreamtest() : dst_{GetTestFilesDirectory() + "/test.file"} {}
~DownloadStreamtest() { (void)UnlinkTestFile(); }

// Open up a file descriptor to @dst_, creating any missing directory components.
int TestFile() {
const Aws::String parent_path = ParentPath(dst_);
Aws::FileSystem::CreateDirectoryIfNotExists(parent_path.c_str(), true);
std::cerr << dst_ << " " << parent_path << "\n"; // XXX
return ::open(dst_.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0600);
}

// Remove @dst_ from the filesystem.
int UnlinkTestFile() { return ::unlink(dst_.c_str()); }

// Return the contents of @dst_.
Aws::String TestFileContents() {
Aws::StringStream ss;
std::ifstream is{dst_};
Expand All @@ -78,8 +90,6 @@ class DownloadStreamtest : public ::testing::Test {
return ss.str();
}

int UnlinkTestFile() { return ::unlink(dst_.c_str()); }

static Aws::String GetTestFilesDirectory() {
Aws::String directory;
#ifdef __ANDROID__
Expand All @@ -92,14 +102,6 @@ class DownloadStreamtest : public ::testing::Test {
return directory;
}

static void SetUpTestCase() {
Aws::FileSystem::DeepDeleteDirectory(GetTestFilesDirectory().c_str());
}

static void TearDownTestCase() {
Aws::FileSystem::DeepDeleteDirectory(GetTestFilesDirectory().c_str());
}

protected:
Aws::String dst_;
Aws::String test_data_{"the quick brown fox jumps over the lazy lackadaisical lapdog"};
Expand All @@ -121,7 +123,6 @@ TEST_F(DownloadStreamtest, FdSupportedMethods) {
FileDescriptorBuf fdb(fd, [&errMsg](Aws::String e) { errMsg = std::move(e); });
char alternateBuf[128] = {0};

std::cerr << "ERROR: "<< errMsg << "\n";; // XXX
ASSERT_GT(fd, 2);
ASSERT_EQ(fdb.pubsync(), 0);
ASSERT_EQ(fdb.sputc('a'), 'a');
Expand Down Expand Up @@ -301,7 +302,6 @@ TEST_F(DownloadStreamtest, PermissionsError) {
DownloadStream d{dst_, [&errMsg](Aws::String e) { errMsg = std::move(e); }};

// ACTION

// Change the directory permissions so that renaming the file will fail:
ASSERT_EQ(::chmod(ParentPath(dst_).c_str(), 0), 0);

Expand All @@ -313,6 +313,9 @@ TEST_F(DownloadStreamtest, PermissionsError) {

// VERIFICATION
EXPECT_TRUE(StringEndsWith(errMsg, "Permission denied"));

// CLEAN-UP (need to restore directory permissions to enable deletion).
ASSERT_EQ(::chmod(ParentPath(dst_).c_str(), 755), 0);
}

} // namespace
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy