test_mvc_simulate_larger.py 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  1. import unittest
  2. import utils
  3. all_files = [
  4. "core/mini_modify.alc",
  5. "core/core_formalism.mvc",
  6. "core/core_algorithm.alc",
  7. "primitives.alc",
  8. "object_operations.alc",
  9. "conformance_scd.alc",
  10. "library.alc",
  11. "transform.alc",
  12. "model_management.alc",
  13. "ramify.alc",
  14. "metamodels.alc",
  15. "random.alc",
  16. "constructors.alc",
  17. "modelling.alc",
  18. "compilation_manager.alc",
  19. ]
  20. class TestMvCSimulateLarger(unittest.TestCase):
  21. def transform_add_MT_pn_simulate_larger(self, optimization_level):
  22. def step_and_print():
  23. return [
  24. # transformation_execute (pn_step)
  25. "Which transformation do you want to execute?",
  26. "Which model to bind for source element PetriNets_Runtime",
  27. "Which model to create for target element PetriNets_Runtime",
  28. "Transformation executed with result: True",
  29. "Ready for command...",
  30. # transformation_execute (pn_runtime_to_design)
  31. "Which transformation do you want to execute?",
  32. "Which model to bind for source element PetriNets_Runtime",
  33. "Which model to create for target element PetriNets",
  34. "Transformation executed with result: True",
  35. "Ready for command...",
  36. # transformation_execute (pn_print)
  37. "Which transformation do you want to execute?",
  38. "Which model to bind for source element PetriNets",
  39. None,
  40. None,
  41. None,
  42. "Transformation executed with result: True",
  43. "Ready for command...",
  44. ]
  45. utils.write_total_runtime_to_file(
  46. 'mvc_large', optimization_level,
  47. utils.run_correctness_test(all_files,
  48. ["root", "root", "root",
  49. "model_add",
  50. "SimpleClassDiagrams",
  51. "PetriNets",
  52. ] + utils.get_model_constructor(open("integration/code/pn_design.mvc", "r").read()) + [
  53. "model_add",
  54. "SimpleClassDiagrams",
  55. "PetriNets_Runtime",
  56. ] + utils.get_model_constructor(open("integration/code/pn_runtime.mvc", "r").read()) + [
  57. "model_add",
  58. "PetriNets",
  59. "my_pn",
  60. ] + utils.get_model_constructor(open("integration/code/pn_design_model_larger.mvc", "r").read()) + [
  61. "model_list",
  62. "transformation_add_MT_language",
  63. "PetriNets_Runtime",
  64. "PetriNets",
  65. "",
  66. "PetriNets_RAM",
  67. "model_list",
  68. "model_modify",
  69. "__merged_PetriNets_RAM",
  70. "instantiate",
  71. "Association",
  72. "D2R_PlaceLink",
  73. "PetriNets/Place",
  74. "PetriNets_Runtime/Place",
  75. "instantiate",
  76. "Association",
  77. "D2R_TransitionLink",
  78. "PetriNets/Transition",
  79. "PetriNets_Runtime/Transition",
  80. "instantiate",
  81. "Association",
  82. "R2D_PlaceLink",
  83. "PetriNets_Runtime/Place",
  84. "PetriNets/Place",
  85. "instantiate",
  86. "Association",
  87. "R2D_TransitionLink",
  88. "PetriNets_Runtime/Transition",
  89. "PetriNets/Transition",
  90. "exit",
  91. "transformation_RAMify",
  92. "__merged_PetriNets_RAM",
  93. "PetriNets_RAM",
  94. "transformation_add_MT",
  95. "PetriNets_RAM",
  96. "PetriNets",
  97. "",
  98. "PetriNets_Runtime",
  99. "",
  100. "pn_design_to_runtime",
  101. ] + utils.get_model_constructor(open("integration/code/pn_design_to_runtime.mvc", "r").read()) + [
  102. "transformation_add_MT",
  103. "PetriNets_RAM",
  104. "PetriNets_Runtime",
  105. "",
  106. "PetriNets",
  107. "",
  108. "pn_runtime_to_design",
  109. ] + utils.get_model_constructor(open("integration/code/pn_runtime_to_design.mvc", "r").read()) + [
  110. "transformation_add_MT",
  111. "PetriNets_RAM",
  112. "PetriNets_Runtime",
  113. "",
  114. "PetriNets_Runtime",
  115. "",
  116. "pn_step",
  117. ] + utils.get_model_constructor(open("integration/code/pn_simulate.mvc", "r").read()) + [
  118. "transformation_add_MT",
  119. "PetriNets_RAM",
  120. "PetriNets",
  121. "",
  122. "",
  123. "pn_print",
  124. ] + utils.get_model_constructor(open("integration/code/pn_print.mvc", "r").read()) + [
  125. "model_list",
  126. "transformation_list",
  127. "transformation_execute",
  128. "pn_print",
  129. "my_pn",
  130. "transformation_execute",
  131. "pn_design_to_runtime",
  132. "my_pn",
  133. "my_pn_runtime", ] + [
  134. "transformation_execute",
  135. "pn_step",
  136. "my_pn_runtime",
  137. "my_pn_runtime",
  138. "transformation_execute",
  139. "pn_runtime_to_design",
  140. "my_pn_runtime",
  141. "my_pn",
  142. "transformation_execute",
  143. "pn_print",
  144. "my_pn",
  145. ] * 10 + [
  146. ],
  147. [ # bootup phase
  148. "Desired username for admin user?",
  149. "Desired password for admin user?",
  150. "Please repeat the password",
  151. "Passwords match!",
  152. "Welcome to the Model Management Interface v2.0!",
  153. "Use the 'help' command for a list of possible commands",
  154. "Ready for command...",
  155. # model_add
  156. "Creating new model!",
  157. "Model type?",
  158. "Model name?",
  159. "Waiting for model constructors...",
  160. "Model upload success!",
  161. "Ready for command...",
  162. # model_add
  163. "Creating new model!",
  164. "Model type?",
  165. "Model name?",
  166. "Waiting for model constructors...",
  167. "Model upload success!",
  168. "Ready for command...",
  169. # model_add
  170. "Creating new model!",
  171. "Model type?",
  172. "Model name?",
  173. "Waiting for model constructors...",
  174. "Model upload success!",
  175. "Ready for command...",
  176. # model_list
  177. set([" SimpleClassDiagrams : SimpleClassDiagrams",
  178. " CoreFormalism : SimpleClassDiagrams",
  179. " PetriNets : SimpleClassDiagrams",
  180. " my_pn : PetriNets",
  181. " PetriNets_Runtime : SimpleClassDiagrams",
  182. " core : CoreFormalism"]),
  183. "Ready for command...",
  184. # transformation_add_MT_language
  185. "Formalisms to include (terminate with empty string)?",
  186. "Name of the RAMified transformation metamodel?",
  187. "Ready for command...",
  188. # model_list
  189. set([" SimpleClassDiagrams : SimpleClassDiagrams",
  190. " CoreFormalism : SimpleClassDiagrams",
  191. " PetriNets_Runtime : SimpleClassDiagrams",
  192. " PetriNets : SimpleClassDiagrams",
  193. " __merged_PetriNets_RAM : SimpleClassDiagrams",
  194. " PetriNets_RAM : SimpleClassDiagrams",
  195. " my_pn : PetriNets",
  196. " core : CoreFormalism"]),
  197. "Ready for command...",
  198. # model_modify
  199. "Which model do you want to modify?",
  200. "Model loaded, ready for commands!",
  201. "Use 'help' command for a list of possible commands",
  202. "Please give your command.",
  203. # instantiate 1
  204. "Type to instantiate?",
  205. "Name of new element?",
  206. "Source name?",
  207. "Destination name?",
  208. "Instantiation successful!",
  209. "Please give your command.",
  210. # instantiate 2
  211. "Type to instantiate?",
  212. "Name of new element?",
  213. "Source name?",
  214. "Destination name?",
  215. "Instantiation successful!",
  216. "Please give your command.",
  217. # instantiate 3
  218. "Type to instantiate?",
  219. "Name of new element?",
  220. "Source name?",
  221. "Destination name?",
  222. "Instantiation successful!",
  223. "Please give your command.",
  224. # instantiate 4
  225. "Type to instantiate?",
  226. "Name of new element?",
  227. "Source name?",
  228. "Destination name?",
  229. "Instantiation successful!",
  230. "Please give your command.",
  231. "Ready for command...",
  232. # transformation_RAMify
  233. "Which metamodel do you want to RAMify?",
  234. "Where do you want to store the RAMified metamodel?",
  235. "Ready for command...",
  236. # transformation_add_MT
  237. "RAMified metamodel to use?",
  238. "Supported metamodels:",
  239. set([" PetriNets",
  240. " PetriNets_Runtime",
  241. ]),
  242. "",
  243. "Which ones do you want to use as source (empty string to finish)?",
  244. "Model added as source",
  245. "Which ones do you want to use as target (empty string to finish)?",
  246. "Model added as target",
  247. "Name of new transformation?",
  248. "Waiting for model constructors...",
  249. "Ready for command...",
  250. # transformation_add_MT
  251. "RAMified metamodel to use?",
  252. "Supported metamodels:",
  253. set([" PetriNets",
  254. " PetriNets_Runtime",
  255. ]),
  256. "",
  257. "Which ones do you want to use as source (empty string to finish)?",
  258. "Model added as source",
  259. "Which ones do you want to use as target (empty string to finish)?",
  260. "Model added as target",
  261. "Name of new transformation?",
  262. "Waiting for model constructors...",
  263. "Ready for command...",
  264. # transformation_add_MT
  265. "RAMified metamodel to use?",
  266. "Supported metamodels:",
  267. set([" PetriNets",
  268. " PetriNets_Runtime",
  269. ]),
  270. "",
  271. "Which ones do you want to use as source (empty string to finish)?",
  272. "Model added as source",
  273. "Which ones do you want to use as target (empty string to finish)?",
  274. "Model added as target",
  275. "Name of new transformation?",
  276. "Waiting for model constructors...",
  277. "Ready for command...",
  278. # transformation_add_MT
  279. "RAMified metamodel to use?",
  280. "Supported metamodels:",
  281. set([" PetriNets",
  282. " PetriNets_Runtime",
  283. ]),
  284. "",
  285. "Which ones do you want to use as source (empty string to finish)?",
  286. "Model added as source",
  287. "Which ones do you want to use as target (empty string to finish)?",
  288. "Name of new transformation?",
  289. "Waiting for model constructors...",
  290. "Ready for command...",
  291. # model_list
  292. set([" SimpleClassDiagrams : SimpleClassDiagrams",
  293. " CoreFormalism : SimpleClassDiagrams",
  294. " PetriNets_Runtime : SimpleClassDiagrams",
  295. " PetriNets : SimpleClassDiagrams",
  296. " pn_print : PetriNets_RAM",
  297. " pn_design_to_runtime : PetriNets_RAM",
  298. " pn_runtime_to_design : PetriNets_RAM",
  299. " pn_step : PetriNets_RAM",
  300. " __merged_PetriNets_RAM : SimpleClassDiagrams",
  301. " PetriNets_RAM : SimpleClassDiagrams",
  302. " my_pn : PetriNets",
  303. " core : CoreFormalism"]),
  304. "Ready for command...",
  305. # transformation_list
  306. set(["[ModelTransformation] pn_print : PetriNets_RAM",
  307. "[ModelTransformation] pn_design_to_runtime : PetriNets_RAM",
  308. "[ModelTransformation] pn_runtime_to_design : PetriNets_RAM",
  309. "[ModelTransformation] pn_step : PetriNets_RAM"]),
  310. "Ready for command...",
  311. # transformation_execute (pn_print)
  312. "Which transformation do you want to execute?",
  313. "Which model to bind for source element PetriNets",
  314. set(['"lock_available" --> 1',
  315. '"critical_section_1" --> 0',
  316. '"critical_section_2" --> 0',
  317. ]),
  318. "Transformation executed with result: True",
  319. "Ready for command...",
  320. # transformation_execute (pn_design_to_runtime)
  321. "Which transformation do you want to execute?",
  322. "Which model to bind for source element PetriNets",
  323. "Which model to create for target element PetriNets_Runtime",
  324. "Transformation executed with result: True",
  325. "Ready for command...",
  326. ] + \
  327. step_and_print() * 10 +
  328. [],
  329. optimization_level))
  330. utils.define_perf_tests(
  331. TestMvCSimulateLarger,
  332. TestMvCSimulateLarger.transform_add_MT_pn_simulate_larger,
  333. optimization_levels=[
  334. utils.OPTIMIZATION_LEVEL_ADAPTIVE_JIT_FAVOR_LOOPS,
  335. utils.OPTIMIZATION_LEVEL_ADAPTIVE_JIT_FAVOR_SMALL_LOOPS,
  336. utils.OPTIMIZATION_LEVEL_FAST_JIT,
  337. utils.OPTIMIZATION_LEVEL_BASELINE_JIT
  338. ])