Skip to content

Commit af58bf2

Browse files
committed
Add unittest for ASM parsing with the Interpreter
1 parent 6abeffe commit af58bf2

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

unittests/CppInterOp/InterpreterTest.cpp

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,3 +448,30 @@ TEST(InterpreterTest, MultipleInterpreter) {
448448
std::string cerrs = testing::internal::GetCapturedStderr();
449449
EXPECT_STREQ(cerrs.c_str(), "printf_jit called!\n");
450450
}
451+
452+
TEST(InterpreterTest, ASMParsing) {
453+
#ifdef EMSCRIPTEN
454+
GTEST_SKIP() << "Test fails for Emscipten builds";
455+
#endif
456+
#ifdef _WIN32
457+
GTEST_SKIP() << "Disabled on Windows. Needs fixing.";
458+
#endif
459+
if (llvm::sys::RunningOnValgrind())
460+
GTEST_SKIP() << "XFAIL due to Valgrind report";
461+
std::vector<const char*> interpreter_args = {"-include", "new"};
462+
auto* I = Cpp::CreateInterpreter(interpreter_args);
463+
EXPECT_TRUE(I);
464+
465+
EXPECT_TRUE(Cpp::Declare(R"(
466+
#include <iostream>
467+
void foo(int &input) {
468+
__asm__ volatile ("addl $10, %0" : "+r"(input));
469+
}
470+
)",
471+
I) == 0);
472+
473+
bool hasError;
474+
EXPECT_TRUE(Cpp::Process("int b = 42; foo(b);") == 0);
475+
EXPECT_TRUE(Cpp::Evaluate("b", &hasError) == 52);
476+
EXPECT_FALSE(hasError);
477+
}

0 commit comments

Comments
 (0)