Use /dev/block/loop* for loop devices in Android.
In Android ueventd creates /dev/block/loop*, we should use that instead
of creating our own.
Fix: 119624750
Test: update_engine_unittests
Change-Id: If6eadbd32b2b8c7aa7a17987b6eb51c93787f95a
diff --git a/common/test_utils.cc b/common/test_utils.cc
index 04f55d0..2e44ff8 100644
--- a/common/test_utils.cc
+++ b/common/test_utils.cc
@@ -35,20 +35,26 @@
#include <vector>
#include <base/files/file_util.h>
-#include <base/format_macros.h>
#include <base/logging.h>
-#include <base/strings/string_util.h>
-#include <base/strings/stringprintf.h>
#include "update_engine/common/error_code_utils.h"
#include "update_engine/common/utils.h"
#include "update_engine/payload_consumer/file_writer.h"
-using base::StringPrintf;
using std::set;
using std::string;
using std::vector;
+namespace {
+
+#ifdef __ANDROID__
+#define kLoopDevicePrefix "/dev/block/loop"
+#else
+#define kLoopDevicePrefix "/dev/loop"
+#endif // __ANDROID__
+
+} // namespace
+
namespace chromeos_update_engine {
void PrintTo(const Extent& extent, ::std::ostream* os) {
@@ -129,7 +135,7 @@
TEST_AND_RETURN_FALSE_ERRNO(control_fd >= 0);
int loop_number = ioctl(control_fd, LOOP_CTL_GET_FREE);
IGNORE_EINTR(close(control_fd));
- *out_lo_dev_name = StringPrintf("/dev/loop%d", loop_number);
+ *out_lo_dev_name = kLoopDevicePrefix + std::to_string(loop_number);
// Double check that the loop exists and is free.
int loop_device_fd =