1 # -*- coding: utf-8 -*-
2 # SPDX-License-Identifier: GPL-2.0+
4 # Copyright (c) 2011 The Chromium OS Authors.
11 from patman import checkpatch
12 from patman import gitutil
13 from patman import patchstream
14 from patman import series
15 from patman import commit
18 class TestPatch(unittest.TestCase):
21 TODO: Write tests for the rest of the functionality
25 """Test basic filter operation"""
28 From 656c9a8c31fa65859d924cd21da920d6ba537fad Mon Sep 17 00:00:00 2001
29 From: Simon Glass <sjg@chromium.org>
30 Date: Thu, 28 Apr 2011 09:58:51 -0700
31 Subject: [PATCH (resend) 3/7] Tegra2: Add more clock support
33 This adds functions to enable/disable clocks and reset to on-chip peripherals.
35 cmd/pci.c:152:11: warning: format ‘%llx’ expects argument of type
36 ‘long long unsigned int’, but argument 3 has type
37 ‘u64 {aka long unsigned int}’ [-Wformat=]
40 TEST=build U-Boot for Seaboard, boot
42 Change-Id: I80fe1d0c0b7dd10aa58ce5bb1d9290b6664d5413
44 Review URL: http://codereview.chromium.org/6900006
46 Signed-off-by: Simon Glass <sjg@chromium.org>
48 arch/arm/cpu/armv7/tegra2/Makefile | 2 +-
49 arch/arm/cpu/armv7/tegra2/ap20.c | 57 ++----
50 arch/arm/cpu/armv7/tegra2/clock.c | 163 +++++++++++++++++
52 expected='''Message-Id: <19991231235959.0.I80fe1d0c0b7dd10aa58ce5bb1d9290b6664d5413@changeid>
55 From 656c9a8c31fa65859d924cd21da920d6ba537fad Mon Sep 17 00:00:00 2001
56 From: Simon Glass <sjg@chromium.org>
57 Date: Thu, 28 Apr 2011 09:58:51 -0700
58 Subject: [PATCH (resend) 3/7] Tegra2: Add more clock support
60 This adds functions to enable/disable clocks and reset to on-chip peripherals.
62 cmd/pci.c:152:11: warning: format ‘%llx’ expects argument of type
63 ‘long long unsigned int’, but argument 3 has type
64 ‘u64 {aka long unsigned int}’ [-Wformat=]
66 Signed-off-by: Simon Glass <sjg@chromium.org>
69 arch/arm/cpu/armv7/tegra2/Makefile | 2 +-
70 arch/arm/cpu/armv7/tegra2/ap20.c | 57 ++----
71 arch/arm/cpu/armv7/tegra2/clock.c | 163 +++++++++++++++++
74 inhandle, inname = tempfile.mkstemp()
75 infd = os.fdopen(inhandle, 'w', encoding='utf-8')
79 exphandle, expname = tempfile.mkstemp()
80 expfd = os.fdopen(exphandle, 'w', encoding='utf-8')
84 # Normally by the time we call FixPatch we've already collected
85 # metadata. Here, we haven't, but at least fake up something.
86 # Set the "count" to -1 which tells FixPatch to use a bogus/fixed
87 # time for generating the Message-Id.
88 com = commit.Commit('')
89 com.change_id = 'I80fe1d0c0b7dd10aa58ce5bb1d9290b6664d5413'
92 patchstream.FixPatch(None, inname, series.Series(), com)
94 rc = os.system('diff -u %s %s' % (inname, expname))
95 self.assertEqual(rc, 0)
100 def GetData(self, data_type):
101 data='''From 4924887af52713cabea78420eff03badea8f0035 Mon Sep 17 00:00:00 2001
102 From: Simon Glass <sjg@chromium.org>
103 Date: Thu, 7 Apr 2011 10:14:41 -0700
104 Subject: [PATCH 1/4] Add microsecond boot time measurement
106 This defines the basics of a new boot time measurement feature. This allows
107 logging of very accurate time measurements as the boot proceeds, by using
108 an available microsecond counter.
114 common/bootstage.c | 50 ++++++++++++++++++++++++++++++++++++
115 include/bootstage.h | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++
116 include/common.h | 8 ++++++
117 5 files changed, 141 insertions(+), 0 deletions(-)
118 create mode 100644 common/bootstage.c
119 create mode 100644 include/bootstage.h
121 diff --git a/README b/README
122 index 6f3748d..f9e4e65 100644
125 @@ -2026,6 +2026,17 @@ The following options need to be configured:
126 example, some LED's) on your board. At the moment,
127 the following checkpoints are implemented:
129 +- Time boot progress
132 + Define this option to enable microsecond boot stage timing
133 + on supported platforms. For this to work your platform
134 + needs to define a function timer_get_us() which returns the
135 + number of microseconds since reset. This would normally
136 + be done in your SOC or board timer.c file.
138 + You can add calls to bootstage_mark() to set time markers.
140 - Standalone program support:
141 CONFIG_STANDALONE_LOAD_ADDR
143 diff --git a/MAINTAINERS b/MAINTAINERS
144 index b167b028ec..beb7dc634f 100644
147 @@ -474,3 +474,8 @@ S: Maintained
148 T: git git://git.denx.de/u-boot.git
153 +M: Simon Glass <sjg@chromium.org>
154 +L: u-boot@lists.denx.de
155 +F: common/bootstage.c
156 diff --git a/common/bootstage.c b/common/bootstage.c
158 index 0000000..2234c87
160 +++ b/common/bootstage.c
164 + * Copyright (c) 2011, Google Inc. All rights reserved.
169 + * This module records the progress of boot and arbitrary commands, and
170 + * permits accurate timestamping of each. The records can optionally be
171 + * passed to kernel in the ATAGs
176 +struct bootstage_record {
181 +static struct bootstage_record record[BOOTSTAGE_COUNT];
183 +u32 bootstage_mark(enum bootstage_id id, const char *name)
185 + struct bootstage_record *rec = &record[id];
187 + /* Only record the first event for each */
189 + rec->time_us = (u32)timer_get_us();
193 + %ssomething_else) {
194 + rec->time_us = (u32)timer_get_us();
197 +%sreturn rec->time_us;
202 signoff = 'Signed-off-by: Simon Glass <sjg@chromium.org>\n'
203 license = '// SPDX-License-Identifier: GPL-2.0+'
206 if data_type == 'good':
208 elif data_type == 'no-signoff':
210 elif data_type == 'no-license':
212 elif data_type == 'spaces':
214 elif data_type == 'indent':
217 print('not implemented')
218 return data % (signoff, license, tab, indent, tab)
220 def SetupData(self, data_type):
221 inhandle, inname = tempfile.mkstemp()
222 infd = os.fdopen(inhandle, 'w')
223 data = self.GetData(data_type)
229 """Test checkpatch operation"""
230 inf = self.SetupData('good')
231 result = checkpatch.CheckPatch(inf)
232 self.assertEqual(result.ok, True)
233 self.assertEqual(result.problems, [])
234 self.assertEqual(result.errors, 0)
235 self.assertEqual(result.warnings, 0)
236 self.assertEqual(result.checks, 0)
237 self.assertEqual(result.lines, 62)
240 def testNoSignoff(self):
241 inf = self.SetupData('no-signoff')
242 result = checkpatch.CheckPatch(inf)
243 self.assertEqual(result.ok, False)
244 self.assertEqual(len(result.problems), 1)
245 self.assertEqual(result.errors, 1)
246 self.assertEqual(result.warnings, 0)
247 self.assertEqual(result.checks, 0)
248 self.assertEqual(result.lines, 62)
251 def testNoLicense(self):
252 inf = self.SetupData('no-license')
253 result = checkpatch.CheckPatch(inf)
254 self.assertEqual(result.ok, False)
255 self.assertEqual(len(result.problems), 1)
256 self.assertEqual(result.errors, 0)
257 self.assertEqual(result.warnings, 1)
258 self.assertEqual(result.checks, 0)
259 self.assertEqual(result.lines, 62)
262 def testSpaces(self):
263 inf = self.SetupData('spaces')
264 result = checkpatch.CheckPatch(inf)
265 self.assertEqual(result.ok, False)
266 self.assertEqual(len(result.problems), 3)
267 self.assertEqual(result.errors, 0)
268 self.assertEqual(result.warnings, 3)
269 self.assertEqual(result.checks, 0)
270 self.assertEqual(result.lines, 62)
273 def testIndent(self):
274 inf = self.SetupData('indent')
275 result = checkpatch.CheckPatch(inf)
276 self.assertEqual(result.ok, False)
277 self.assertEqual(len(result.problems), 1)
278 self.assertEqual(result.errors, 0)
279 self.assertEqual(result.warnings, 0)
280 self.assertEqual(result.checks, 1)
281 self.assertEqual(result.lines, 62)
285 if __name__ == "__main__":