Skip to content

Commit 73067a6

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

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

unittests/CppInterOp/InterpreterTest.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,3 +448,34 @@ 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 (defined(_M_ARM) || defined(_M_ARM64))
460+
GTEST_SKIP() << "Skipped on ARM, we test ASM for x86_64";
461+
#endif
462+
463+
if (llvm::sys::RunningOnValgrind())
464+
GTEST_SKIP() << "XFAIL due to Valgrind report";
465+
std::vector<const char*> interpreter_args = {"-include", "new"};
466+
auto* I = Cpp::CreateInterpreter(interpreter_args);
467+
EXPECT_TRUE(I);
468+
469+
EXPECT_TRUE(Cpp::Declare(R"(
470+
#include <iostream>
471+
void foo(int &input) {
472+
__asm__ volatile ("addl $10, %0" : "+r"(input));
473+
}
474+
)",
475+
I) == 0);
476+
477+
bool hasError;
478+
EXPECT_TRUE(Cpp::Process("int b = 42; foo(b);") == 0);
479+
EXPECT_TRUE(Cpp::Evaluate("b", &hasError) == 52);
480+
EXPECT_FALSE(hasError);
481+
}

0 commit comments

Comments
 (0)