[test] Add test for symbol version names

- Add a shell script that checks all `link_name`s are in the
  right format and correct `link` attribute appears exactly once.
- Add tests/symbol_version_name.rs that calls out to the script.

Closes #8

Change-Id: I2d433fcee343c131f6e67a86902602f1d81cf199
diff --git a/boringssl/test_symbol_version_name.sh b/boringssl/test_symbol_version_name.sh
new file mode 100755
index 0000000..4491441
--- /dev/null
+++ b/boringssl/test_symbol_version_name.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+# cd to the directory this script lives in
+readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+cd "$SCRIPT_DIR"
+
+if [ $# -ne 3 ]; then
+    echo "Usage: $0 <major> <minor> <patch>" >&2
+    exit 1
+fi
+
+MAJOR="$1"
+MINOR="$2"
+PATCH="$3"
+
+LINK_PATTERN="crypto_${MAJOR}_${MINOR}_${PATCH}"
+LINK_RESULT=$(grep "#\[link(name = \"${LINK_PATTERN}\")\]" boringssl.rs | wc -l)
+if [ "$LINK_RESULT" -ne 1 ]; then
+    echo "link attribute missing or incorrect"
+    exit 1
+fi
+
+LINK_NAME_PATTERN="__RUST_MUNDANE_${MAJOR}_${MINOR}_${PATCH}_[A-Za-z0-9_]\+"
+LINK_NAME_RESULT=$(grep -n "#\[link_name = \".*\"\]" boringssl.rs \
+                   | grep -v "#\[link_name = \"${LINK_NAME_PATTERN}\"\]")
+if [[ ! -z "$LINK_NAME_RESULT" ]]; then
+    echo "Mismatched link_name attribute(s) found:"
+    echo "$LINK_NAME_RESULT"
+    exit 1
+fi
+
+exit 0
diff --git a/tests/symbol_version_name.rs b/tests/symbol_version_name.rs
new file mode 100644
index 0000000..7dbf2ad
--- /dev/null
+++ b/tests/symbol_version_name.rs
@@ -0,0 +1,23 @@
+use std::process::Command;
+
+// Relative to CARGO_MANIFEST_DIR
+const TEST_SCRIPT: &str = "boringssl/test_symbol_version_name.sh";
+
+#[test]
+fn test_symbol_version_name() {
+    let manifest_dir = env!("CARGO_MANIFEST_DIR");
+    let test_script = format!("{}/{}", manifest_dir, TEST_SCRIPT);
+    let major = env!("CARGO_PKG_VERSION_MAJOR");
+    let minor = env!("CARGO_PKG_VERSION_MINOR");
+    let patch = env!("CARGO_PKG_VERSION_PATCH");
+
+    let status = Command::new("bash")
+        .arg(test_script)
+        .arg(major)
+        .arg(minor)
+        .arg(patch)
+        .status()
+        .expect("failed to execute script");
+
+    assert!(status.success());
+}