|
1 #============================================================================ |
|
2 #Name : test_deltazip.py |
|
3 #Part of : Helium |
|
4 |
|
5 #Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
6 #All rights reserved. |
|
7 #This component and the accompanying materials are made available |
|
8 #under the terms of the License "Eclipse Public License v1.0" |
|
9 #which accompanies this distribution, and is available |
|
10 #at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
11 # |
|
12 #Initial Contributors: |
|
13 #Nokia Corporation - initial contribution. |
|
14 # |
|
15 #Contributors: |
|
16 # |
|
17 #Description: |
|
18 #=============================================================================== |
|
19 |
|
20 """ Unit tests for the delta zip tool. |
|
21 |
|
22 """ |
|
23 |
|
24 import unittest |
|
25 import delta_zip |
|
26 import logging |
|
27 import os |
|
28 |
|
29 class DeltaZipTest( unittest.TestCase ): |
|
30 |
|
31 def setUp(self): |
|
32 self.cwd_backup = os.getcwd() |
|
33 self.helium_home = os.environ["HELIUM_HOME"] |
|
34 self.logger = logging.getLogger('test.deltazip') |
|
35 self.root = os.path.join(self.helium_home, r'tools\common\python\lib') |
|
36 self.output = os.path.join(os.environ['TEMP'], 'deltazip') |
|
37 self.output2 = os.path.join(os.environ['TEMP'], 'deltazip2') |
|
38 |
|
39 logging.basicConfig(level=logging.INFO) |
|
40 |
|
41 def test_MD5SignatureBuilder(self): |
|
42 |
|
43 output = os.path.join(self.output2, 'md5_list.txt') |
|
44 md5output = os.path.join(self.output2, 'delta.md5') |
|
45 |
|
46 if os.path.exists(output): |
|
47 os.remove(output) |
|
48 |
|
49 sig = delta_zip.MD5SignatureBuilderEBS(self.root, 1, self.output2, '', output) |
|
50 sig.write_build_file() |
|
51 |
|
52 assert os.path.exists(output) |
|
53 |
|
54 def test_DeltaZipBuilder(self): |
|
55 if not os.path.exists(self.output): |
|
56 os.mkdir(self.output) |
|
57 |
|
58 md5output = os.path.join(self.output, 'delta.md5') |
|
59 oldmd5output = os.path.join(self.output, 'olddelta.md5') |
|
60 |
|
61 thisfile = os.path.abspath(__file__) |
|
62 md5string = """ |
|
63 Host:fasym014 |
|
64 Username:ssteiner |
|
65 Date-Time:Fri Aug 17 08:47:40 2007 |
|
66 Version:0.02 |
|
67 Directory:z:\ |
|
68 FileList:z:\output/delta_zip\list_files.txt |
|
69 Exclusion(s): |
|
70 Inclusion(s): |
|
71 ---------------- |
|
72 %s TYPE=unknown format MD5=34dcda0d351c75e4942b55e1b2e2422f |
|
73 """ % thisfile |
|
74 |
|
75 |
|
76 tempoutput = open(md5output, 'w') |
|
77 tempoutput.write(md5string) |
|
78 tempoutput.close() |
|
79 |
|
80 md5string = """ |
|
81 Host:fasym014 |
|
82 Username:ssteiner |
|
83 Date-Time:Fri Aug 17 08:47:40 2007 |
|
84 Version:0.02 |
|
85 Directory:z:\ |
|
86 FileList:z:\output/delta_zip\list_files.txt |
|
87 Exclusion(s): |
|
88 Inclusion(s): |
|
89 ---------------- |
|
90 %s TYPE=unknown format MD5=34dcda0d351c75e4942b55e1b2e2422g |
|
91 """ % thisfile |
|
92 |
|
93 tempoutput = open(oldmd5output, 'w') |
|
94 tempoutput.write(md5string) |
|
95 tempoutput.close() |
|
96 |
|
97 deltazipfile = os.path.join(self.output, 'delta.zip') |
|
98 deltaantfile = os.path.join(self.output, 'delta.ant.xml') |
|
99 deletefile = os.path.join(self.output, 'delta_zip_specialInstructions.xml') |
|
100 |
|
101 |
|
102 delta = delta_zip.DeltaZipBuilder(self.root, self.output, oldmd5output, md5output) |
|
103 delta.create_delta_zip(deltazipfile, deletefile, 1, deltaantfile) |
|
104 |
|
105 def tearDown(self): |
|
106 """ Restore path """ |
|
107 os.chdir(self.cwd_backup) |