From f215e02bf85f68d3a6106c2a1f4f7f063f819064 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 11 Apr 2024 10:17:27 +0200 Subject: Adding upstream version 7.0.14-dfsg. Signed-off-by: Daniel Baumann --- .../Firmware/IntelFsp2Pkg/Tools/Tests/test_yaml.py | 96 ++++++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 src/VBox/Devices/EFI/Firmware/IntelFsp2Pkg/Tools/Tests/test_yaml.py (limited to 'src/VBox/Devices/EFI/Firmware/IntelFsp2Pkg/Tools/Tests/test_yaml.py') diff --git a/src/VBox/Devices/EFI/Firmware/IntelFsp2Pkg/Tools/Tests/test_yaml.py b/src/VBox/Devices/EFI/Firmware/IntelFsp2Pkg/Tools/Tests/test_yaml.py new file mode 100644 index 00000000..a71073ba --- /dev/null +++ b/src/VBox/Devices/EFI/Firmware/IntelFsp2Pkg/Tools/Tests/test_yaml.py @@ -0,0 +1,96 @@ +# @file +# Split a file into two pieces at the request offset. +# +# Copyright (c) 2021, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +# Import Modules +import unittest +import tempfile +import os +import shutil +import struct as st +import filecmp + +import os, sys +currentdir = os.path.dirname(os.path.realpath(__file__)) +parentdir = os.path.dirname(currentdir) +sys.path.append(parentdir) +import FspDscBsf2Yaml + +YamlHeaderLineLength = 10 +HdrFileHeaderLineLength = 32 +BsfFileHeaderLineLength = 19 + +def GenFileWithoutHdr(inputfile, numLineToStrip): + yaml_file = open(inputfile, "r") + lines = yaml_file.readlines() + yaml_file.close() + del lines[:numLineToStrip] + + noHdrOutputFileName = "no-header-" + inputfile + stripped_file = open(noHdrOutputFileName, "w") + for line in lines: + stripped_file.write(line) + stripped_file.close() + return noHdrOutputFileName + +class TestFspScripts(unittest.TestCase): + def test_generateFspHeader_fromDsc(self): + # Generate HEADER + cmd = '{} {} HEADER {} {} {}'.format( + 'python', + '..\GenCfgOpt.py', + 'QemuFspPkg.dsc', + '.', + "") + os.system(cmd) + noHdrOutputFileName = GenFileWithoutHdr("FspUpd.h", HdrFileHeaderLineLength) + self.assertTrue(filecmp.cmp(noHdrOutputFileName, + 'ExpectedFspUpd.h')) + + def test_generateFspsHeader_fromDsc(self): + noHdrOutputFileName = GenFileWithoutHdr("FspsUpd.h", HdrFileHeaderLineLength) + self.assertTrue(filecmp.cmp(noHdrOutputFileName, + 'ExpectedFspsUpd.h')) + + def test_generateFsptHeader_fromDsc(self): + noHdrOutputFileName = GenFileWithoutHdr("FsptUpd.h", HdrFileHeaderLineLength) + self.assertTrue(filecmp.cmp(noHdrOutputFileName, + 'ExpectedFsptUpd.h')) + + def test_generateFspmHeader_fromDsc(self): + noHdrOutputFileName = GenFileWithoutHdr("FspmUpd.h", HdrFileHeaderLineLength) + self.assertTrue(filecmp.cmp(noHdrOutputFileName, + 'ExpectedFspmUpd.h')) + + def test_generateBsf_fromDsc(self): + # Generate BSF + cmd = '{} {} GENBSF {} {} {}'.format( + 'python', + '..\GenCfgOpt.py', + 'QemuFspPkg.dsc', + '.', + "Output.bsf") + os.system(cmd) + noHdrOutputFileName = GenFileWithoutHdr("Output.bsf", BsfFileHeaderLineLength) + self.assertTrue(filecmp.cmp(noHdrOutputFileName, + 'ExpectedOutput.bsf')) + + def test_generateYaml_fromDsc(self): + # Generate YAML + cmd = '{} {} {} {}'.format( + 'python', + '..\FspDscBsf2Yaml.py', + 'QemuFspPkg.dsc', + "Output.yaml") + os.system(cmd) + noHdrOutputFileName = GenFileWithoutHdr("Output.yaml", YamlHeaderLineLength) + self.assertTrue(filecmp.cmp(noHdrOutputFileName, + 'ExpectedOutput.yaml')) + +if __name__ == '__main__': + unittest.main() -- cgit v1.2.3