Add upstream fix for OCaml tests.
This commit is contained in:
parent
0ac4d82a5d
commit
b8b9bd910d
@ -0,0 +1,70 @@
|
|||||||
|
From 7a98b786b179c626699969d41f2d4ff4550937a7 Mon Sep 17 00:00:00 2001
|
||||||
|
From: "Richard W.M. Jones" <rjones@redhat.com>
|
||||||
|
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
|
||||||
|
|
@ -23,7 +23,7 @@ Source1: http://libguestfs.org/download/libnbd/%{source_directory}/%{name
|
|||||||
Source2: libguestfs.keyring
|
Source2: libguestfs.keyring
|
||||||
|
|
||||||
# Patches.
|
# Patches.
|
||||||
#(none)
|
Patch1: 0001-ocaml-tests-Fix-race-when-creating-and-deleting-file.patch
|
||||||
|
|
||||||
%if 0%{patches_touch_autotools}
|
%if 0%{patches_touch_autotools}
|
||||||
BuildRequires: autoconf, automake, libtool
|
BuildRequires: autoconf, automake, libtool
|
||||||
|
Loading…
Reference in New Issue
Block a user