crypto: introduce some common functions for af_alg backend
[qemu/ar7.git] / tests / qapi-schema / test-qapi.py
blobc7724d343757972bce165d17831a3f69ce4c80bb
2 # QAPI parser test harness
4 # Copyright (c) 2013 Red Hat Inc.
6 # Authors:
7 # Markus Armbruster <armbru@redhat.com>
9 # This work is licensed under the terms of the GNU GPL, version 2 or later.
10 # See the COPYING file in the top-level directory.
13 from qapi import *
14 from pprint import pprint
15 import os
16 import sys
19 class QAPISchemaTestVisitor(QAPISchemaVisitor):
20 def visit_enum_type(self, name, info, values, prefix):
21 print 'enum %s %s' % (name, values)
22 if prefix:
23 print ' prefix %s' % prefix
25 def visit_object_type(self, name, info, base, members, variants):
26 print 'object %s' % name
27 if base:
28 print ' base %s' % base.name
29 for m in members:
30 print ' member %s: %s optional=%s' % \
31 (m.name, m.type.name, m.optional)
32 self._print_variants(variants)
34 def visit_alternate_type(self, name, info, variants):
35 print 'alternate %s' % name
36 self._print_variants(variants)
38 def visit_command(self, name, info, arg_type, ret_type,
39 gen, success_response, boxed):
40 print 'command %s %s -> %s' % \
41 (name, arg_type and arg_type.name, ret_type and ret_type.name)
42 print ' gen=%s success_response=%s boxed=%s' % \
43 (gen, success_response, boxed)
45 def visit_event(self, name, info, arg_type, boxed):
46 print 'event %s %s' % (name, arg_type and arg_type.name)
47 print ' boxed=%s' % boxed
49 @staticmethod
50 def _print_variants(variants):
51 if variants:
52 print ' tag %s' % variants.tag_member.name
53 for v in variants.variants:
54 print ' case %s: %s' % (v.name, v.type.name)
56 schema = QAPISchema(sys.argv[1])
57 schema.visit(QAPISchemaTestVisitor())
59 for doc in schema.docs:
60 if doc.symbol:
61 print 'doc symbol=%s' % doc.symbol
62 else:
63 print 'doc freeform'
64 print ' body=\n%s' % doc.body
65 for arg, section in doc.args.iteritems():
66 print ' arg=%s\n%s' % (arg, section)
67 for section in doc.sections:
68 print ' section=%s\n%s' % (section.name, section)