shill: DHCPConfig: Get new lease with RenewIP

If a DHCP process is not running when RenewIP is called, acquire
a new lease instead of returning.  This allows callers external
to shill to avoid having to keep track of whether the IPConfig
object has a lease or not.

BUG=chromium:318290
TEST=Unit test + manual: Reproduce the issue in crbug.com/318290.
In specific, change the IP address to a static IP first and close
the configuration panel, then separately switch to custom name
servers.

Change-Id: Ifebf7507f65dc981e5ca77d000ba298e0c6f22ee
Reviewed-on: https://chromium-review.googlesource.com/177350
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Commit-Queue: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/dhcp_config_unittest.cc b/dhcp_config_unittest.cc
index 312530d..88adfd2 100644
--- a/dhcp_config_unittest.cc
+++ b/dhcp_config_unittest.cc
@@ -31,6 +31,7 @@
 using testing::_;
 using testing::AnyNumber;
 using testing::ContainsRegex;
+using testing::Mock;
 using testing::Return;
 using testing::SetArgumentPointee;
 using testing::Test;
@@ -604,6 +605,11 @@
 }
 
 TEST_F(DHCPConfigTest, RenewIP) {
+  EXPECT_CALL(*minijail_, RunAndDestroy(_, _, _)).WillOnce(Return(false));
+  config_->pid_ = 0;
+  EXPECT_FALSE(config_->RenewIP());  // Expect a call to Start() if pid_ is 0.
+  Mock::VerifyAndClearExpectations(minijail_.get());
+  EXPECT_CALL(*minijail_, RunAndDestroy(_, _, _)).Times(0);
   EXPECT_TRUE(config_->lease_acquisition_timeout_callback_.IsCancelled());
   config_->pid_ = 456;
   EXPECT_FALSE(config_->RenewIP());  // Expect no crash with NULL proxy.