]>
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.
25 class Tests(TestTools
.BaseToolsTest
):
28 TestTools
.BaseToolsTest
.setUp(self
)
29 self
.toolName
= 'TianoCompress'
32 result
= self
.RunTool('--help', logFile
='help')
33 #self.DisplayFile('help')
34 self
.assertTrue(result
== 0)
36 def compressionTestCycle(self
, data
):
37 path
= self
.GetTmpFilePath('input')
38 self
.WriteTmpFile('input', data
)
39 result
= self
.RunTool(
41 '-o', self
.GetTmpFilePath('output1'),
42 self
.GetTmpFilePath('input')
44 self
.assertTrue(result
== 0)
45 result
= self
.RunTool(
47 '-o', self
.GetTmpFilePath('output2'),
48 self
.GetTmpFilePath('output1')
50 self
.assertTrue(result
== 0)
51 start
= self
.ReadTmpFile('input')
52 finish
= self
.ReadTmpFile('output2')
53 startEqualsFinish
= start
== finish
54 if not startEqualsFinish
:
56 print 'Original data did not match decompress(compress(data))'
57 self
.DisplayBinaryData('original data', start
)
58 self
.DisplayBinaryData('after compression', self
.ReadTmpFile('output1'))
59 self
.DisplayBinaryData('after decomression', finish
)
60 self
.assertTrue(startEqualsFinish
)
62 def testRandomDataCycles(self
):
64 data
= self
.GetRandomString(1024, 2048)
65 self
.compressionTestCycle(data
)
68 TheTestSuite
= TestTools
.MakeTheTestSuite(locals())
70 if __name__
== '__main__':
71 allTests
= TheTestSuite()
72 unittest
.TextTestRunner().run(allTests
)