Merge changes I89c9c96d,I9c7b68d5,I6b3f2b0c

* changes:
  Fix test action that tampered file at wrong offset
  Verify the last incomplete chunk on resize
  Verify read_chunk for writable file
diff --git a/tests/common.cc b/tests/common.cc
index 9602283..5d32351 100644
--- a/tests/common.cc
+++ b/tests/common.cc
@@ -14,14 +14,22 @@
  * limitations under the License.
  */
 
+#include <android/sysprop/HypervisorProperties.sysprop.h>
+
 #include "virt/VirtualizationTest.h"
 
+using android::sysprop::HypervisorProperties::hypervisor_protected_vm_supported;
+using android::sysprop::HypervisorProperties::hypervisor_vm_supported;
+
 namespace {
 
 bool isVmSupported() {
-    const std::array<const char *, 4> needed_files = {
-            "/dev/kvm",
-            "/dev/vhost-vsock",
+    bool has_capability = hypervisor_vm_supported().value_or(false) ||
+            hypervisor_protected_vm_supported().value_or(false);
+    if (!has_capability) {
+        return false;
+    }
+    const std::array<const char *, 2> needed_files = {
             "/apex/com.android.virt/bin/crosvm",
             "/apex/com.android.virt/bin/virtualizationservice",
     };