[Libguestfs] [PATCH 2/3 take 2] Use LUA variable to determine with which Lua version the tests are run

Hilko Bengen bengen at hilluzination.de
Thu Dec 13 20:56:03 UTC 2012


---
 configure.ac                         |   15 +++++++++
 lua/run-bindtests                    |    4 ++-
 lua/tests/010-load.lua               |   19 -----------
 lua/tests/010-load.lua.in            |   19 +++++++++++
 lua/tests/015-globals.lua            |   26 ---------------
 lua/tests/015-globals.lua.in         |   26 +++++++++++++++
 lua/tests/020-create.lua             |   21 ------------
 lua/tests/020-create.lua.in          |   21 ++++++++++++
 lua/tests/025-create-flags.lua       |   21 ------------
 lua/tests/025-create-flags.lua.in    |   21 ++++++++++++
 lua/tests/027-create-multiple.lua    |   32 ------------------
 lua/tests/027-create-multiple.lua.in |   32 ++++++++++++++++++
 lua/tests/030-config.lua             |   40 ----------------------
 lua/tests/030-config.lua.in          |   40 ++++++++++++++++++++++
 lua/tests/050-lvcreate.lua           |   46 -------------------------
 lua/tests/050-lvcreate.lua.in        |   46 +++++++++++++++++++++++++
 lua/tests/060-readdir.lua            |   61 ----------------------------------
 lua/tests/060-readdir.lua.in         |   61 ++++++++++++++++++++++++++++++++++
 lua/tests/070-optargs.lua            |   25 --------------
 lua/tests/070-optargs.lua.in         |   25 ++++++++++++++
 lua/tests/400-events.lua             |   53 -----------------------------
 lua/tests/400-events.lua.in          |   53 +++++++++++++++++++++++++++++
 lua/tests/400-progress.lua           |   44 ------------------------
 lua/tests/400-progress.lua.in        |   44 ++++++++++++++++++++++++
 lua/tests/900-errors.lua             |   37 ---------------------
 lua/tests/900-errors.lua.in          |   37 +++++++++++++++++++++
 run.in                               |    1 +
 27 files changed, 444 insertions(+), 426 deletions(-)
 delete mode 100755 lua/tests/010-load.lua
 create mode 100755 lua/tests/010-load.lua.in
 delete mode 100755 lua/tests/015-globals.lua
 create mode 100755 lua/tests/015-globals.lua.in
 delete mode 100755 lua/tests/020-create.lua
 create mode 100755 lua/tests/020-create.lua.in
 delete mode 100755 lua/tests/025-create-flags.lua
 create mode 100755 lua/tests/025-create-flags.lua.in
 delete mode 100755 lua/tests/027-create-multiple.lua
 create mode 100755 lua/tests/027-create-multiple.lua.in
 delete mode 100755 lua/tests/030-config.lua
 create mode 100755 lua/tests/030-config.lua.in
 delete mode 100755 lua/tests/050-lvcreate.lua
 create mode 100755 lua/tests/050-lvcreate.lua.in
 delete mode 100755 lua/tests/060-readdir.lua
 create mode 100755 lua/tests/060-readdir.lua.in
 delete mode 100755 lua/tests/070-optargs.lua
 create mode 100755 lua/tests/070-optargs.lua.in
 delete mode 100755 lua/tests/400-events.lua
 create mode 100755 lua/tests/400-events.lua.in
 delete mode 100755 lua/tests/400-progress.lua
 create mode 100755 lua/tests/400-progress.lua.in
 delete mode 100755 lua/tests/900-errors.lua
 create mode 100755 lua/tests/900-errors.lua.in

diff --git a/configure.ac b/configure.ac
index 0d8a081..7214aac 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1460,6 +1460,21 @@ AC_CONFIG_FILES([Makefile
                  tests/tmpdirs/Makefile
                  tests/xml/Makefile
                  tools/Makefile])
+AS_IF([test "$xHAVE_LUA" != "x"],[
+  AC_CONFIG_FILES([lua/tests/010-load.lua],[chmod +x,-w lua/tests/010-load.lua])
+  AC_CONFIG_FILES([lua/tests/015-globals.lua],[chmod +x,-w lua/tests/015-globals.lua])
+  AC_CONFIG_FILES([lua/tests/020-create.lua],[chmod +x,-w lua/tests/020-create.lua])
+  AC_CONFIG_FILES([lua/tests/025-create-flags.lua],[chmod +x,-w lua/tests/025-create-flags.lua])
+  AC_CONFIG_FILES([lua/tests/027-create-multiple.lua],[chmod +x,-w lua/tests/027-create-multiple.lua])
+  AC_CONFIG_FILES([lua/tests/030-config.lua],[chmod +x,-w lua/tests/030-config.lua])
+  AC_CONFIG_FILES([lua/tests/050-lvcreate.lua],[chmod +x,-w lua/tests/050-lvcreate.lua])
+  AC_CONFIG_FILES([lua/tests/060-readdir.lua],[chmod +x,-w lua/tests/060-readdir.lua])
+  AC_CONFIG_FILES([lua/tests/070-optargs.lua],[chmod +x,-w lua/tests/070-optargs.lua])
+  AC_CONFIG_FILES([lua/tests/400-events.lua],[chmod +x,-w lua/tests/400-events.lua])
+  AC_CONFIG_FILES([lua/tests/400-progress.lua],[chmod +x,-w lua/tests/400-progress.lua])
+  AC_CONFIG_FILES([lua/tests/900-errors.lua],[chmod +x,-w lua/tests/900-errors.lua])
+])
+
 AC_OUTPUT
 
 dnl Produce summary.
diff --git a/lua/run-bindtests b/lua/run-bindtests
index 170e45b..fd2e67f 100755
--- a/lua/run-bindtests
+++ b/lua/run-bindtests
@@ -16,5 +16,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
-lua bindtests.lua > bindtests.tmp
+set -e
+
+$LUA $srcdir/bindtests.lua > bindtests.tmp
 diff -u $srcdir/../bindtests bindtests.tmp
diff --git a/lua/tests/010-load.lua b/lua/tests/010-load.lua
deleted file mode 100755
index 4443e32..0000000
--- a/lua/tests/010-load.lua
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/usr/bin/lua
--- libguestfs Lua bindings -*- lua -*-
--- Copyright (C) 2012 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.
-
-require "guestfs"
diff --git a/lua/tests/010-load.lua.in b/lua/tests/010-load.lua.in
new file mode 100755
index 0000000..3e7dfcc
--- /dev/null
+++ b/lua/tests/010-load.lua.in
@@ -0,0 +1,19 @@
+#!/usr/bin/env @LUA@
+-- libguestfs Lua bindings -*- lua -*-
+-- Copyright (C) 2012 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.
+
+require "guestfs"
diff --git a/lua/tests/015-globals.lua b/lua/tests/015-globals.lua
deleted file mode 100755
index 9733ef5..0000000
--- a/lua/tests/015-globals.lua
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/usr/bin/lua
--- libguestfs Lua bindings -*- lua -*-
--- Copyright (C) 2012 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.
-
-local G = require "guestfs"
-
-assert (G._COPYRIGHT)
-print ("_COPYRIGHT = ", G._COPYRIGHT)
-assert (G._DESCRIPTION)
-print ("_DESCRIPTION = ", G._DESCRIPTION)
-assert (G._VERSION)
-print ("_VERSION = ", G._VERSION)
diff --git a/lua/tests/015-globals.lua.in b/lua/tests/015-globals.lua.in
new file mode 100755
index 0000000..9d056c2
--- /dev/null
+++ b/lua/tests/015-globals.lua.in
@@ -0,0 +1,26 @@
+#!/usr/bin/env @LUA@
+-- libguestfs Lua bindings -*- lua -*-
+-- Copyright (C) 2012 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.
+
+local G = require "guestfs"
+
+assert (G._COPYRIGHT)
+print ("_COPYRIGHT = ", G._COPYRIGHT)
+assert (G._DESCRIPTION)
+print ("_DESCRIPTION = ", G._DESCRIPTION)
+assert (G._VERSION)
+print ("_VERSION = ", G._VERSION)
diff --git a/lua/tests/020-create.lua b/lua/tests/020-create.lua
deleted file mode 100755
index b7e748d..0000000
--- a/lua/tests/020-create.lua
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/lua
--- libguestfs Lua bindings -*- lua -*-
--- Copyright (C) 2012 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.
-
-local G = require "guestfs"
-
-local g = G.create ()
diff --git a/lua/tests/020-create.lua.in b/lua/tests/020-create.lua.in
new file mode 100755
index 0000000..7940177
--- /dev/null
+++ b/lua/tests/020-create.lua.in
@@ -0,0 +1,21 @@
+#!/usr/bin/env @LUA@
+-- libguestfs Lua bindings -*- lua -*-
+-- Copyright (C) 2012 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.
+
+local G = require "guestfs"
+
+local g = G.create ()
diff --git a/lua/tests/025-create-flags.lua b/lua/tests/025-create-flags.lua
deleted file mode 100755
index 08865c7..0000000
--- a/lua/tests/025-create-flags.lua
+++ /dev/null
@@ -1,21 +0,0 @@
-#!/usr/bin/lua
--- libguestfs Lua bindings -*- lua -*-
--- Copyright (C) 2012 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.
-
-local G = require "guestfs"
-
-local g = G.create { environment = 0 }
diff --git a/lua/tests/025-create-flags.lua.in b/lua/tests/025-create-flags.lua.in
new file mode 100755
index 0000000..68d04eb
--- /dev/null
+++ b/lua/tests/025-create-flags.lua.in
@@ -0,0 +1,21 @@
+#!/usr/bin/env @LUA@
+-- libguestfs Lua bindings -*- lua -*-
+-- Copyright (C) 2012 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.
+
+local G = require "guestfs"
+
+local g = G.create { environment = 0 }
diff --git a/lua/tests/027-create-multiple.lua b/lua/tests/027-create-multiple.lua
deleted file mode 100755
index a3f8c8c..0000000
--- a/lua/tests/027-create-multiple.lua
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/bin/lua
--- libguestfs Lua bindings -*- lua -*-
--- Copyright (C) 2012 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.
-
-local G = require "guestfs"
-
-local g1 = G.create ()
-local g2 = G.create ()
-local g3 = G.create ()
-
--- Check that each handle is independent.
-g1:set_path ("1")
-g2:set_path ("2")
-g3:set_path ("3")
-
-assert (g1:get_path () == "1", "incorrect path in g1, expected '1'")
-assert (g2:get_path () == "2", "incorrect path in g2, expected '2'")
-assert (g3:get_path () == "3", "incorrect path in g3, expected '3'")
diff --git a/lua/tests/027-create-multiple.lua.in b/lua/tests/027-create-multiple.lua.in
new file mode 100755
index 0000000..b11bdd9
--- /dev/null
+++ b/lua/tests/027-create-multiple.lua.in
@@ -0,0 +1,32 @@
+#!/usr/bin/env @LUA@
+-- libguestfs Lua bindings -*- lua -*-
+-- Copyright (C) 2012 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.
+
+local G = require "guestfs"
+
+local g1 = G.create ()
+local g2 = G.create ()
+local g3 = G.create ()
+
+-- Check that each handle is independent.
+g1:set_path ("1")
+g2:set_path ("2")
+g3:set_path ("3")
+
+assert (g1:get_path () == "1", "incorrect path in g1, expected '1'")
+assert (g2:get_path () == "2", "incorrect path in g2, expected '2'")
+assert (g3:get_path () == "3", "incorrect path in g3, expected '3'")
diff --git a/lua/tests/030-config.lua b/lua/tests/030-config.lua
deleted file mode 100755
index d70528c..0000000
--- a/lua/tests/030-config.lua
+++ /dev/null
@@ -1,40 +0,0 @@
-#!/usr/bin/lua
--- libguestfs Lua bindings -*- lua -*-
--- Copyright (C) 2012 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.
-
-local G = require "guestfs"
-
-local g = G.create ()
-
-local verbose = g:get_verbose ()
-g:set_verbose (true)
-g:set_verbose (verbose)
-
-g:set_autosync (false)
-g:set_autosync (true)
-
-g:set_path (".")
-assert (g:get_path () == ".")
-
-g:add_drive ("/dev/null")
-
-local version = g:version ()
-for k,v in pairs (version) do
-   print(k,v)
-end
-
-g:close ()
diff --git a/lua/tests/030-config.lua.in b/lua/tests/030-config.lua.in
new file mode 100755
index 0000000..7ff5b4f
--- /dev/null
+++ b/lua/tests/030-config.lua.in
@@ -0,0 +1,40 @@
+#!/usr/bin/env @LUA@
+-- libguestfs Lua bindings -*- lua -*-
+-- Copyright (C) 2012 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.
+
+local G = require "guestfs"
+
+local g = G.create ()
+
+local verbose = g:get_verbose ()
+g:set_verbose (true)
+g:set_verbose (verbose)
+
+g:set_autosync (false)
+g:set_autosync (true)
+
+g:set_path (".")
+assert (g:get_path () == ".")
+
+g:add_drive ("/dev/null")
+
+local version = g:version ()
+for k,v in pairs (version) do
+   print(k,v)
+end
+
+g:close ()
diff --git a/lua/tests/050-lvcreate.lua b/lua/tests/050-lvcreate.lua
deleted file mode 100755
index 9fd5bec..0000000
--- a/lua/tests/050-lvcreate.lua
+++ /dev/null
@@ -1,46 +0,0 @@
-#!/usr/bin/lua
--- libguestfs Lua bindings -*- lua -*-
--- Copyright (C) 2012 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.
-
-local G = require "guestfs"
-
-local g = G.create ()
-
-file = io.open ("test.img", "w")
-file:seek ("set", 500 * 1024 * 1024)
-file:write (' ')
-file:close ()
-
-g:add_drive ("test.img")
-
-g:launch ()
-
-g:pvcreate ("/dev/sda")
-g:vgcreate ("VG", {"/dev/sda"})
-g:lvcreate ("LV1", "VG", 200)
-g:lvcreate ("LV2", "VG", 200)
-
-local lvs = g:lvs ()
-assert (table.getn (lvs) == 2 and
-        lvs[1] == "/dev/VG/LV1" and lvs[2] == "/dev/VG/LV2",
-        "g:lvs returned incorrect result")
-
-g:shutdown ()
-
-g:close ()
-
-os.remove ("test.img")
diff --git a/lua/tests/050-lvcreate.lua.in b/lua/tests/050-lvcreate.lua.in
new file mode 100755
index 0000000..8cc9541
--- /dev/null
+++ b/lua/tests/050-lvcreate.lua.in
@@ -0,0 +1,46 @@
+#!/usr/bin/env @LUA@
+-- libguestfs Lua bindings -*- lua -*-
+-- Copyright (C) 2012 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.
+
+local G = require "guestfs"
+
+local g = G.create ()
+
+file = io.open ("test.img", "w")
+file:seek ("set", 500 * 1024 * 1024)
+file:write (' ')
+file:close ()
+
+g:add_drive ("test.img")
+
+g:launch ()
+
+g:pvcreate ("/dev/sda")
+g:vgcreate ("VG", {"/dev/sda"})
+g:lvcreate ("LV1", "VG", 200)
+g:lvcreate ("LV2", "VG", 200)
+
+local lvs = g:lvs ()
+assert (table.getn (lvs) == 2 and
+        lvs[1] == "/dev/VG/LV1" and lvs[2] == "/dev/VG/LV2",
+        "g:lvs returned incorrect result")
+
+g:shutdown ()
+
+g:close ()
+
+os.remove ("test.img")
diff --git a/lua/tests/060-readdir.lua b/lua/tests/060-readdir.lua
deleted file mode 100755
index b148137..0000000
--- a/lua/tests/060-readdir.lua
+++ /dev/null
@@ -1,61 +0,0 @@
-#!/usr/bin/lua
--- libguestfs Lua bindings -*- lua -*-
--- Copyright (C) 2012 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.
-
-local G = require "guestfs"
-
-local g = G.create ()
-
-file = io.open ("test.img", "w")
-file:seek ("set", 10 * 1024 * 1024)
-file:write (' ')
-file:close ()
-
-g:add_drive ("test.img")
-
-g:launch ()
-
-g:part_disk ("/dev/sda", "mbr")
-g:mkfs ("ext2", "/dev/sda1")
-g:mount ("/dev/sda1", "/")
-g:mkdir ("/p")
-g:touch ("/q")
-
-local dirs = g:readdir ("/")
-
-function print_dirs(dirs)
-   for i,dentry in ipairs (dirs) do
-      for k,v in pairs (dentry) do
-         print(i, k, v)
-      end
-   end
-end
-
-print_dirs (dirs)
-table.sort (dirs, function (a,b) return a["name"] < b["name"] end)
-print_dirs (dirs)
-
--- Slots 1, 2, 3 contain "." and ".." and "lost+found" respectively.
-
-assert (dirs[4]["name"] == "p", "incorrect name in slot 4")
-assert (dirs[5]["name"] == "q", "incorrect name in slot 5")
-
-g:shutdown ()
-
-g:close ()
-
-os.remove ("test.img")
diff --git a/lua/tests/060-readdir.lua.in b/lua/tests/060-readdir.lua.in
new file mode 100755
index 0000000..fed485d
--- /dev/null
+++ b/lua/tests/060-readdir.lua.in
@@ -0,0 +1,61 @@
+#!/usr/bin/env @LUA@
+-- libguestfs Lua bindings -*- lua -*-
+-- Copyright (C) 2012 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.
+
+local G = require "guestfs"
+
+local g = G.create ()
+
+file = io.open ("test.img", "w")
+file:seek ("set", 10 * 1024 * 1024)
+file:write (' ')
+file:close ()
+
+g:add_drive ("test.img")
+
+g:launch ()
+
+g:part_disk ("/dev/sda", "mbr")
+g:mkfs ("ext2", "/dev/sda1")
+g:mount ("/dev/sda1", "/")
+g:mkdir ("/p")
+g:touch ("/q")
+
+local dirs = g:readdir ("/")
+
+function print_dirs(dirs)
+   for i,dentry in ipairs (dirs) do
+      for k,v in pairs (dentry) do
+         print(i, k, v)
+      end
+   end
+end
+
+print_dirs (dirs)
+table.sort (dirs, function (a,b) return a["name"] < b["name"] end)
+print_dirs (dirs)
+
+-- Slots 1, 2, 3 contain "." and ".." and "lost+found" respectively.
+
+assert (dirs[4]["name"] == "p", "incorrect name in slot 4")
+assert (dirs[5]["name"] == "q", "incorrect name in slot 5")
+
+g:shutdown ()
+
+g:close ()
+
+os.remove ("test.img")
diff --git a/lua/tests/070-optargs.lua b/lua/tests/070-optargs.lua
deleted file mode 100755
index 00559a1..0000000
--- a/lua/tests/070-optargs.lua
+++ /dev/null
@@ -1,25 +0,0 @@
-#!/usr/bin/lua
--- libguestfs Lua bindings -*- lua -*-
--- Copyright (C) 2012 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.
-
-local G = require "guestfs"
-
-local g = G.create ()
-
-g:add_drive ("/dev/null")
-g:add_drive ("/dev/null", { readonly = true })
-g:add_drive ("/dev/null", { format = "raw", readonly = false })
diff --git a/lua/tests/070-optargs.lua.in b/lua/tests/070-optargs.lua.in
new file mode 100755
index 0000000..543e517
--- /dev/null
+++ b/lua/tests/070-optargs.lua.in
@@ -0,0 +1,25 @@
+#!/usr/bin/env @LUA@
+-- libguestfs Lua bindings -*- lua -*-
+-- Copyright (C) 2012 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.
+
+local G = require "guestfs"
+
+local g = G.create ()
+
+g:add_drive ("/dev/null")
+g:add_drive ("/dev/null", { readonly = true })
+g:add_drive ("/dev/null", { format = "raw", readonly = false })
diff --git a/lua/tests/400-events.lua b/lua/tests/400-events.lua
deleted file mode 100755
index c17bdc2..0000000
--- a/lua/tests/400-events.lua
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/lua
--- libguestfs Lua bindings -*- lua -*-
--- Copyright (C) 2012 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.
-
-local G = require "guestfs"
-
-for i, v in ipairs (G.event_all) do
-   print (i, v)
-end
-
-local g = G.create ()
-
-function log_callback (g, event, eh, flags, buf, array)
-   io.write (string.format ("lua event logged: event=%s eh=%d buf='%s'\n",
-                            event, eh, buf))
-end
-
-close_invoked = 0
-function close_callback (g, event, eh, flags, buf, array)
-   close_invoked = close_invoked+1
-   log_callback (g, event, eh, flags, buf, array)
-end
-
--- Register an event callback for all log messages.
-g:set_event_callback (log_callback, { "appliance", "library", "trace" })
-
--- Register an event callback for the close event.
-g:set_event_callback (close_callback, "close")
-
--- Make sure we see some messages.
-g:set_trace (true)
-g:set_verbose (true)
-
--- Do some stuff.
-g:add_drive_ro ("/dev/null")
-
--- Close the handle.  The close callback should be invoked.
-g:close ()
-assert (close_invoked == 1, "close callback was not invoked")
diff --git a/lua/tests/400-events.lua.in b/lua/tests/400-events.lua.in
new file mode 100755
index 0000000..8693f24
--- /dev/null
+++ b/lua/tests/400-events.lua.in
@@ -0,0 +1,53 @@
+#!/usr/bin/env @LUA@
+-- libguestfs Lua bindings -*- lua -*-
+-- Copyright (C) 2012 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.
+
+local G = require "guestfs"
+
+for i, v in ipairs (G.event_all) do
+   print (i, v)
+end
+
+local g = G.create ()
+
+function log_callback (g, event, eh, flags, buf, array)
+   io.write (string.format ("lua event logged: event=%s eh=%d buf='%s'\n",
+                            event, eh, buf))
+end
+
+close_invoked = 0
+function close_callback (g, event, eh, flags, buf, array)
+   close_invoked = close_invoked+1
+   log_callback (g, event, eh, flags, buf, array)
+end
+
+-- Register an event callback for all log messages.
+g:set_event_callback (log_callback, { "appliance", "library", "trace" })
+
+-- Register an event callback for the close event.
+g:set_event_callback (close_callback, "close")
+
+-- Make sure we see some messages.
+g:set_trace (true)
+g:set_verbose (true)
+
+-- Do some stuff.
+g:add_drive_ro ("/dev/null")
+
+-- Close the handle.  The close callback should be invoked.
+g:close ()
+assert (close_invoked == 1, "close callback was not invoked")
diff --git a/lua/tests/400-progress.lua b/lua/tests/400-progress.lua
deleted file mode 100755
index 293a463..0000000
--- a/lua/tests/400-progress.lua
+++ /dev/null
@@ -1,44 +0,0 @@
-#!/usr/bin/lua
--- libguestfs Lua bindings -*- lua -*-
--- Copyright (C) 2012 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.
-
-local G = require "guestfs"
-
-local g = G.create ()
-
-g:add_drive ("/dev/null")
-g:launch ()
-
-calls = 0
-function cb ()
-   calls = calls+1
-end
-
-eh = g:set_event_callback (cb, "progress")
-assert (g:debug ("progress", {"5"}) == "ok", "debug progress command failed")
-assert (calls > 0, "progress callback was not invoked")
-
-calls = 0
-g:delete_event_callback (eh)
-assert (g:debug ("progress", {"5"}) == "ok", "debug progress command failed")
-assert (calls == 0, "progress callback was invoked when deleted")
-
-g:set_event_callback (cb, "progress")
-assert (g:debug ("progress", {"5"}) == "ok", "debug progress command failed")
-assert (calls > 0, "progress callback was not invoked")
-
-g:close ()
diff --git a/lua/tests/400-progress.lua.in b/lua/tests/400-progress.lua.in
new file mode 100755
index 0000000..1f5031e
--- /dev/null
+++ b/lua/tests/400-progress.lua.in
@@ -0,0 +1,44 @@
+#!/usr/bin/env @LUA@
+-- libguestfs Lua bindings -*- lua -*-
+-- Copyright (C) 2012 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.
+
+local G = require "guestfs"
+
+local g = G.create ()
+
+g:add_drive ("/dev/null")
+g:launch ()
+
+calls = 0
+function cb ()
+   calls = calls+1
+end
+
+eh = g:set_event_callback (cb, "progress")
+assert (g:debug ("progress", {"5"}) == "ok", "debug progress command failed")
+assert (calls > 0, "progress callback was not invoked")
+
+calls = 0
+g:delete_event_callback (eh)
+assert (g:debug ("progress", {"5"}) == "ok", "debug progress command failed")
+assert (calls == 0, "progress callback was invoked when deleted")
+
+g:set_event_callback (cb, "progress")
+assert (g:debug ("progress", {"5"}) == "ok", "debug progress command failed")
+assert (calls > 0, "progress callback was not invoked")
+
+g:close ()
diff --git a/lua/tests/900-errors.lua b/lua/tests/900-errors.lua
deleted file mode 100755
index c560f7f..0000000
--- a/lua/tests/900-errors.lua
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/lua
--- libguestfs Lua bindings -*- lua -*-
--- Copyright (C) 2012 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.
-
-local G = require "guestfs"
-
-local g = G.create ()
-
-code, err = pcall (function (fn) g:add_drive (fn) end, "/NOTSUCHFILE")
-assert (not code)
-
--- The default __tostring function will convert the error to either:
---
---   "%s", msg
--- or:
---   "%s: %s", msg, strerror (err)
---
--- We are expecting the second case here, but since the libguestfs
--- code calls perrorf, the string version of ENOENT is already
--- included in 'msg' and so appears twice here.
-local str = tostring (err)
-assert (str == "/NOTSUCHFILE: No such file or directory: No such file or directory",
-        string.format ("unexpected error string: %s", str))
diff --git a/lua/tests/900-errors.lua.in b/lua/tests/900-errors.lua.in
new file mode 100755
index 0000000..dbf8462
--- /dev/null
+++ b/lua/tests/900-errors.lua.in
@@ -0,0 +1,37 @@
+#!/usr/bin/env @LUA@
+-- libguestfs Lua bindings -*- lua -*-
+-- Copyright (C) 2012 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.
+
+local G = require "guestfs"
+
+local g = G.create ()
+
+code, err = pcall (function (fn) g:add_drive (fn) end, "/NOTSUCHFILE")
+assert (not code)
+
+-- The default __tostring function will convert the error to either:
+--
+--   "%s", msg
+-- or:
+--   "%s: %s", msg, strerror (err)
+--
+-- We are expecting the second case here, but since the libguestfs
+-- code calls perrorf, the string version of ENOENT is already
+-- included in 'msg' and so appears twice here.
+local str = tostring (err)
+assert (str == "/NOTSUCHFILE: No such file or directory: No such file or directory",
+        string.format ("unexpected error string: %s", str))
diff --git a/run.in b/run.in
index ec0b018..9d4a6b1 100755
--- a/run.in
+++ b/run.in
@@ -108,6 +108,7 @@ fi
 export CLASSPATH
 
 # For Lua.
+export LUA=@LUA@
 if [ -z "$LUA_CPATH" ]; then
     LUA_CPATH="$b/lua/?.so"
 else
-- 
1.7.10.4




More information about the Libguestfs mailing list