Modify 1.2 VTS tests to consume test struct directly.

Comparing with v1.1, the converter for 1.2 HIDL model has additional support
for extraParam, dynamic output shape, and zero-sized output.

Modify CompilationCachingTests to use the new test struct.

Bug: 123092187
Bug: 138718240
Test: All VTS
Change-Id: I54ac97f62898e47a338b51cc6d895a0309ab001f
Merged-In: I54ac97f62898e47a338b51cc6d895a0309ab001f
(cherry picked from commit 491b0a89133b8519a68b5999cf3b227c750f6deb)
diff --git a/neuralnetworks/1.0/vts/functional/Utils.cpp b/neuralnetworks/1.0/vts/functional/Utils.cpp
index 94ba183..5aa2751 100644
--- a/neuralnetworks/1.0/vts/functional/Utils.cpp
+++ b/neuralnetworks/1.0/vts/functional/Utils.cpp
@@ -25,6 +25,7 @@
 #include <android/hidl/memory/1.0/IMemory.h>
 #include <hidlmemory/mapping.h>
 
+#include <algorithm>
 #include <vector>
 
 namespace android {
@@ -63,11 +64,19 @@
     size_t outputSize = 0;
     for (uint32_t i = 0; i < testModel.outputIndexes.size(); i++) {
         const auto& op = testModel.operands[testModel.outputIndexes[i]];
-        size_t dataSize = op.data.size();
+
+        // In the case of zero-sized output, we should at least provide a one-byte buffer.
+        // This is because zero-sized tensors are only supported internally to the driver, or
+        // reported in output shapes. It is illegal for the client to pre-specify a zero-sized
+        // tensor as model output. Otherwise, we will have two semantic conflicts:
+        // - "Zero dimension" conflicts with "unspecified dimension".
+        // - "Omitted operand buffer" conflicts with "zero-sized operand buffer".
+        size_t bufferSize = std::max<size_t>(op.data.size(), 1);
+
         DataLocation loc = {.poolIndex = kOutputPoolIndex,
                             .offset = static_cast<uint32_t>(outputSize),
-                            .length = static_cast<uint32_t>(dataSize)};
-        outputSize += op.data.alignedSize();
+                            .length = static_cast<uint32_t>(bufferSize)};
+        outputSize += op.data.size() == 0 ? TestBuffer::kAlignment : op.data.alignedSize();
         outputs[i] = {.hasNoValue = false, .location = loc, .dimensions = {}};
     }