patchpanel: Improve unit test maintainability

This patch contains the following changes:
a) Use NiceMock by default. NiceMock won't log anything on uninteresting
calls, so the output will be easier to read. Note that this won't change
the expectation set on the mock object.
b) Give mock methods a reasonable default return value when it makes
sense. As a result, the error output from the production code will be
reduced.
c) Mock the iptables-restore calls in Datapath tests. Since it will be
called in ctor and dtor of the Datapath class, actually it will cause a
lot of process forking during the test, which introduces error logs in
the test output and also takes time.

This patch reduces log lines of unit tests by 80% (from ~12.5K to 2.5K),
and the execution time by 80% (from 7.4s to 1.6s).

BUG=None
TEST=None

Change-Id: I352c0639cba38ac813fa8893f608e35cf283d078
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform2/+/5859677
Reviewed-by: Hugo Benichi <[email protected]>
Tested-by: Jie Jiang <[email protected]>
Commit-Queue: Jie Jiang <[email protected]>
diff --git a/patchpanel/clat_service_test.cc b/patchpanel/clat_service_test.cc
index 659c7cd..33e928d 100644
--- a/patchpanel/clat_service_test.cc
+++ b/patchpanel/clat_service_test.cc
@@ -30,6 +30,7 @@
 using testing::Exactly;
 using testing::Invoke;
 using testing::IsEmpty;
+using testing::NiceMock;
 using testing::Return;
 using testing::StrEq;
 
@@ -129,9 +130,9 @@
         target_(&datapath_, &process_manager_, &system_) {}
 
   FakeProcessRunner process_runner_;
-  MockSystem system_;
-  MockDatapath datapath_;
-  net_base::MockProcessManager process_manager_;
+  NiceMock<MockSystem> system_;
+  NiceMock<MockDatapath> datapath_;
+  NiceMock<net_base::MockProcessManager> process_manager_;
   ClatServiceUnderTest target_;
 };