]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Tests/TianoCompress.py
Fix the typo for the structure definition of EFI_ADAPTER_INFO_NETWORK_BOOT in Adapter...
[mirror_edk2.git] / BaseTools / Tests / TianoCompress.py
CommitLineData
30fdf114
LG
1## @file
2# Unit tests for TianoCompress utility
3#
40d841f6 4# Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>
30fdf114 5#
40d841f6 6# This program and the accompanying materials
30fdf114
LG
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
10#
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.
13#
14
15##
16# Import Modules
17#
18import os
19import random
20import sys
21import unittest
22
23import TestTools
24
25class Tests(TestTools.BaseToolsTest):
26
27 def setUp(self):
28 TestTools.BaseToolsTest.setUp(self)
29 self.toolName = 'TianoCompress'
30
31 def testHelp(self):
32 result = self.RunTool('--help', logFile='help')
33 #self.DisplayFile('help')
34 self.assertTrue(result == 0)
35
36 def compressionTestCycle(self, data):
37 path = self.GetTmpFilePath('input')
38 self.WriteTmpFile('input', data)
39 result = self.RunTool(
40 '-e',
41 '-o', self.GetTmpFilePath('output1'),
42 self.GetTmpFilePath('input')
43 )
44 self.assertTrue(result == 0)
45 result = self.RunTool(
46 '-d',
47 '-o', self.GetTmpFilePath('output2'),
48 self.GetTmpFilePath('output1')
49 )
50 self.assertTrue(result == 0)
51 start = self.ReadTmpFile('input')
52 finish = self.ReadTmpFile('output2')
53 startEqualsFinish = start == finish
54 if not startEqualsFinish:
55 print
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)
61
62 def testRandomDataCycles(self):
63 for i in range(8):
64 data = self.GetRandomString(1024, 2048)
65 self.compressionTestCycle(data)
66 self.CleanUpTmpDir()
67
68TheTestSuite = TestTools.MakeTheTestSuite(locals())
69
70if __name__ == '__main__':
71 allTests = TheTestSuite()
72 unittest.TextTestRunner().run(allTests)
73
74