html/guestfs.3.html
html/recipes.html
html/virt-inspector.1.html
+images/test.sqsh
initramfs
initramfs.timestamp
inspector/virt-inspector.1
- XDR, rpcgen (on Linux these are provided by glibc)
+- squashfs-tools (mksquashfs only)
+
- (Optional) Augeas (http://augeas.net/)
- perldoc (pod2man, pod2text) to generate the manual pages and
return 0;
}
+static int test_checksum_8_skip (void)
+{
+ const char *str;
+
+ str = getenv ("SKIP_TEST_CHECKSUM_8");
+ if (str && strcmp (str, "1") == 0) return 1;
+ str = getenv ("SKIP_TEST_CHECKSUM");
+ if (str && strcmp (str, "1") == 0) return 1;
+ return 0;
+}
+
+static int test_checksum_8 (void)
+{
+ if (test_checksum_8_skip ()) {
+ printf ("%s skipped (reason: SKIP_TEST_* variable set)\n", "test_checksum_8");
+ return 0;
+ }
+
+ /* InitBasicFS for test_checksum_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;
+ }
+ /* TestOutput for checksum (8) */
+ char expected[] = "46d6ca27ee07cdc6fa99c2e138cc522c";
+ {
+ char device[] = "/dev/sdd";
+ device[5] = devchar;
+ char mountpoint[] = "/";
+ int r;
+ suppress_error = 0;
+ r = guestfs_mount (g, device, mountpoint);
+ if (r == -1)
+ return -1;
+ }
+ {
+ char csumtype[] = "md5";
+ char path[] = "/known-3";
+ char *r;
+ suppress_error = 0;
+ r = guestfs_checksum (g, csumtype, path);
+ if (r == NULL)
+ return -1;
+ if (strcmp (r, expected) != 0) {
+ fprintf (stderr, "test_checksum_8: expected \"%s\" but got \"%s\"\n", expected, r);
+ return -1;
+ }
+ free (r);
+ }
+ return 0;
+}
+
static int test_download_0_skip (void)
{
const char *str;
return -1;
}
}
- if (r[3] != NULL) {
+ if (!r[3]) {
+ fprintf (stderr, "test_list_devices_0: short list returned from command\n");
+ print_strings (r);
+ return -1;
+ }
+ {
+ char expected[] = "/dev/sdd";
+ expected[5] = devchar;
+ if (strcmp (r[3], expected) != 0) {
+ fprintf (stderr, "test_list_devices_0: expected \"%s\" but got \"%s\"\n", expected, r[3]);
+ return -1;
+ }
+ }
+ if (r[4] != NULL) {
fprintf (stderr, "test_list_devices_0: extra elements returned from command\n");
print_strings (r);
return -1;
exit (1);
}
+ if (guestfs_add_drive (g, "../images/test.sqsh") == -1) {
+ printf ("guestfs_add_drive %s FAILED\n", filename);
+ exit (1);
+ }
+
if (guestfs_launch (g) == -1) {
printf ("guestfs_launch FAILED\n");
exit (1);
free (devs[i]);
free (devs);
- nr_tests = 142;
+ nr_tests = 143;
test_num++;
printf ("%3d/%3d test_find_0\n", test_num, nr_tests);
failed++;
}
test_num++;
+ printf ("%3d/%3d test_checksum_8\n", test_num, nr_tests);
+ if (test_checksum_8 () == -1) {
+ printf ("test_checksum_8 FAILED\n");
+ failed++;
+ }
+ test_num++;
printf ("%3d/%3d test_download_0\n", test_num, nr_tests);
if (test_download_0 () == -1) {
printf ("test_download_0 FAILED\n");
test "x$POD2TEXT" = "xno" &&
AC_MSG_ERROR([pod2text must be installed])
+dnl Check for mksquashfs.
+AC_PATH_PROGS([MKSQUASHFS],[mksquashfs],[no],
+ [$PATH$PATH_SEPARATOR/usr/sbin$PATH_SEPARATOR/sbin])
+test "x$MKSQUASHFS" = "xno" && AC_MSG_ERROR([mksquashfs must be installed])
+
dnl Check for QEMU for running binaries on this $host_cpu, fall
dnl back to basic 'qemu'. Allow the user to override it.
default_qemu="qemu-kvm qemu-system-$host_cpu qemu"
EXTRA_DIST = \
helloworld.tar \
helloworld.tar.gz \
- mbr-ext2-empty.img.gz
+ mbr-ext2-empty.img.gz \
+ empty known-1 known-2 known-3
+
+noinst_DATA = test.sqsh
+
+CLEANFILES = test.sqsh
+
+squash_files = helloworld.tar helloworld.tar.gz empty known-1 known-2 known-3
+
+test.sqsh: $(squash_files)
+ rm -f $@
+ $(MKSQUASHFS) $(squash_files) $@
--- /dev/null
+ I WANDERED lonely as a cloud
+ That floats on high o'er vales and hills,
+ When all at once I saw a crowd,
+ A host, of golden daffodils;
+ Beside the lake, beneath the trees,
+ Fluttering and dancing in the breeze.
+
+ Continuous as the stars that shine
+ And twinkle on the milky way,
+ They stretched in never-ending line
+ Along the margin of a bay:
+ Ten thousand saw I at a glance,
+ Tossing their heads in sprightly dance.
+
+ The waves beside them danced; but they
+ Out-did the sparkling waves in glee:
+ A poet could not but be gay,
+ In such a jocund company:
+ I gazed--and gazed--but little thought
+ What wealth the show to me had brought:
+
+ For oft, when on my couch I lie
+ In vacant or in pensive mood,
+ They flash upon that inward eye
+ Which is the bliss of solitude;
+ And then my heart with pleasure fills,
+ And dances with the daffodils.
(* You can supply zero or as many tests as you want per API call.
*
* Note that the test environment has 3 block devices, of size 500MB,
- * 50MB and 10MB (respectively /dev/sda, /dev/sdb, /dev/sdc).
+ * 50MB and 10MB (respectively /dev/sda, /dev/sdb, /dev/sdc), and
+ * a fourth squashfs block device with some known files on it (/dev/sdd).
+ *
* Note for partitioning purposes, the 500MB device has 63 cylinders.
*
+ * The squashfs block device (/dev/sdd) comes from images/test.sqsh.
+ *
* To be able to run the tests in a reasonable amount of time,
* the virtual machine and block devices are reused between tests.
* So don't try testing kill_subprocess :-x
("list_devices", (RStringList "devices", []), 7, [],
[InitEmpty, Always, TestOutputList (
- [["list_devices"]], ["/dev/sda"; "/dev/sdb"; "/dev/sdc"])],
+ [["list_devices"]], ["/dev/sda"; "/dev/sdb"; "/dev/sdc"; "/dev/sdd"])],
"list the block devices",
"\
List all the block devices.
["checksum"; "sha384"; "/new"]], "109bb6b5b6d5547c1ce03c7a8bd7d8f80c1cb0957f50c4f7fda04692079917e4f9cad52b878f3d8234e1a170b154b72d");
InitBasicFS, Always, TestOutput (
[["write_file"; "/new"; "test\n"; "0"];
- ["checksum"; "sha512"; "/new"]], "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123")],
+ ["checksum"; "sha512"; "/new"]], "0e3e75234abc68f4378a86b3f4b32a198ba301845b0cd6e50106e874345700cc6663a86c1ea125dc5e92be17c98f9a0f85ca9d5f595db2012f7cc3571945c123");
+ InitBasicFS, Always, TestOutput (
+ [["mount"; "/dev/sdd"; "/"];
+ ["checksum"; "md5"; "/known-3"]], "46d6ca27ee07cdc6fa99c2e138cc522c")],
"compute MD5, SHAx or CRC checksum of file",
"\
This call computes the MD5, SHAx or CRC checksum of the
exit (1);
}
+ if (guestfs_add_drive (g, \"../images/test.sqsh\") == -1) {
+ printf (\"guestfs_add_drive %%s FAILED\\n\", filename);
+ exit (1);
+ }
+
if (guestfs_launch (g) == -1) {
printf (\"guestfs_launch FAILED\\n\");
exit (1);