Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1468)

Unified Diff: mojo/public/rust/tests/util/mod.rs

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/rust/tests/system.rs ('k') | mojo/public/rust/tests/util/mojom_validation.rs » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/rust/tests/util/mod.rs
diff --git a/mojo/public/rust/tests/util/mod.rs b/mojo/public/rust/tests/util/mod.rs
deleted file mode 100644
index b72b24c7da3215aa4deb7c480f1f04dab27bda36..0000000000000000000000000000000000000000
--- a/mojo/public/rust/tests/util/mod.rs
+++ /dev/null
@@ -1,95 +0,0 @@
-// Copyright 2016 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-//! This module contains useful functions and macros for testing.
-
-pub mod mojom_validation;
-
-use std::ffi::{CStr, CString};
-use std::os::raw::c_char;
-use std::slice;
-use std::ptr;
-
-/// This macro sets up tests by adding in Mojo embedder
-/// initialization.
-macro_rules! tests {
- ( $( $( #[ $attr:meta ] )* fn $i:ident() $b:block)* ) => {
- use std::sync::{Once, ONCE_INIT};
- static START: Once = ONCE_INIT;
- $(
- #[test]
- $(
- #[ $attr ]
- )*
- fn $i() {
- START.call_once(|| unsafe {
- util::InitializeMojoEmbedder();
- });
- $b
- }
- )*
- }
-}
-
-#[link(name = "stdc++")]
-extern "C" {}
-
-#[link(name = "c")]
-extern "C" {
- fn free(ptr: *mut u8);
-}
-
-#[link(name = "rust_embedder")]
-extern "C" {
- pub fn InitializeMojoEmbedder();
-}
-
-#[link(name = "validation_parser")]
-extern "C" {
- #[allow(dead_code)]
- fn ParseValidationTest(input: *const c_char,
- num_handles: *mut usize,
- data: *mut *mut u8,
- data_len: *mut usize)
- -> *mut c_char;
-}
-
-#[allow(dead_code)]
-pub fn parse_validation_test(input: &str) -> Result<(Vec<u8>, usize), String> {
- let input_c = CString::new(input.to_string()).unwrap();
- let mut num_handles: usize = 0;
- let mut data: *mut u8 = ptr::null_mut();
- let mut data_len: usize = 0;
- let error = unsafe {
- ParseValidationTest(input_c.as_ptr(),
- &mut num_handles as *mut usize,
- &mut data as *mut *mut u8,
- &mut data_len as *mut usize)
- };
- if error == ptr::null_mut() {
- if data == ptr::null_mut() || data_len == 0 {
- // We assume we were just given an empty file
- Ok((Vec::new(), 0))
- } else {
- // Make a copy of the buffer
- let buffer;
- unsafe {
- buffer = slice::from_raw_parts(data, data_len).to_vec();
- free(data);
- }
- Ok((buffer, num_handles))
- }
- } else {
- let err_str;
- unsafe {
- // Copy the error string
- err_str = CStr::from_ptr(error)
- .to_str()
- .expect("Could not convert error message to UTF-8!")
- .to_owned();
- free(error as *mut u8);
- }
- Err(err_str)
- }
-}
« no previous file with comments | « mojo/public/rust/tests/system.rs ('k') | mojo/public/rust/tests/util/mojom_validation.rs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698