OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 | 2 |
3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 """Unittests for cbuildbot. Needs to be run inside of chroot for mox.""" | 7 """Unittests for cbuildbot. Needs to be run inside of chroot for mox.""" |
8 | 8 |
9 import __builtin__ | 9 import __builtin__ |
10 import mox | 10 import mox |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 'chromeos-base/chromeos-login').AndReturn( | 69 'chromeos-base/chromeos-login').AndReturn( |
70 '/home/test/platform/login_manager') | 70 '/home/test/platform/login_manager') |
71 self.mox.ReplayAll() | 71 self.mox.ReplayAll() |
72 repo_dict = cbuildbot._CreateRepoDictionary(self._buildroot, | 72 repo_dict = cbuildbot._CreateRepoDictionary(self._buildroot, |
73 self._test_board) | 73 self._test_board) |
74 self.assertEqual(repo_dict['kernel'], ['chromeos-base/kernel']) | 74 self.assertEqual(repo_dict['kernel'], ['chromeos-base/kernel']) |
75 self.assertEqual(repo_dict['login_manager'], | 75 self.assertEqual(repo_dict['login_manager'], |
76 ['chromeos-base/chromeos-login']) | 76 ['chromeos-base/chromeos-login']) |
77 self.mox.VerifyAll() | 77 self.mox.VerifyAll() |
78 | 78 |
| 79 # TODO(sosa): Re-add once we use cros_mark vs. cros_mark_all. |
| 80 #def testUprevPackages(self): |
| 81 # """Test if we get actual revisions in revisions.pfq.""" |
| 82 # self.mox.StubOutWithMock(cbuildbot, '_CreateRepoDictionary') |
| 83 # self.mox.StubOutWithMock(cbuildbot, '_ParseRevisionString') |
| 84 # self.mox.StubOutWithMock(cbuildbot, '_UprevFromRevisionList') |
| 85 # self.mox.StubOutWithMock(__builtin__, 'open') |
| 86 |
| 87 # # Mock out file interaction. |
| 88 # m_file = self.mox.CreateMock(file) |
| 89 # __builtin__.open(self._revision_file).AndReturn(m_file) |
| 90 # m_file.read().AndReturn(self._test_string) |
| 91 # m_file.close() |
| 92 |
| 93 # cbuildbot._CreateRepoDictionary(self._buildroot, |
| 94 # self._test_board).AndReturn(self._test_dict
) |
| 95 # cbuildbot._ParseRevisionString(self._test_string, |
| 96 # self._test_dict).AndReturn( |
| 97 # self._test_parsed_string_array) |
| 98 # cbuildbot._UprevFromRevisionList(self._buildroot, |
| 99 # self._test_parsed_string_array) |
| 100 # self.mox.ReplayAll() |
| 101 # cbuildbot._UprevPackages(self._buildroot, self._revision_file, |
| 102 # self._test_board) |
| 103 # self.mox.VerifyAll() |
| 104 |
| 105 # TODO(sosa): Remove once we un-comment above. |
79 def testUprevPackages(self): | 106 def testUprevPackages(self): |
80 self.mox.StubOutWithMock(cbuildbot, '_CreateRepoDictionary') | 107 """Test if we get actual revisions in revisions.pfq.""" |
81 self.mox.StubOutWithMock(cbuildbot, '_ParseRevisionString') | |
82 self.mox.StubOutWithMock(cbuildbot, '_UprevFromRevisionList') | |
83 self.mox.StubOutWithMock(__builtin__, 'open') | 108 self.mox.StubOutWithMock(__builtin__, 'open') |
84 | 109 |
85 # Mock out file interaction. | 110 # Mock out file interaction. |
86 m_file = self.mox.CreateMock(file) | 111 m_file = self.mox.CreateMock(file) |
87 __builtin__.open(self._revision_file).AndReturn(m_file) | 112 __builtin__.open(self._revision_file).AndReturn(m_file) |
88 m_file.read().AndReturn(self._test_string) | 113 m_file.read().AndReturn(self._test_string) |
89 m_file.close() | 114 m_file.close() |
90 | 115 |
91 cbuildbot._CreateRepoDictionary(self._buildroot, | 116 cbuildbot.RunCommand(['./cros_mark_all_as_stable', |
92 self._test_board).AndReturn(self._test_dict) | 117 '--tracking_branch="cros/master"'], |
93 cbuildbot._ParseRevisionString(self._test_string, | 118 cwd='%s/src/scripts' % self._buildroot, |
94 self._test_dict).AndReturn( | 119 enter_chroot=True) |
95 self._test_parsed_string_array) | 120 |
96 cbuildbot._UprevFromRevisionList(self._buildroot, | |
97 self._test_parsed_string_array) | |
98 self.mox.ReplayAll() | 121 self.mox.ReplayAll() |
99 cbuildbot._UprevPackages(self._buildroot, self._revision_file, | 122 cbuildbot._UprevPackages(self._buildroot, self._revision_file, |
100 self._test_board) | 123 self._test_board) |
| 124 self.mox.VerifyAll() |
| 125 |
| 126 def testUprevAllPackages(self): |
| 127 """Test if we get None in revisions.pfq indicating Full Builds.""" |
| 128 self.mox.StubOutWithMock(__builtin__, 'open') |
| 129 |
| 130 # Mock out file interaction. |
| 131 m_file = self.mox.CreateMock(file) |
| 132 __builtin__.open(self._revision_file).AndReturn(m_file) |
| 133 m_file.read().AndReturn('None') |
| 134 m_file.close() |
| 135 |
| 136 cbuildbot.RunCommand(['./cros_mark_all_as_stable', |
| 137 '--tracking_branch="cros/master"'], |
| 138 cwd='%s/src/scripts' % self._buildroot, |
| 139 enter_chroot=True) |
| 140 |
| 141 self.mox.ReplayAll() |
| 142 cbuildbot._UprevPackages(self._buildroot, self._revision_file, |
| 143 self._test_board) |
101 self.mox.VerifyAll() | 144 self.mox.VerifyAll() |
102 | 145 |
103 | 146 |
104 if __name__ == '__main__': | 147 if __name__ == '__main__': |
105 unittest.main() | 148 unittest.main() |
OLD | NEW |