@@ -67,21 +67,31 @@ class LLVMExecutableCodeTest : public testing::Test
6767 TestMock m_mock;
6868};
6969
70+ TEST_F (LLVMExecutableCodeTest, CreateExecutionContext)
71+ {
72+ std::vector<std::unique_ptr<ValueData>> constValues;
73+ LLVMExecutableCode code (std::move (m_module), constValues);
74+ auto ctx = code.createExecutionContext (&m_target);
75+ ASSERT_TRUE (ctx);
76+ ASSERT_EQ (ctx->target (), &m_target);
77+ ASSERT_TRUE (dynamic_cast <LLVMExecutionContext *>(ctx.get ()));
78+ }
79+
7080TEST_F (LLVMExecutableCodeTest, NoFunctions)
7181{
72- LLVMExecutionContext ctx (&m_target);
7382 std::vector<std::unique_ptr<ValueData>> constValues;
7483 LLVMExecutableCode code (std::move (m_module), constValues);
75- ASSERT_TRUE (code.isFinished (&ctx));
84+ auto ctx = code.createExecutionContext (&m_target);
85+ ASSERT_TRUE (code.isFinished (ctx.get ()));
7686
77- code.run (& ctx);
78- ASSERT_TRUE (code.isFinished (& ctx));
87+ code.run (ctx. get () );
88+ ASSERT_TRUE (code.isFinished (ctx. get () ));
7989
80- code.kill (& ctx);
81- ASSERT_TRUE (code.isFinished (& ctx));
90+ code.kill (ctx. get () );
91+ ASSERT_TRUE (code.isFinished (ctx. get () ));
8292
83- code.reset (& ctx);
84- ASSERT_TRUE (code.isFinished (& ctx));
93+ code.reset (ctx. get () );
94+ ASSERT_TRUE (code.isFinished (ctx. get () ));
8595}
8696
8797TEST_F (LLVMExecutableCodeTest, SingleFunction)
@@ -90,27 +100,27 @@ TEST_F(LLVMExecutableCodeTest, SingleFunction)
90100 addTestFunction (f);
91101 endFunction (0 );
92102
93- LLVMExecutionContext ctx (&m_target);
94103 std::vector<std::unique_ptr<ValueData>> constValues;
95104 LLVMExecutableCode code (std::move (m_module), constValues);
96- ASSERT_FALSE (code.isFinished (&ctx));
105+ auto ctx = code.createExecutionContext (&m_target);
106+ ASSERT_FALSE (code.isFinished (ctx.get ()));
97107
98108 EXPECT_CALL (m_mock, f (&m_target));
99- code.run (& ctx);
100- ASSERT_TRUE (code.isFinished (& ctx));
109+ code.run (ctx. get () );
110+ ASSERT_TRUE (code.isFinished (ctx. get () ));
101111
102- code.kill (& ctx);
103- ASSERT_TRUE (code.isFinished (& ctx));
112+ code.kill (ctx. get () );
113+ ASSERT_TRUE (code.isFinished (ctx. get () ));
104114
105- code.reset (& ctx);
106- ASSERT_FALSE (code.isFinished (& ctx));
115+ code.reset (ctx. get () );
116+ ASSERT_FALSE (code.isFinished (ctx. get () ));
107117
108- code.kill (& ctx);
109- ASSERT_TRUE (code.isFinished (& ctx));
118+ code.kill (ctx. get () );
119+ ASSERT_TRUE (code.isFinished (ctx. get () ));
110120
111121 EXPECT_CALL (m_mock, f).Times (0 );
112- code.run (& ctx);
113- ASSERT_TRUE (code.isFinished (& ctx));
122+ code.run (ctx. get () );
123+ ASSERT_TRUE (code.isFinished (ctx. get () ));
114124}
115125
116126TEST_F (LLVMExecutableCodeTest, MultipleFunctions)
@@ -123,18 +133,18 @@ TEST_F(LLVMExecutableCodeTest, MultipleFunctions)
123133 endFunction (i);
124134 }
125135
126- LLVMExecutionContext ctx (&m_target);
127136 std::vector<std::unique_ptr<ValueData>> constValues;
128137 LLVMExecutableCode code (std::move (m_module), constValues);
129- ASSERT_FALSE (code.isFinished (&ctx));
138+ auto ctx = code.createExecutionContext (&m_target);
139+ ASSERT_FALSE (code.isFinished (ctx.get ()));
130140
131141 for (int i = 0 ; i < count; i++) {
132- ASSERT_FALSE (code.isFinished (& ctx));
142+ ASSERT_FALSE (code.isFinished (ctx. get () ));
133143 EXPECT_CALL (m_mock, f (&m_target));
134- code.run (& ctx);
144+ code.run (ctx. get () );
135145 }
136146
137- ASSERT_TRUE (code.isFinished (& ctx));
147+ ASSERT_TRUE (code.isFinished (ctx. get () ));
138148}
139149
140150TEST_F (LLVMExecutableCodeTest, ConstValues)
@@ -159,13 +169,13 @@ TEST_F(LLVMExecutableCodeTest, ConstValues)
159169 addTestPrintFunction (ptr1, ptr2);
160170 endFunction (0 );
161171
162- LLVMExecutionContext ctx (&m_target);
163172 LLVMExecutableCode code (std::move (m_module), constValues);
173+ auto ctx = code.createExecutionContext (&m_target);
164174 ASSERT_TRUE (constValues.empty ());
165- ASSERT_FALSE (code.isFinished (& ctx));
175+ ASSERT_FALSE (code.isFinished (ctx. get () ));
166176
167177 testing::internal::CaptureStdout ();
168- code.run (& ctx);
178+ code.run (ctx. get () );
169179 ASSERT_EQ (testing::internal::GetCapturedStdout (), " 1 2\n " );
170- ASSERT_TRUE (code.isFinished (& ctx));
180+ ASSERT_TRUE (code.isFinished (ctx. get () ));
171181}
0 commit comments