]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Tests/TianoCompress.py
2 # Unit tests for TianoCompress utility
4 # Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>
6 # SPDX-License-Identifier: BSD-2-Clause-Patent
12 from __future__
import print_function
20 class Tests(TestTools
.BaseToolsTest
):
23 TestTools
.BaseToolsTest
.setUp(self
)
24 self
.toolName
= 'TianoCompress'
27 result
= self
.RunTool('--help', logFile
='help')
28 #self.DisplayFile('help')
29 self
.assertTrue(result
== 0)
31 def compressionTestCycle(self
, data
):
32 path
= self
.GetTmpFilePath('input')
33 self
.WriteTmpFile('input', data
)
34 result
= self
.RunTool(
36 '-o', self
.GetTmpFilePath('output1'),
37 self
.GetTmpFilePath('input')
39 self
.assertTrue(result
== 0)
40 result
= self
.RunTool(
42 '-o', self
.GetTmpFilePath('output2'),
43 self
.GetTmpFilePath('output1')
45 self
.assertTrue(result
== 0)
46 start
= self
.ReadTmpFile('input')
47 finish
= self
.ReadTmpFile('output2')
48 startEqualsFinish
= start
== finish
49 if not startEqualsFinish
:
51 print('Original data did not match decompress(compress(data))')
52 self
.DisplayBinaryData('original data', start
)
53 self
.DisplayBinaryData('after compression', self
.ReadTmpFile('output1'))
54 self
.DisplayBinaryData('after decompression', finish
)
55 self
.assertTrue(startEqualsFinish
)
57 def testRandomDataCycles(self
):
59 data
= self
.GetRandomString(1024, 2048)
60 self
.compressionTestCycle(data
)
63 TheTestSuite
= TestTools
.MakeTheTestSuite(locals())
65 if __name__
== '__main__':
66 allTests
= TheTestSuite()
67 unittest
.TextTestRunner().run(allTests
)