pci_validation.py 2.92 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Copyright 2021 Max Planck Institute for Software Systems, and
# National University of Singapore
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

import sys
import re
import json

def transform_internal(ts, component, msg):
    if not component.startswith('system.pc.simbricks_0'):
        return None
    elif component.endswith('.pio'):
        return None
    elif msg.startswith('read device register ') and 'res=' in msg:
        return None
    elif msg.startswith('our dma') or \
         msg.startswith('issuing dma') or \
         msg.startswith('processing ip packet') or \
         msg.startswith('transmitting non-ip packet') or \
         msg.startswith('transmitting ip packet'):
        return None

    return (ts + ' ' + msg)

def transform_external(ts, component, msg):
    if msg.startswith('igbe: requesting restart clock:') or \
       msg == 'igbe: scheduled' or \
       msg == 'igbe: rescheduling next cycle' or \
       msg == 'igbe: no next cycle scheduled':
        return None
    elif msg.startswith('[rxdesc]') or msg.startswith('[txdesc]'):
        msg = msg[9:]

        
    return (ts + ' ' + msg)

if len(sys.argv) != 3:
    print('Usage: pci_validation.py JSON-DIR VARIANT')
    print('       VARIANT can be internal or external')
    sys.exit(1)

outdir = sys.argv[1]
variant = sys.argv[2]

with open(outdir + '/' + 'pci_validation-' + variant + '-1.json', 'r') as f:
    data = json.load(f)

if variant == 'internal':
    line_pat = re.compile(r'(\d*):\s*([a-zA-Z0-9\._]*):\s*(.*)')
    it = iter(data['sims']['host.client']['stdout'])
    transform = transform_internal
else:
    line_pat = re.compile(r'(\d*):\s*([a-zA-Z0-9\._]*):\s*(.*)')
    it = iter(data['sims']['nic.client.']['stderr'])
    transform = transform_external

# we're doing the comparision for the client
for l in it:
    m = line_pat.match(l)
    if not m:
        continue

    l = transform(m.group(1), m.group(2), m.group(3).lower())
    if l:
        print(l)