Adding support for SHA256 for remote execution. Switch remote execution to use
the currently defined hash function for blobs. Some refactoring. Adding an option to set the hash function in the remote worker, defaulting to the current behavior (unfortunately it is a build option, have not found a clean way to specify it at runtime).

BUG=62622420
TESTED=remote worker
RELNOTES: none
PiperOrigin-RevId: 159473116
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
index b8afb21..16b7a393 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
@@ -40,6 +40,7 @@
 import com.google.devtools.build.lib.events.NullEventHandler;
 import com.google.devtools.build.lib.util.Pair;
 import com.google.devtools.build.lib.vfs.FileStatus;
+import com.google.devtools.build.lib.vfs.FileSystem.HashFunction;
 import com.google.devtools.build.lib.vfs.FileSystemUtils;
 import com.google.devtools.build.lib.vfs.Path;
 import com.google.devtools.build.lib.vfs.PathFragment;
@@ -82,7 +83,7 @@
     Artifact output = createDerivedArtifact("output");
     Path path = output.getPath();
     file(path, "contents");
-    assertValueMatches(path.stat(), expectDigest ? path.getMD5Digest() : null, evaluateFAN(output));
+    assertValueMatches(path.stat(), expectDigest ? path.getDigest() : null, evaluateFAN(output));
   }
 
   @Test
@@ -129,10 +130,10 @@
     setupRoot(
         new CustomInMemoryFs() {
           @Override
-          public byte[] getMD5Digest(Path path) throws IOException {
+          public byte[] getDigest(Path path, HashFunction hf) throws IOException {
             return path.getBaseName().equals("unreadable")
                 ? expectedDigest
-                : super.getMD5Digest(path);
+                : super.getDigest(path, hf);
           }
         });
 
@@ -186,7 +187,7 @@
     setupRoot(
         new CustomInMemoryFs() {
           @Override
-          public byte[] getMD5Digest(Path path) throws IOException {
+          public byte[] getDigest(Path path, HashFunction hf) throws IOException {
             throw exception;
           }
         });
@@ -231,7 +232,7 @@
     Path path = artifact.getPath();
     writeFile(path, "hello"); //Non-empty file.
     FileArtifactValue value = create(artifact);
-    assertThat(value.getDigest()).isEqualTo(path.getMD5Digest());
+    assertThat(value.getDigest()).isEqualTo(path.getDigest());
     try {
       value.getModifiedTime();
       fail("mtime for non-empty file should not be stored.");
@@ -259,7 +260,7 @@
     writeFile(path, "");
     path.setLastModifiedTime(1L);
     FileArtifactValue value = create(artifact);
-    assertThat(value.getDigest()).isEqualTo(path.getMD5Digest());
+    assertThat(value.getDigest()).isEqualTo(path.getDigest());
     assertThat(value.getSize()).isEqualTo(0L);
   }