Change ErrorCode into an enum class.
This change is needed in order for us to be able to import ErrorCode
symbols from chromeos_update_engine into chromeos_update_manager.
Unfortunately, shifting from plain 'enum' into an 'enum class' means
that the compiler treats the new class as a distinct type from int,
which in turn means that plenty of seamless arithmetic/bitwise
operations we used for manipulating error code values throughout the
code needed to be retrofitted with static_cast operators.
In the future, we should consider imposing a proper abstraction on
update engine error codes that'll prevent mingling with value encoding
directly and prevent such nastiness. It'll also make things more
coherent (types, semantics) and safer.
BUG=chromium:358329
TEST=Unit tests.
Change-Id: Ie55fa566b764cdab6c4785d995fb6daee4cb32d3
Reviewed-on: https://chromium-review.googlesource.com/203209
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/filesystem_copier_action_unittest.cc b/filesystem_copier_action_unittest.cc
index 300708f..3e5f1b9 100644
--- a/filesystem_copier_action_unittest.cc
+++ b/filesystem_copier_action_unittest.cc
@@ -49,7 +49,7 @@
public:
FilesystemCopierActionTestDelegate(GMainLoop* loop,
FilesystemCopierAction* action)
- : loop_(loop), action_(action), ran_(false), code_(kErrorCodeError) {}
+ : loop_(loop), action_(action), ran_(false), code_(ErrorCode::kError) {}
void ExitMainLoop() {
GMainContext* context = g_main_loop_get_context(loop_);
// We cannot use g_main_context_pending() alone to determine if it is safe
@@ -242,18 +242,18 @@
success = success && is_delegate_ran;
}
if (run_out_of_space || terminate_early) {
- EXPECT_EQ(kErrorCodeError, delegate.code());
- return (kErrorCodeError == delegate.code());
+ EXPECT_EQ(ErrorCode::kError, delegate.code());
+ return (ErrorCode::kError == delegate.code());
}
if (verify_hash == 2) {
ErrorCode expected_exit_code =
(use_kernel_partition ?
- kErrorCodeNewKernelVerificationError :
- kErrorCodeNewRootfsVerificationError);
+ ErrorCode::kNewKernelVerificationError :
+ ErrorCode::kNewRootfsVerificationError);
EXPECT_EQ(expected_exit_code, delegate.code());
return (expected_exit_code == delegate.code());
}
- EXPECT_EQ(kErrorCodeSuccess, delegate.code());
+ EXPECT_EQ(ErrorCode::kSuccess, delegate.code());
// Make sure everything in the out_image is there
vector<char> a_out;
@@ -320,7 +320,7 @@
processor.StartProcessing();
EXPECT_FALSE(processor.IsRunning());
EXPECT_TRUE(delegate.ran_);
- EXPECT_EQ(kErrorCodeError, delegate.code_);
+ EXPECT_EQ(ErrorCode::kError, delegate.code_);
}
TEST_F(FilesystemCopierActionTest, ResumeTest) {
@@ -345,7 +345,7 @@
processor.StartProcessing();
EXPECT_FALSE(processor.IsRunning());
EXPECT_TRUE(delegate.ran_);
- EXPECT_EQ(kErrorCodeSuccess, delegate.code_);
+ EXPECT_EQ(ErrorCode::kSuccess, delegate.code_);
EXPECT_EQ(kUrl, collector_action.object().download_url);
}
@@ -378,7 +378,7 @@
processor.StartProcessing();
EXPECT_FALSE(processor.IsRunning());
EXPECT_TRUE(delegate.ran_);
- EXPECT_EQ(kErrorCodeError, delegate.code_);
+ EXPECT_EQ(ErrorCode::kError, delegate.code_);
}
TEST_F(FilesystemCopierActionTest, RunAsRootVerifyHashTest) {