From b8b9bd910dc801c36e291f8134dff7c0c52919ca Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 5 Aug 2019 16:20:39 +0100 Subject: [PATCH] Add upstream fix for OCaml tests. --- ...race-when-creating-and-deleting-file.patch | 70 +++++++++++++++++++ libnbd.spec | 2 +- 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 0001-ocaml-tests-Fix-race-when-creating-and-deleting-file.patch diff --git a/0001-ocaml-tests-Fix-race-when-creating-and-deleting-file.patch b/0001-ocaml-tests-Fix-race-when-creating-and-deleting-file.patch new file mode 100644 index 0000000..f2c7250 --- /dev/null +++ b/0001-ocaml-tests-Fix-race-when-creating-and-deleting-file.patch @@ -0,0 +1,70 @@ +From 7a98b786b179c626699969d41f2d4ff4550937a7 Mon Sep 17 00:00:00 2001 +From: "Richard W.M. Jones" +Date: Mon, 5 Aug 2019 16:16:58 +0100 +Subject: [PATCH] ocaml/tests: Fix race when creating and deleting files in + tests. + +Two of the OCaml tests used a test file in the local directory with a +fixed name. However because each test runs twice (once for bytecode +and once for native code), on a machine with many cores the file might +be deleted by one instance of the test while it is still in use by the +other instance, causing a test failure. (This was observed on a +machine with 48 cores.) +--- + ocaml/tests/test_410_pwrite.ml | 9 +++++---- + ocaml/tests/test_510_aio_pwrite.ml | 9 +++++---- + 2 files changed, 10 insertions(+), 8 deletions(-) + +diff --git a/ocaml/tests/test_410_pwrite.ml b/ocaml/tests/test_410_pwrite.ml +index 3b63da7..0b14e1b 100644 +--- a/ocaml/tests/test_410_pwrite.ml ++++ b/ocaml/tests/test_410_pwrite.ml +@@ -24,10 +24,11 @@ let () = + Bytes.set buf1 510 '\x55'; + Bytes.set buf1 511 '\xAA'; + +- let datafile = "410-pwrite.data" in +- let fd = openfile datafile [O_WRONLY;O_CREAT;O_TRUNC] 0o644 in ++ let datafile, chan = ++ Filename.open_temp_file ~mode:[Open_binary] "410" ".data" in ++ let fd = descr_of_out_channel chan in + ftruncate fd 512; +- close fd; ++ close_out chan; + + let nbd = NBD.create () in + NBD.connect_command nbd ["nbdkit"; "-s"; "--exit-with-parent"; "-v"; +@@ -44,4 +45,4 @@ let () = + close fd; + assert (buf1 = content); + +- Unix.unlink datafile ++ unlink datafile +diff --git a/ocaml/tests/test_510_aio_pwrite.ml b/ocaml/tests/test_510_aio_pwrite.ml +index 4e3f630..0930dcd 100644 +--- a/ocaml/tests/test_510_aio_pwrite.ml ++++ b/ocaml/tests/test_510_aio_pwrite.ml +@@ -24,10 +24,11 @@ let () = + Bytes.set buf 510 '\x55'; + Bytes.set buf 511 '\xAA'; + +- let datafile = "510-pwrite.data" in +- let fd = openfile datafile [O_WRONLY;O_CREAT;O_TRUNC] 0o644 in ++ let datafile, chan = ++ Filename.open_temp_file ~mode:[Open_binary] "510" ".data" in ++ let fd = descr_of_out_channel chan in + ftruncate fd 512; +- close fd; ++ close_out chan; + + let nbd = NBD.create () in + NBD.connect_command nbd ["nbdkit"; "-s"; "--exit-with-parent"; "-v"; +@@ -53,4 +54,4 @@ let () = + close fd; + assert (buf = content); + +- Unix.unlink datafile ++ unlink datafile +-- +2.22.0 + diff --git a/libnbd.spec b/libnbd.spec index 19e3804..0b9472b 100644 --- a/libnbd.spec +++ b/libnbd.spec @@ -23,7 +23,7 @@ Source1: http://libguestfs.org/download/libnbd/%{source_directory}/%{name Source2: libguestfs.keyring # Patches. -#(none) +Patch1: 0001-ocaml-tests-Fix-race-when-creating-and-deleting-file.patch %if 0%{patches_touch_autotools} BuildRequires: autoconf, automake, libtool