]>
Commit | Line | Data |
---|---|---|
0d24de9d SG |
1 | # |
2 | # Copyright (c) 2011 The Chromium OS Authors. | |
3 | # | |
1a459660 | 4 | # SPDX-License-Identifier: GPL-2.0+ |
0d24de9d SG |
5 | # |
6 | ||
7 | import os | |
8 | import tempfile | |
9 | import unittest | |
10 | ||
11 | import checkpatch | |
12 | import gitutil | |
13 | import patchstream | |
14 | import series | |
15 | ||
16 | ||
17 | class TestPatch(unittest.TestCase): | |
18 | """Test this program | |
19 | ||
20 | TODO: Write tests for the rest of the functionality | |
21 | """ | |
22 | ||
23 | def testBasic(self): | |
24 | """Test basic filter operation""" | |
25 | data=''' | |
26 | ||
27 | From 656c9a8c31fa65859d924cd21da920d6ba537fad Mon Sep 17 00:00:00 2001 | |
28 | From: Simon Glass <sjg@chromium.org> | |
29 | Date: Thu, 28 Apr 2011 09:58:51 -0700 | |
30 | Subject: [PATCH (resend) 3/7] Tegra2: Add more clock support | |
31 | ||
32 | This adds functions to enable/disable clocks and reset to on-chip peripherals. | |
33 | ||
34 | BUG=chromium-os:13875 | |
35 | TEST=build U-Boot for Seaboard, boot | |
36 | ||
37 | Change-Id: I80fe1d0c0b7dd10aa58ce5bb1d9290b6664d5413 | |
38 | ||
39 | Review URL: http://codereview.chromium.org/6900006 | |
40 | ||
41 | Signed-off-by: Simon Glass <sjg@chromium.org> | |
42 | --- | |
43 | arch/arm/cpu/armv7/tegra2/Makefile | 2 +- | |
44 | arch/arm/cpu/armv7/tegra2/ap20.c | 57 ++---- | |
45 | arch/arm/cpu/armv7/tegra2/clock.c | 163 +++++++++++++++++ | |
46 | ''' | |
47 | expected=''' | |
48 | ||
49 | From 656c9a8c31fa65859d924cd21da920d6ba537fad Mon Sep 17 00:00:00 2001 | |
50 | From: Simon Glass <sjg@chromium.org> | |
51 | Date: Thu, 28 Apr 2011 09:58:51 -0700 | |
52 | Subject: [PATCH (resend) 3/7] Tegra2: Add more clock support | |
53 | ||
54 | This adds functions to enable/disable clocks and reset to on-chip peripherals. | |
55 | ||
56 | Signed-off-by: Simon Glass <sjg@chromium.org> | |
57 | --- | |
e752edcb | 58 | |
0d24de9d SG |
59 | arch/arm/cpu/armv7/tegra2/Makefile | 2 +- |
60 | arch/arm/cpu/armv7/tegra2/ap20.c | 57 ++---- | |
61 | arch/arm/cpu/armv7/tegra2/clock.c | 163 +++++++++++++++++ | |
62 | ''' | |
63 | out = '' | |
64 | inhandle, inname = tempfile.mkstemp() | |
65 | infd = os.fdopen(inhandle, 'w') | |
66 | infd.write(data) | |
67 | infd.close() | |
68 | ||
69 | exphandle, expname = tempfile.mkstemp() | |
70 | expfd = os.fdopen(exphandle, 'w') | |
71 | expfd.write(expected) | |
72 | expfd.close() | |
73 | ||
74 | patchstream.FixPatch(None, inname, series.Series(), None) | |
75 | rc = os.system('diff -u %s %s' % (inname, expname)) | |
76 | self.assertEqual(rc, 0) | |
77 | ||
78 | os.remove(inname) | |
79 | os.remove(expname) | |
80 | ||
81 | def GetData(self, data_type): | |
82 | data=''' | |
83 | From 4924887af52713cabea78420eff03badea8f0035 Mon Sep 17 00:00:00 2001 | |
84 | From: Simon Glass <sjg@chromium.org> | |
85 | Date: Thu, 7 Apr 2011 10:14:41 -0700 | |
86 | Subject: [PATCH 1/4] Add microsecond boot time measurement | |
87 | ||
88 | This defines the basics of a new boot time measurement feature. This allows | |
89 | logging of very accurate time measurements as the boot proceeds, by using | |
90 | an available microsecond counter. | |
91 | ||
92 | %s | |
93 | --- | |
94 | README | 11 ++++++++ | |
95 | common/bootstage.c | 50 ++++++++++++++++++++++++++++++++++++ | |
96 | include/bootstage.h | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++ | |
97 | include/common.h | 8 ++++++ | |
98 | 5 files changed, 141 insertions(+), 0 deletions(-) | |
99 | create mode 100644 common/bootstage.c | |
100 | create mode 100644 include/bootstage.h | |
101 | ||
102 | diff --git a/README b/README | |
103 | index 6f3748d..f9e4e65 100644 | |
104 | --- a/README | |
105 | +++ b/README | |
106 | @@ -2026,6 +2026,17 @@ The following options need to be configured: | |
05d5282b DA |
107 | example, some LED's) on your board. At the moment, |
108 | the following checkpoints are implemented: | |
0d24de9d SG |
109 | |
110 | +- Time boot progress | |
111 | + CONFIG_BOOTSTAGE | |
112 | + | |
113 | + Define this option to enable microsecond boot stage timing | |
114 | + on supported platforms. For this to work your platform | |
115 | + needs to define a function timer_get_us() which returns the | |
116 | + number of microseconds since reset. This would normally | |
117 | + be done in your SOC or board timer.c file. | |
118 | + | |
119 | + You can add calls to bootstage_mark() to set time markers. | |
120 | + | |
121 | - Standalone program support: | |
05d5282b | 122 | CONFIG_STANDALONE_LOAD_ADDR |
0d24de9d SG |
123 | |
124 | diff --git a/common/bootstage.c b/common/bootstage.c | |
125 | new file mode 100644 | |
126 | index 0000000..2234c87 | |
127 | --- /dev/null | |
128 | +++ b/common/bootstage.c | |
1a459660 | 129 | @@ -0,0 +1,39 @@ |
0d24de9d SG |
130 | +/* |
131 | + * Copyright (c) 2011, Google Inc. All rights reserved. | |
132 | + * | |
1a459660 | 133 | + * SPDX-License-Identifier: GPL-2.0+ |
0d24de9d SG |
134 | + */ |
135 | + | |
136 | + | |
137 | +/* | |
138 | + * This module records the progress of boot and arbitrary commands, and | |
139 | + * permits accurate timestamping of each. The records can optionally be | |
140 | + * passed to kernel in the ATAGs | |
141 | + */ | |
142 | + | |
143 | +#include <common.h> | |
144 | + | |
145 | + | |
146 | +struct bootstage_record { | |
147 | + uint32_t time_us; | |
148 | + const char *name; | |
149 | +}; | |
150 | + | |
151 | +static struct bootstage_record record[BOOTSTAGE_COUNT]; | |
152 | + | |
153 | +uint32_t bootstage_mark(enum bootstage_id id, const char *name) | |
154 | +{ | |
155 | + struct bootstage_record *rec = &record[id]; | |
156 | + | |
157 | + /* Only record the first event for each */ | |
158 | +%sif (!rec->name) { | |
159 | + rec->time_us = (uint32_t)timer_get_us(); | |
160 | + rec->name = name; | |
161 | + } | |
d29fe6e2 SG |
162 | + if (!rec->name && |
163 | + %ssomething_else) { | |
164 | + rec->time_us = (uint32_t)timer_get_us(); | |
165 | + rec->name = name; | |
166 | + } | |
0d24de9d SG |
167 | +%sreturn rec->time_us; |
168 | +} | |
169 | -- | |
170 | 1.7.3.1 | |
171 | ''' | |
172 | signoff = 'Signed-off-by: Simon Glass <sjg@chromium.org>\n' | |
173 | tab = ' ' | |
d29fe6e2 | 174 | indent = ' ' |
0d24de9d SG |
175 | if data_type == 'good': |
176 | pass | |
177 | elif data_type == 'no-signoff': | |
178 | signoff = '' | |
179 | elif data_type == 'spaces': | |
180 | tab = ' ' | |
d29fe6e2 SG |
181 | elif data_type == 'indent': |
182 | indent = tab | |
0d24de9d SG |
183 | else: |
184 | print 'not implemented' | |
d29fe6e2 | 185 | return data % (signoff, tab, indent, tab) |
0d24de9d SG |
186 | |
187 | def SetupData(self, data_type): | |
188 | inhandle, inname = tempfile.mkstemp() | |
189 | infd = os.fdopen(inhandle, 'w') | |
190 | data = self.GetData(data_type) | |
191 | infd.write(data) | |
192 | infd.close() | |
193 | return inname | |
194 | ||
d29fe6e2 | 195 | def testGood(self): |
0d24de9d SG |
196 | """Test checkpatch operation""" |
197 | inf = self.SetupData('good') | |
d29fe6e2 SG |
198 | result = checkpatch.CheckPatch(inf) |
199 | self.assertEqual(result.ok, True) | |
200 | self.assertEqual(result.problems, []) | |
201 | self.assertEqual(result.errors, 0) | |
202 | self.assertEqual(result.warnings, 0) | |
203 | self.assertEqual(result.checks, 0) | |
e752edcb | 204 | self.assertEqual(result.lines, 56) |
0d24de9d SG |
205 | os.remove(inf) |
206 | ||
d29fe6e2 | 207 | def testNoSignoff(self): |
0d24de9d | 208 | inf = self.SetupData('no-signoff') |
d29fe6e2 SG |
209 | result = checkpatch.CheckPatch(inf) |
210 | self.assertEqual(result.ok, False) | |
211 | self.assertEqual(len(result.problems), 1) | |
212 | self.assertEqual(result.errors, 1) | |
213 | self.assertEqual(result.warnings, 0) | |
214 | self.assertEqual(result.checks, 0) | |
e752edcb | 215 | self.assertEqual(result.lines, 56) |
0d24de9d SG |
216 | os.remove(inf) |
217 | ||
d29fe6e2 | 218 | def testSpaces(self): |
0d24de9d | 219 | inf = self.SetupData('spaces') |
d29fe6e2 SG |
220 | result = checkpatch.CheckPatch(inf) |
221 | self.assertEqual(result.ok, False) | |
e752edcb | 222 | self.assertEqual(len(result.problems), 2) |
d29fe6e2 | 223 | self.assertEqual(result.errors, 0) |
e752edcb | 224 | self.assertEqual(result.warnings, 2) |
d29fe6e2 | 225 | self.assertEqual(result.checks, 0) |
e752edcb | 226 | self.assertEqual(result.lines, 56) |
d29fe6e2 SG |
227 | os.remove(inf) |
228 | ||
229 | def testIndent(self): | |
230 | inf = self.SetupData('indent') | |
231 | result = checkpatch.CheckPatch(inf) | |
232 | self.assertEqual(result.ok, False) | |
233 | self.assertEqual(len(result.problems), 1) | |
234 | self.assertEqual(result.errors, 0) | |
235 | self.assertEqual(result.warnings, 0) | |
236 | self.assertEqual(result.checks, 1) | |
e752edcb | 237 | self.assertEqual(result.lines, 56) |
0d24de9d SG |
238 | os.remove(inf) |
239 | ||
240 | ||
241 | if __name__ == "__main__": | |
242 | unittest.main() | |
243 | gitutil.RunTests() |