summaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2010-09-15 17:15:44 +0100
committerRichard Jones <rjones@redhat.com>2010-09-15 17:16:51 +0100
commitff38fea645e69e8f4d84f2691dac3116d9bac1c4 (patch)
tree55f1b0f40051505533ad95d8d0df09c668a8f73f /generator
parent43d5ea6f1ed4cc74c521e4d2b0eec6110f5c44fd (diff)
downloadlibguestfs-ff38fea645e69e8f4d84f2691dac3116d9bac1c4.tar.gz
libguestfs-ff38fea645e69e8f4d84f2691dac3116d9bac1c4.tar.xz
libguestfs-ff38fea645e69e8f4d84f2691dac3116d9bac1c4.zip
generator: Add TestOutputDevice.
This is for testing functions that return a device or partition name, so that we can compare the return value with the canonical device name (eg. "/dev/vda1" == "/dev/sda1").
Diffstat (limited to 'generator')
-rw-r--r--generator/generator_capitests.ml13
-rw-r--r--generator/generator_types.ml6
-rw-r--r--generator/generator_utils.ml1
3 files changed, 20 insertions, 0 deletions
diff --git a/generator/generator_capitests.ml b/generator/generator_capitests.ml
index 044c70d4..594c8676 100644
--- a/generator/generator_capitests.ml
+++ b/generator/generator_capitests.ml
@@ -685,6 +685,19 @@ and generate_one_test_body name i test_name init test =
in
List.iter (generate_test_command_call test_name) seq;
generate_test_command_call ~test test_name last
+ | TestOutputDevice (seq, expected) ->
+ pr " /* TestOutputDevice for %s (%d) */\n" name i;
+ pr " const char *expected = \"%s\";\n" (c_quote expected);
+ let seq, last = get_seq_last seq in
+ let test () =
+ pr " r[5] = 's';\n";
+ pr " if (STRNEQ (r, expected)) {\n";
+ pr " fprintf (stderr, \"%s: expected \\\"%%s\\\" but got \\\"%%s\\\"\\n\", expected, r);\n" test_name;
+ pr " return -1;\n";
+ pr " }\n"
+ in
+ List.iter (generate_test_command_call test_name) seq;
+ generate_test_command_call ~test test_name last
| TestLastFail seq ->
pr " /* TestLastFail for %s (%d) */\n" name i;
let seq, last = get_seq_last seq in
diff --git a/generator/generator_types.ml b/generator/generator_types.ml
index 49d37922..0ed6f748 100644
--- a/generator/generator_types.ml
+++ b/generator/generator_types.ml
@@ -266,6 +266,12 @@ and test =
*)
| TestOutputFileMD5 of seq * string
+ (* Run the command sequence and expect the output of the final
+ * command to be a string which is a block device name (we don't
+ * check the 5th character of the string, so "/dev/sda" == "/dev/vda").
+ *)
+ | TestOutputDevice of seq * string
+
(* Run the command sequence and expect the final command (only)
* to fail.
*)
diff --git a/generator/generator_utils.ml b/generator/generator_utils.ml
index 329e6ceb..2bdcc0d8 100644
--- a/generator/generator_utils.ml
+++ b/generator/generator_utils.ml
@@ -240,6 +240,7 @@ let seq_of_test = function
| TestOutputLength (s, _) | TestOutputBuffer (s, _)
| TestOutputStruct (s, _)
| TestOutputFileMD5 (s, _)
+ | TestOutputDevice (s, _)
| TestLastFail s -> s
let c_quote str =