diff --git a/oss-internship-2020/guetzli/BUILD.bazel b/oss-internship-2020/guetzli/BUILD.bazel index 6e3332a..fe5bfb8 100644 --- a/oss-internship-2020/guetzli/BUILD.bazel +++ b/oss-internship-2020/guetzli/BUILD.bazel @@ -1,3 +1,17 @@ +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + load( "@com_google_sandboxed_api//sandboxed_api/bazel:sapi.bzl", "sapi_library", diff --git a/oss-internship-2020/guetzli/README.md b/oss-internship-2020/guetzli/README.md new file mode 100644 index 0000000..e69de29 diff --git a/oss-internship-2020/guetzli/guetzli_entry_points.cc b/oss-internship-2020/guetzli/guetzli_entry_points.cc index a815673..ec0743b 100644 --- a/oss-internship-2020/guetzli/guetzli_entry_points.cc +++ b/oss-internship-2020/guetzli/guetzli_entry_points.cc @@ -1,3 +1,25 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include + +#include +#include +#include +#include +#include + #include "guetzli/jpeg_data_reader.h" #include "guetzli/quality.h" #include "guetzli_entry_points.h" @@ -5,17 +27,10 @@ #include "sandboxed_api/sandbox2/util/fileops.h" #include "sandboxed_api/util/statusor.h" -#include -#include -#include -#include -#include -#include - namespace { constexpr int kBytesPerPixel = 350; -constexpr int kLowestMemusageMB = 100; // in MB +constexpr int kLowestMemusageMB = 100; struct GuetzliInitData { std::string in_data; @@ -26,7 +41,7 @@ struct GuetzliInitData { template void CopyMemoryToLenVal(const T* data, size_t size, sapi::LenValStruct* out_data) { - free(out_data->data); // Not sure about this + free(out_data->data); // Not sure about this out_data->size = size; T* new_out = static_cast(malloc(size)); memcpy(new_out, data, size); @@ -49,7 +64,6 @@ sapi::StatusOr ReadFromFd(int fd) { status = read(fd, buf.get(), fsize); if (status < 0) { - lseek(fd, 0, SEEK_SET); return absl::FailedPreconditionError( "Error reading input from fd" ); @@ -275,4 +289,4 @@ extern "C" bool ProcessRgb(const ProcessingParams* processing_params, extern "C" bool WriteDataToFd(int fd, sapi::LenValStruct* data) { return sandbox2::file_util::fileops::WriteToFD(fd, static_cast(data->data), data->size); -} \ No newline at end of file +} diff --git a/oss-internship-2020/guetzli/guetzli_entry_points.h b/oss-internship-2020/guetzli/guetzli_entry_points.h index 90b0d97..b7fd2c5 100644 --- a/oss-internship-2020/guetzli/guetzli_entry_points.h +++ b/oss-internship-2020/guetzli/guetzli_entry_points.h @@ -1,4 +1,19 @@ -#pragma once +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef GUETZLI_SANDBOXED_GUETZLI_ENTRY_POINTS_H_ +#define GUETZLI_SANDBOXED_GUETZLI_ENTRY_POINTS_H_ #include "guetzli/processor.h" #include "sandboxed_api/lenval_core.h" @@ -15,4 +30,6 @@ extern "C" bool ProcessJpeg(const ProcessingParams* processing_params, sapi::LenValStruct* output); extern "C" bool ProcessRgb(const ProcessingParams* processing_params, sapi::LenValStruct* output); -extern "C" bool WriteDataToFd(int fd, sapi::LenValStruct* data); \ No newline at end of file +extern "C" bool WriteDataToFd(int fd, sapi::LenValStruct* data); + +#endif // GUETZLI_SANDBOXED_GUETZLI_ENTRY_POINTS_H_ diff --git a/oss-internship-2020/guetzli/guetzli_sandbox.h b/oss-internship-2020/guetzli/guetzli_sandbox.h index 3fa2b10..e55875a 100644 --- a/oss-internship-2020/guetzli/guetzli_sandbox.h +++ b/oss-internship-2020/guetzli/guetzli_sandbox.h @@ -1,13 +1,29 @@ -#pragma once +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef GUETZLI_SANDBOXED_GUETZLI_SANDBOX_H_ +#define GUETZLI_SANDBOXED_GUETZLI_SANDBOX_H_ #include #include -#include "guetzli_sapi.sapi.h" #include "sandboxed_api/sandbox2/policy.h" #include "sandboxed_api/sandbox2/policybuilder.h" #include "sandboxed_api/util/flag.h" +#include "guetzli_sapi.sapi.h" + namespace guetzli { namespace sandbox { @@ -32,5 +48,7 @@ class GuetzliSapiSandbox : public GuetzliSandbox { } }; -} // namespace sandbox -} // namespace guetzli \ No newline at end of file +} // namespace sandbox +} // namespace guetzli + +#endif // GUETZLI_SANDBOXED_GUETZLI_SANDBOX_H_ diff --git a/oss-internship-2020/guetzli/guetzli_sandboxed.cc b/oss-internship-2020/guetzli/guetzli_sandboxed.cc index 3393b8f..cb6543c 100644 --- a/oss-internship-2020/guetzli/guetzli_sandboxed.cc +++ b/oss-internship-2020/guetzli/guetzli_sandboxed.cc @@ -1,19 +1,34 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include #include #include #include #include -#include #include -#include "guetzli_transaction.h" #include "sandboxed_api/sandbox2/util/fileops.h" #include "sandboxed_api/util/statusor.h" +#include "guetzli_transaction.h" + namespace { constexpr int kDefaultJPEGQuality = 95; -constexpr int kDefaultMemlimitMB = 6000; // in MB +constexpr int kDefaultMemlimitMB = 6000; void TerminateHandler() { fprintf(stderr, "Unhandled exception. Most likely insufficient memory available.\n" @@ -124,9 +139,9 @@ int main(int argc, const char** argv) { } } else { - fprintf(stderr, "%s\n", result.ToString().c_str()); // Use cerr instead ? + fprintf(stderr, "%s\n", result.ToString().c_str()); // Use cerr instead ? return 1; } return 0; -} \ No newline at end of file +} diff --git a/oss-internship-2020/guetzli/guetzli_transaction.cc b/oss-internship-2020/guetzli/guetzli_transaction.cc index 0f7e1bd..2613bdf 100644 --- a/oss-internship-2020/guetzli/guetzli_transaction.cc +++ b/oss-internship-2020/guetzli/guetzli_transaction.cc @@ -1,3 +1,17 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + #include "guetzli_transaction.h" #include @@ -45,8 +59,8 @@ absl::Status GuetzliTransaction::Init() { "Error receiving remote FD: remote output fd is set to -1"); } - in_fd_.OwnLocalFd(false); // FDCloser will close local fd - out_fd_.OwnLocalFd(false); // FDCloser will close local fd + in_fd_.OwnLocalFd(false); // FDCloser will close local fd + out_fd_.OwnLocalFd(false); // FDCloser will close local fd return absl::OkStatus(); } @@ -62,14 +76,14 @@ absl::Status GuetzliTransaction::Main() { params_.memlimit_mb }; - auto result_status = image_type_ == ImageType::JPEG ? + auto result_status = image_type_ == ImageType::kJpeg ? api.ProcessJpeg(processing_params.PtrBefore(), output.PtrBoth()) : api.ProcessRgb(processing_params.PtrBefore(), output.PtrBoth()); if (!result_status.value_or(false)) { std::stringstream error_stream; error_stream << "Error processing " - << (image_type_ == ImageType::JPEG ? "jpeg" : "rgb") << " data" + << (image_type_ == ImageType::kJpeg ? "jpeg" : "rgb") << " data" << std::endl; return absl::FailedPreconditionError( @@ -113,8 +127,8 @@ sapi::StatusOr GuetzliTransaction::GetImageTypeFromFd(int fd) const { } return memcmp(read_buf, kPNGMagicBytes, sizeof(kPNGMagicBytes)) == 0 ? - ImageType::PNG : ImageType::JPEG; + ImageType::kPng : ImageType::kJpeg; } -} // namespace sandbox -} // namespace guetzli \ No newline at end of file +} // namespace sandbox +} // namespace guetzli diff --git a/oss-internship-2020/guetzli/guetzli_transaction.h b/oss-internship-2020/guetzli/guetzli_transaction.h index 8dbd7ec..2db681d 100644 --- a/oss-internship-2020/guetzli/guetzli_transaction.h +++ b/oss-internship-2020/guetzli/guetzli_transaction.h @@ -1,21 +1,34 @@ -#pragma once +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#ifndef GUETZLI_SANDBOXED_GUETZLI_TRANSACTION_H_ +#define GUETZLI_SANDBOXED_GUETZLI_TRANSACTION_H_ #include #include -#include "guetzli_sandbox.h" #include "sandboxed_api/transaction.h" #include "sandboxed_api/vars.h" +#include "guetzli_sandbox.h" + namespace guetzli { namespace sandbox { -constexpr int kDefaultTransactionRetryCount = 0; -constexpr uint64_t kMpixPixels = 1'000'000; - enum class ImageType { - JPEG, - PNG + kJpeg, + kPng }; struct TransactionParams { @@ -55,8 +68,13 @@ class GuetzliTransaction : public sapi::Transaction { const TransactionParams params_; sapi::v::Fd in_fd_; sapi::v::Fd out_fd_; - ImageType image_type_ = ImageType::JPEG; + ImageType image_type_ = ImageType::kJpeg; + + static const int kDefaultTransactionRetryCount = 0; + static const uint64_t kMpixPixels = 1'000'000; }; -} // namespace sandbox -} // namespace guetzli +} // namespace sandbox +} // namespace guetzli + +#endif // GUETZLI_SANDBOXED_GUETZLI_TRANSACTION_H_ diff --git a/oss-internship-2020/guetzli/tests/BUILD.bazel b/oss-internship-2020/guetzli/tests/BUILD.bazel index fa8b4ae..34f3f76 100644 --- a/oss-internship-2020/guetzli/tests/BUILD.bazel +++ b/oss-internship-2020/guetzli/tests/BUILD.bazel @@ -1,3 +1,17 @@ +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + cc_test( name = "transaction_tests", srcs = ["guetzli_transaction_test.cc"], diff --git a/oss-internship-2020/guetzli/tests/guetzli_sapi_test.cc b/oss-internship-2020/guetzli/tests/guetzli_sapi_test.cc index 2de4cb3..71439d7 100644 --- a/oss-internship-2020/guetzli/tests/guetzli_sapi_test.cc +++ b/oss-internship-2020/guetzli/tests/guetzli_sapi_test.cc @@ -1,16 +1,32 @@ +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#include +#include +#include + +#include +#include +#include +#include + #include "gtest/gtest.h" -#include "guetzli_sandbox.h" #include "sandboxed_api/sandbox2/util/fileops.h" #include "sandboxed_api/vars.h" -#include -#include -#include -#include -#include -#include -#include -#include +#include "guetzli_sandbox.h" namespace guetzli { namespace sandbox { @@ -18,23 +34,23 @@ namespace tests { namespace { -constexpr const char* IN_PNG_FILENAME = "bees.png"; -constexpr const char* IN_JPG_FILENAME = "nature.jpg"; -constexpr const char* PNG_REFERENCE_FILENAME = "bees_reference.jpg"; -constexpr const char* JPG_REFERENCE_FILENAME = "nature_reference.jpg"; +constexpr const char* kInPngFilename = "bees.png"; +constexpr const char* kInJpegFilename = "nature.jpg"; +constexpr const char* kPngReferenceFilename = "bees_reference.jpg"; +constexpr const char* kJpegReferenceFIlename = "nature_reference.jpg"; -constexpr int PNG_EXPECTED_SIZE = 38'625; -constexpr int JPG_EXPECTED_SIZE = 10'816; +constexpr int kPngExpectedSize = 38'625; +constexpr int kJpegExpectedSize = 10'816; -constexpr int DEFAULT_QUALITY_TARGET = 95; -constexpr int DEFAULT_MEMLIMIT_MB = 6000; +constexpr int kDefaultQualityTarget = 95; +constexpr int kDefaultMemlimitMb = 6000; -constexpr const char* RELATIVE_PATH_TO_TESTDATA = +constexpr const char* kRelativePathToTestdata = "/guetzli_sandboxed/tests/testdata/"; std::string GetPathToInputFile(const char* filename) { return std::string(getenv("TEST_SRCDIR")) - + std::string(RELATIVE_PATH_TO_TESTDATA) + + std::string(kRelativePathToTestdata) + std::string(filename); } @@ -78,7 +94,7 @@ protected: // This test can take up to few minutes depending on your hardware TEST_F(GuetzliSapiTest, ProcessRGB) { - sapi::v::Fd in_fd(open(GetPathToInputFile(IN_PNG_FILENAME).c_str(), + sapi::v::Fd in_fd(open(GetPathToInputFile(kInPngFilename).c_str(), O_RDONLY)); ASSERT_TRUE(in_fd.GetValue() != -1) << "Error opening input file"; ASSERT_EQ(api_->sandbox()->TransferToSandboxee(&in_fd), absl::OkStatus()) @@ -87,17 +103,17 @@ TEST_F(GuetzliSapiTest, ProcessRGB) { sapi::v::Struct processing_params; *processing_params.mutable_data() = {in_fd.GetRemoteFd(), 0, - DEFAULT_QUALITY_TARGET, - DEFAULT_MEMLIMIT_MB + kDefaultQualityTarget, + kDefaultMemlimitMb }; sapi::v::LenVal output(0); auto processing_result = api_->ProcessRgb(processing_params.PtrBefore(), output.PtrBoth()); ASSERT_TRUE(processing_result.value_or(false)) << "Error processing rgb data"; - ASSERT_EQ(output.GetDataSize(), PNG_EXPECTED_SIZE) + ASSERT_EQ(output.GetDataSize(), kPngExpectedSize) << "Incorrect result data size"; std::string reference_data = - ReadFromFile(GetPathToInputFile(PNG_REFERENCE_FILENAME)); + ReadFromFile(GetPathToInputFile(kPngReferenceFilename)); ASSERT_EQ(output.GetDataSize(), reference_data.size()) << "Incorrect result data size"; ASSERT_TRUE(CompareBytesInLenValAndContainer(output, reference_data)) @@ -106,7 +122,7 @@ TEST_F(GuetzliSapiTest, ProcessRGB) { // This test can take up to few minutes depending on your hardware TEST_F(GuetzliSapiTest, ProcessJpeg) { - sapi::v::Fd in_fd(open(GetPathToInputFile(IN_JPG_FILENAME).c_str(), + sapi::v::Fd in_fd(open(GetPathToInputFile(kInJpegFilename).c_str(), O_RDONLY)); ASSERT_TRUE(in_fd.GetValue() != -1) << "Error opening input file"; ASSERT_EQ(api_->sandbox()->TransferToSandboxee(&in_fd), absl::OkStatus()) @@ -115,27 +131,23 @@ TEST_F(GuetzliSapiTest, ProcessJpeg) { sapi::v::Struct processing_params; *processing_params.mutable_data() = {in_fd.GetRemoteFd(), 0, - DEFAULT_QUALITY_TARGET, - DEFAULT_MEMLIMIT_MB + kDefaultQualityTarget, + kDefaultMemlimitMb }; sapi::v::LenVal output(0); auto processing_result = api_->ProcessJpeg(processing_params.PtrBefore(), output.PtrBoth()); ASSERT_TRUE(processing_result.value_or(false)) << "Error processing jpg data"; - ASSERT_EQ(output.GetDataSize(), JPG_EXPECTED_SIZE) + ASSERT_EQ(output.GetDataSize(), kJpegExpectedSize) << "Incorrect result data size"; std::string reference_data = - ReadFromFile(GetPathToInputFile(JPG_REFERENCE_FILENAME)); + ReadFromFile(GetPathToInputFile(kJpegReferenceFIlename)); ASSERT_EQ(output.GetDataSize(), reference_data.size()) << "Incorrect result data size"; ASSERT_TRUE(CompareBytesInLenValAndContainer(output, reference_data)) << "Processed data doesn't match reference output"; } -// TEST_F(GuetzliSapiTest, WriteDataToFd) { -// sapi::v::Fd fd(open(".", O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR)); -// } - -} // namespace tests -} // namespace sandbox -} // namespace guetzli \ No newline at end of file +} // namespace tests +} // namespace sandbox +} // namespace guetzli diff --git a/oss-internship-2020/guetzli/tests/guetzli_transaction_test.cc b/oss-internship-2020/guetzli/tests/guetzli_transaction_test.cc index b9e3a22..da76dde 100644 --- a/oss-internship-2020/guetzli/tests/guetzli_transaction_test.cc +++ b/oss-internship-2020/guetzli/tests/guetzli_transaction_test.cc @@ -1,14 +1,30 @@ -#include "gtest/gtest.h" -#include "guetzli_transaction.h" -#include "sandboxed_api/sandbox2/util/fileops.h" +// Copyright 2020 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. #include #include #include #include + #include -#include #include +#include + +#include "gtest/gtest.h" +#include "sandboxed_api/sandbox2/util/fileops.h" + +#include "guetzli_transaction.h" namespace guetzli { namespace sandbox { @@ -16,23 +32,23 @@ namespace tests { namespace { -constexpr const char* IN_PNG_FILENAME = "bees.png"; -constexpr const char* IN_JPG_FILENAME = "nature.jpg"; -constexpr const char* PNG_REFERENCE_FILENAME = "bees_reference.jpg"; -constexpr const char* JPG_REFERENCE_FILENAME = "nature_reference.jpg"; +constexpr const char* kInPngFilename = "bees.png"; +constexpr const char* kInJpegFilename = "nature.jpg"; +constexpr const char* kPngReferenceFilename = "bees_reference.jpg"; +constexpr const char* kJpegReferenceFIlename = "nature_reference.jpg"; -constexpr int PNG_EXPECTED_SIZE = 38'625; -constexpr int JPG_EXPECTED_SIZE = 10'816; +constexpr int kPngExpectedSize = 38'625; +constexpr int kJpegExpectedSize = 10'816; -constexpr int DEFAULT_QUALITY_TARGET = 95; -constexpr int DEFAULT_MEMLIMIT_MB = 6000; +constexpr int kDefaultQualityTarget = 95; +constexpr int kDefaultMemlimitMb = 6000; -constexpr const char* RELATIVE_PATH_TO_TESTDATA = +constexpr const char* kRelativePathToTestdata = "/guetzli_sandboxed/tests/testdata/"; std::string GetPathToInputFile(const char* filename) { return std::string(getenv("TEST_SRCDIR")) - + std::string(RELATIVE_PATH_TO_TESTDATA) + + std::string(kRelativePathToTestdata) + std::string(filename); } @@ -48,11 +64,11 @@ std::string ReadFromFile(const std::string& filename) { return result.str(); } -} // namespace +} // namespace TEST(GuetzliTransactionTest, TestTransactionJpg) { sandbox2::file_util::fileops::FDCloser in_fd_closer( - open(GetPathToInputFile(IN_JPG_FILENAME).c_str(), O_RDONLY)); + open(GetPathToInputFile(kInJpegFilename).c_str(), O_RDONLY)); ASSERT_TRUE(in_fd_closer.get() != -1) << "Error opening input jpg file"; sandbox2::file_util::fileops::FDCloser out_fd_closer( open(".", O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR)); @@ -61,8 +77,8 @@ TEST(GuetzliTransactionTest, TestTransactionJpg) { in_fd_closer.get(), out_fd_closer.get(), 0, - DEFAULT_QUALITY_TARGET, - DEFAULT_MEMLIMIT_MB + kDefaultQualityTarget, + kDefaultMemlimitMb }; { GuetzliTransaction transaction(std::move(params)); @@ -72,7 +88,7 @@ TEST(GuetzliTransactionTest, TestTransactionJpg) { } ASSERT_TRUE(fcntl(out_fd_closer.get(), F_GETFD) != -1 || errno != EBADF) << "Local output fd closed"; - auto reference_data = ReadFromFile(GetPathToInputFile(JPG_REFERENCE_FILENAME)); + auto reference_data = ReadFromFile(GetPathToInputFile(kJpegReferenceFIlename)); auto output_size = lseek(out_fd_closer.get(), 0, SEEK_END); ASSERT_EQ(reference_data.size(), output_size) << "Different sizes of reference and returned data"; @@ -90,7 +106,7 @@ TEST(GuetzliTransactionTest, TestTransactionJpg) { TEST(GuetzliTransactionTest, TestTransactionPng) { sandbox2::file_util::fileops::FDCloser in_fd_closer( - open(GetPathToInputFile(IN_PNG_FILENAME).c_str(), O_RDONLY)); + open(GetPathToInputFile(kInPngFilename).c_str(), O_RDONLY)); ASSERT_TRUE(in_fd_closer.get() != -1) << "Error opening input png file"; sandbox2::file_util::fileops::FDCloser out_fd_closer( open(".", O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR)); @@ -99,8 +115,8 @@ TEST(GuetzliTransactionTest, TestTransactionPng) { in_fd_closer.get(), out_fd_closer.get(), 0, - DEFAULT_QUALITY_TARGET, - DEFAULT_MEMLIMIT_MB + kDefaultQualityTarget, + kDefaultMemlimitMb }; { GuetzliTransaction transaction(std::move(params)); @@ -110,7 +126,7 @@ TEST(GuetzliTransactionTest, TestTransactionPng) { } ASSERT_TRUE(fcntl(out_fd_closer.get(), F_GETFD) != -1 || errno != EBADF) << "Local output fd closed"; - auto reference_data = ReadFromFile(GetPathToInputFile(PNG_REFERENCE_FILENAME)); + auto reference_data = ReadFromFile(GetPathToInputFile(kPngReferenceFilename)); auto output_size = lseek(out_fd_closer.get(), 0, SEEK_END); ASSERT_EQ(reference_data.size(), output_size) << "Different sizes of reference and returned data"; @@ -126,6 +142,6 @@ TEST(GuetzliTransactionTest, TestTransactionPng) { << "Returned data doesn't match refernce"; } -} // namespace tests -} // namespace sandbox -} // namespace guetzli \ No newline at end of file +} // namespace tests +} // namespace sandbox +} // namespace guetzli