Hi KOBAYASHI-san,

Let me share the attached script I'm using to generate markdown text.
The usage of this script is like:

$ ryu run ryu/tests/switch/tester.py --test-switch-dir ryu/tests/switch --log-file result.txt
$ cat result.txt | python markdown.py > result.md

This script contains so many test case specific codes.
So if you would like to format the result of your original test cases,
you need to customize the script too.

Thanks,
--
Hisaharu Ishii


On 2015年04月02日 19:11, Satoshi KOBAYASHI wrote:
Hi Ishii-san,

I see. Although test tool is really really great even now, If we can we get
the readable results, I think it will be more convenient.

Thanks,
Satoshi

2015-04-02 18:09 GMT+09:00 Hisaharu Ishii <[email protected]>:

Hi KOBAYASHI-san,

I'm running a script to generate a markdown text from a test result log
and push it to github.
It contains many hard-coded settings, so not be included in the Ryu
repository.

Thanks,
--
Hisaharu Ishii


On 2015年04月02日 17:24, Satoshi KOBAYASHI wrote:
Hi folks,

I have been trying switch test tool and got a result of the plain text
file. But it seems that a result of the page of Ryu Certification is
formatted into HTML. I would like to translate, but how is that
performed?

Thanks,
Satoshi




------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your hub
for all
things parallel software development, from weekly thought leadership
blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/



_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel




------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website,
sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for
all
things parallel software development, from weekly thought leadership blogs
to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel




------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the
conversation now. http://goparallel.sourceforge.net/



_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel


#!/usr/bin/env python

import os
import sys
import re
import md5
import copy

write = sys.stdout.write

list_required = ['action: 00_OUTPUT','match: 00_IN_PORT','match: 03_ETH_DST','match: 03_ETH_DST (Mask)','match: 04_ETH_SRC','match: 04_ETH_SRC (Mask)','match: 05_ETH_TYPE','match: 10_IP_PROTO (IPv4)','match: 11_IPV4_SRC','match: 11_IPV4_SRC (Mask)','match: 12_IPV4_DST','match: 12_IPV4_DST (Mask)','match: 13_TCP_SRC (IPv4)','match: 14_TCP_DST (IPv4)','match: 15_UDP_SRC (IPv4)','match: 16_UDP_DST (IPv4)','match: 10_IP_PROTO (IPv6)','match: 13_TCP_SRC (IPv6)','match: 14_TCP_DST (IPv6)','match: 15_UDP_SRC (IPv6)','match: 16_UDP_DST (IPv6)','match: 26_IPV6_SRC','match: 26_IPV6_SRC (Mask)','match: 27_IPV6_DST','match: 27_IPV6_DST (Mask)', 'group: 00_ALL']

def disp_table(a, k, num, len):
    for v in k:
        if a.has_key(v) == False:
            continue;
        url = "https://github.com/osrg/ryu/tree/master/ryu/tests/switch/of13/"; + v.replace(': ', '/').replace('(', '').replace(')', '').replace(' ', '_').replace('set_field', '25_SET_FIELD') + '.json'
        req = 'x' if v in list_required else '-'
        print "|[%s](%s)|%s" % (v[len:], url, req),
        i = 0
        for w in a.get(v):
            if i%num == 0:
                 print '|',
            else:
                 print '/',
            print "[%s](#%s)" % (w[1], md5.new(v).hexdigest()),
            i = i+1
        print '|'

def disp_raw(b, k):
    for v in k:
        if b.has_key(v) == False:
            continue;
	m = md5.new(v).hexdigest()
        print '<a name="%s">%s</a>' % (m, v)
        print '<pre>\n%s\n</pre>' % ('\n'.join(b[v]))

def disp_result(a, k, title):
    r = {'OK': 0, 'ERROR': 0}
    for v in k:
        if a.has_key(v) == False:
            continue;
        for w in a.get(v):
            r.setdefault(w[1], 0)
            r[w[1]] = r[w[1]] + 1

    print "|[%s](#%s)|%d|%d|" % (title, title, r['OK'], r['ERROR'])

def disp_result2(a, k, title):
    r = {'OK': 0, 'ERROR': 0}
    for v in k:
        if a.has_key(v) == False:
            continue;
        for w in a.get(v):
            r.setdefault(w[1], 0)
            r[w[1]] = r[w[1]] + 1

    print "|&nbsp;&nbsp;&nbsp;&nbsp;(%s)|&nbsp;&nbsp;&nbsp;&nbsp;(%d)|&nbsp;&nbsp;&nbsp;&nbsp;(%d)|" % (title, r['OK'], r['ERROR'])

def move_optional(a, k):
    ret = copy.deepcopy(a)
    for v in k:
        if a.has_key(v) == False:
            continue;
        ret['match: 08_IP_DSCP (IPv4)'].extend(a[v][3:])
        ret[v] = a[v][0:3]

    return ret

if '__main__' == __name__:
    started = False
    a = {}
    b = {}
    title = ''
    ok = 0
    err = 0
    for line in sys.stdin:
        line = line.rstrip()

	if not started:
            if line[0:8] == 'action: ':
                started = True
            else:
                continue

        if line.find('OK') != -1:
            ok = ok + 1
        elif line.find('ERROR') != -1:
            err = err + 1

        if line[0:8] == '        ':
            detail = line[8:]
            a[title][-1].append(detail)
            b[title].append(line)
        elif line[0:8] == '    ethe'or line[0:5] == '    2':
            result = re.split('\s+', line[4:])
            a[title].append(result)
            b[title].append(line)
        elif line[0:4] == 'matc' or line[0:4] == 'acti'or line[0:4] == 'mete' or line[0:4] == 'grou':
            title = line
            a[title] = []
            b[title] = []
        elif line == '---  Test end  ---' or line == '--- Test terminated ---':
            break;
        else:
            b[title].append(line)

    a['action: 11_COPY_TTL_OUT'].append(['',''])
    a['action: 12_COPY_TTL_IN'].append(['',''])

    action_l2 = ['action: 00_OUTPUT','action: 17_PUSH_VLAN','action: 19_PUSH_MPLS','action: 26_PUSH_PBB','action: 17_PUSH_VLAN (multiple)','action: 18_POP_VLAN','action: 11_COPY_TTL_OUT','action: 12_COPY_TTL_IN','action: 15_SET_MPLS_TTL','action: 16_DEC_MPLS_TTL','action: 19_PUSH_MPLS (multiple)','action: 20_POP_MPLS','action: 26_PUSH_PBB (multiple)','action: 27_POP_PBB']
    action_l3 = ['action: 23_SET_NW_TTL (IPv4)','action: 24_DEC_NW_TTL (IPv4)','action: 23_SET_NW_TTL (IPv6)','action: 24_DEC_NW_TTL (IPv6)']
    set_field_l2 = ['action: set_field: 03_ETH_DST','action: set_field: 04_ETH_SRC','action: set_field: 05_ETH_TYPE','action: set_field: 38_TUNNEL_ID','action: set_field: 06_VLAN_VID','action: set_field: 07_VLAN_PCP','action: set_field: 34_MPLS_LABEL','action: set_field: 35_MPLS_TC','action: set_field: 36_MPLS_BOS','action: set_field: 37_PBB_ISID']
    set_field_l3 = ['action: set_field: 08_IP_DSCP (IPv4)','action: set_field: 09_IP_ECN (IPv4)','action: set_field: 10_IP_PROTO (IPv4)','action: set_field: 11_IPV4_SRC','action: set_field: 12_IPV4_DST','action: set_field: 13_TCP_SRC (IPv4)','action: set_field: 14_TCP_DST (IPv4)','action: set_field: 15_UDP_SRC (IPv4)','action: set_field: 16_UDP_DST (IPv4)','action: set_field: 17_SCTP_SRC (IPv4)','action: set_field: 18_SCTP_DST (IPv4)','action: set_field: 19_ICMPV4_TYPE','action: set_field: 20_ICMPV4_CODE','action: set_field: 08_IP_DSCP (IPv6)','action: set_field: 09_IP_ECN (IPv6)','action: set_field: 10_IP_PROTO (IPv6)','action: set_field: 13_TCP_SRC (IPv6)','action: set_field: 14_TCP_DST (IPv6)','action: set_field: 15_UDP_SRC (IPv6)','action: set_field: 16_UDP_DST (IPv6)','action: set_field: 17_SCTP_SRC (IPv6)','action: set_field: 18_SCTP_DST (IPv6)','action: set_field: 26_IPV6_SRC','action: set_field: 27_IPV6_DST','action: set_field: 28_IPV6_FLABEL','action: set_field: 29_ICMPV6_TYPE','action: set_field: 30_ICMPV6_CODE','action: set_field: 31_IPV6_ND_TARGET','action: set_field: 32_IPV6_ND_SLL','action: set_field: 33_IPV6_ND_TLL','action: set_field: 21_ARP_OP','action: set_field: 22_ARP_SPA','action: set_field: 23_ARP_TPA','action: set_field: 24_ARP_SHA','action: set_field: 25_ARP_THA']
    match_l2 = ['match: 00_IN_PORT','match: 02_METADATA','match: 02_METADATA (Mask)','match: 03_ETH_DST','match: 03_ETH_DST (Mask)','match: 04_ETH_SRC','match: 04_ETH_SRC (Mask)','match: 05_ETH_TYPE','match: 38_TUNNEL_ID','match: 38_TUNNEL_ID (Mask)','match: 06_VLAN_VID','match: 06_VLAN_VID (Mask)','match: 07_VLAN_PCP','match: 34_MPLS_LABEL','match: 35_MPLS_TC','match: 36_MPLS_BOS','match: 37_PBB_ISID','match: 37_PBB_ISID (Mask)']
    match_l3 = ['match: 08_IP_DSCP (IPv4)','match: 09_IP_ECN (IPv4)','match: 10_IP_PROTO (IPv4)','match: 11_IPV4_SRC','match: 11_IPV4_SRC (Mask)','match: 12_IPV4_DST','match: 12_IPV4_DST (Mask)','match: 13_TCP_SRC (IPv4)','match: 14_TCP_DST (IPv4)','match: 15_UDP_SRC (IPv4)','match: 16_UDP_DST (IPv4)','match: 17_SCTP_SRC (IPv4)','match: 18_SCTP_DST (IPv4)','match: 19_ICMPV4_TYPE','match: 20_ICMPV4_CODE','match: 08_IP_DSCP (IPv6)','match: 09_IP_ECN (IPv6)','match: 10_IP_PROTO (IPv6)','match: 13_TCP_SRC (IPv6)','match: 14_TCP_DST (IPv6)','match: 15_UDP_SRC (IPv6)','match: 16_UDP_DST (IPv6)','match: 17_SCTP_SRC (IPv6)','match: 18_SCTP_DST (IPv6)','match: 26_IPV6_SRC','match: 26_IPV6_SRC (Mask)','match: 27_IPV6_DST','match: 27_IPV6_DST (Mask)','match: 28_IPV6_FLABEL','match: 28_IPV6_FLABEL (Mask)','match: 29_ICMPV6_TYPE','match: 30_ICMPV6_CODE','match: 31_IPV6_ND_TARGET','match: 32_IPV6_ND_SLL','match: 33_IPV6_ND_TLL','match: 39_IPV6_EXTHDR','match: 39_IPV6_EXTHDR (Mask)','match: 21_ARP_OP','match: 22_ARP_SPA','match: 22_ARP_SPA (Mask)','match: 23_ARP_TPA','match: 23_ARP_TPA (Mask)','match: 24_ARP_SHA','match: 24_ARP_SHA (Mask)','match: 25_ARP_THA','match: 25_ARP_THA (Mask)']
    meter = ['meter: 01_DROP_00_KBPS_00_1M', 'meter: 01_DROP_00_KBPS_01_10M', 'meter: 01_DROP_00_KBPS_02_100M', 'meter: 01_DROP_01_PKTPS_00_100', 'meter: 01_DROP_01_PKTPS_01_1000', 'meter: 01_DROP_01_PKTPS_02_10000', 'meter: 02_DSCP_REMARK_00_KBPS_00_1M', 'meter: 02_DSCP_REMARK_00_KBPS_01_10M', 'meter: 02_DSCP_REMARK_00_KBPS_02_100M', 'meter: 02_DSCP_REMARK_01_PKTPS_00_100', 'meter: 02_DSCP_REMARK_01_PKTPS_01_1000', 'meter: 02_DSCP_REMARK_01_PKTPS_02_10000']
    group = ['group: 00_ALL', 'group: 01_SELECT_Ether', 'group: 01_SELECT_IP', 'group: 01_SELECT_Weight_Ether', 'group: 01_SELECT_Weight_IP']

#    required = ['action: 00_OUTPUT','match: 00_IN_PORT','match: 03_ETH_DST','match: 03_ETH_DST (Mask)','match: 04_ETH_SRC','match: 04_ETH_SRC (Mask)','match: 05_ETH_TYPE','match: 10_IP_PROTO (IPv4)','match: 11_IPV4_SRC','match: 11_IPV4_SRC (Mask)','match: 12_IPV4_DST','match: 12_IPV4_DST (Mask)','match: 13_TCP_SRC (IPv4)','match: 14_TCP_DST (IPv4)','match: 15_UDP_SRC (IPv4)','match: 16_UDP_DST (IPv4)','match: 10_IP_PROTO (IPv6)','match: 13_TCP_SRC (IPv6)','match: 14_TCP_DST (IPv6)','match: 15_UDP_SRC (IPv6)','match: 16_UDP_DST (IPv6)','match: 26_IPV6_SRC','match: 26_IPV6_SRC (Mask)','match: 27_IPV6_DST','match: 27_IPV6_DST (Mask)']

    header_l2 = "\n| |Required|IPv4|IPv6|ARP|\n|-----------|----|----|----|----|"
    header_l3 = "\n| |Required|ether|vlan|mpls|pbb|\n|-----------|----|----|----|----|----|"

    filename = ""
    title = ""
    argv = sys.argv
    if len(argv) > 1:
        filename = argv[1]
        title = filename.replace('_', ' ')
    else:
        filename = "__TITLE__"
        title = "__TITLE__"

    print "---\nlayout: default\ntitle: Ryu Certification - %s\n---" % title

    print "\n# [Ryu Certification](http://osrg.github.io/ryu/certification.html)"
    print "* %s"  % title
    print "* [Configuration](http://osrg.github.io/ryu-certification/switch/config/%s.html)" % filename

    print "\n| |OK|ERROR|\n|----------|---|---|"
    disp_result(a, action_l2 + action_l3, 'Action')
    disp_result2(a, set(list_required)&set(action_l2+action_l3), 'Required')
    disp_result2(a, set(action_l2+action_l3)-set(list_required), 'Optional')
    disp_result(a, set_field_l2 + set_field_l3, 'set_field')
#    disp_result2(a, set(list_required)&set(set_field_l2+set_field_l3), 'Required')
    disp_result2(a, set(set_field_l2+set_field_l3)-set(list_required), 'Optional')
    disp_result(a, match_l2 + match_l3, 'Match')
    aa = move_optional(a, set(list_required)&set(match_l3))
    disp_result2(aa, set(list_required)&set(match_l2+match_l3), 'Required')
    disp_result2(aa, set(match_l2+match_l3)-set(list_required), 'Optional')
    disp_result(a, group, 'Group')
    disp_result2(a, set(list_required)&set(group), 'Required')
    disp_result2(a, set(group)-set(list_required), 'Optional')
    disp_result(a, meter, 'Meter')
    disp_result2(a, set(meter)-set(list_required), 'Optional')
    print "|Total|%d|%d|" % (ok, err)
    disp_result2(aa, set(list_required)&set(action_l2+action_l3+set_field_l2+set_field_l3+match_l2+match_l3+meter+group), 'Required')
    disp_result2(aa, set(action_l2+action_l3+set_field_l2+set_field_l3+match_l2+match_l3+meter+group)-set(list_required), 'Optional')

    print "\n## <a name ='Action'>Action</a>"
    print header_l2
    disp_table(a, action_l2, 1, 11)

    print header_l3
    disp_table(a, action_l3, 1, 11)

    print "\n## <a name='set_field'>set_field</a>"
    print header_l2
    disp_table(a, set_field_l2, 1, 22)

    print header_l3
    disp_table(a, set_field_l3, 1, 22)

    print "\n## <a name='Match'>Match(OUTPUT/Packet-in/Table-miss)</a>"
    print header_l2
    disp_table(a, match_l2, 3, 10)

    print header_l3
    disp_table(a, match_l3, 3, 10)

    print "\n## <a name ='Group'>Group</a>"
    print header_l2
    disp_table(a, group, 1, 10)

    print "\n## <a name ='Meter'>Meter</a>"
    print header_l2
    disp_table(a, meter, 1, 10)

    print "\n## Detailed log"
    disp_raw(b, action_l2)
    disp_raw(b, action_l3)
    disp_raw(b, set_field_l2)
    disp_raw(b, set_field_l3)
    disp_raw(b, match_l2)
    disp_raw(b, match_l3)
    disp_raw(b, group)
    disp_raw(b, meter)
------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
Ryu-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ryu-devel

Reply via email to