diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-11 08:17:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-11 08:17:27 +0000 |
commit | f215e02bf85f68d3a6106c2a1f4f7f063f819064 (patch) | |
tree | 6bb5b92c046312c4e95ac2620b10ddf482d3fa8b /src/VBox/Devices/EFI/Firmware/IntelFsp2Pkg/Tools/Tests/test_yaml.py | |
parent | Initial commit. (diff) | |
download | virtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.tar.xz virtualbox-f215e02bf85f68d3a6106c2a1f4f7f063f819064.zip |
Adding upstream version 7.0.14-dfsg.upstream/7.0.14-dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/VBox/Devices/EFI/Firmware/IntelFsp2Pkg/Tools/Tests/test_yaml.py')
-rw-r--r-- | src/VBox/Devices/EFI/Firmware/IntelFsp2Pkg/Tools/Tests/test_yaml.py | 96 |
1 files changed, 96 insertions, 0 deletions
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.<BR> +# +# 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() |