[Libguestfs] [PATCH 11/12] Rust bindings: Format test files

Hiroyuki Katsura hiroyuki.katsura.0513 at gmail.com
Tue Jul 2 13:14:29 UTC 2019


---
 rust/tests/010_load.rs              | 28 ++++++-------
 rust/tests/020_create.rs            | 28 ++++++-------
 rust/tests/030_create_flags.rs      | 29 +++++++-------
 rust/tests/040_create_multiple.rs   | 28 ++++++-------
 rust/tests/050_handle_properties.rs | 31 ++++++++-------
 rust/tests/070_opt_args.rs          | 39 ++++++++++--------
 rust/tests/080_version.rs           | 31 +++++++--------
 rust/tests/090_ret_values.rs        | 61 +++++++++++++++++++++++++++++
 8 files changed, 169 insertions(+), 106 deletions(-)
 create mode 100644 rust/tests/090_ret_values.rs

diff --git a/rust/tests/010_load.rs b/rust/tests/010_load.rs
index eadd78896..4cb43f2c1 100644
--- a/rust/tests/010_load.rs
+++ b/rust/tests/010_load.rs
@@ -1,20 +1,20 @@
-/* libguestfs Python bindings
- Copyright (C) 2009-2019 Red Hat Inc.
+/* libguestfs Rust bindings
+Copyright (C) 2009-2019 Red Hat Inc.
 
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
 
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
 
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
 
 extern crate guestfs;
 
diff --git a/rust/tests/020_create.rs b/rust/tests/020_create.rs
index 0b57b19d7..017dbbac0 100644
--- a/rust/tests/020_create.rs
+++ b/rust/tests/020_create.rs
@@ -1,20 +1,20 @@
-/* libguestfs Python bindings
- Copyright (C) 2009-2019 Red Hat Inc.
+/* libguestfs Rust bindings
+Copyright (C) 2009-2019 Red Hat Inc.
 
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
 
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
 
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
 
 extern crate guestfs;
 
diff --git a/rust/tests/030_create_flags.rs b/rust/tests/030_create_flags.rs
index 5de0589c1..df3190d4c 100644
--- a/rust/tests/030_create_flags.rs
+++ b/rust/tests/030_create_flags.rs
@@ -1,19 +1,19 @@
-/* libguestfs Python bindings
- Copyright (C) 2009-2019 Red Hat Inc.
+/* libguestfs Rust bindings
+Copyright (C) 2009-2019 Red Hat Inc.
 
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
 
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
 
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
 
 extern crate guestfs;
 
@@ -23,8 +23,7 @@ use guestfs::*;
 fn create_flags() {
     let _h = Handle::create_flags(CreateFlags::none()).expect("create_flags fail");
     // TODO: Add parse_environment to check the flag is created correctly
-    let flags = CreateFlags::new()
-        .create_no_environment(true);
+    let flags = CreateFlags::new().create_no_environment(true);
     let _h = Handle::create_flags(flags).expect("create_flags fail");
     // TODO: Add parse_environment to check the flag is created correctly
 }
diff --git a/rust/tests/040_create_multiple.rs b/rust/tests/040_create_multiple.rs
index ee481c278..372fad7ee 100644
--- a/rust/tests/040_create_multiple.rs
+++ b/rust/tests/040_create_multiple.rs
@@ -1,20 +1,20 @@
-/* libguestfs Python bindings
- Copyright (C) 2009-2019 Red Hat Inc.
+/* libguestfs Rust bindings
+Copyright (C) 2009-2019 Red Hat Inc.
 
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
 
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
 
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
 
 extern crate guestfs;
 
diff --git a/rust/tests/050_handle_properties.rs b/rust/tests/050_handle_properties.rs
index 3c7b449f9..0b955d5cf 100644
--- a/rust/tests/050_handle_properties.rs
+++ b/rust/tests/050_handle_properties.rs
@@ -1,20 +1,20 @@
-/* libguestfs Python bindings
- Copyright (C) 2009-2019 Red Hat Inc.
+/* libguestfs Rust bindings
+Copyright (C) 2009-2019 Red Hat Inc.
 
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
 
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
 
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
 
 extern crate guestfs;
 
@@ -57,5 +57,6 @@ fn path() {
 #[test]
 fn add_drive() {
     let g = guestfs::Handle::create().expect("create");
-    g.add_drive("/dev/null", Default::default()).expect("add_drive");
+    g.add_drive("/dev/null", Default::default())
+        .expect("add_drive");
 }
diff --git a/rust/tests/070_opt_args.rs b/rust/tests/070_opt_args.rs
index 241c95b35..04b4890c2 100644
--- a/rust/tests/070_opt_args.rs
+++ b/rust/tests/070_opt_args.rs
@@ -1,20 +1,20 @@
-/* libguestfs Python bindings
- Copyright (C) 2009-2019 Red Hat Inc.
+/* libguestfs Rust bindings
+Copyright (C) 2009-2019 Red Hat Inc.
 
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
 
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
 
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
 
 extern crate guestfs;
 
@@ -30,7 +30,12 @@ fn no_optargs() {
 #[test]
 fn one_optarg() {
     let g = guestfs::Handle::create().expect("create");
-    g.add_drive("/dev/null",
-        guestfs::OptArgsAddDrive::default().readonly(true))
-        .expect("add_drive");
+    g.add_drive(
+        "/dev/null",
+        guestfs::AddDriveOptArgs {
+            readonly: Some(true),
+            ..Default::default()
+        },
+    )
+    .expect("add_drive");
 }
diff --git a/rust/tests/080_version.rs b/rust/tests/080_version.rs
index ab5314edc..19e441d67 100644
--- a/rust/tests/080_version.rs
+++ b/rust/tests/080_version.rs
@@ -1,29 +1,26 @@
-/* libguestfs Python bindings
- Copyright (C) 2009-2019 Red Hat Inc.
+/* libguestfs Rust bindings
+Copyright (C) 2009-2019 Red Hat Inc.
 
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
 
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
 
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
 
 extern crate guestfs;
 
-use std::default::Default;
-
 #[test]
 fn version() {
     let g = guestfs::Handle::create().expect("create");
     let v = g.version().expect("version");
     assert_eq!(v.major, 1)
 }
-
diff --git a/rust/tests/090_ret_values.rs b/rust/tests/090_ret_values.rs
new file mode 100644
index 000000000..d3e2e80da
--- /dev/null
+++ b/rust/tests/090_ret_values.rs
@@ -0,0 +1,61 @@
+/* libguestfs Rust bindings
+Copyright (C) 2009-2019 Red Hat Inc.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+*/
+
+extern crate guestfs;
+
+#[test]
+fn rint() {
+    let g = guestfs::Handle::create().expect("create");
+    assert_eq!(g.internal_test_rint("10").unwrap(), 10);
+    assert!(g.internal_test_rinterr().is_err())
+}
+
+#[test]
+fn rint64() {
+    let g = guestfs::Handle::create().expect("create");
+    assert_eq!(g.internal_test_rint64("10").unwrap(), 10);
+    assert!(g.internal_test_rint64err().is_err())
+}
+
+#[test]
+fn rbool() {
+    let g = guestfs::Handle::create().expect("create");
+    assert!(g.internal_test_rbool("true").unwrap());
+    assert!(!g.internal_test_rbool("false").unwrap());
+    assert!(g.internal_test_rboolerr().is_err())
+}
+
+#[test]
+fn rconststring() {
+    let g = guestfs::Handle::create().expect("create");
+    assert_eq!(
+        g.internal_test_rconststring("test").unwrap(),
+        "static string"
+    );
+    assert!(g.internal_test_rconststringerr().is_err())
+}
+
+#[test]
+fn rconstoptstring() {
+    let g = guestfs::Handle::create().expect("create");
+    assert_eq!(
+        g.internal_test_rconstoptstring("test").unwrap(),
+        Some("static string")
+    );
+    assert_eq!(g.internal_test_rconstoptstringerr().unwrap(), None)
+}
-- 
2.20.1 (Apple Git-117)




More information about the Libguestfs mailing list