scripts: Add key to remote latest SDK file

In the new recipes-based SDK builder, we don't want to update the latest
SDK as soon as we build it, since the uprev/test steps come later. Thus,
we need to create a way to distinguish between the latest SDK for users
and the next SDK uprev target.

This CL just changes the format of the remote latest file. In a future
CL I'll add onto it so that `upload_prebuilts.py` takes in a CLI flag
specifying which of the two keys to update. The other key should retain
the existing value.

The unittest change here is pretty mild, but again, it'll be more
significant once the script has new logic.

BUG=b:270142110
TEST=./run_tests

Change-Id: If5854e39a11ca1f14364dc3bfa8f9b9a465f4399
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/4283093
Commit-Queue: Greg Edelston <gredelston@google.com>
Tested-by: Greg Edelston <gredelston@google.com>
Reviewed-by: Cindy Lin <xcl@google.com>
diff --git a/scripts/upload_prebuilts_unittest.py b/scripts/upload_prebuilts_unittest.py
index 02faa29..c1d98ce 100644
--- a/scripts/upload_prebuilts_unittest.py
+++ b/scripts/upload_prebuilts_unittest.py
@@ -694,6 +694,7 @@
             "UpdateBinhostConfFile",
             side_effect=Exception("should not get called"),
         )
+        self.write_file_mock = self.PatchObject(osutils, "WriteFile")
         self.upload_mock = self.PatchObject(
             prebuilt.PrebuiltUploader, "_Upload"
         )
@@ -729,7 +730,7 @@
         ver = "1234"
         vtar = "cros-sdk-%s.tar.xz" % ver
 
-        calls = [
+        upload_calls = [
             mock.call(
                 "%s.Manifest" % tar, "gs://chromiumos-sdk/%s.Manifest" % vtar
             ),
@@ -737,7 +738,7 @@
         ]
         for to in to_tarballs:
             to = to.split(":")
-            calls.append(
+            upload_calls.append(
                 mock.call(
                     to[1],
                     ("gs://chromiumos-sdk/" + to_upload_path)
@@ -746,14 +747,14 @@
             )
         for tc in tc_tarballs:
             tc = tc.split(":")
-            calls.append(
+            upload_calls.append(
                 mock.call(
                     tc[1],
                     ("gs://chromiumos-sdk/" + tc_upload_path)
                     % {"target": tc[0]},
                 )
             )
-        calls.append(
+        upload_calls.append(
             mock.call(mock.ANY, "gs://chromiumos-sdk/cros-sdk-latest.conf")
         )
 
@@ -766,7 +767,18 @@
             tc_tarballs,
             tc_upload_path,
         )
-        self.upload_mock.assert_has_calls(calls)
+        self.upload_mock.assert_has_calls(upload_calls)
+
+        expected_latest_file_contents = f"""\
+# The most recent SDK that is tested and ready for use.
+LATEST_SDK="{ver}"
+
+# The most recently built version. New uprev attempts should target this.
+# Warning: This version may not be tested yet.
+LATEST_SDK_UPREV_TARGET=\"None\""""
+        self.write_file_mock.assert_any_call(
+            mock.ANY, expected_latest_file_contents
+        )
 
     def testBoardOverlayTarballUpload(self):
         """Make sure processing of board-specific overlay tarballs works."""