#NEWLINE# def test_existing_file( self ) : #NEWLINE# #INDENT# ( fd , name ) = mkstemp ( dir = self . testdir ) #NEWLINE# os . write ( fd , b'test' ) #NEWLINE# os . close ( fd ) #NEWLINE# opts = ( '-f @%s' % name ) #NEWLINE# dev_name = ( '/dev/1.%s' % os . path . basename ( name ) ) #NEWLINE# cmd_line = ' ' . join ( [ self . program , ( '-f %s' % dev_name ) ] ) #NEWLINE# self . argv . extend ( opts . split ( ) ) #NEWLINE# shell = Shell ( self . argv ) #NEWLINE# try : #NEWLINE# #INDENT# with pytest . raises ( SystemExit ) : #NEWLINE# #INDENT# shell . run ( ) #NEWLINE# #UNINDENT# files = os . listdir ( shell . zvsh . tmpdir ) #NEWLINE# self . assertTrue ( ( 'manifest.1' in files ) ) #NEWLINE# self . assertTrue ( ( 'nvram.1' in files ) ) #NEWLINE# manifest = _read_manifest ( join_path ( shell . zvsh . tmpdir , 'manifest.1' ) ) #NEWLINE# reference = self . _reference_manifest ( shell . zvsh . tmpdir ) #NEWLINE# channels = reference [ 'channel' ] #NEWLINE# file_chan = [ name , self , '3' , '0' , str ( DEFAULT_LIMITS [ 'reads' ] ) , str ( DEFAULT_LIMITS [ 'rbytes' ] ) , str ( DEFAULT_LIMITS [ 'writes' ] ) , str ( DEFAULT_LIMITS [ 'wbytes' ] ) ] #NEWLINE# channels . insert ( 3 , file_chan ) #NEWLINE# self . assertEqual ( manifest , reference ) #NEWLINE# nvram = _read_nvram ( join_path ( shell . zvsh . tmpdir , 'nvram.1' ) ) #NEWLINE# reference = _reference_nvram ( cmd_line , [ { #NEWLINE# #INDENT# 'channel' : dev_name , #NEWLINE# 'mode' : 'file' , #NEWLINE# #UNINDENT# } ] ) #NEWLINE# self . assertEqual ( nvram , reference ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# shell . zvsh . orig_cleanup ( )