Generated code for 'equal' command.
[libguestfs.git] / tests.c
diff --git a/tests.c b/tests.c
index 082068a..d1bccc5 100644 (file)
--- a/tests.c
+++ b/tests.c
@@ -112,6 +112,258 @@ static void no_test_warnings (void)
   fprintf (stderr, "warning: \"guestfs_get_e2uuid\" has no tests\n");
 }
 
+static int test_equal_0 (void)
+{
+  /* InitBasicFS for equal (0): create ext2 on /dev/sda1 */
+  {
+    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 *lines[] = {
+      ",",
+      NULL
+    };
+    int r;
+    suppress_error = 0;
+    r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
+    if (r == -1)
+      return -1;
+  }
+  {
+    int r;
+    suppress_error = 0;
+    r = guestfs_mkfs (g, "ext2", "/dev/sda1");
+    if (r == -1)
+      return -1;
+  }
+  {
+    int r;
+    suppress_error = 0;
+    r = guestfs_mount (g, "/dev/sda1", "/");
+    if (r == -1)
+      return -1;
+  }
+  /* TestOutputTrue for equal (0) */
+  {
+    int r;
+    suppress_error = 0;
+    r = guestfs_write_file (g, "/file1", "contents of a file", 0);
+    if (r == -1)
+      return -1;
+  }
+  {
+    int r;
+    suppress_error = 0;
+    r = guestfs_cp (g, "/file1", "/file2");
+    if (r == -1)
+      return -1;
+  }
+  {
+    int r;
+    suppress_error = 0;
+    r = guestfs_equal (g, "/file1", "/file2");
+    if (r == -1)
+      return -1;
+    if (!r) {
+      fprintf (stderr, "test_equal_0: expected true, got false\n");
+      return -1;
+    }
+  }
+  return 0;
+}
+
+static int test_equal_1 (void)
+{
+  /* InitBasicFS for equal (1): create ext2 on /dev/sda1 */
+  {
+    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 *lines[] = {
+      ",",
+      NULL
+    };
+    int r;
+    suppress_error = 0;
+    r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
+    if (r == -1)
+      return -1;
+  }
+  {
+    int r;
+    suppress_error = 0;
+    r = guestfs_mkfs (g, "ext2", "/dev/sda1");
+    if (r == -1)
+      return -1;
+  }
+  {
+    int r;
+    suppress_error = 0;
+    r = guestfs_mount (g, "/dev/sda1", "/");
+    if (r == -1)
+      return -1;
+  }
+  /* TestOutputFalse for equal (1) */
+  {
+    int r;
+    suppress_error = 0;
+    r = guestfs_write_file (g, "/file1", "contents of a file", 0);
+    if (r == -1)
+      return -1;
+  }
+  {
+    int r;
+    suppress_error = 0;
+    r = guestfs_write_file (g, "/file2", "contents of another file", 0);
+    if (r == -1)
+      return -1;
+  }
+  {
+    int r;
+    suppress_error = 0;
+    r = guestfs_equal (g, "/file1", "/file2");
+    if (r == -1)
+      return -1;
+    if (r) {
+      fprintf (stderr, "test_equal_1: expected false, got true\n");
+      return -1;
+    }
+  }
+  return 0;
+}
+
+static int test_equal_2 (void)
+{
+  /* InitBasicFS for equal (2): create ext2 on /dev/sda1 */
+  {
+    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 *lines[] = {
+      ",",
+      NULL
+    };
+    int r;
+    suppress_error = 0;
+    r = guestfs_sfdisk (g, "/dev/sda", 0, 0, 0, lines);
+    if (r == -1)
+      return -1;
+  }
+  {
+    int r;
+    suppress_error = 0;
+    r = guestfs_mkfs (g, "ext2", "/dev/sda1");
+    if (r == -1)
+      return -1;
+  }
+  {
+    int r;
+    suppress_error = 0;
+    r = guestfs_mount (g, "/dev/sda1", "/");
+    if (r == -1)
+      return -1;
+  }
+  /* TestLastFail for equal (2) */
+  {
+    int r;
+    suppress_error = 1;
+    r = guestfs_equal (g, "/file1", "/file2");
+    if (r != -1)
+      return -1;
+  }
+  return 0;
+}
+
+static int test_ping_daemon_0 (void)
+{
+  /* InitEmpty for ping_daemon (0) */
+  {
+    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;
+  }
+  /* TestRun for ping_daemon (0) */
+  {
+    int r;
+    suppress_error = 0;
+    r = guestfs_ping_daemon (g);
+    if (r == -1)
+      return -1;
+  }
+  return 0;
+}
+
+static int test_dmesg_0 (void)
+{
+  /* InitEmpty for dmesg (0) */
+  {
+    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;
+  }
+  /* TestRun for dmesg (0) */
+  {
+    char *r;
+    suppress_error = 0;
+    r = guestfs_dmesg (g);
+    if (r == NULL)
+      return -1;
+    free (r);
+  }
+  return 0;
+}
+
 static int test_drop_caches_0 (void)
 {
   /* InitEmpty for drop_caches (0) */
@@ -7263,9 +7515,39 @@ int main (int argc, char *argv[])
     exit (1);
   }
 
-  nr_tests = 102;
+  nr_tests = 107;
 
   test_num++;
+  printf ("%3d/%3d test_equal_0\n", test_num, nr_tests);
+  if (test_equal_0 () == -1) {
+    printf ("test_equal_0 FAILED\n");
+    failed++;
+  }
+  test_num++;
+  printf ("%3d/%3d test_equal_1\n", test_num, nr_tests);
+  if (test_equal_1 () == -1) {
+    printf ("test_equal_1 FAILED\n");
+    failed++;
+  }
+  test_num++;
+  printf ("%3d/%3d test_equal_2\n", test_num, nr_tests);
+  if (test_equal_2 () == -1) {
+    printf ("test_equal_2 FAILED\n");
+    failed++;
+  }
+  test_num++;
+  printf ("%3d/%3d test_ping_daemon_0\n", test_num, nr_tests);
+  if (test_ping_daemon_0 () == -1) {
+    printf ("test_ping_daemon_0 FAILED\n");
+    failed++;
+  }
+  test_num++;
+  printf ("%3d/%3d test_dmesg_0\n", test_num, nr_tests);
+  if (test_dmesg_0 () == -1) {
+    printf ("test_dmesg_0 FAILED\n");
+    failed++;
+  }
+  test_num++;
   printf ("%3d/%3d test_drop_caches_0\n", test_num, nr_tests);
   if (test_drop_caches_0 () == -1) {
     printf ("test_drop_caches_0 FAILED\n");