]>
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 # This program and the accompanying materials
7 # are licensed and made available under the terms and conditions of the BSD License
8 # which accompanies this distribution. The full text of the license may be found at
9 # http://opensource.org/licenses/bsd-license.php
11 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 from __future__
import print_function
26 class Tests(TestTools
.BaseToolsTest
):
29 TestTools
.BaseToolsTest
.setUp(self
)
30 self
.toolName
= 'TianoCompress'
33 result
= self
.RunTool('--help', logFile
='help')
34 #self.DisplayFile('help')
35 self
.assertTrue(result
== 0)
37 def compressionTestCycle(self
, data
):
38 path
= self
.GetTmpFilePath('input')
39 self
.WriteTmpFile('input', data
)
40 result
= self
.RunTool(
42 '-o', self
.GetTmpFilePath('output1'),
43 self
.GetTmpFilePath('input')
45 self
.assertTrue(result
== 0)
46 result
= self
.RunTool(
48 '-o', self
.GetTmpFilePath('output2'),
49 self
.GetTmpFilePath('output1')
51 self
.assertTrue(result
== 0)
52 start
= self
.ReadTmpFile('input')
53 finish
= self
.ReadTmpFile('output2')
54 startEqualsFinish
= start
== finish
55 if not startEqualsFinish
:
57 print('Original data did not match decompress(compress(data))')
58 self
.DisplayBinaryData('original data', start
)
59 self
.DisplayBinaryData('after compression', self
.ReadTmpFile('output1'))
60 self
.DisplayBinaryData('after decomression', finish
)
61 self
.assertTrue(startEqualsFinish
)
63 def testRandomDataCycles(self
):
65 data
= self
.GetRandomString(1024, 2048)
66 self
.compressionTestCycle(data
)
69 TheTestSuite
= TestTools
.MakeTheTestSuite(locals())
71 if __name__
== '__main__':
72 allTests
= TheTestSuite()
73 unittest
.TextTestRunner().run(allTests
)