From: Richard Jones Date: Tue, 12 May 2009 16:16:59 +0000 (+0100) Subject: Test the 'command' and 'command_lines' functions thoroughly. X-Git-Tag: 1.0.25~4 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=45d78361d791f4a752fca9472b81bdc75f9f92a4;p=libguestfs.git Test the 'command' and 'command_lines' functions thoroughly. --- diff --git a/.gitignore b/.gitignore index c9b27a3..2668099 100644 --- a/.gitignore +++ b/.gitignore @@ -82,6 +82,7 @@ ruby/ext/guestfs/extconf.h ruby/ext/guestfs/mkmf.log pod2htm?.tmp stamp-h1 +test-command test*.img test*.tmp tests diff --git a/Makefile.am b/Makefile.am index 592ed94..60cfac0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -95,7 +95,7 @@ make-initramfs.sh: make-initramfs.sh.in # Tests. These are auto-generated from the test descriptions # in the generator. -check_PROGRAMS = tests +check_PROGRAMS = tests test-command tests_SOURCES = tests.c tests_CFLAGS = \ @@ -112,6 +112,12 @@ $(TESTS): $(INITRAMFS) $(VMLINUZ) valgrind: $(MAKE) check VG="valgrind --quiet --leak-check=full" +# This binary must be statically linked. It is used for testing +# the "guestfs_command" and "guestfs_command_lines" functions. + +test_command_SOURCES = test-command.c +test_command_LDFLAGS = -all-static + # Manual pages. # guestfs-actions.pod and guestfs-structs are autogenerated. There is # no include mechanism for POD, so we have to do it by hand. diff --git a/fish/cmds.c b/fish/cmds.c index 8c1cb53..4c5b5fa 100644 --- a/fish/cmds.c +++ b/fish/cmds.c @@ -352,10 +352,10 @@ void display_command (const char *cmd) pod2text ("file - determine file type", " file \n\nThis call uses the standard L command to determine\nthe type or contents of the file. This also works on devices,\nfor example to find out whether a partition contains a filesystem.\n\nThe exact command which runs is C. Note in\nparticular that the filename is not prepended to the output\n(the C<-b> option)."); else if (strcasecmp (cmd, "command") == 0) - pod2text ("command - run a command from the guest filesystem", " command \n\nThis call runs a command from the guest filesystem. The\nfilesystem must be mounted, and must contain a compatible\noperating system (ie. something Linux, with the same\nor compatible processor architecture).\n\nThe single parameter is an argv-style list of arguments.\nThe first element is the name of the program to run.\nSubsequent elements are parameters. The list must be\nnon-empty (ie. must contain a program name).\n\nThe C<$PATH> environment variable will contain at least\nC and C. If you require a program from\nanother location, you should provide the full path in the\nfirst parameter.\n\nShared libraries and data files required by the program\nmust be available on filesystems which are mounted in the\ncorrect places. It is the caller's responsibility to ensure\nall filesystems that are needed are mounted at the right\nlocations."); + pod2text ("command - run a command from the guest filesystem", " command \n\nThis call runs a command from the guest filesystem. The\nfilesystem must be mounted, and must contain a compatible\noperating system (ie. something Linux, with the same\nor compatible processor architecture).\n\nThe single parameter is an argv-style list of arguments.\nThe first element is the name of the program to run.\nSubsequent elements are parameters. The list must be\nnon-empty (ie. must contain a program name).\n\nThe return value is anything printed to I by\nthe command.\n\nIf the command returns a non-zero exit status, then\nthis function returns an error message. The error message\nstring is the content of I from the command.\n\nThe C<$PATH> environment variable will contain at least\nC and C. If you require a program from\nanother location, you should provide the full path in the\nfirst parameter.\n\nShared libraries and data files required by the program\nmust be available on filesystems which are mounted in the\ncorrect places. It is the caller's responsibility to ensure\nall filesystems that are needed are mounted at the right\nlocations.\n\nBecause of the message protocol, there is a transfer limit \nof somewhere between 2MB and 4MB. To transfer large files you should use\nFTP."); else if (strcasecmp (cmd, "command_lines") == 0 || strcasecmp (cmd, "command-lines") == 0) - pod2text ("command-lines - run a command, returning lines", " command-lines \n\nThis is the same as C, but splits the\nresult into a list of lines."); + pod2text ("command-lines - run a command, returning lines", " command-lines \n\nThis is the same as C, but splits the\nresult into a list of lines.\n\nBecause of the message protocol, there is a transfer limit \nof somewhere between 2MB and 4MB. To transfer large files you should use\nFTP."); else if (strcasecmp (cmd, "stat") == 0) pod2text ("stat - get file information", " stat \n\nReturns file information for the given C.\n\nThis is the same as the C system call."); diff --git a/guestfish-actions.pod b/guestfish-actions.pod index 04343af..7d46206 100644 --- a/guestfish-actions.pod +++ b/guestfish-actions.pod @@ -372,6 +372,13 @@ The first element is the name of the program to run. Subsequent elements are parameters. The list must be non-empty (ie. must contain a program name). +The return value is anything printed to I by +the command. + +If the command returns a non-zero exit status, then +this function returns an error message. The error message +string is the content of I from the command. + The C<$PATH> environment variable will contain at least C and C. If you require a program from another location, you should provide the full path in the @@ -383,6 +390,10 @@ correct places. It is the caller's responsibility to ensure all filesystems that are needed are mounted at the right locations. +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. + =head2 command-lines command-lines 'arguments ...' @@ -390,6 +401,10 @@ locations. This is the same as C, but splits the result into a list of lines. +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. + =head2 config config qemuparam qemuvalue diff --git a/guestfs-actions.pod b/guestfs-actions.pod index 8f602b8..c187540 100644 --- a/guestfs-actions.pod +++ b/guestfs-actions.pod @@ -479,6 +479,13 @@ The first element is the name of the program to run. Subsequent elements are parameters. The list must be non-empty (ie. must contain a program name). +The return value is anything printed to I by +the command. + +If the command returns a non-zero exit status, then +this function returns an error message. The error message +string is the content of I from the command. + The C<$PATH> environment variable will contain at least C and C. If you require a program from another location, you should provide the full path in the @@ -493,6 +500,10 @@ locations. This function returns a string, or NULL on error. I. +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. + =head2 guestfs_command_lines char **guestfs_command_lines (guestfs_h *handle, @@ -505,6 +516,10 @@ This function returns a NULL-terminated array of strings (like L), or NULL if there was an error. I. +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. + =head2 guestfs_config int guestfs_config (guestfs_h *handle, diff --git a/java/com/redhat/et/libguestfs/GuestFS.java b/java/com/redhat/et/libguestfs/GuestFS.java index 26f1aaa..70efb8d 100644 --- a/java/com/redhat/et/libguestfs/GuestFS.java +++ b/java/com/redhat/et/libguestfs/GuestFS.java @@ -1646,6 +1646,13 @@ public class GuestFS { * Subsequent elements are parameters. The list must be * non-empty (ie. must contain a program name). * + * The return value is anything printed to *stdout* by the + * command. + * + * If the command returns a non-zero exit status, then this + * function returns an error message. The error message + * string is the content of *stderr* from the command. + * * The $PATH environment variable will contain at least * "/usr/bin" and "/bin". If you require a program from * another location, you should provide the full path in @@ -1657,6 +1664,10 @@ public class GuestFS { * ensure all filesystems that are needed are mounted at * the right locations. * + * Because of the message protocol, there is a transfer + * limit of somewhere between 2MB and 4MB. To transfer + * large files you should use FTP. + * * @throws LibGuestFSException */ public String command (String[] arguments) @@ -1675,6 +1686,10 @@ public class GuestFS { * This is the same as "g.command", but splits the result * into a list of lines. * + * Because of the message protocol, there is a transfer + * limit of somewhere between 2MB and 4MB. To transfer + * large files you should use FTP. + * * @throws LibGuestFSException */ public String[] command_lines (String[] arguments) diff --git a/perl/lib/Sys/Guestfs.pm b/perl/lib/Sys/Guestfs.pm index 5aac2e9..001fa88 100644 --- a/perl/lib/Sys/Guestfs.pm +++ b/perl/lib/Sys/Guestfs.pm @@ -405,6 +405,13 @@ The first element is the name of the program to run. Subsequent elements are parameters. The list must be non-empty (ie. must contain a program name). +The return value is anything printed to I by +the command. + +If the command returns a non-zero exit status, then +this function returns an error message. The error message +string is the content of I from the command. + The C<$PATH> environment variable will contain at least C and C. If you require a program from another location, you should provide the full path in the @@ -416,11 +423,19 @@ correct places. It is the caller's responsibility to ensure all filesystems that are needed are mounted at the right locations. +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. + =item @lines = $h->command_lines (\@arguments); This is the same as C<$h-Ecommand>, but splits the result into a list of lines. +Because of the message protocol, there is a transfer limit +of somewhere between 2MB and 4MB. To transfer large files you should use +FTP. + =item $h->config ($qemuparam, $qemuvalue); This can be used to add arbitrary qemu command line parameters diff --git a/python/guestfs.py b/python/guestfs.py index 678e298..37dc80f 100644 --- a/python/guestfs.py +++ b/python/guestfs.py @@ -820,6 +820,13 @@ class GuestFS: Subsequent elements are parameters. The list must be non-empty (ie. must contain a program name). + The return value is anything printed to *stdout* by the + command. + + If the command returns a non-zero exit status, then this + function returns an error message. The error message + string is the content of *stderr* from the command. + The $PATH environment variable will contain at least "/usr/bin" and "/bin". If you require a program from another location, you should provide the full path in @@ -830,6 +837,10 @@ class GuestFS: the correct places. It is the caller's responsibility to ensure all filesystems that are needed are mounted at the right locations. + + Because of the message protocol, there is a transfer + limit of somewhere between 2MB and 4MB. To transfer + large files you should use FTP. """ return libguestfsmod.command (self._o, arguments) @@ -838,6 +849,10 @@ class GuestFS: into a list of lines. This function returns a list of strings. + + Because of the message protocol, there is a transfer + limit of somewhere between 2MB and 4MB. To transfer + large files you should use FTP. """ return libguestfsmod.command_lines (self._o, arguments) diff --git a/src/generator.ml b/src/generator.ml index 7f24802..b3388f6 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -1148,8 +1148,55 @@ The exact command which runs is C. Note in particular that the filename is not prepended to the output (the C<-b> option)."); - ("command", (RString "output", [StringList "arguments"]), 50, [], - [], (* XXX how to test? *) + ("command", (RString "output", [StringList "arguments"]), 50, [ProtocolLimitWarning], + [InitBasicFS, TestOutput ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command"; "/test-command 1"]], "Result1"); + InitBasicFS, TestOutput ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command"; "/test-command 2"]], "Result2\n"); + InitBasicFS, TestOutput ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command"; "/test-command 3"]], "\nResult3"); + InitBasicFS, TestOutput ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command"; "/test-command 4"]], "\nResult4\n"); + InitBasicFS, TestOutput ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command"; "/test-command 5"]], "\nResult5\n\n"); + InitBasicFS, TestOutput ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command"; "/test-command 6"]], "\n\nResult6\n\n"); + InitBasicFS, TestOutput ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command"; "/test-command 7"]], ""); + InitBasicFS, TestOutput ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command"; "/test-command 8"]], "\n"); + InitBasicFS, TestOutput ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command"; "/test-command 9"]], "\n\n"); + InitBasicFS, TestOutput ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command"; "/test-command 10"]], "Result10-1\nResult10-2\n"); + InitBasicFS, TestOutput ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command"; "/test-command 11"]], "Result11-1\nResult11-2"); + InitBasicFS, TestLastFail ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command"; "/test-command"]])], "run a command from the guest filesystem", "\ This call runs a command from the guest filesystem. The @@ -1162,6 +1209,13 @@ The first element is the name of the program to run. Subsequent elements are parameters. The list must be non-empty (ie. must contain a program name). +The return value is anything printed to I by +the command. + +If the command returns a non-zero exit status, then +this function returns an error message. The error message +string is the content of I from the command. + The C<$PATH> environment variable will contain at least C and C. If you require a program from another location, you should provide the full path in the @@ -1173,8 +1227,51 @@ correct places. It is the caller's responsibility to ensure all filesystems that are needed are mounted at the right locations."); - ("command_lines", (RStringList "lines", [StringList "arguments"]), 51, [], - [], (* XXX how to test? *) + ("command_lines", (RStringList "lines", [StringList "arguments"]), 51, [ProtocolLimitWarning], + [InitBasicFS, TestOutputList ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command_lines"; "/test-command 1"]], ["Result1"]); + InitBasicFS, TestOutputList ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command_lines"; "/test-command 2"]], ["Result2"]); + InitBasicFS, TestOutputList ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command_lines"; "/test-command 3"]], ["";"Result3"]); + InitBasicFS, TestOutputList ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command_lines"; "/test-command 4"]], ["";"Result4"]); + InitBasicFS, TestOutputList ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command_lines"; "/test-command 5"]], ["";"Result5";""]); + InitBasicFS, TestOutputList ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command_lines"; "/test-command 6"]], ["";"";"Result6";""]); + InitBasicFS, TestOutputList ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command_lines"; "/test-command 7"]], []); + InitBasicFS, TestOutputList ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command_lines"; "/test-command 8"]], [""]); + InitBasicFS, TestOutputList ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command_lines"; "/test-command 9"]], ["";""]); + InitBasicFS, TestOutputList ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command_lines"; "/test-command 10"]], ["Result10-1";"Result10-2"]); + InitBasicFS, TestOutputList ( + [["upload"; "test-command"; "/test-command"]; + ["chmod"; "493"; "/test-command"]; + ["command_lines"; "/test-command 11"]], ["Result11-1";"Result11-2"])], "run a command, returning lines", "\ This is the same as C, but splits the @@ -1820,7 +1917,10 @@ The external L program is used for the comparison."); ("strings", (RStringList "stringsout", [String "path"]), 94, [ProtocolLimitWarning], [InitBasicFS, TestOutputList ( [["write_file"; "/new"; "hello\nworld\n"; "0"]; - ["strings"; "/new"]], ["hello"; "world"])], + ["strings"; "/new"]], ["hello"; "world"]); + InitBasicFS, TestOutputList ( + [["touch"; "/new"]; + ["strings"; "/new"]], [])], "print the printable strings in a file", "\ This runs the L command on a file and returns diff --git a/test-command.c b/test-command.c new file mode 100644 index 0000000..1e29ee9 --- /dev/null +++ b/test-command.c @@ -0,0 +1,64 @@ +/* libguestfs + * Copyright (C) 2009 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. + */ + +/* This program, which must be statically linked, is used to test the + * guestfs_command and guestfs_command_lines functions. + */ + +#include +#include +#include +#include + +int +main (int argc, char *argv[]) +{ + if (argc > 1) { + if (strcmp (argv[1], "1") == 0) { + printf ("Result1"); + } else if (strcmp (argv[1], "2") == 0) { + printf ("Result2\n"); + } else if (strcmp (argv[1], "3") == 0) { + printf ("\nResult3"); + } else if (strcmp (argv[1], "4") == 0) { + printf ("\nResult4\n"); + } else if (strcmp (argv[1], "5") == 0) { + printf ("\nResult5\n\n"); + } else if (strcmp (argv[1], "6") == 0) { + printf ("\n\nResult6\n\n"); + } else if (strcmp (argv[1], "7") == 0) { + /* nothing */ + } else if (strcmp (argv[1], "8") == 0) { + printf ("\n"); + } else if (strcmp (argv[1], "9") == 0) { + printf ("\n\n"); + } else if (strcmp (argv[1], "10") == 0) { + printf ("Result10-1\nResult10-2\n"); + } else if (strcmp (argv[1], "11") == 0) { + printf ("Result11-1\nResult11-2"); + } else { + fprintf (stderr, "unknown parameter: %s\n", argv[1]); + exit (1); + } + } else { + fprintf (stderr, "missing parameter\n"); + exit (1); + } + + exit (0); +} diff --git a/tests.c b/tests.c index a8f1d73..f09c754 100644 --- a/tests.c +++ b/tests.c @@ -105,8 +105,6 @@ static void no_test_warnings (void) fprintf (stderr, "warning: \"guestfs_chown\" has no tests\n"); fprintf (stderr, "warning: \"guestfs_sfdisk\" has no tests\n"); fprintf (stderr, "warning: \"guestfs_lvm_remove_all\" has no tests\n"); - fprintf (stderr, "warning: \"guestfs_command\" has no tests\n"); - fprintf (stderr, "warning: \"guestfs_command_lines\" has no tests\n"); fprintf (stderr, "warning: \"guestfs_tune2fs_l\" has no tests\n"); fprintf (stderr, "warning: \"guestfs_blockdev_setbsz\" has no tests\n"); fprintf (stderr, "warning: \"guestfs_tar_out\" has no tests\n"); @@ -410,6 +408,95 @@ static int test_strings_0 (void) return 0; } +static int test_strings_1 (void) +{ + /* InitBasicFS for strings (1): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutputList for strings (1) */ + { + char path[] = "/new"; + int r; + suppress_error = 0; + r = guestfs_touch (g, path); + if (r == -1) + return -1; + } + { + char path[] = "/new"; + char **r; + int i; + suppress_error = 0; + r = guestfs_strings (g, path); + if (r == NULL) + return -1; + if (r[0] != NULL) { + fprintf (stderr, "test_strings_1: extra elements returned from command\n"); + print_strings (r); + return -1; + } + for (i = 0; r[i] != NULL; ++i) + free (r[i]); + free (r); + } + return 0; +} + static int test_equal_0 (void) { /* InitBasicFS for equal (0): create ext2 on /dev/sda1 */ @@ -4427,9 +4514,2541 @@ static int test_blockdev_getbsz_0 (void) return 0; } -static int test_blockdev_getss_0 (void) +static int test_blockdev_getss_0 (void) +{ + /* InitEmpty for blockdev_getss (0) */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + /* TestOutputInt for blockdev_getss (0) */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_getss (g, device); + if (r == -1) + return -1; + if (r != 512) { + fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r); + return -1; + } + } + return 0; +} + +static int test_blockdev_getro_0 (void) +{ + /* InitEmpty for blockdev_getro (0) */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + /* TestOutputTrue for blockdev_getro (0) */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setro (g, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_getro (g, device); + if (r == -1) + return -1; + if (!r) { + fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n"); + return -1; + } + } + return 0; +} + +static int test_blockdev_setrw_0 (void) +{ + /* InitEmpty for blockdev_setrw (0) */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + /* TestOutputFalse for blockdev_setrw (0) */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_getro (g, device); + if (r == -1) + return -1; + if (r) { + fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n"); + return -1; + } + } + return 0; +} + +static int test_blockdev_setro_0 (void) +{ + /* InitEmpty for blockdev_setro (0) */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + /* TestOutputTrue for blockdev_setro (0) */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setro (g, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_getro (g, device); + if (r == -1) + return -1; + if (!r) { + fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n"); + return -1; + } + } + return 0; +} + +static int test_statvfs_0 (void) +{ + /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutputStruct for statvfs (0) */ + { + char path[] = "/"; + struct guestfs_statvfs *r; + suppress_error = 0; + r = guestfs_statvfs (g, path); + if (r == NULL) + return -1; + if (r->bfree != 487702) { + fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n", + (int) r->bfree); + return -1; + } + if (r->blocks != 490020) { + fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n", + (int) r->blocks); + return -1; + } + if (r->bsize != 1024) { + fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n", + (int) r->bsize); + return -1; + } + free (r); + } + return 0; +} + +static int test_lstat_0 (void) +{ + /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutputStruct for lstat (0) */ + { + char path[] = "/new"; + int r; + suppress_error = 0; + r = guestfs_touch (g, path); + if (r == -1) + return -1; + } + { + char path[] = "/new"; + struct guestfs_stat *r; + suppress_error = 0; + r = guestfs_lstat (g, path); + if (r == NULL) + return -1; + if (r->size != 0) { + fprintf (stderr, "test_lstat_0: size was %d, expected 0\n", + (int) r->size); + return -1; + } + free (r); + } + return 0; +} + +static int test_stat_0 (void) +{ + /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutputStruct for stat (0) */ + { + char path[] = "/new"; + int r; + suppress_error = 0; + r = guestfs_touch (g, path); + if (r == -1) + return -1; + } + { + char path[] = "/new"; + struct guestfs_stat *r; + suppress_error = 0; + r = guestfs_stat (g, path); + if (r == NULL) + return -1; + if (r->size != 0) { + fprintf (stderr, "test_stat_0: size was %d, expected 0\n", + (int) r->size); + return -1; + } + free (r); + } + return 0; +} + +static int test_command_lines_0 (void) +{ + /* InitBasicFS for command_lines (0): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutputList for command_lines (0) */ + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "1"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char **r; + int i; + suppress_error = 0; + r = guestfs_command_lines (g, arguments); + if (r == NULL) + return -1; + if (!r[0]) { + fprintf (stderr, "test_command_lines_0: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = "Result1"; + if (strcmp (r[0], expected) != 0) { + fprintf (stderr, "test_command_lines_0: expected \"%s\" but got \"%s\"\n", expected, r[0]); + return -1; + } + } + if (r[1] != NULL) { + fprintf (stderr, "test_command_lines_0: extra elements returned from command\n"); + print_strings (r); + return -1; + } + for (i = 0; r[i] != NULL; ++i) + free (r[i]); + free (r); + } + return 0; +} + +static int test_command_lines_1 (void) +{ + /* InitBasicFS for command_lines (1): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutputList for command_lines (1) */ + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "2"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char **r; + int i; + suppress_error = 0; + r = guestfs_command_lines (g, arguments); + if (r == NULL) + return -1; + if (!r[0]) { + fprintf (stderr, "test_command_lines_1: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = "Result2"; + if (strcmp (r[0], expected) != 0) { + fprintf (stderr, "test_command_lines_1: expected \"%s\" but got \"%s\"\n", expected, r[0]); + return -1; + } + } + if (r[1] != NULL) { + fprintf (stderr, "test_command_lines_1: extra elements returned from command\n"); + print_strings (r); + return -1; + } + for (i = 0; r[i] != NULL; ++i) + free (r[i]); + free (r); + } + return 0; +} + +static int test_command_lines_2 (void) +{ + /* InitBasicFS for command_lines (2): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutputList for command_lines (2) */ + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "3"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char **r; + int i; + suppress_error = 0; + r = guestfs_command_lines (g, arguments); + if (r == NULL) + return -1; + if (!r[0]) { + fprintf (stderr, "test_command_lines_2: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = ""; + if (strcmp (r[0], expected) != 0) { + fprintf (stderr, "test_command_lines_2: expected \"%s\" but got \"%s\"\n", expected, r[0]); + return -1; + } + } + if (!r[1]) { + fprintf (stderr, "test_command_lines_2: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = "Result3"; + if (strcmp (r[1], expected) != 0) { + fprintf (stderr, "test_command_lines_2: expected \"%s\" but got \"%s\"\n", expected, r[1]); + return -1; + } + } + if (r[2] != NULL) { + fprintf (stderr, "test_command_lines_2: extra elements returned from command\n"); + print_strings (r); + return -1; + } + for (i = 0; r[i] != NULL; ++i) + free (r[i]); + free (r); + } + return 0; +} + +static int test_command_lines_3 (void) +{ + /* InitBasicFS for command_lines (3): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutputList for command_lines (3) */ + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "4"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char **r; + int i; + suppress_error = 0; + r = guestfs_command_lines (g, arguments); + if (r == NULL) + return -1; + if (!r[0]) { + fprintf (stderr, "test_command_lines_3: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = ""; + if (strcmp (r[0], expected) != 0) { + fprintf (stderr, "test_command_lines_3: expected \"%s\" but got \"%s\"\n", expected, r[0]); + return -1; + } + } + if (!r[1]) { + fprintf (stderr, "test_command_lines_3: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = "Result4"; + if (strcmp (r[1], expected) != 0) { + fprintf (stderr, "test_command_lines_3: expected \"%s\" but got \"%s\"\n", expected, r[1]); + return -1; + } + } + if (r[2] != NULL) { + fprintf (stderr, "test_command_lines_3: extra elements returned from command\n"); + print_strings (r); + return -1; + } + for (i = 0; r[i] != NULL; ++i) + free (r[i]); + free (r); + } + return 0; +} + +static int test_command_lines_4 (void) +{ + /* InitBasicFS for command_lines (4): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutputList for command_lines (4) */ + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "5"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char **r; + int i; + suppress_error = 0; + r = guestfs_command_lines (g, arguments); + if (r == NULL) + return -1; + if (!r[0]) { + fprintf (stderr, "test_command_lines_4: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = ""; + if (strcmp (r[0], expected) != 0) { + fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[0]); + return -1; + } + } + if (!r[1]) { + fprintf (stderr, "test_command_lines_4: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = "Result5"; + if (strcmp (r[1], expected) != 0) { + fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[1]); + return -1; + } + } + if (!r[2]) { + fprintf (stderr, "test_command_lines_4: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = ""; + if (strcmp (r[2], expected) != 0) { + fprintf (stderr, "test_command_lines_4: expected \"%s\" but got \"%s\"\n", expected, r[2]); + return -1; + } + } + if (r[3] != NULL) { + fprintf (stderr, "test_command_lines_4: extra elements returned from command\n"); + print_strings (r); + return -1; + } + for (i = 0; r[i] != NULL; ++i) + free (r[i]); + free (r); + } + return 0; +} + +static int test_command_lines_5 (void) +{ + /* InitBasicFS for command_lines (5): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutputList for command_lines (5) */ + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "6"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char **r; + int i; + suppress_error = 0; + r = guestfs_command_lines (g, arguments); + if (r == NULL) + return -1; + if (!r[0]) { + fprintf (stderr, "test_command_lines_5: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = ""; + if (strcmp (r[0], expected) != 0) { + fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[0]); + return -1; + } + } + if (!r[1]) { + fprintf (stderr, "test_command_lines_5: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = ""; + if (strcmp (r[1], expected) != 0) { + fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[1]); + return -1; + } + } + if (!r[2]) { + fprintf (stderr, "test_command_lines_5: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = "Result6"; + if (strcmp (r[2], expected) != 0) { + fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[2]); + return -1; + } + } + if (!r[3]) { + fprintf (stderr, "test_command_lines_5: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = ""; + if (strcmp (r[3], expected) != 0) { + fprintf (stderr, "test_command_lines_5: expected \"%s\" but got \"%s\"\n", expected, r[3]); + return -1; + } + } + if (r[4] != NULL) { + fprintf (stderr, "test_command_lines_5: extra elements returned from command\n"); + print_strings (r); + return -1; + } + for (i = 0; r[i] != NULL; ++i) + free (r[i]); + free (r); + } + return 0; +} + +static int test_command_lines_6 (void) +{ + /* InitBasicFS for command_lines (6): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutputList for command_lines (6) */ + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "7"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char **r; + int i; + suppress_error = 0; + r = guestfs_command_lines (g, arguments); + if (r == NULL) + return -1; + if (r[0] != NULL) { + fprintf (stderr, "test_command_lines_6: extra elements returned from command\n"); + print_strings (r); + return -1; + } + for (i = 0; r[i] != NULL; ++i) + free (r[i]); + free (r); + } + return 0; +} + +static int test_command_lines_7 (void) +{ + /* InitBasicFS for command_lines (7): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutputList for command_lines (7) */ + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "8"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char **r; + int i; + suppress_error = 0; + r = guestfs_command_lines (g, arguments); + if (r == NULL) + return -1; + if (!r[0]) { + fprintf (stderr, "test_command_lines_7: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = ""; + if (strcmp (r[0], expected) != 0) { + fprintf (stderr, "test_command_lines_7: expected \"%s\" but got \"%s\"\n", expected, r[0]); + return -1; + } + } + if (r[1] != NULL) { + fprintf (stderr, "test_command_lines_7: extra elements returned from command\n"); + print_strings (r); + return -1; + } + for (i = 0; r[i] != NULL; ++i) + free (r[i]); + free (r); + } + return 0; +} + +static int test_command_lines_8 (void) +{ + /* InitBasicFS for command_lines (8): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutputList for command_lines (8) */ + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "9"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char **r; + int i; + suppress_error = 0; + r = guestfs_command_lines (g, arguments); + if (r == NULL) + return -1; + if (!r[0]) { + fprintf (stderr, "test_command_lines_8: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = ""; + if (strcmp (r[0], expected) != 0) { + fprintf (stderr, "test_command_lines_8: expected \"%s\" but got \"%s\"\n", expected, r[0]); + return -1; + } + } + if (!r[1]) { + fprintf (stderr, "test_command_lines_8: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = ""; + if (strcmp (r[1], expected) != 0) { + fprintf (stderr, "test_command_lines_8: expected \"%s\" but got \"%s\"\n", expected, r[1]); + return -1; + } + } + if (r[2] != NULL) { + fprintf (stderr, "test_command_lines_8: extra elements returned from command\n"); + print_strings (r); + return -1; + } + for (i = 0; r[i] != NULL; ++i) + free (r[i]); + free (r); + } + return 0; +} + +static int test_command_lines_9 (void) +{ + /* InitBasicFS for command_lines (9): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutputList for command_lines (9) */ + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "10"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char **r; + int i; + suppress_error = 0; + r = guestfs_command_lines (g, arguments); + if (r == NULL) + return -1; + if (!r[0]) { + fprintf (stderr, "test_command_lines_9: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = "Result10-1"; + if (strcmp (r[0], expected) != 0) { + fprintf (stderr, "test_command_lines_9: expected \"%s\" but got \"%s\"\n", expected, r[0]); + return -1; + } + } + if (!r[1]) { + fprintf (stderr, "test_command_lines_9: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = "Result10-2"; + if (strcmp (r[1], expected) != 0) { + fprintf (stderr, "test_command_lines_9: expected \"%s\" but got \"%s\"\n", expected, r[1]); + return -1; + } + } + if (r[2] != NULL) { + fprintf (stderr, "test_command_lines_9: extra elements returned from command\n"); + print_strings (r); + return -1; + } + for (i = 0; r[i] != NULL; ++i) + free (r[i]); + free (r); + } + return 0; +} + +static int test_command_lines_10 (void) +{ + /* InitBasicFS for command_lines (10): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutputList for command_lines (10) */ + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "11"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char **r; + int i; + suppress_error = 0; + r = guestfs_command_lines (g, arguments); + if (r == NULL) + return -1; + if (!r[0]) { + fprintf (stderr, "test_command_lines_10: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = "Result11-1"; + if (strcmp (r[0], expected) != 0) { + fprintf (stderr, "test_command_lines_10: expected \"%s\" but got \"%s\"\n", expected, r[0]); + return -1; + } + } + if (!r[1]) { + fprintf (stderr, "test_command_lines_10: short list returned from command\n"); + print_strings (r); + return -1; + } + { + char expected[] = "Result11-2"; + if (strcmp (r[1], expected) != 0) { + fprintf (stderr, "test_command_lines_10: expected \"%s\" but got \"%s\"\n", expected, r[1]); + return -1; + } + } + if (r[2] != NULL) { + fprintf (stderr, "test_command_lines_10: extra elements returned from command\n"); + print_strings (r); + return -1; + } + for (i = 0; r[i] != NULL; ++i) + free (r[i]); + free (r); + } + return 0; +} + +static int test_command_0 (void) +{ + /* InitBasicFS for command (0): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutput for command (0) */ + char expected[] = "Result1"; + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "1"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char *r; + suppress_error = 0; + r = guestfs_command (g, arguments); + if (r == NULL) + return -1; + if (strcmp (r, expected) != 0) { + fprintf (stderr, "test_command_0: expected \"%s\" but got \"%s\"\n", expected, r); + return -1; + } + free (r); + } + return 0; +} + +static int test_command_1 (void) +{ + /* InitBasicFS for command (1): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutput for command (1) */ + char expected[] = "Result2\n"; + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "2"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char *r; + suppress_error = 0; + r = guestfs_command (g, arguments); + if (r == NULL) + return -1; + if (strcmp (r, expected) != 0) { + fprintf (stderr, "test_command_1: expected \"%s\" but got \"%s\"\n", expected, r); + return -1; + } + free (r); + } + return 0; +} + +static int test_command_2 (void) +{ + /* InitBasicFS for command (2): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutput for command (2) */ + char expected[] = "\nResult3"; + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "3"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char *r; + suppress_error = 0; + r = guestfs_command (g, arguments); + if (r == NULL) + return -1; + if (strcmp (r, expected) != 0) { + fprintf (stderr, "test_command_2: expected \"%s\" but got \"%s\"\n", expected, r); + return -1; + } + free (r); + } + return 0; +} + +static int test_command_3 (void) +{ + /* InitBasicFS for command (3): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutput for command (3) */ + char expected[] = "\nResult4\n"; + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "4"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char *r; + suppress_error = 0; + r = guestfs_command (g, arguments); + if (r == NULL) + return -1; + if (strcmp (r, expected) != 0) { + fprintf (stderr, "test_command_3: expected \"%s\" but got \"%s\"\n", expected, r); + return -1; + } + free (r); + } + return 0; +} + +static int test_command_4 (void) +{ + /* InitBasicFS for command (4): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutput for command (4) */ + char expected[] = "\nResult5\n\n"; + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "5"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char *r; + suppress_error = 0; + r = guestfs_command (g, arguments); + if (r == NULL) + return -1; + if (strcmp (r, expected) != 0) { + fprintf (stderr, "test_command_4: expected \"%s\" but got \"%s\"\n", expected, r); + return -1; + } + free (r); + } + return 0; +} + +static int test_command_5 (void) +{ + /* InitBasicFS for command (5): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutput for command (5) */ + char expected[] = "\n\nResult6\n\n"; + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "6"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char *r; + suppress_error = 0; + r = guestfs_command (g, arguments); + if (r == NULL) + return -1; + if (strcmp (r, expected) != 0) { + fprintf (stderr, "test_command_5: expected \"%s\" but got \"%s\"\n", expected, r); + return -1; + } + free (r); + } + return 0; +} + +static int test_command_6 (void) +{ + /* InitBasicFS for command (6): create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_blockdev_setrw (g, device); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_umount_all (g); + if (r == -1) + return -1; + } + { + int r; + suppress_error = 0; + r = guestfs_lvm_remove_all (g); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda"; + device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; + int r; + suppress_error = 0; + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); + if (r == -1) + return -1; + } + { + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; + device[5] = devchar; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutput for command (6) */ + char expected[] = ""; + { + char remotefilename[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) + return -1; + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "7"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char *r; + suppress_error = 0; + r = guestfs_command (g, arguments); + if (r == NULL) + return -1; + if (strcmp (r, expected) != 0) { + fprintf (stderr, "test_command_6: expected \"%s\" but got \"%s\"\n", expected, r); + return -1; + } + free (r); + } + return 0; +} + +static int test_command_7 (void) { - /* InitEmpty for blockdev_getss (0) */ + /* InitBasicFS for command (7): create ext2 on /dev/sda1 */ { char device[] = "/dev/sda"; device[5] = devchar; @@ -4453,78 +7072,83 @@ static int test_blockdev_getss_0 (void) if (r == -1) return -1; } - /* TestOutputInt for blockdev_getss (0) */ { char device[] = "/dev/sda"; device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; int r; suppress_error = 0; - r = guestfs_blockdev_getss (g, device); + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); if (r == -1) return -1; - if (r != 512) { - fprintf (stderr, "test_blockdev_getss_0: expected 512 but got %d\n", (int) r); - return -1; - } } - return 0; -} - -static int test_blockdev_getro_0 (void) -{ - /* InitEmpty for blockdev_getro (0) */ { - char device[] = "/dev/sda"; + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; device[5] = devchar; int r; suppress_error = 0; - r = guestfs_blockdev_setrw (g, device); + r = guestfs_mkfs (g, fstype, device); if (r == -1) return -1; } { + char device[] = "/dev/sda1"; + device[5] = devchar; + char mountpoint[] = "/"; int r; suppress_error = 0; - r = guestfs_umount_all (g); + r = guestfs_mount (g, device, mountpoint); if (r == -1) return -1; } + /* TestOutput for command (7) */ + char expected[] = "\n"; { + char remotefilename[] = "/test-command"; int r; suppress_error = 0; - r = guestfs_lvm_remove_all (g); + r = guestfs_upload (g, "test-command", remotefilename); if (r == -1) return -1; } - /* TestOutputTrue for blockdev_getro (0) */ { - char device[] = "/dev/sda"; - device[5] = devchar; + char path[] = "/test-command"; int r; suppress_error = 0; - r = guestfs_blockdev_setro (g, device); + r = guestfs_chmod (g, 493, path); if (r == -1) return -1; } { - char device[] = "/dev/sda"; - device[5] = devchar; - int r; + char arguments_0[] = "/test-command"; + char arguments_1[] = "8"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char *r; suppress_error = 0; - r = guestfs_blockdev_getro (g, device); - if (r == -1) + r = guestfs_command (g, arguments); + if (r == NULL) return -1; - if (!r) { - fprintf (stderr, "test_blockdev_getro_0: expected true, got false\n"); + if (strcmp (r, expected) != 0) { + fprintf (stderr, "test_command_7: expected \"%s\" but got \"%s\"\n", expected, r); return -1; } + free (r); } return 0; } -static int test_blockdev_setrw_0 (void) +static int test_command_8 (void) { - /* InitEmpty for blockdev_setrw (0) */ + /* InitBasicFS for command (8): create ext2 on /dev/sda1 */ { char device[] = "/dev/sda"; device[5] = devchar; @@ -4548,87 +7172,83 @@ static int test_blockdev_setrw_0 (void) if (r == -1) return -1; } - /* TestOutputFalse for blockdev_setrw (0) */ { char device[] = "/dev/sda"; device[5] = devchar; + char lines_0[] = ","; + char *lines[] = { + lines_0, + NULL + }; int r; suppress_error = 0; - r = guestfs_blockdev_setrw (g, device); + r = guestfs_sfdisk (g, device, 0, 0, 0, lines); if (r == -1) return -1; } { - char device[] = "/dev/sda"; + char fstype[] = "ext2"; + char device[] = "/dev/sda1"; device[5] = devchar; int r; suppress_error = 0; - r = guestfs_blockdev_getro (g, device); + r = guestfs_mkfs (g, fstype, device); if (r == -1) return -1; - if (r) { - fprintf (stderr, "test_blockdev_setrw_0: expected false, got true\n"); - return -1; - } } - return 0; -} - -static int test_blockdev_setro_0 (void) -{ - /* InitEmpty for blockdev_setro (0) */ { - char device[] = "/dev/sda"; + char device[] = "/dev/sda1"; device[5] = devchar; + char mountpoint[] = "/"; int r; suppress_error = 0; - r = guestfs_blockdev_setrw (g, device); - if (r == -1) - return -1; - } - { - int r; - suppress_error = 0; - r = guestfs_umount_all (g); + r = guestfs_mount (g, device, mountpoint); if (r == -1) return -1; } + /* TestOutput for command (8) */ + char expected[] = "\n\n"; { + char remotefilename[] = "/test-command"; int r; suppress_error = 0; - r = guestfs_lvm_remove_all (g); + r = guestfs_upload (g, "test-command", remotefilename); if (r == -1) return -1; } - /* TestOutputTrue for blockdev_setro (0) */ { - char device[] = "/dev/sda"; - device[5] = devchar; + char path[] = "/test-command"; int r; suppress_error = 0; - r = guestfs_blockdev_setro (g, device); + r = guestfs_chmod (g, 493, path); if (r == -1) return -1; } { - char device[] = "/dev/sda"; - device[5] = devchar; - int r; + char arguments_0[] = "/test-command"; + char arguments_1[] = "9"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char *r; suppress_error = 0; - r = guestfs_blockdev_getro (g, device); - if (r == -1) + r = guestfs_command (g, arguments); + if (r == NULL) return -1; - if (!r) { - fprintf (stderr, "test_blockdev_setro_0: expected true, got false\n"); + if (strcmp (r, expected) != 0) { + fprintf (stderr, "test_command_8: expected \"%s\" but got \"%s\"\n", expected, r); return -1; } + free (r); } return 0; } -static int test_statvfs_0 (void) +static int test_command_9 (void) { - /* InitBasicFS for statvfs (0): create ext2 on /dev/sda1 */ + /* InitBasicFS for command (9): create ext2 on /dev/sda1 */ { char device[] = "/dev/sda"; device[5] = devchar; @@ -4686,27 +7306,39 @@ static int test_statvfs_0 (void) if (r == -1) return -1; } - /* TestOutputStruct for statvfs (0) */ + /* TestOutput for command (9) */ + char expected[] = "Result10-1\nResult10-2\n"; { - char path[] = "/"; - struct guestfs_statvfs *r; + char remotefilename[] = "/test-command"; + int r; suppress_error = 0; - r = guestfs_statvfs (g, path); - if (r == NULL) + r = guestfs_upload (g, "test-command", remotefilename); + if (r == -1) return -1; - if (r->bfree != 487702) { - fprintf (stderr, "test_statvfs_0: bfree was %d, expected 487702\n", - (int) r->bfree); + } + { + char path[] = "/test-command"; + int r; + suppress_error = 0; + r = guestfs_chmod (g, 493, path); + if (r == -1) return -1; - } - if (r->blocks != 490020) { - fprintf (stderr, "test_statvfs_0: blocks was %d, expected 490020\n", - (int) r->blocks); + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "10"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char *r; + suppress_error = 0; + r = guestfs_command (g, arguments); + if (r == NULL) return -1; - } - if (r->bsize != 1024) { - fprintf (stderr, "test_statvfs_0: bsize was %d, expected 1024\n", - (int) r->bsize); + if (strcmp (r, expected) != 0) { + fprintf (stderr, "test_command_9: expected \"%s\" but got \"%s\"\n", expected, r); return -1; } free (r); @@ -4714,9 +7346,9 @@ static int test_statvfs_0 (void) return 0; } -static int test_lstat_0 (void) +static int test_command_10 (void) { - /* InitBasicFS for lstat (0): create ext2 on /dev/sda1 */ + /* InitBasicFS for command (10): create ext2 on /dev/sda1 */ { char device[] = "/dev/sda"; device[5] = devchar; @@ -4774,25 +7406,39 @@ static int test_lstat_0 (void) if (r == -1) return -1; } - /* TestOutputStruct for lstat (0) */ + /* TestOutput for command (10) */ + char expected[] = "Result11-1\nResult11-2"; { - char path[] = "/new"; + char remotefilename[] = "/test-command"; int r; suppress_error = 0; - r = guestfs_touch (g, path); + r = guestfs_upload (g, "test-command", remotefilename); if (r == -1) return -1; } { - char path[] = "/new"; - struct guestfs_stat *r; + char path[] = "/test-command"; + int r; suppress_error = 0; - r = guestfs_lstat (g, path); + r = guestfs_chmod (g, 493, path); + if (r == -1) + return -1; + } + { + char arguments_0[] = "/test-command"; + char arguments_1[] = "11"; + char *arguments[] = { + arguments_0, + arguments_1, + NULL + }; + char *r; + suppress_error = 0; + r = guestfs_command (g, arguments); if (r == NULL) return -1; - if (r->size != 0) { - fprintf (stderr, "test_lstat_0: size was %d, expected 0\n", - (int) r->size); + if (strcmp (r, expected) != 0) { + fprintf (stderr, "test_command_10: expected \"%s\" but got \"%s\"\n", expected, r); return -1; } free (r); @@ -4800,9 +7446,9 @@ static int test_lstat_0 (void) return 0; } -static int test_stat_0 (void) +static int test_command_11 (void) { - /* InitBasicFS for stat (0): create ext2 on /dev/sda1 */ + /* InitBasicFS for command (11): create ext2 on /dev/sda1 */ { char device[] = "/dev/sda"; device[5] = devchar; @@ -4860,27 +7506,34 @@ static int test_stat_0 (void) if (r == -1) return -1; } - /* TestOutputStruct for stat (0) */ + /* TestLastFail for command (11) */ { - char path[] = "/new"; + char remotefilename[] = "/test-command"; int r; suppress_error = 0; - r = guestfs_touch (g, path); + r = guestfs_upload (g, "test-command", remotefilename); if (r == -1) return -1; } { - char path[] = "/new"; - struct guestfs_stat *r; + char path[] = "/test-command"; + int r; suppress_error = 0; - r = guestfs_stat (g, path); - if (r == NULL) + r = guestfs_chmod (g, 493, path); + if (r == -1) return -1; - if (r->size != 0) { - fprintf (stderr, "test_stat_0: size was %d, expected 0\n", - (int) r->size); + } + { + char arguments_0[] = "/test-command"; + char *arguments[] = { + arguments_0, + NULL + }; + char *r; + suppress_error = 1; + r = guestfs_command (g, arguments); + if (r != NULL) return -1; - } free (r); } return 0; @@ -10157,7 +12810,7 @@ int main (int argc, char *argv[]) free (devs[i]); free (devs); - nr_tests = 110; + nr_tests = 134; test_num++; printf ("%3d/%3d test_hexdump_0\n", test_num, nr_tests); @@ -10178,6 +12831,12 @@ int main (int argc, char *argv[]) failed++; } test_num++; + printf ("%3d/%3d test_strings_1\n", test_num, nr_tests); + if (test_strings_1 () == -1) { + printf ("test_strings_1 FAILED\n"); + failed++; + } + test_num++; printf ("%3d/%3d test_equal_0\n", test_num, nr_tests); if (test_equal_0 () == -1) { printf ("test_equal_0 FAILED\n"); @@ -10508,6 +13167,144 @@ int main (int argc, char *argv[]) failed++; } test_num++; + printf ("%3d/%3d test_command_lines_0\n", test_num, nr_tests); + if (test_command_lines_0 () == -1) { + printf ("test_command_lines_0 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_lines_1\n", test_num, nr_tests); + if (test_command_lines_1 () == -1) { + printf ("test_command_lines_1 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_lines_2\n", test_num, nr_tests); + if (test_command_lines_2 () == -1) { + printf ("test_command_lines_2 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_lines_3\n", test_num, nr_tests); + if (test_command_lines_3 () == -1) { + printf ("test_command_lines_3 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_lines_4\n", test_num, nr_tests); + if (test_command_lines_4 () == -1) { + printf ("test_command_lines_4 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_lines_5\n", test_num, nr_tests); + if (test_command_lines_5 () == -1) { + printf ("test_command_lines_5 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_lines_6\n", test_num, nr_tests); + if (test_command_lines_6 () == -1) { + printf ("test_command_lines_6 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_lines_7\n", test_num, nr_tests); + if (test_command_lines_7 () == -1) { + printf ("test_command_lines_7 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_lines_8\n", test_num, nr_tests); + if (test_command_lines_8 () == -1) { + printf ("test_command_lines_8 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_lines_9\n", test_num, nr_tests); + if (test_command_lines_9 () == -1) { + printf ("test_command_lines_9 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_lines_10\n", test_num, nr_tests); + if (test_command_lines_10 () == -1) { + printf ("test_command_lines_10 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_0\n", test_num, nr_tests); + if (test_command_0 () == -1) { + printf ("test_command_0 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_1\n", test_num, nr_tests); + if (test_command_1 () == -1) { + printf ("test_command_1 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_2\n", test_num, nr_tests); + if (test_command_2 () == -1) { + printf ("test_command_2 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_3\n", test_num, nr_tests); + if (test_command_3 () == -1) { + printf ("test_command_3 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_4\n", test_num, nr_tests); + if (test_command_4 () == -1) { + printf ("test_command_4 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_5\n", test_num, nr_tests); + if (test_command_5 () == -1) { + printf ("test_command_5 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_6\n", test_num, nr_tests); + if (test_command_6 () == -1) { + printf ("test_command_6 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_7\n", test_num, nr_tests); + if (test_command_7 () == -1) { + printf ("test_command_7 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_8\n", test_num, nr_tests); + if (test_command_8 () == -1) { + printf ("test_command_8 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_9\n", test_num, nr_tests); + if (test_command_9 () == -1) { + printf ("test_command_9 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_10\n", test_num, nr_tests); + if (test_command_10 () == -1) { + printf ("test_command_10 FAILED\n"); + failed++; + } + test_num++; + printf ("%3d/%3d test_command_11\n", test_num, nr_tests); + if (test_command_11 () == -1) { + printf ("test_command_11 FAILED\n"); + failed++; + } + test_num++; printf ("%3d/%3d test_file_0\n", test_num, nr_tests); if (test_file_0 () == -1) { printf ("test_file_0 FAILED\n");