From 685c5fb3b10e45bb8c4b60480da805a49cadb9c7 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Fri, 12 Apr 2013 17:19:22 +0100 Subject: [PATCH] tests: Replace TestOutput/TestOutputDevice with TestResult{String,Device}. --- generator/actions.ml | 224 +++++++++++++++++++-------------------- generator/tests_c_api.ml | 47 ++++---- generator/types.ml | 8 +- generator/utils.ml | 4 +- 4 files changed, 144 insertions(+), 139 deletions(-) diff --git a/generator/actions.ml b/generator/actions.ml index a7baa5056..df68dc79f 100644 --- a/generator/actions.ml +++ b/generator/actions.ml @@ -742,29 +742,29 @@ to specify the QEMU interface emulation to use at run time." }; name = "file_architecture"; style = RString "arch", [Pathname "filename"], []; tests = [ - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["file_architecture"; "/bin-i586-dynamic"]], "i386"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["file_architecture"; "/bin-sparc-dynamic"]], "sparc"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["file_architecture"; "/bin-win32.exe"]], "i386"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["file_architecture"; "/bin-win64.exe"]], "x86_64"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["file_architecture"; "/bin-x86_64-dynamic"]], "x86_64"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["file_architecture"; "/lib-i586.so"]], "i386"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["file_architecture"; "/lib-sparc.so"]], "sparc"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["file_architecture"; "/lib-win32.dll"]], "i386"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["file_architecture"; "/lib-win64.dll"]], "x86_64"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["file_architecture"; "/lib-x86_64.so"]], "x86_64"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["file_architecture"; "/initrd-x86_64.img"]], "x86_64"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["file_architecture"; "/initrd-x86_64.img.gz"]], "x86_64"); ]; shortdesc = "detect the architecture of a binary file"; @@ -2263,7 +2263,7 @@ but note that any errors are ignored in that case." }; name = "cat"; style = RString "content", [Pathname "path"], []; tests = [ - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["cat"; "/known-2"]], "abcdef\n") ]; shortdesc = "list the contents of a file"; @@ -2395,22 +2395,22 @@ function and split the buffer into lines yourself." }; name = "write"; style = RErr, [Pathname "path"; BufferIn "content"], []; tests = [ - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["write"; "/write"; "new file contents"]; ["cat"; "/write"]], "new file contents"); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["write"; "/write2"; "\nnew file contents\n"]; ["cat"; "/write2"]], "\nnew file contents\n"); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["write"; "/write3"; "\n\n"]; ["cat"; "/write3"]], "\n\n"); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["write"; "/write4"; ""]; ["cat"; "/write4"]], ""); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["write"; "/write5"; "\n\n\n"]; ["cat"; "/write5"]], "\n\n\n"); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["write"; "/write6"; "\n"]; ["cat"; "/write6"]], "\n") ]; @@ -2425,7 +2425,7 @@ See also C." }; name = "write_append"; style = RErr, [Pathname "path"; BufferIn "content"], []; tests = [ - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["write"; "/write_append"; "line1\n"]; ["write_append"; "/write_append"; "line2\n"]; ["write_append"; "/write_append"; "line3a"]; @@ -2544,11 +2544,11 @@ data." }; name = "disk_format"; style = RString "format", [String "filename"], []; tests = [ - InitEmpty, Always, TestOutput ( + InitEmpty, Always, TestResultString ( [["disk_format"; "test1.img"]], "raw"); - InitEmpty, Always, TestOutput ( + InitEmpty, Always, TestResultString ( [["disk_format"; "test2.img"]], "raw"); - InitEmpty, Always, TestOutput ( + InitEmpty, Always, TestResultString ( [["disk_format"; "test3.img"]], "raw"); ]; shortdesc = "detect the disk format of a disk image"; @@ -2903,7 +2903,7 @@ let daemon_functions = [ style = RErr, [Mountable "mountable"; String "mountpoint"], []; proc_nr = Some 1; tests = [ - InitEmpty, Always, TestOutput ( + InitEmpty, Always, TestResultString ( [["part_disk"; "/dev/sda"; "mbr"]; ["mkfs"; "ext2"; "/dev/sda1"; ""; "NOARG"; ""; ""]; ["mount"; "/dev/sda1"; "/"]; @@ -3760,15 +3760,15 @@ and physical volumes." }; style = RString "description", [Dev_or_Path "path"], []; proc_nr = Some 49; tests = [ - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["file"; "/empty"]], "empty"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["file"; "/known-1"]], "ASCII text"); InitISOFS, Always, TestLastFail ( [["file"; "/notexists"]]); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["file"; "/abssymlink"]], "symbolic link"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["file"; "/directory"]], "directory") ]; shortdesc = "determine file type"; @@ -3796,57 +3796,57 @@ C, C (etc), C." }; proc_nr = Some 50; protocol_limit_warning = true; tests = [ - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/command"]; ["upload"; "test-command"; "/command/test-command"]; ["chmod"; "0o755"; "/command/test-command"]; ["command"; "/command/test-command 1"]], "Result1"); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/command2"]; ["upload"; "test-command"; "/command2/test-command"]; ["chmod"; "0o755"; "/command2/test-command"]; ["command"; "/command2/test-command 2"]], "Result2\n"); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/command3"]; ["upload"; "test-command"; "/command3/test-command"]; ["chmod"; "0o755"; "/command3/test-command"]; ["command"; "/command3/test-command 3"]], "\nResult3"); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/command4"]; ["upload"; "test-command"; "/command4/test-command"]; ["chmod"; "0o755"; "/command4/test-command"]; ["command"; "/command4/test-command 4"]], "\nResult4\n"); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/command5"]; ["upload"; "test-command"; "/command5/test-command"]; ["chmod"; "0o755"; "/command5/test-command"]; ["command"; "/command5/test-command 5"]], "\nResult5\n\n"); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/command6"]; ["upload"; "test-command"; "/command6/test-command"]; ["chmod"; "0o755"; "/command6/test-command"]; ["command"; "/command6/test-command 6"]], "\n\nResult6\n\n"); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/command7"]; ["upload"; "test-command"; "/command7/test-command"]; ["chmod"; "0o755"; "/command7/test-command"]; ["command"; "/command7/test-command 7"]], ""); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/command8"]; ["upload"; "test-command"; "/command8/test-command"]; ["chmod"; "0o755"; "/command8/test-command"]; ["command"; "/command8/test-command 8"]], "\n"); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/command9"]; ["upload"; "test-command"; "/command9/test-command"]; ["chmod"; "0o755"; "/command9/test-command"]; ["command"; "/command9/test-command 9"]], "\n\n"); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/command10"]; ["upload"; "test-command"; "/command10/test-command"]; ["chmod"; "0o755"; "/command10/test-command"]; ["command"; "/command10/test-command 10"]], "Result10-1\nResult10-2\n"); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/command11"]; ["upload"; "test-command"; "/command11/test-command"]; ["chmod"; "0o755"; "/command11/test-command"]; @@ -3856,7 +3856,7 @@ C, C (etc), C." }; ["upload"; "test-command"; "/command12/test-command"]; ["chmod"; "0o755"; "/command12/test-command"]; ["command"; "/command12/test-command"]]); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/pwd"]; ["upload"; "test-pwd"; "/pwd/test-pwd"]; ["chmod"; "0o755"; "/pwd/test-pwd"]; @@ -4204,7 +4204,7 @@ This uses the L command." }; proc_nr = Some 66; progress = true; cancellable = true; tests = [ - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( (* Pick a file from cwd which isn't likely to change. *) [["mkdir"; "/upload"]; ["upload"; "../../COPYING.LIB"; "/upload/COPYING.LIB"]; @@ -4226,7 +4226,7 @@ See also C." }; proc_nr = Some 67; progress = true; cancellable = true; tests = [ - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( (* Pick a file from cwd which isn't likely to change. *) [["mkdir"; "/download"]; ["upload"; "../../COPYING.LIB"; "/download/COPYING.LIB"]; @@ -4249,24 +4249,24 @@ See also C, C." }; style = RString "checksum", [String "csumtype"; Pathname "path"], []; proc_nr = Some 68; tests = [ - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["checksum"; "crc"; "/known-3"]], "2891671662"); InitISOFS, Always, TestLastFail ( [["checksum"; "crc"; "/notexists"]]); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["checksum"; "md5"; "/known-3"]], "46d6ca27ee07cdc6fa99c2e138cc522c"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["checksum"; "sha1"; "/known-3"]], "b7ebccc3ee418311091c3eda0a45b83c0a770f15"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["checksum"; "sha224"; "/known-3"]], "d2cd1774b28f3659c14116be0a6dc2bb5c4b350ce9cd5defac707741"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["checksum"; "sha256"; "/known-3"]], "75bb71b90cd20cb13f86d2bea8dad63ac7194e7517c3b52b8d06ff52d3487d30"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["checksum"; "sha384"; "/known-3"]], "5fa7883430f357b5d7b7271d3a1d2872b51d73cba72731de6863d3dea55f30646af2799bef44d5ea776a5ec7941ac640"); - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["checksum"; "sha512"; "/known-3"]], "2794062c328c6b216dca90443b7f7134c5f40e56bd0ed7853123275a09982a6f992e6ca682f9d2fba34a4c5e870d8fe077694ff831e3032a004ee077e00603f6"); (* Test for RHBZ#579608, absolute symbolic links. *) - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["checksum"; "sha512"; "/abssymlink"]], "5f57d0639bc95081c53afc63a449403883818edc64da48930ad6b1a4fb49be90404686877743fbcd7c99811f3def7df7bc22635c885c6a8cf79c806b43451c1a") ]; shortdesc = "compute MD5, SHAx or CRC checksum of file"; @@ -4323,15 +4323,15 @@ To get the checksums for many files, use C." }; once_had_no_optargs = true; cancellable = true; tests = [ - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/tar_in"]; ["tar_in"; "../data/helloworld.tar"; "/tar_in"; "NOARG"]; ["cat"; "/tar_in/hello"]], "hello\n"); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/tar_in_gz"]; ["tar_in"; "../data/helloworld.tar.gz"; "/tar_in_gz"; "gzip"]; ["cat"; "/tar_in_gz/hello"]], "hello\n"); - InitScratchFS, IfAvailable "xz", TestOutput ( + InitScratchFS, IfAvailable "xz", TestResultString ( [["mkdir"; "/tar_in_xz"]; ["tar_in"; "../data/helloworld.tar.xz"; "/tar_in_xz"; "xz"]; ["cat"; "/tar_in_xz/hello"]], "hello\n") @@ -4388,7 +4388,7 @@ instead of user/group names. deprecated_by = Some "tar_in"; cancellable = true; tests = [ - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/tgz_in"]; ["tgz_in"; "../data/helloworld.tar.gz"; "/tgz_in"]; ["cat"; "/tgz_in/hello"]], "hello\n") @@ -4418,7 +4418,7 @@ it to local file C." }; [["umount"; "/"; "false"; "false"]; ["mount_ro"; "/dev/sda1"; "/"]; ["touch"; "/new"]]); - InitBasicFS, Always, TestOutput ( + InitBasicFS, Always, TestResultString ( [["write"; "/new"; "data"]; ["umount"; "/"; "false"; "false"]; ["mount_ro"; "/dev/sda1"; "/"]; @@ -4594,7 +4594,7 @@ to remove those first." }; proc_nr = Some 80; deprecated_by = Some "set_label"; tests = [ - InitBasicFS, Always, TestOutput ( + InitBasicFS, Always, TestResultString ( [["set_e2label"; "/dev/sda1"; "testlabel"]; ["get_e2label"; "/dev/sda1"]], "testlabel") ]; @@ -4623,10 +4623,10 @@ C." }; proc_nr = Some 82; tests = (let uuid = uuidgen () in [ - InitBasicFS, Always, TestOutput ( + InitBasicFS, Always, TestResultString ( [["set_e2uuid"; "/dev/sda1"; uuid]; ["get_e2uuid"; "/dev/sda1"]], uuid); - InitBasicFS, Always, TestOutput ( + InitBasicFS, Always, TestResultString ( [["set_e2uuid"; "/dev/sda1"; "clear"]; ["get_e2uuid"; "/dev/sda1"]], ""); (* We can't predict what UUIDs will be, so just check @@ -4654,7 +4654,7 @@ to return the existing UUID of a filesystem." }; tests = (* Regression test for RHBZ#597112. *) (let uuid = uuidgen () in [ - InitNone, Always, TestOutput ( + InitNone, Always, TestResultString ( [["mke2journal"; "1024"; "/dev/sdc"]; ["set_e2uuid"; "/dev/sdc"; uuid]; ["get_e2uuid"; "/dev/sdc"]], uuid) @@ -4792,7 +4792,7 @@ replacing C with the name of the installation device. style = RErr, [Pathname "src"; Pathname "dest"], []; proc_nr = Some 87; tests = [ - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/cp"]; ["write"; "/cp/old"; "file content"]; ["cp"; "/cp/old"; "/cp/new"]; @@ -4802,7 +4802,7 @@ replacing C with the name of the installation device. ["write"; "/cp2/old"; "file content"]; ["cp"; "/cp2/old"; "/cp2/new"]; ["is_file"; "/cp2/old"]]); - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/cp3"]; ["write"; "/cp3/old"; "file content"]; ["mkdir"; "/cp3/dir"]; @@ -4819,7 +4819,7 @@ either a destination filename or destination directory." }; style = RErr, [Pathname "src"; Pathname "dest"], []; proc_nr = Some 88; tests = [ - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/cp_a1"]; ["mkdir"; "/cp_a2"]; ["write"; "/cp_a1/file"; "file content"]; @@ -4836,7 +4836,7 @@ recursively using the C command." }; style = RErr, [Pathname "src"; Pathname "dest"], []; proc_nr = Some 89; tests = [ - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir"; "/mv"]; ["write"; "/mv/old"; "file content"]; ["mv"; "/mv/old"; "/mv/new"]; @@ -5016,7 +5016,7 @@ The returned strings are transcoded to UTF-8." }; proc_nr = Some 96; protocol_limit_warning = true; tests = [ - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["hexdump"; "/known-4"]], "00000000 61 62 63 0a 64 65 66 0a 67 68 69 |abc.def.ghi|\n0000000b\n"); (* Test for RHBZ#501888c2 regression which caused large hexdump * commands to segfault. @@ -5038,7 +5038,7 @@ the human-readable, canonical hex dump of the file." }; proc_nr = Some 97; optional = Some "zerofree"; tests = [ - InitNone, Always, TestOutput ( + InitNone, Always, TestResultString ( [["part_disk"; "/dev/sda"; "mbr"]; ["mkfs"; "ext3"; "/dev/sda1"; ""; "NOARG"; ""; ""]; ["mount"; "/dev/sda1"; "/"]; @@ -5159,7 +5159,7 @@ are activated or deactivated." }; proc_nr = Some 105; optional = Some "lvm2"; tests = [ - InitNone, Always, TestOutput ( + InitNone, Always, TestResultString ( [["part_disk"; "/dev/sda"; "mbr"]; ["pvcreate"; "/dev/sda1"]; ["vgcreate"; "VG"; "/dev/sda1"]; @@ -6307,7 +6307,7 @@ matching lines." }; proc_nr = Some 163; optional = Some "realpath"; tests = [ - InitISOFS, Always, TestOutput ( + InitISOFS, Always, TestResultString ( [["realpath"; "/../directory"]], "/directory") ]; shortdesc = "canonicalized absolute pathname"; @@ -6368,7 +6368,7 @@ This command creates a symbolic link using the C command." }; style = RErr, [String "target"; Pathname "linkname"], []; proc_nr = Some 167; tests = [ - InitScratchFS, Always, TestOutput ( + InitScratchFS, Always, TestResultString ( [["mkdir_p"; "/ln_sf/b"]; ["touch"; "/ln_sf/b/c"]; ["ln_sf"; "../d"; "/ln_sf/b/c"]; @@ -6689,7 +6689,7 @@ and C" }; proc_nr = Some 187; deprecated_by = Some "mkfs"; tests = [ - InitEmpty, Always, TestOutput ( + InitEmpty, Always, TestResultString ( [["part_disk"; "/dev/sda"; "mbr"]; ["mkfs_b"; "ext2"; "4096"; "/dev/sda1"]; ["mount"; "/dev/sda1"; "/"]; @@ -6724,7 +6724,7 @@ the requested cluster size." }; proc_nr = Some 188; deprecated_by = Some "mke2fs"; tests = [ - InitEmpty, Always, TestOutput ( + InitEmpty, Always, TestResultString ( [["part_init"; "/dev/sda"; "mbr"]; ["part_add"; "/dev/sda"; "p"; "64"; "204799"]; ["part_add"; "/dev/sda"; "p"; "204800"; "-64"]; @@ -6747,7 +6747,7 @@ to the command: proc_nr = Some 189; deprecated_by = Some "mke2fs"; tests = [ - InitEmpty, Always, TestOutput ( + InitEmpty, Always, TestResultString ( [["part_init"; "/dev/sda"; "mbr"]; ["part_add"; "/dev/sda"; "p"; "64"; "204799"]; ["part_add"; "/dev/sda"; "p"; "204800"; "-64"]; @@ -6769,7 +6769,7 @@ This creates an ext2 external journal on C with label C