summaryrefslogtreecommitdiffstats
path: root/capitests
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2009-06-29 12:47:20 +0100
committerRichard W.M. Jones <rjones@redhat.com>2009-06-29 12:47:20 +0100
commite492608f2f3809a824cb70ee03ff305964b69dd7 (patch)
tree953ec56c34431549dab177eec9e0fe979606e5eb /capitests
parent9a92446bcad09b492dee42dd5950bac67073fbea (diff)
downloadlibguestfs-e492608f2f3809a824cb70ee03ff305964b69dd7.tar.gz
libguestfs-e492608f2f3809a824cb70ee03ff305964b69dd7.tar.xz
libguestfs-e492608f2f3809a824cb70ee03ff305964b69dd7.zip
Generated code for 'du' command.
Diffstat (limited to 'capitests')
-rw-r--r--capitests/tests.c107
1 files changed, 106 insertions, 1 deletions
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,9 +18608,15 @@ 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) {
printf ("test_tail_n_0 FAILED\n");