Wrap part of //aos:init for Rust

Just enough to run tests for now.

Change-Id: I714fbabfe713b34494a0a47a5679c409cce211c4
Signed-off-by: Brian Silverman <bsilver16384@gmail.com>
diff --git a/aos/init.rs b/aos/init.rs
new file mode 100644
index 0000000..8a5f262
--- /dev/null
+++ b/aos/init.rs
@@ -0,0 +1,29 @@
+use std::{ffi::CString, sync::Once};
+
+autocxx::include_cpp! (
+#include "aos/init.h"
+
+safety!(unsafe)
+
+generate!("aos::InitFromRust")
+);
+
+/// Initializes things for a test.
+///
+/// TODO(Brian): Should we provide a proc macro attribute that handles calling this?
+///
+/// # Panics
+///
+/// Panics if non-test initialization has already been performed.
+pub fn test_init() {
+    static ONCE: Once = Once::new();
+    ONCE.call_once(|| {
+        let argv0 = std::env::args().next().expect("must have argv[0]");
+        let argv0 = CString::new(argv0).expect("argv[0] may not have NUL");
+        // SAFETY: argv0 is a NUL-terminated string.
+        unsafe { ffi::aos::InitFromRust(argv0.as_ptr()) };
+    });
+
+    // TODO(Brian): Do we want any of the other stuff that `:gtest_main` has?
+    // TODO(Brian): Call `aos::SetShmBase` like `:gtest_main` does.
+}