Test that an invalid write gets an error response

This commit is contained in:
Alex Young
2012-07-02 15:37:52 +01:00
parent ea4642a878
commit cc2e67d4bb
3 changed files with 51 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
#!/usr/bin/env ruby
# encoding: utf-8
# Connect, read the hello then make a write request with an impossible
# (from,len) pair. We expect an error response, and not to be
# disconnected.
require 'flexnbd/fake_source'
include FlexNBD::FakeSource
addr, port = *ARGV
client_sock = connect( addr, port, "Timed out connecting" )
read_hello( client_sock )
write_write_request( client_sock, 1 << 31, 1 << 31, "myhandle" )
response = read_response( client_sock )
fail "Not an error" if response[:error] == 0
fail "Wrong handle" unless "myhandle" == response[:handle]
client_sock.close
exit(0)