X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=generator%2Fgenerator_capitests.ml;h=190e10f7e387e87164b6690ee51b01454c92ff4e;hb=a22d5a7390339eca5d9bafb2155439ad1ccc02ac;hp=707d59b7416bfc19e791de90eaaf47f66d4ccba3;hpb=2a33d81e2b7fa2affaaad48538307c818b4a8260;p=libguestfs.git diff --git a/generator/generator_capitests.ml b/generator/generator_capitests.ml index 707d59b..190e10f 100644 --- a/generator/generator_capitests.ml +++ b/generator/generator_capitests.ml @@ -176,19 +176,13 @@ int main (int argc, char *argv[]) guestfs_set_error_handler (g, print_error, NULL); filename = \"test1.img\"; - fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666); + fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_TRUNC, 0666); if (fd == -1) { perror (filename); exit (EXIT_FAILURE); } - if (lseek (fd, %d, SEEK_SET) == -1) { - perror (\"lseek\"); - close (fd); - unlink (filename); - exit (EXIT_FAILURE); - } - if (write (fd, &c, 1) == -1) { - perror (\"write\"); + if (ftruncate (fd, %d) == -1) { + perror (\"ftruncate\"); close (fd); unlink (filename); exit (EXIT_FAILURE); @@ -204,19 +198,13 @@ int main (int argc, char *argv[]) } filename = \"test2.img\"; - fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666); + fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_TRUNC, 0666); if (fd == -1) { perror (filename); exit (EXIT_FAILURE); } - if (lseek (fd, %d, SEEK_SET) == -1) { - perror (\"lseek\"); - close (fd); - unlink (filename); - exit (EXIT_FAILURE); - } - if (write (fd, &c, 1) == -1) { - perror (\"write\"); + if (ftruncate (fd, %d) == -1) { + perror (\"ftruncate\"); close (fd); unlink (filename); exit (EXIT_FAILURE); @@ -232,19 +220,13 @@ int main (int argc, char *argv[]) } filename = \"test3.img\"; - fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_NONBLOCK|O_TRUNC, 0666); + fd = open (filename, O_WRONLY|O_CREAT|O_NOCTTY|O_TRUNC, 0666); if (fd == -1) { perror (filename); exit (EXIT_FAILURE); } - if (lseek (fd, %d, SEEK_SET) == -1) { - perror (\"lseek\"); - close (fd); - unlink (filename); - exit (EXIT_FAILURE); - } - if (write (fd, &c, 1) == -1) { - perror (\"write\"); + if (ftruncate (fd, %d) == -1) { + perror (\"ftruncate\"); close (fd); unlink (filename); exit (EXIT_FAILURE); @@ -762,6 +744,9 @@ and generate_test_command_call ?(expect_error = false) ?test test_name cmd = ) strs; pr " NULL\n"; pr " };\n"; + | Pointer _, _ -> + (* Difficult to make these pointers in order to run a test. *) + assert false ) (List.combine (snd style) args); let error_code = @@ -817,6 +802,7 @@ and generate_test_command_call ?(expect_error = false) ?test test_name cmd = pr ", %Ld" i | Bool _, arg -> let b = bool_of_string arg in pr ", %d" (if b then 1 else 0) + | Pointer _, _ -> assert false ) (List.combine (snd style) args); (match fst style with