2 Tests for the fiu_ctrl.py module.
4 Note the command line utility is covered by the utils/ tests, not from here,
5 this is just for the Python module.
13 fiu_ctrl
.PLIBPATH
= "./libs/"
15 def run_cat(**kwargs
):
16 return fiu_ctrl
.Subprocess(["./small-cat"],
17 stdin
= subprocess
.PIPE
, stdout
= subprocess
.PIPE
,
18 stderr
= subprocess
.PIPE
, **kwargs
)
20 # Run without any failure point being enabled.
23 out
, err
= p
.communicate('test\n')
24 assert out
== 'test\n', out
27 # Enable before starting.
28 cmd
= run_cat(fiu_enable_posix
= True)
29 cmd
.enable('posix/io/rw/*', failinfo
= errno
.ENOSPC
)
31 out
, err
= p
.communicate('test\n')
33 assert 'space' in err
, err
35 # Enable after starting.
36 cmd
= run_cat(fiu_enable_posix
= True)
38 cmd
.enable('posix/io/rw/*', failinfo
= errno
.ENOSPC
)
39 out
, err
= p
.communicate('test\n')
41 assert 'space' in err
, err
44 cmd
= run_cat(fiu_enable_posix
= True)
46 cmd
.enable('posix/io/rw/*', failinfo
= errno
.ENOSPC
)
47 cmd
.disable('posix/io/rw/*')
48 out
, err
= p
.communicate('test\n')
49 assert out
== 'test\n', (out
, err
)
52 # This relies on cat doing a reasonably small number of read and writes, which
54 result
= { True: 0, False: 0 }
56 cmd
= run_cat(fiu_enable_posix
= True)
58 cmd
.enable_random('posix/io/rw/*', failinfo
= errno
.ENOSPC
,
60 out
, err
= p
.communicate('test\n')
66 assert False, (out
, err
)
68 assert 10 < result
[True] < 40, result
69 assert 10 < result
[False] < 40, result