test_mvc_simulate.py 14 KB

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