@@ -116,6 +116,38 @@ def test_mpi(self):
116116 #self.assertEqual(out.stderr.decode("utf-8"), expected_std_err)
117117 #self.assertEqual(out.stdout.decode("utf-8"), "hello world\n")
118118
119+ def test_call_main (self ):
120+ env = self .env
121+ env ["SCOREP_EXPERIMENT_DIRECTORY" ] += "/test_call_main"
122+ trace_path = env ["SCOREP_EXPERIMENT_DIRECTORY" ] + "/traces.otf2"
123+ out = subprocess .run (["python3" ,
124+ "-m" ,
125+ "scorep" ,
126+ "test_call_main.py" ],
127+ stdout = subprocess .PIPE ,
128+ stderr = subprocess .PIPE ,
129+ env = env )
130+ expected_std_err = """scorep: Someone called scorep.__main__.main(argv).
131+ This is not supposed to happen, but might be triggered, if your application calls "sys.modules['__main__'].main".
132+ This python stacktrace might be helpfull to find the reason:
133+ File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
134+ "__main__", mod_spec)
135+ File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
136+ exec(code, run_globals)
137+ File "/home/gocht/virtenv/test_scorep_python_3.6/lib/python3.6/site-packages/scorep/__main__.py", line 161, in <module>
138+ scorep_main()
139+ File "/home/gocht/virtenv/test_scorep_python_3.6/lib/python3.6/site-packages/scorep/__main__.py", line 143, in scorep_main
140+ global_trace.runctx(code, globs, globs)
141+ File "/home/gocht/virtenv/test_scorep_python_3.6/lib/python3.6/site-packages/scorep/trace.py", line 57, in runctx
142+ exec(cmd, globals, locals)
143+ File "test_call_main.py", line 6, in <module>
144+ sys.modules['__main__'].main(sys.argv)
145+
146+ """
147+ expected_std_out = ""
148+ self .assertEqual (out .stderr .decode ("utf-8" ), expected_std_err )
149+ self .assertEqual (out .stdout .decode ("utf-8" ), expected_std_out )
150+
119151 def tearDown (self ):
120152 shutil .rmtree (
121153 self .env ["SCOREP_EXPERIMENT_DIRECTORY" ],
0 commit comments