New function to write a whole .data file

Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/scripts/mbedtls_dev/test_case.py b/scripts/mbedtls_dev/test_case.py
index 8ef1851..a6ed8fc 100644
--- a/scripts/mbedtls_dev/test_case.py
+++ b/scripts/mbedtls_dev/test_case.py
@@ -17,7 +17,8 @@
 # limitations under the License.
 
 import binascii
-from typing import Any, List, Optional
+import sys
+from typing import Any, Iterable, List, Optional
 import typing_extensions #pylint: disable=import-error
 
 class Writable(typing_extensions.Protocol):
@@ -86,3 +87,21 @@
         if self.dependencies:
             out.write('depends_on:' + ':'.join(self.dependencies) + '\n')
         out.write(self.function + ':' + ':'.join(self.arguments) + '\n')
+
+
+
+def write_data_file(filename: str,
+                    test_cases: Iterable[TestCase],
+                    caller: Optional[str] = None) -> None:
+    """Write the test cases to the specified file.
+
+    If the file already exists, it is overwritten.
+    """
+    if caller is None:
+        caller = sys.argv[0]
+    with open(filename, 'w') as out:
+        out.write('# Automatically generated by {}. Do not edit!\n'
+                  .format(caller))
+        for tc in test_cases:
+            tc.write(out)
+        out.write('\n# End of automatically generated file.\n')