cros_boot_mode: make cros_debug bootloader argument prempt others

cros_debug was meant to be a replacement for cros_* to force
developer mode behavior - such as on legacy firmware.  However,
the easiest way to do so without modifying a file is to add the
argument to the bootloader during boot.  With syslinux, it is
appended.  That means that a cros_legacy commandline will have
cros_debug appended.  Since order matters, moving cros_debug
up the chain allows it to preempt any other values.

BUG=chromium-os:824
TEST=unittests

Review URL: http://codereview.chromium.org/3601014

Change-Id: I4cb51216cb9ae9ac9172728da2aba92e75a2411c
diff --git a/bootloader_type.cc b/bootloader_type.cc
index 41a5fd8..62ccf52 100644
--- a/bootloader_type.cc
+++ b/bootloader_type.cc
@@ -15,10 +15,10 @@
 namespace cros_boot_mode {
 
 const char *BootloaderType::kBootloaderTypeText[] = {
+ "debug",  // cros_debug (cros_fw with developer override)
  "chromeos",  // cros_fw (any platform)
  "efi",  // cros_efi
  "legacy",  // cros_legacy
- "debug",  // cros_debug (cros_fw with developer override)
 };
 const size_t BootloaderType::kBootloaderTypeCount =
   sizeof(kBootloaderTypeText) / sizeof(*kBootloaderTypeText);
@@ -26,10 +26,10 @@
 // or '\0' word boundaries.  The ordering of this array must correspond to
 // the array above and the defined enum.
 const char *BootloaderType::kSupportedBootloaders[] = {
+  "cros_debug",
   "cros_secure",
   "cros_efi",
   "cros_legacy",
-  "cros_debug",
 };
 
 const int BootloaderType::kMaxKernelCmdlineSize = 4096;  // one page.
diff --git a/bootloader_type.h b/bootloader_type.h
index 0a3fd8d..d7d2682 100644
--- a/bootloader_type.h
+++ b/bootloader_type.h
@@ -24,10 +24,10 @@
  public:
   static const char *kBootloaderTypePath;
   enum {
-    kChromeOS = 0,
+    kDebug = 0,
+    kChromeOS,
     kEFI,
     kLegacy,
-    kDebug,
   };
   // API-exposed names
   static const char *kBootloaderTypeText[];
diff --git a/bootloader_type_unittest.cc b/bootloader_type_unittest.cc
index 57ab2f5..39cfe29 100644
--- a/bootloader_type_unittest.cc
+++ b/bootloader_type_unittest.cc
@@ -99,16 +99,17 @@
   ExpectType(cros_boot_mode::BootloaderType::kUnsupported);
 }
 
-TEST_F(BootloaderTypeTest, FirstMatchIsUsed) {
+TEST_F(BootloaderTypeTest, FirstMatchInEnumOrderIsUsed) {
   std::string contents = StringPrintf(" %s %s ",
     cros_boot_mode::BootloaderType::kSupportedBootloaders[
       cros_boot_mode::BootloaderType::kChromeOS],
     cros_boot_mode::BootloaderType::kSupportedBootloaders[
-      cros_boot_mode::BootloaderType::kEFI]);
+      cros_boot_mode::BootloaderType::kDebug]);
 
   EXPECT_EQ(file_util::WriteFile(FilePath(type_file_path_),
                                  contents.c_str(), contents.length()),
             contents.length());
   type_.Initialize();
-  ExpectType(cros_boot_mode::BootloaderType::kChromeOS);
+  ExpectType(cros_boot_mode::BootloaderType::kDebug);
 }
+