зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1161339 - Add gtest calling rust code. r=cajbir
This is mostly to verify compilation and linkage. The test itself just verifies the contents of an returned string. --HG-- extra : rebase_source : b35f41d565c6fda85ad010a328cd61b3c37681da
This commit is contained in:
Родитель
2ea918802d
Коммит
c832f2d6d6
|
@ -0,0 +1,8 @@
|
|||
#include <stdint.h>
|
||||
|
||||
extern "C" uint8_t* test_rust();
|
||||
|
||||
TEST(rust, CallFromCpp) {
|
||||
auto greeting = test_rust();
|
||||
EXPECT_STREQ(reinterpret_cast<char*>(greeting), "hello from rust.");
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
#[no_mangle]
|
||||
pub extern fn test_rust() -> *const u8 {
|
||||
// NB: rust &str aren't null terminated.
|
||||
let greeting = "hello from rust.\0";
|
||||
greeting.as_ptr()
|
||||
}
|
|
@ -29,6 +29,11 @@ if CONFIG['MOZ_WEBM_ENCODER']:
|
|||
'TestWebMWriter.cpp',
|
||||
]
|
||||
|
||||
if CONFIG['MOZ_RUST']:
|
||||
SOURCES += ['hello.rs',]
|
||||
UNIFIED_SOURCES += ['TestRust.cpp',]
|
||||
|
||||
|
||||
TEST_HARNESS_FILES.gtest += [
|
||||
'../test/gizmo-frag.mp4',
|
||||
'../test/gizmo.mp4',
|
||||
|
|
Загрузка…
Ссылка в новой задаче