[opentitantool] Fix OTP tests to work under bazel

Moves OTP test data to a more appropriate location and adds them to the
bazel BUILD file to fix "file not found" errors encountered when running
`bazel run //sw/host/opentitanlib:opentitanlib_test`.

Signed-off-by: Jon Flatley <jflat@google.com>
diff --git a/sw/host/opentitanlib/BUILD b/sw/host/opentitanlib/BUILD
index 0273769..71aee5b 100644
--- a/sw/host/opentitanlib/BUILD
+++ b/sw/host/opentitanlib/BUILD
@@ -82,5 +82,9 @@
     data = [
         "src/util/testdata/hello.txt",
         "src/util/testdata/world.txt",
+        "src/otp/testdata/lc_ctrl_state.hjson",
+        "src/otp/testdata/otp_ctrl_img_dev.hjson",
+        "src/otp/testdata/otp_ctrl_mmap.hjson",
+        "src/otp/testdata/output.vmem",
     ],
 )
diff --git a/sw/host/opentitanlib/src/otp/lc_state.rs b/sw/host/opentitanlib/src/otp/lc_state.rs
index 813d8da..5592738 100644
--- a/sw/host/opentitanlib/src/otp/lc_state.rs
+++ b/sw/host/opentitanlib/src/otp/lc_state.rs
@@ -73,13 +73,14 @@
 #[cfg(test)]
 mod tests {
     use super::*;
+    use crate::otp::tests::testdata;
     use anyhow::Result;
     use deser_hjson::from_str;
     use std::fs::read_to_string;
 
     #[test]
     fn test_lc_state_deserialize() -> Result<()> {
-        let _: LcState = from_str(&read_to_string("tests/lc_ctrl_state.hjson")?)?;
+        let _: LcState = from_str(&read_to_string(&testdata("lc_ctrl_state.hjson"))?)?;
         Ok(())
     }
 
diff --git a/sw/host/opentitanlib/src/otp/mod.rs b/sw/host/opentitanlib/src/otp/mod.rs
index 8465483..635dcdf 100644
--- a/sw/host/opentitanlib/src/otp/mod.rs
+++ b/sw/host/opentitanlib/src/otp/mod.rs
@@ -16,15 +16,21 @@
     use anyhow::Result;
     use std::path::Path;
 
+    pub(crate) fn testdata(s: &str) -> String {
+        let mut result = "sw/host/opentitanlib/src/otp/testdata/".to_string();
+        result.push_str(s);
+        result
+    }
+
     #[test]
     fn test_vmem_serialize() -> Result<()> {
-        let mut otp_mmap = otp_mmap::OtpMap::new(Path::new("tests/otp_ctrl_mmap.hjson"))?;
-        let mut otp_img = otp_img::OtpImg::new(Path::new("tests/otp_ctrl_img_dev.hjson"))?;
-        let lc_state = lc_state::LcSecded::new(Path::new("tests/lc_ctrl_state.hjson"))?;
+        let mut otp_mmap = otp_mmap::OtpMap::new(Path::new(&testdata("otp_ctrl_mmap.hjson")))?;
+        let mut otp_img = otp_img::OtpImg::new(Path::new(&testdata("otp_ctrl_img_dev.hjson")))?;
+        let lc_state = lc_state::LcSecded::new(Path::new(&testdata("lc_ctrl_state.hjson")))?;
         let vmem = otp_mmap.make_vmem(&mut otp_img)?;
         let keys = otp_mmap.generate_keys(&otp_img);
         let result = vmem.generate(keys, &lc_state)?;
-        let expected = std::fs::read_to_string(Path::new("tests/output.vmem"))?;
+        let expected = std::fs::read_to_string(Path::new(&testdata("output.vmem")))?;
         let expected = expected
             .split("\n")
             .filter(|s| !s.is_empty())
diff --git a/sw/host/opentitanlib/src/otp/otp_mmap.rs b/sw/host/opentitanlib/src/otp/otp_mmap.rs
index e6960c3..0a6be49 100644
--- a/sw/host/opentitanlib/src/otp/otp_mmap.rs
+++ b/sw/host/opentitanlib/src/otp/otp_mmap.rs
@@ -190,18 +190,20 @@
 #[cfg(test)]
 mod tests {
     use super::*;
+    use crate::otp::tests::testdata;
     use std::fs::read_to_string;
 
     #[test]
     fn test_mmap_deserialize() {
         let _: OtpMap =
-            deser_hjson::from_str(&read_to_string("tests/otp_ctrl_mmap.hjson").unwrap()).unwrap();
+            deser_hjson::from_str(&read_to_string(testdata("otp_ctrl_mmap.hjson")).unwrap())
+                .unwrap();
     }
 
     #[test]
     fn test_img_deserialize() {
         let _: OtpImg =
-            deser_hjson::from_str(&read_to_string("tests/otp_ctrl_img_dev.hjson").unwrap())
+            deser_hjson::from_str(&read_to_string(testdata("otp_ctrl_img_dev.hjson")).unwrap())
                 .unwrap();
     }
 }
diff --git a/sw/host/opentitanlib/tests/lc_ctrl_state.hjson b/sw/host/opentitanlib/src/otp/testdata/lc_ctrl_state.hjson
similarity index 100%
rename from sw/host/opentitanlib/tests/lc_ctrl_state.hjson
rename to sw/host/opentitanlib/src/otp/testdata/lc_ctrl_state.hjson
diff --git a/sw/host/opentitanlib/tests/otp_ctrl_img_dev.hjson b/sw/host/opentitanlib/src/otp/testdata/otp_ctrl_img_dev.hjson
similarity index 100%
rename from sw/host/opentitanlib/tests/otp_ctrl_img_dev.hjson
rename to sw/host/opentitanlib/src/otp/testdata/otp_ctrl_img_dev.hjson
diff --git a/sw/host/opentitanlib/tests/otp_ctrl_mmap.hjson b/sw/host/opentitanlib/src/otp/testdata/otp_ctrl_mmap.hjson
similarity index 100%
rename from sw/host/opentitanlib/tests/otp_ctrl_mmap.hjson
rename to sw/host/opentitanlib/src/otp/testdata/otp_ctrl_mmap.hjson
diff --git a/sw/host/opentitanlib/tests/output.vmem b/sw/host/opentitanlib/src/otp/testdata/output.vmem
similarity index 100%
rename from sw/host/opentitanlib/tests/output.vmem
rename to sw/host/opentitanlib/src/otp/testdata/output.vmem