qapi: Add tests of redefined expressions
Demonstrate that the qapi generator doesn't deal very well with redefined expressions. At the parse level, they are silently accepted; and while the testsuite just stops at parsing, I've further tested that many of them cause generator crashes or invalid C code if they were appended to qapi-schema-test.json. A later patch will tighten things up and adjust the testsuite to match. Signed-off-by: Eric Blake <eblake@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
		
							parent
							
								
									0545f6b887
								
							
						
					
					
						commit
						cfdd5bcad5
					
				@ -214,6 +214,8 @@ check-qapi-schema-y := $(addprefix tests/qapi-schema/, \
 | 
				
			|||||||
	missing-type.json bad-ident.json ident-with-escape.json \
 | 
						missing-type.json bad-ident.json ident-with-escape.json \
 | 
				
			||||||
	double-type.json bad-base.json bad-type-bool.json bad-type-int.json \
 | 
						double-type.json bad-base.json bad-type-bool.json bad-type-int.json \
 | 
				
			||||||
	bad-type-dict.json double-data.json unknown-expr-key.json \
 | 
						bad-type-dict.json double-data.json unknown-expr-key.json \
 | 
				
			||||||
 | 
						redefined-type.json redefined-command.json redefined-builtin.json \
 | 
				
			||||||
 | 
						redefined-event.json command-int.json event-max.json \
 | 
				
			||||||
	missing-colon.json missing-comma-list.json \
 | 
						missing-colon.json missing-comma-list.json \
 | 
				
			||||||
	missing-comma-object.json non-objects.json \
 | 
						missing-comma-object.json non-objects.json \
 | 
				
			||||||
	qapi-schema-test.json quoted-structural-chars.json \
 | 
						qapi-schema-test.json quoted-structural-chars.json \
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										0
									
								
								tests/qapi-schema/command-int.err
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								tests/qapi-schema/command-int.err
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										1
									
								
								tests/qapi-schema/command-int.exit
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								tests/qapi-schema/command-int.exit
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					0
 | 
				
			||||||
							
								
								
									
										3
									
								
								tests/qapi-schema/command-int.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tests/qapi-schema/command-int.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					# FIXME: we should reject collisions between commands and types
 | 
				
			||||||
 | 
					{ 'command': 'int', 'data': { 'character': 'str' },
 | 
				
			||||||
 | 
					  'returns': { 'value': 'int' } }
 | 
				
			||||||
							
								
								
									
										3
									
								
								tests/qapi-schema/command-int.out
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tests/qapi-schema/command-int.out
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					[OrderedDict([('command', 'int'), ('data', OrderedDict([('character', 'str')])), ('returns', OrderedDict([('value', 'int')]))])]
 | 
				
			||||||
 | 
					[]
 | 
				
			||||||
 | 
					[]
 | 
				
			||||||
							
								
								
									
										0
									
								
								tests/qapi-schema/event-max.err
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								tests/qapi-schema/event-max.err
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										1
									
								
								tests/qapi-schema/event-max.exit
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								tests/qapi-schema/event-max.exit
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					0
 | 
				
			||||||
							
								
								
									
										2
									
								
								tests/qapi-schema/event-max.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/qapi-schema/event-max.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					# FIXME: an event named 'MAX' would conflict with implicit C enum
 | 
				
			||||||
 | 
					{ 'event': 'MAX' }
 | 
				
			||||||
							
								
								
									
										3
									
								
								tests/qapi-schema/event-max.out
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tests/qapi-schema/event-max.out
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					[OrderedDict([('event', 'MAX')])]
 | 
				
			||||||
 | 
					[]
 | 
				
			||||||
 | 
					[]
 | 
				
			||||||
							
								
								
									
										0
									
								
								tests/qapi-schema/redefined-builtin.err
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								tests/qapi-schema/redefined-builtin.err
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										1
									
								
								tests/qapi-schema/redefined-builtin.exit
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								tests/qapi-schema/redefined-builtin.exit
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					0
 | 
				
			||||||
							
								
								
									
										2
									
								
								tests/qapi-schema/redefined-builtin.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								tests/qapi-schema/redefined-builtin.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,2 @@
 | 
				
			|||||||
 | 
					# FIXME: we should reject types that duplicate builtin names
 | 
				
			||||||
 | 
					{ 'type': 'size', 'data': { 'myint': 'size' } }
 | 
				
			||||||
							
								
								
									
										3
									
								
								tests/qapi-schema/redefined-builtin.out
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tests/qapi-schema/redefined-builtin.out
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					[OrderedDict([('type', 'size'), ('data', OrderedDict([('myint', 'size')]))])]
 | 
				
			||||||
 | 
					[]
 | 
				
			||||||
 | 
					[OrderedDict([('type', 'size'), ('data', OrderedDict([('myint', 'size')]))])]
 | 
				
			||||||
							
								
								
									
										0
									
								
								tests/qapi-schema/redefined-command.err
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								tests/qapi-schema/redefined-command.err
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										1
									
								
								tests/qapi-schema/redefined-command.exit
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								tests/qapi-schema/redefined-command.exit
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					0
 | 
				
			||||||
							
								
								
									
										3
									
								
								tests/qapi-schema/redefined-command.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tests/qapi-schema/redefined-command.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					# FIXME: we should reject commands defined more than once
 | 
				
			||||||
 | 
					{ 'command': 'foo', 'data': { 'one': 'str' } }
 | 
				
			||||||
 | 
					{ 'command': 'foo', 'data': { '*two': 'str' } }
 | 
				
			||||||
							
								
								
									
										4
									
								
								tests/qapi-schema/redefined-command.out
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								tests/qapi-schema/redefined-command.out
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					[OrderedDict([('command', 'foo'), ('data', OrderedDict([('one', 'str')]))]),
 | 
				
			||||||
 | 
					 OrderedDict([('command', 'foo'), ('data', OrderedDict([('*two', 'str')]))])]
 | 
				
			||||||
 | 
					[]
 | 
				
			||||||
 | 
					[]
 | 
				
			||||||
							
								
								
									
										0
									
								
								tests/qapi-schema/redefined-event.err
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								tests/qapi-schema/redefined-event.err
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										1
									
								
								tests/qapi-schema/redefined-event.exit
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								tests/qapi-schema/redefined-event.exit
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					0
 | 
				
			||||||
							
								
								
									
										3
									
								
								tests/qapi-schema/redefined-event.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tests/qapi-schema/redefined-event.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					# FIXME: we should reject duplicate events
 | 
				
			||||||
 | 
					{ 'event': 'EVENT_A', 'data': { 'myint': 'int' } }
 | 
				
			||||||
 | 
					{ 'event': 'EVENT_A', 'data': { 'myint': 'int' } }
 | 
				
			||||||
							
								
								
									
										4
									
								
								tests/qapi-schema/redefined-event.out
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								tests/qapi-schema/redefined-event.out
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					[OrderedDict([('event', 'EVENT_A'), ('data', OrderedDict([('myint', 'int')]))]),
 | 
				
			||||||
 | 
					 OrderedDict([('event', 'EVENT_A'), ('data', OrderedDict([('myint', 'int')]))])]
 | 
				
			||||||
 | 
					[]
 | 
				
			||||||
 | 
					[]
 | 
				
			||||||
							
								
								
									
										0
									
								
								tests/qapi-schema/redefined-type.err
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								tests/qapi-schema/redefined-type.err
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										1
									
								
								tests/qapi-schema/redefined-type.exit
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								tests/qapi-schema/redefined-type.exit
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1 @@
 | 
				
			|||||||
 | 
					0
 | 
				
			||||||
							
								
								
									
										3
									
								
								tests/qapi-schema/redefined-type.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										3
									
								
								tests/qapi-schema/redefined-type.json
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,3 @@
 | 
				
			|||||||
 | 
					# FIXME: we should reject types defined more than once
 | 
				
			||||||
 | 
					{ 'type': 'foo', 'data': { 'one': 'str' } }
 | 
				
			||||||
 | 
					{ 'enum': 'foo', 'data': [ 'two' ] }
 | 
				
			||||||
							
								
								
									
										4
									
								
								tests/qapi-schema/redefined-type.out
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								tests/qapi-schema/redefined-type.out
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,4 @@
 | 
				
			|||||||
 | 
					[OrderedDict([('type', 'foo'), ('data', OrderedDict([('one', 'str')]))]),
 | 
				
			||||||
 | 
					 OrderedDict([('enum', 'foo'), ('data', ['two'])])]
 | 
				
			||||||
 | 
					[{'enum_name': 'foo', 'enum_values': ['two']}]
 | 
				
			||||||
 | 
					[OrderedDict([('type', 'foo'), ('data', OrderedDict([('one', 'str')]))])]
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user