Richard W.M. Jones
2019-Jun-27 08:52 UTC
Re: [Libguestfs] [PATCH 3/9] Rust bindings: Add 4 bindings tests
On Thu, Jun 27, 2019 at 05:06:04PM +0900, Hiroyuki Katsura wrote:> From: Hiroyuki_Katsura <hiroyuki.katsura.0513@gmail.com> > > --- > generator/rust.ml | 13 ++++++++--- > run.in | 9 ++++++++ > rust/Cargo.lock | 6 +++++ > rust/Cargo.toml | 4 +--- > rust/tests/010_load.rs | 24 +++++++++++++++++++ > rust/tests/020_create.rs | 24 +++++++++++++++++++ > rust/tests/030_create_flags.rs | 30 ++++++++++++++++++++++++ > rust/tests/040_create_multiple.rs | 38 +++++++++++++++++++++++++++++++ > 8 files changed, 142 insertions(+), 6 deletions(-) > create mode 100644 rust/Cargo.lock > create mode 100644 rust/tests/010_load.rs > create mode 100644 rust/tests/020_create.rs > create mode 100644 rust/tests/030_create_flags.rs > create mode 100644 rust/tests/040_create_multiple.rs > > diff --git a/generator/rust.ml b/generator/rust.ml > index dbe9db010..251eb1594 100644 > --- a/generator/rust.ml > +++ b/generator/rust.ml > @@ -37,14 +37,16 @@ let generate_rust () > #[allow(non_camel_case_types)] > enum guestfs_h {} > > +#[link(name = \"guestfs\")] > extern \"C\" { > fn guestfs_create() -> *mut guestfs_h; > fn guestfs_create_flags(flags: i64) -> *mut guestfs_h; > fn guestfs_close(g: *mut guestfs_h); > - static GUESTFS_CREATE_NO_ENVIRONMENT: i64; > - static GUESTFS_CREATE_NO_CLOSE_ON_EXIT: i64; > } > > +const GUESTFS_CREATE_NO_ENVIRONMENT: i64 = 1; > +const GUESTFS_CREATE_NO_CLOSE_ON_EXIT: i64 = 2; > + > pub struct Handle { > g: *mut guestfs_h, > } > @@ -61,13 +63,17 @@ pub struct CreateFlags { > } > > impl CreateFlags { > - pub fn new() -> CreateFlags { > + pub fn none() -> CreateFlags { > CreateFlags { > create_no_environment_flag: false, > create_no_close_on_exit_flag: false, > } > } > > + pub fn new() -> CreateFlags { > + CreateFlags::none() > + } > + > pub fn create_no_environment(mut self, flag: bool) -> CreateFlags { > self.create_no_environment_flag = flag; > selfShouldn't these changes be folded into patch 2?> @@ -97,6 +103,7 @@ impl CreateFlags { > impl Handle { > pub fn create() -> Result<Handle, &'static str> { > let g = unsafe { guestfs_create() }; > + println!(\"hoge\");I guess this is a stray debug message?> if g.is_null() { > Err(\"failed to create guestfs handle\") > } else { > diff --git a/run.in b/run.in > index 488e1b937..301b02664 100755 > --- a/run.in > +++ b/run.in > @@ -201,6 +201,15 @@ else > fi > export CGO_LDFLAGS > > +# For rust > +export RUST="@RUST@" > +if [ -z "$RUSTFLAGS" ]; then > + RUSTFLAGS="-C link-args=-L$b/lib/.libs" > +else > + RUSTFLAGS="$RUSTFLAGS -C link-args=-L$b/lib/.libs" > +fi > +export RUSTFLAGS > + > # For GObject, Javascript and friends. > export GJS="@GJS@" > prepend GI_TYPELIB_PATH "$b/gobject" > diff --git a/rust/Cargo.lock b/rust/Cargo.lock > new file mode 100644 > index 000000000..c03586e3f > --- /dev/null > +++ b/rust/Cargo.lock > @@ -0,0 +1,6 @@ > +# This file is automatically @generated by Cargo. > +# It is not intended for manual editing. > +[[package]] > +name = "guestfs" > +version = "0.1.0" > + > diff --git a/rust/Cargo.toml b/rust/Cargo.toml > index 6cd94ce6a..4ea7c299b 100644 > --- a/rust/Cargo.toml > +++ b/rust/Cargo.toml > @@ -1,8 +1,6 @@ > [package] > -name = "rust" > +name = "guestfs" > version = "0.1.0" > edition = "2018" > > [dependencies] > -libc = "0.2" > -In nbdkit we added Cargo.lock and Cargo.toml to .gitignore and we did *not* check them into git.> diff --git a/rust/tests/010_load.rs b/rust/tests/010_load.rs > new file mode 100644 > index 000000000..eadd78896 > --- /dev/null > +++ b/rust/tests/010_load.rs > @@ -0,0 +1,24 @@ > +/* libguestfs Python 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 load() { > + // nop > +} > diff --git a/rust/tests/020_create.rs b/rust/tests/020_create.rs > new file mode 100644 > index 000000000..0b57b19d7 > --- /dev/null > +++ b/rust/tests/020_create.rs > @@ -0,0 +1,24 @@ > +/* libguestfs Python 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 create() { > + assert!(!guestfs::Handle::create().is_err(), "create fail"); > +} > diff --git a/rust/tests/030_create_flags.rs b/rust/tests/030_create_flags.rs > new file mode 100644 > index 000000000..5de0589c1 > --- /dev/null > +++ b/rust/tests/030_create_flags.rs > @@ -0,0 +1,30 @@ > +/* libguestfs Python 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; > + > +use guestfs::*; > + > +#[test] > +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 _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 > new file mode 100644 > index 000000000..ee481c278 > --- /dev/null > +++ b/rust/tests/040_create_multiple.rs > @@ -0,0 +1,38 @@ > +/* libguestfs Python 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; > + > +fn create() -> guestfs::Handle { > + match guestfs::Handle::create() { > + Ok(g) => g, > + Err(e) => panic!("fail: {}", e), > + } > +} > + > +fn ignore(_x: guestfs::Handle, _y: guestfs::Handle, _z: guestfs::Handle) { > + // drop > +} > + > +#[test] > +fn create_multiple() { > + let x = create(); > + let y = create(); > + let z = create(); > + ignore(x, y, z) > +} > -- > 2.20.1 (Apple Git-117)The actual test parts of this patch are fine, but you need to spend a bit of time with ‘git rebase -i’ to move parts of patch 3 into patch 2. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/
Hiroyuki Katsura
2019-Jun-27 09:27 UTC
Re: [Libguestfs] [PATCH 3/9] Rust bindings: Add 4 bindings tests
> I guess this is a stray debug message?Yes. I'm sorry...> we did *not* check them into git.Really? Does it mean that every time you build the library, Cargo.toml is generated?> The actual test parts of this patch are fine, but you need to spend a > bit of time with ‘git rebase -i’ to move parts of patch 3 into patch 2.Does this mean that the followings should be moved to patch 2? generator/rust.ml | 13 ++++++++--- run.in | 9 ++++++++ rust/Cargo.lock | 6 +++++ rust/Cargo.toml | 4 +--- Regards, Hiroyuki 2019年6月27日(木) 17:52 Richard W.M. Jones <rjones@redhat.com>:> On Thu, Jun 27, 2019 at 05:06:04PM +0900, Hiroyuki Katsura wrote: > > From: Hiroyuki_Katsura <hiroyuki.katsura.0513@gmail.com> > > > > --- > > generator/rust.ml | 13 ++++++++--- > > run.in | 9 ++++++++ > > rust/Cargo.lock | 6 +++++ > > rust/Cargo.toml | 4 +--- > > rust/tests/010_load.rs | 24 +++++++++++++++++++ > > rust/tests/020_create.rs | 24 +++++++++++++++++++ > > rust/tests/030_create_flags.rs | 30 ++++++++++++++++++++++++ > > rust/tests/040_create_multiple.rs | 38 +++++++++++++++++++++++++++++++ > > 8 files changed, 142 insertions(+), 6 deletions(-) > > create mode 100644 rust/Cargo.lock > > create mode 100644 rust/tests/010_load.rs > > create mode 100644 rust/tests/020_create.rs > > create mode 100644 rust/tests/030_create_flags.rs > > create mode 100644 rust/tests/040_create_multiple.rs > > > > diff --git a/generator/rust.ml b/generator/rust.ml > > index dbe9db010..251eb1594 100644 > > --- a/generator/rust.ml > > +++ b/generator/rust.ml > > @@ -37,14 +37,16 @@ let generate_rust () > > #[allow(non_camel_case_types)] > > enum guestfs_h {} > > > > +#[link(name = \"guestfs\")] > > extern \"C\" { > > fn guestfs_create() -> *mut guestfs_h; > > fn guestfs_create_flags(flags: i64) -> *mut guestfs_h; > > fn guestfs_close(g: *mut guestfs_h); > > - static GUESTFS_CREATE_NO_ENVIRONMENT: i64; > > - static GUESTFS_CREATE_NO_CLOSE_ON_EXIT: i64; > > } > > > > +const GUESTFS_CREATE_NO_ENVIRONMENT: i64 = 1; > > +const GUESTFS_CREATE_NO_CLOSE_ON_EXIT: i64 = 2; > > + > > pub struct Handle { > > g: *mut guestfs_h, > > } > > @@ -61,13 +63,17 @@ pub struct CreateFlags { > > } > > > > impl CreateFlags { > > - pub fn new() -> CreateFlags { > > + pub fn none() -> CreateFlags { > > CreateFlags { > > create_no_environment_flag: false, > > create_no_close_on_exit_flag: false, > > } > > } > > > > + pub fn new() -> CreateFlags { > > + CreateFlags::none() > > + } > > + > > pub fn create_no_environment(mut self, flag: bool) -> CreateFlags { > > self.create_no_environment_flag = flag; > > self > > Shouldn't these changes be folded into patch 2? > > > @@ -97,6 +103,7 @@ impl CreateFlags { > > impl Handle { > > pub fn create() -> Result<Handle, &'static str> { > > let g = unsafe { guestfs_create() }; > > + println!(\"hoge\"); > > I guess this is a stray debug message? > > > if g.is_null() { > > Err(\"failed to create guestfs handle\") > > } else { > > diff --git a/run.in b/run.in > > index 488e1b937..301b02664 100755 > > --- a/run.in > > +++ b/run.in > > @@ -201,6 +201,15 @@ else > > fi > > export CGO_LDFLAGS > > > > +# For rust > > +export RUST="@RUST@" > > +if [ -z "$RUSTFLAGS" ]; then > > + RUSTFLAGS="-C link-args=-L$b/lib/.libs" > > +else > > + RUSTFLAGS="$RUSTFLAGS -C link-args=-L$b/lib/.libs" > > +fi > > +export RUSTFLAGS > > + > > # For GObject, Javascript and friends. > > export GJS="@GJS@" > > prepend GI_TYPELIB_PATH "$b/gobject" > > diff --git a/rust/Cargo.lock b/rust/Cargo.lock > > new file mode 100644 > > index 000000000..c03586e3f > > --- /dev/null > > +++ b/rust/Cargo.lock > > @@ -0,0 +1,6 @@ > > +# This file is automatically @generated by Cargo. > > +# It is not intended for manual editing. > > +[[package]] > > +name = "guestfs" > > +version = "0.1.0" > > + > > diff --git a/rust/Cargo.toml b/rust/Cargo.toml > > index 6cd94ce6a..4ea7c299b 100644 > > --- a/rust/Cargo.toml > > +++ b/rust/Cargo.toml > > @@ -1,8 +1,6 @@ > > [package] > > -name = "rust" > > +name = "guestfs" > > version = "0.1.0" > > edition = "2018" > > > > [dependencies] > > -libc = "0.2" > > - > > In nbdkit we added Cargo.lock and Cargo.toml to .gitignore and > we did *not* check them into git. > > > diff --git a/rust/tests/010_load.rs b/rust/tests/010_load.rs > > new file mode 100644 > > index 000000000..eadd78896 > > --- /dev/null > > +++ b/rust/tests/010_load.rs > > @@ -0,0 +1,24 @@ > > +/* libguestfs Python 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 load() { > > + // nop > > +} > > diff --git a/rust/tests/020_create.rs b/rust/tests/020_create.rs > > new file mode 100644 > > index 000000000..0b57b19d7 > > --- /dev/null > > +++ b/rust/tests/020_create.rs > > @@ -0,0 +1,24 @@ > > +/* libguestfs Python 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 create() { > > + assert!(!guestfs::Handle::create().is_err(), "create fail"); > > +} > > diff --git a/rust/tests/030_create_flags.rs b/rust/tests/ > 030_create_flags.rs > > new file mode 100644 > > index 000000000..5de0589c1 > > --- /dev/null > > +++ b/rust/tests/030_create_flags.rs > > @@ -0,0 +1,30 @@ > > +/* libguestfs Python 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; > > + > > +use guestfs::*; > > + > > +#[test] > > +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 _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 > > new file mode 100644 > > index 000000000..ee481c278 > > --- /dev/null > > +++ b/rust/tests/040_create_multiple.rs > > @@ -0,0 +1,38 @@ > > +/* libguestfs Python 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; > > + > > +fn create() -> guestfs::Handle { > > + match guestfs::Handle::create() { > > + Ok(g) => g, > > + Err(e) => panic!("fail: {}", e), > > + } > > +} > > + > > +fn ignore(_x: guestfs::Handle, _y: guestfs::Handle, _z: > guestfs::Handle) { > > + // drop > > +} > > + > > +#[test] > > +fn create_multiple() { > > + let x = create(); > > + let y = create(); > > + let z = create(); > > + ignore(x, y, z) > > +} > > -- > > 2.20.1 (Apple Git-117) > > The actual test parts of this patch are fine, but you need to spend a > bit of time with ‘git rebase -i’ to move parts of patch 3 into patch 2. > > Rich. > > -- > Richard Jones, Virtualization Group, Red Hat > http://people.redhat.com/~rjones > Read my programming and virtualization blog: http://rwmj.wordpress.com > virt-df lists disk usage of guests without needing to install any > software inside the virtual machine. Supports Linux and Windows. > http://people.redhat.com/~rjones/virt-df/ >
Richard W.M. Jones
2019-Jun-27 09:51 UTC
Re: [Libguestfs] [PATCH 3/9] Rust bindings: Add 4 bindings tests
On Thu, Jun 27, 2019 at 06:27:05PM +0900, Hiroyuki Katsura wrote:> > I guess this is a stray debug message? > > Yes. I'm sorry... > > > we did *not* check them into git. > > Really? Does it mean that every time you build the library, Cargo.toml is > generated?That's how it has worked in nbdkit. Whether it's right or not I don't know. Normally we wouldn't check generated files into git.> > The actual test parts of this patch are fine, but you need to spend a > > bit of time with ‘git rebase -i’ to move parts of patch 3 into patch 2. > > Does this mean that the followings should be moved to patch 2? > > generator/rust.ml | 13 ++++++++--- > run.in | 9 ++++++++ > rust/Cargo.lock | 6 +++++ > rust/Cargo.toml | 4 +---I think so, except maybe the Cargo.* files might not be included at all - see above. Rich.> Regards, > Hiroyuki > > > 2019年6月27日(木) 17:52 Richard W.M. Jones <rjones@redhat.com>: > > > On Thu, Jun 27, 2019 at 05:06:04PM +0900, Hiroyuki Katsura wrote: > > > From: Hiroyuki_Katsura <hiroyuki.katsura.0513@gmail.com> > > > > > > --- > > > generator/rust.ml | 13 ++++++++--- > > > run.in | 9 ++++++++ > > > rust/Cargo.lock | 6 +++++ > > > rust/Cargo.toml | 4 +--- > > > rust/tests/010_load.rs | 24 +++++++++++++++++++ > > > rust/tests/020_create.rs | 24 +++++++++++++++++++ > > > rust/tests/030_create_flags.rs | 30 ++++++++++++++++++++++++ > > > rust/tests/040_create_multiple.rs | 38 +++++++++++++++++++++++++++++++ > > > 8 files changed, 142 insertions(+), 6 deletions(-) > > > create mode 100644 rust/Cargo.lock > > > create mode 100644 rust/tests/010_load.rs > > > create mode 100644 rust/tests/020_create.rs > > > create mode 100644 rust/tests/030_create_flags.rs > > > create mode 100644 rust/tests/040_create_multiple.rs > > > > > > diff --git a/generator/rust.ml b/generator/rust.ml > > > index dbe9db010..251eb1594 100644 > > > --- a/generator/rust.ml > > > +++ b/generator/rust.ml > > > @@ -37,14 +37,16 @@ let generate_rust () > > > #[allow(non_camel_case_types)] > > > enum guestfs_h {} > > > > > > +#[link(name = \"guestfs\")] > > > extern \"C\" { > > > fn guestfs_create() -> *mut guestfs_h; > > > fn guestfs_create_flags(flags: i64) -> *mut guestfs_h; > > > fn guestfs_close(g: *mut guestfs_h); > > > - static GUESTFS_CREATE_NO_ENVIRONMENT: i64; > > > - static GUESTFS_CREATE_NO_CLOSE_ON_EXIT: i64; > > > } > > > > > > +const GUESTFS_CREATE_NO_ENVIRONMENT: i64 = 1; > > > +const GUESTFS_CREATE_NO_CLOSE_ON_EXIT: i64 = 2; > > > + > > > pub struct Handle { > > > g: *mut guestfs_h, > > > } > > > @@ -61,13 +63,17 @@ pub struct CreateFlags { > > > } > > > > > > impl CreateFlags { > > > - pub fn new() -> CreateFlags { > > > + pub fn none() -> CreateFlags { > > > CreateFlags { > > > create_no_environment_flag: false, > > > create_no_close_on_exit_flag: false, > > > } > > > } > > > > > > + pub fn new() -> CreateFlags { > > > + CreateFlags::none() > > > + } > > > + > > > pub fn create_no_environment(mut self, flag: bool) -> CreateFlags { > > > self.create_no_environment_flag = flag; > > > self > > > > Shouldn't these changes be folded into patch 2? > > > > > @@ -97,6 +103,7 @@ impl CreateFlags { > > > impl Handle { > > > pub fn create() -> Result<Handle, &'static str> { > > > let g = unsafe { guestfs_create() }; > > > + println!(\"hoge\"); > > > > I guess this is a stray debug message? > > > > > if g.is_null() { > > > Err(\"failed to create guestfs handle\") > > > } else { > > > diff --git a/run.in b/run.in > > > index 488e1b937..301b02664 100755 > > > --- a/run.in > > > +++ b/run.in > > > @@ -201,6 +201,15 @@ else > > > fi > > > export CGO_LDFLAGS > > > > > > +# For rust > > > +export RUST="@RUST@" > > > +if [ -z "$RUSTFLAGS" ]; then > > > + RUSTFLAGS="-C link-args=-L$b/lib/.libs" > > > +else > > > + RUSTFLAGS="$RUSTFLAGS -C link-args=-L$b/lib/.libs" > > > +fi > > > +export RUSTFLAGS > > > + > > > # For GObject, Javascript and friends. > > > export GJS="@GJS@" > > > prepend GI_TYPELIB_PATH "$b/gobject" > > > diff --git a/rust/Cargo.lock b/rust/Cargo.lock > > > new file mode 100644 > > > index 000000000..c03586e3f > > > --- /dev/null > > > +++ b/rust/Cargo.lock > > > @@ -0,0 +1,6 @@ > > > +# This file is automatically @generated by Cargo. > > > +# It is not intended for manual editing. > > > +[[package]] > > > +name = "guestfs" > > > +version = "0.1.0" > > > + > > > diff --git a/rust/Cargo.toml b/rust/Cargo.toml > > > index 6cd94ce6a..4ea7c299b 100644 > > > --- a/rust/Cargo.toml > > > +++ b/rust/Cargo.toml > > > @@ -1,8 +1,6 @@ > > > [package] > > > -name = "rust" > > > +name = "guestfs" > > > version = "0.1.0" > > > edition = "2018" > > > > > > [dependencies] > > > -libc = "0.2" > > > - > > > > In nbdkit we added Cargo.lock and Cargo.toml to .gitignore and > > we did *not* check them into git. > > > > > diff --git a/rust/tests/010_load.rs b/rust/tests/010_load.rs > > > new file mode 100644 > > > index 000000000..eadd78896 > > > --- /dev/null > > > +++ b/rust/tests/010_load.rs > > > @@ -0,0 +1,24 @@ > > > +/* libguestfs Python 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 load() { > > > + // nop > > > +} > > > diff --git a/rust/tests/020_create.rs b/rust/tests/020_create.rs > > > new file mode 100644 > > > index 000000000..0b57b19d7 > > > --- /dev/null > > > +++ b/rust/tests/020_create.rs > > > @@ -0,0 +1,24 @@ > > > +/* libguestfs Python 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 create() { > > > + assert!(!guestfs::Handle::create().is_err(), "create fail"); > > > +} > > > diff --git a/rust/tests/030_create_flags.rs b/rust/tests/ > > 030_create_flags.rs > > > new file mode 100644 > > > index 000000000..5de0589c1 > > > --- /dev/null > > > +++ b/rust/tests/030_create_flags.rs > > > @@ -0,0 +1,30 @@ > > > +/* libguestfs Python 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; > > > + > > > +use guestfs::*; > > > + > > > +#[test] > > > +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 _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 > > > new file mode 100644 > > > index 000000000..ee481c278 > > > --- /dev/null > > > +++ b/rust/tests/040_create_multiple.rs > > > @@ -0,0 +1,38 @@ > > > +/* libguestfs Python 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; > > > + > > > +fn create() -> guestfs::Handle { > > > + match guestfs::Handle::create() { > > > + Ok(g) => g, > > > + Err(e) => panic!("fail: {}", e), > > > + } > > > +} > > > + > > > +fn ignore(_x: guestfs::Handle, _y: guestfs::Handle, _z: > > guestfs::Handle) { > > > + // drop > > > +} > > > + > > > +#[test] > > > +fn create_multiple() { > > > + let x = create(); > > > + let y = create(); > > > + let z = create(); > > > + ignore(x, y, z) > > > +} > > > -- > > > 2.20.1 (Apple Git-117) > > > > The actual test parts of this patch are fine, but you need to spend a > > bit of time with ‘git rebase -i’ to move parts of patch 3 into patch 2. > > > > Rich. > > > > -- > > Richard Jones, Virtualization Group, Red Hat > > http://people.redhat.com/~rjones > > Read my programming and virtualization blog: http://rwmj.wordpress.com > > virt-df lists disk usage of guests without needing to install any > > software inside the virtual machine. Supports Linux and Windows. > > http://people.redhat.com/~rjones/virt-df/ > >-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/