qemu-iotests: add poke_file utility function
The new poke_file function sets bytes at an offset in a file given a printf-style format string. It can be used to corrupt an image file for test coverage of error paths. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
		
							parent
							
								
									e98768d437
								
							
						
					
					
						commit
						23ea2ecc2a
					
				@ -34,6 +34,12 @@ dd()
 | 
				
			|||||||
   fi
 | 
					   fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# poke_file 'test.img' 512 '\xff\xfe'
 | 
				
			||||||
 | 
					poke_file()
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    printf "$3" | dd "of=$1" bs=1 "seek=$2" conv=notrunc &>/dev/null
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# we need common.config
 | 
					# we need common.config
 | 
				
			||||||
if [ "$iam" != "check" ]
 | 
					if [ "$iam" != "check" ]
 | 
				
			||||||
then
 | 
					then
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user