From f230da44541724544146f9bf0f967210a9816343 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 3 May 2021 12:47:29 +0100 Subject: [PATCH] path resolution tests: cd to / for library_load and specs This tests that both client and server path resolution works. Signed-off-by: Ian Jackson --- apitest/at-otter.rs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index 8d82797b..f1966f14 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -199,6 +199,17 @@ impl Ctx { su_rc: self.su_rc.clone(), } } + + pub fn chdir_root(&mut self, f: F) + where F: FnOnce(&mut Self) -> Result<(),AE> + { + let tmp = &(*self.su_rc).borrow().ds.abstmp.clone(); + env::set_current_dir("/").expect("cd /"); + self.rctx = ResolveContext::RelativeTo(tmp.clone()); + f(self).expect("run test"); + env::set_current_dir(&tmp).expect("cd back"); + self.rctx = default(); + } } mod pi { @@ -683,9 +694,9 @@ impl Ctx { #[throws(AE)] fn tests(mut c: Ctx) { - test!(c, "library-load", c.library_load()?); - test!(c, "hidden-hand", c.hidden_hand()?); - test!(c, "specs", c.specs()?); + test!(c, "library-load", c.chdir_root(|c| c.library_load() )); + test!(c, "hidden-hand", c.hidden_hand() ?); + test!(c, "specs", c.chdir_root(|c| c.specs() )); } #[throws(AE)] -- 2.30.2