summaryrefslogtreecommitdiffstats
path: root/bitbake/bin
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2023-12-06 22:44:22 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-12-06 22:46:29 +0000
commit3ee5c86da3773deb091e24b98ad592c5d19274fb (patch)
treed45c9f0d5545f9300990689305c9b49bb44756ca /bitbake/bin
parent637fdcc2b13dadc07db9c8b486893bc3a35d718e (diff)
downloadpoky-3ee5c86da3773deb091e24b98ad592c5d19274fb.tar.gz
bitbake: toaster-eventreplay: Remove ordering assumptions
Currently the script assumes the variarables are dumped at the start of the file which is hard to arrange safely in the bitbake code and no longer a true assumption. Rewrite the code so that it can cope with different ordering and event files containing multiple builds. (Bitbake rev: a833a403a8f7c05008108f3ec1710c211cfa9ec2) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/bin')
-rwxr-xr-xbitbake/bin/toaster-eventreplay20
1 files changed, 17 insertions, 3 deletions
diff --git a/bitbake/bin/toaster-eventreplay b/bitbake/bin/toaster-eventreplay
index 404b61f516..f137c71d5c 100755
--- a/bitbake/bin/toaster-eventreplay
+++ b/bitbake/bin/toaster-eventreplay
@@ -45,7 +45,13 @@ class EventPlayer:
45 if not line: 45 if not line:
46 return 46 return
47 try: 47 try:
48 event_str = json.loads(line)['vars'].encode('utf-8') 48 decodedline = json.loads(line)
49 if 'allvariables' in decodedline:
50 self.variables = decodedline['allvariables']
51 return
52 if not 'vars' in decodedline:
53 raise ValueError
54 event_str = decodedline['vars'].encode('utf-8')
49 event = pickle.loads(codecs.decode(event_str, 'base64')) 55 event = pickle.loads(codecs.decode(event_str, 'base64'))
50 event_name = "%s.%s" % (event.__module__, event.__class__.__name__) 56 event_name = "%s.%s" % (event.__module__, event.__class__.__name__)
51 if event_name not in self.eventmask: 57 if event_name not in self.eventmask:
@@ -99,8 +105,16 @@ class EventPlayer:
99def main(argv): 105def main(argv):
100 with open(argv[-1]) as eventfile: 106 with open(argv[-1]) as eventfile:
101 # load variables from the first line 107 # load variables from the first line
102 variables = json.loads(eventfile.readline().strip())['allvariables'] 108 variables = None
103 109 while line := eventfile.readline().strip():
110 try:
111 variables = json.loads(line)['allvariables']
112 break
113 except (KeyError, json.JSONDecodeError):
114 continue
115 if not variables:
116 sys.exit("Cannot find allvariables entry in event log file %s" % argv[-1])
117 eventfile.seek(0)
104 params = namedtuple('ConfigParams', ['observe_only'])(True) 118 params = namedtuple('ConfigParams', ['observe_only'])(True)
105 player = EventPlayer(eventfile, variables) 119 player = EventPlayer(eventfile, variables)
106 120