From e492608f2f3809a824cb70ee03ff305964b69dd7 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 29 Jun 2009 12:47:20 +0100 Subject: Generated code for 'du' command. --- capitests/tests.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 106 insertions(+), 1 deletion(-) (limited to 'capitests') diff --git a/capitests/tests.c b/capitests/tests.c index 08f64ee1..6e31c401 100644 --- a/capitests/tests.c +++ b/capitests/tests.c @@ -155,6 +155,105 @@ static void no_test_warnings (void) fprintf (stderr, "warning: \"guestfs_df_h\" has no tests\n"); } +static int test_du_0_skip (void) +{ + const char *str; + + str = getenv ("TEST_ONLY"); + if (str) + return strstr (str, "du") == NULL; + str = getenv ("SKIP_TEST_DU_0"); + if (str && strcmp (str, "1") == 0) return 1; + str = getenv ("SKIP_TEST_DU"); + if (str && strcmp (str, "1") == 0) return 1; + return 0; +} + +static int test_du_0 (void) +{ + if (test_du_0_skip ()) { + printf ("%s skipped (reason: environment variable set)\n", "test_du_0"); + return 0; + } + + /* InitBasicFS for test_du_0: create ext2 on /dev/sda1 */ + { + char device[] = "/dev/sda"; + 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"; + 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"; + int r; + suppress_error = 0; + r = guestfs_mkfs (g, fstype, device); + if (r == -1) + return -1; + } + { + char device[] = "/dev/sda1"; + char mountpoint[] = "/"; + int r; + suppress_error = 0; + r = guestfs_mount (g, device, mountpoint); + if (r == -1) + return -1; + } + /* TestOutputInt for du (0) */ + { + char path[] = "/p"; + int r; + suppress_error = 0; + r = guestfs_mkdir (g, path); + if (r == -1) + return -1; + } + { + char path[] = "/p"; + int64_t r; + suppress_error = 0; + r = guestfs_du (g, path); + if (r == -1) + return -1; + if (r != 1) { + fprintf (stderr, "test_du_0: expected 1 but got %d\n", (int) r); + return -1; + } + } + return 0; +} + static int test_tail_n_0_skip (void) { const char *str; @@ -18509,8 +18608,14 @@ int main (int argc, char *argv[]) /* Cancel previous alarm. */ alarm (0); - nr_tests = 164; + nr_tests = 165; + test_num++; + printf ("%3d/%3d test_du_0\n", test_num, nr_tests); + if (test_du_0 () == -1) { + printf ("test_du_0 FAILED\n"); + failed++; + } test_num++; printf ("%3d/%3d test_tail_n_0\n", test_num, nr_tests); if (test_tail_n_0 () == -1) { -- cgit