To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

test_rt_rpython.py 8.54 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# Copyright 2019 The Australian National University
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

from rpython.rtyper.lltypesystem import rffi, lltype
from rpython.rlib.rmu import zebu as rmu
from rpython.rlib.rrtmu import rtzebu as rrtmu
from rpython.translator.platform import platform
from rpython.tool.ansi_print import AnsiLogger
from util import fncptr_from_rpy_func, fncptr_from_py_script, may_spawn_proc, bin_dir, executable_from_rpy_func
import ctypes, py, stat, os
import pytest
import time

logger = AnsiLogger('rt_rpython_tests')

# --------------------------
# tests
# @may_spawn_proc
# def test_newregion():
#     from rpython.dev.dev_new_region import tester
#
#     fn, _ = fncptr_from_rpy_func(tester, [], rffi.VOIDPP)
#
#     assert fn() != lltype.nullptr(rffi.VOIDPP.TO)
# #
# #
# @may_spawn_proc
# def test_ralloc():
#     from rpython.dev.dev_ralloc import test_ralloc
#     fn, _ = fncptr_from_rpy_func(test_ralloc, [rffi.SIGNED, rffi.SIGNED, rffi.SIGNED], rffi.SIGNED)
#
#     assert fn(-2, 7, 0) == 5
# #
# #
# @may_spawn_proc
# def test_ealloc():
#     from rpython.dev.dev_ealloc import test_ealloc
#     fn, _ = fncptr_from_rpy_func(test_ealloc, [rffi.SIGNED, rffi.SIGNED, rffi.SIGNED], rffi.SIGNED)
#
#     assert fn(111, 1335, 17) == 1463
# #
# #
# @may_spawn_proc
# def test_mixed_memory_areas():
#     from rpython.dev.dev_memory_areas import test_memory_areas
#     fn, _ = fncptr_from_rpy_func(test_memory_areas, [rffi.SIGNED, rffi.SIGNED, rffi.SIGNED], rffi.SIGNED)
#
#     assert fn(2, -11, 14) == 15
#
# @may_spawn_proc
# def test_edelete():
#     from rpython.dev.dev_edelete import test_edelete
#     fn, _ = fncptr_from_rpy_func(test_edelete, [rffi.SIGNED, rffi.SIGNED, rffi.SIGNED], rffi.SIGNED)
#
#     assert fn(3, 1, 7) == 11


# @may_spawn_proc
# def test_thread_simple():
#     from rpython.dev.dev_new_thread import test_simple_threads
#     logger.info('going to build the test function')
#     exec_path = executable_from_rpy_func(test_simple_threads, [], rffi.SIGNED)
#
#     logger.info('going to run the test function')
#
#     # import subprocess
#     # subprocess.call([fn()])
#     # subprocess.check_output([fn()])
#
#     import os
#
#     start = time.time()
#     os.system('sudo LD_LIBRARY_PATH=$PWD/emit %s' % exec_path)
#     end = time.time()
#
#     print("Test took: ")
#     print(end-start)
#
#     logger.info('second call')
#
#     assert True

# @may_spawn_proc
# def test_default_thread_attr():
#     from rpython.dev.dev_thread_attr import test_default_attr
#     logger.info('going to build the test function')
#     exec_path = executable_from_rpy_func(test_default_attr, [], rffi.SIGNED)
#
#     logger.info('going to run the test function')
#
#     # import subprocess
#     # subprocess.call([fn()])
#     # subprocess.check_output([fn()])
#
#     import os
#
#     start = time.time()
#     os.system('sudo LD_LIBRARY_PATH=$PWD/emit %s' % exec_path)
#     end = time.time()
#
#     print("Test took: ")
#     print(end-start)
#
#     logger.info('second call')
#
#     assert True

# @may_spawn_proc
# def test_set_attr_priority():
#     from rpython.dev.dev_thread_attr import test_set_priority
#     logger.info('going to build the test function')
#     exec_path = executable_from_rpy_func(test_set_priority, [], rffi.SIGNED)
#
#     logger.info('going to run the test function')
#
#     # import subprocess
#     # subprocess.call([fn()])
#     # subprocess.check_output([fn()])
#
#     import os
#
#     start = time.time()
#     os.system('sudo LD_LIBRARY_PATH=$PWD/emit %s' % exec_path)
#     end = time.time()
#
#     print("Test took: ")
#     print(end-start)
#
#     logger.info('second call')
#
#     assert True


# @may_spawn_proc
# def test_thread_global_args():
#     from rpython.dev.dev_thread_global_args import test_simple_threads
#     logger.info('going to build the test function')
#     exec_path = executable_from_rpy_func(test_simple_threads, [], rffi.SIGNED)
#
#     logger.info('going to run the test function')
#
#     # import subprocess
#     # subprocess.call([fn()])
#     # subprocess.check_output([fn()])
#
#     import os
#
#     start = time.time()
#     os.system('sudo LD_LIBRARY_PATH=$PWD/emit %s' % exec_path)
#     end = time.time()
#
#     print("Test took: ")
#     print(end-start)
#
#     logger.info('second call')
#
#     assert True


# @may_spawn_proc
# def test_futex_global():
#     from rpython.dev.dev_futex import test_simple_threads
#     logger.info('going to build the test function')
#     exec_path = executable_from_rpy_func(test_simple_threads, [], rffi.SIGNED)
#
#     logger.info('going to run the test function')
#
#     # import subprocess
#     # subprocess.call([fn()])
#     # subprocess.check_output([fn()])
#
#     import os
#
#     start = time.time()
#     os.system('sudo LD_LIBRARY_PATH=$PWD/emit %s' % exec_path)
#     end = time.time()
#
#     print("Test took: ")
#     print(end-start)
#
#     logger.info('second call')
#
#     assert True

# @may_spawn_proc
# def test_thread_global_args():
#     from rpython.dev.dev_thread_local_args import test_simple_threads
#     logger.info('going to build the test function')
#     exec_path = executable_from_rpy_func(test_simple_threads, [], rffi.SIGNED)
#
#     logger.info('going to run the test function')
#
#     # import subprocess
#     # subprocess.call([fn()])
#     # subprocess.check_output([fn()])
#
#     import os
#
#     start = time.time()
#     os.system('sudo LD_LIBRARY_PATH=$PWD/emit %s' % exec_path)
#     end = time.time()
#
#     print("Test took: ")
#     print(end-start)
#
#     logger.info('second call')
#
#     assert True

# @may_spawn_proc
# def test_gettime_ns():
#     from rpython.dev.dev_get_time import test_gettime
#     fn, _ = fncptr_from_rpy_func(test_gettime, [rffi.SIGNED, rffi.SIGNED], rffi.SIGNED)
#
#     res =  fn(10000, 10000)
#
#     print("result:")
#     print(res)
#
#     assert res > 0

# @may_spawn_proc
# def test_get_time():
#     from rpython.dev.dev_get_time import test_gettime
#     logger.info('going to build the test function')
#     # exec_path = executable_from_rpy_func(test_gettime, [rffi.SIGNED, rffi.SIGNED], rffi.SIGNED)
#     exec_path = executable_from_rpy_func(test_gettime, [], rffi.SIGNED)
#
#     logger.info('going to run the test function')
#
#     # import subprocess
#     # subprocess.call([fn()])
#     # subprocess.check_output([fn()])
#
#     import subprocess
#
#     start = time.time()
#     res = subprocess.call('sudo LD_LIBRARY_PATH=$PWD/emit %s' % exec_path, shell=True)
#     end = time.time()
#
#     logger.info("Test took: ")
#     logger.info(end-start)
#
#     logger.info('returned result: %s' % res)
#
#     assert False

259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# @may_spawn_proc
# def test_simple_timer():
#     from rpython.dev.dev_timer import test_simple_timer
#     logger.info('going to build the test function')
#     exec_path = executable_from_rpy_func(test_simple_timer, [], rffi.SIGNED)
#
#     logger.info('going to run the test function')
#
#     # import subprocess
#     # subprocess.call([fn()])
#     # subprocess.check_output([fn()])
#
#     import subprocess
#     import os
#
#     start = time.time()
#
#     res = subprocess.call(
#         'sudo LD_LIBRARY_PATH=$PWD/emit:$LD_LIBRARY_PATH MU_LOG_LEVEL=debug %s' % exec_path, shell=True)
#
#     end = time.time()
#
#     logger.info("Test took: ")
#     logger.info(end-start)
#
#     logger.info('returned res = %d' % res)
#
#     # assert False
#     assert 0 <= res <= 50


290
@may_spawn_proc
291
292
def test_collision_detection():
    from rpython.dev.dev_CD import dev_cd
293
    logger.info('going to build the test function')
294
    exec_path = executable_from_rpy_func(dev_cd.main_region, [], rffi.SIGNED)
295
296
297
298
299
300
301
302

    logger.info('going to run the test function')

    # import subprocess
    # subprocess.call([fn()])
    # subprocess.check_output([fn()])

    import subprocess
303
    import os
304
305

    start = time.time()
306
307

    res = subprocess.call(
308
        'sudo LD_LIBRARY_PATH=$PWD/emit:$LD_LIBRARY_PATH MU_LOG_LEVEL=trace %s' % exec_path, shell=True)
309

310
311
312
313
314
    end = time.time()

    logger.info("Test took: ")
    logger.info(end-start)

315
    logger.info('returned res = %d' % res)
316

317
318
319
    assert False
    # assert 0 <= res <= 50