• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# this doctest contains tests for miscellaneous features of the RPC interface
2# that would clutter the main rpc_test
3
4# setup
5>>> from autotest_lib.frontend.afe import rpc_interface
6
7>>> rpc_interface.add_profiler(name='oprofile')
81
9>>> rpc_interface.add_profiler(name='iostat')
102
11
12# profiler support in control file generation
13>>> cf_info = rpc_interface.generate_control_file(
14...     client_control_file='print "Hi"\n',
15...     profilers=['oprofile', 'iostat'])
16>>> print cf_info['control_file']
17def step_init():
18    job.next_step('step0')
19    job.next_step('step1')
20    job.next_step('step2')
21    job.next_step('step3')
22    job.next_step('step4')
23<BLANKLINE>
24def step0():
25    job.profilers.add('oprofile')
26<BLANKLINE>
27def step1():
28    job.profilers.add('iostat')
29<BLANKLINE>
30def step2():
31    print "Hi"
32<BLANKLINE>
33    return locals()
34<BLANKLINE>
35def step3():
36    job.profilers.delete('oprofile')
37<BLANKLINE>
38def step4():
39    job.profilers.delete('iostat')
40
41# profile_only=False support in control file generation
42>>> cf_info = rpc_interface.generate_control_file(
43...     client_control_file='print "Hi"\n',
44...     profilers=['oprofile'],
45...     profile_only=False)
46>>> print cf_info['control_file']
47def step_init():
48    job.next_step('step0')
49    job.next_step('step1')
50    job.next_step('step2')
51    job.next_step('step3')
52<BLANKLINE>
53def step0():
54    job.default_profile_only = False
55<BLANKLINE>
56def step1():
57    job.profilers.add('oprofile')
58<BLANKLINE>
59def step2():
60    print "Hi"
61<BLANKLINE>
62    return locals()
63<BLANKLINE>
64def step3():
65    job.profilers.delete('oprofile')
66
67# profile_only=True support in control file generation
68>>> cf_info = rpc_interface.generate_control_file(
69...     client_control_file='print "Hi"\n',
70...     profilers=['iostat'],
71...     profile_only=True)
72>>> print cf_info['control_file']
73def step_init():
74    job.next_step('step0')
75    job.next_step('step1')
76    job.next_step('step2')
77    job.next_step('step3')
78<BLANKLINE>
79def step0():
80    job.default_profile_only = True
81<BLANKLINE>
82def step1():
83    job.profilers.add('iostat')
84<BLANKLINE>
85def step2():
86    print "Hi"
87<BLANKLINE>
88    return locals()
89<BLANKLINE>
90def step3():
91    job.profilers.delete('iostat')
92
93# test that multiline quoted strings are not indented
94>>> import common
95>>> from autotest_lib.frontend.afe import test, control_file
96>>> import os
97>>> control_path = os.path.join(os.path.dirname(test.__file__),
98...                             'doctests', 'test.control.3')
99>>> control_path = os.path.abspath(control_path)
100>>> class FakeTest(object):
101...   path = control_path
102...
103>>> print control_file.generate_control([FakeTest()], is_server=True) #doctest: +NORMALIZE_WHITESPACE
104def step_init():
105    step0()
106def step0():
107    client_code = """
108some content\"""quoted content\"""
109'''other quoted content\"""'''
110\\"""
111    client_code2 = '''
112some content\'''quoted content\'''
113"""other quoted content\'''"""
114\\'''
115    job.run_test('testname')
116step_init()
117