/[packages]/cauldron/rust/current/SOURCES/rust-52760-test_loading_atoi.patch
ViewVC logotype

Contents of /cauldron/rust/current/SOURCES/rust-52760-test_loading_atoi.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1251113 - (show annotations) (download)
Sun Aug 12 09:55:02 2018 UTC (6 years, 2 months ago) by akien
File size: 2548 byte(s)
- Sync with Fedora: Thu Aug 02 2018 Josh Stone <jistone@redhat.com> - 1.28.0-1
  o Update to 1.28.0.
  o Exclude rust-src from auto-requires.
  o Remove backup files from %%configure munging.

1 From efa11da26a882aaf57f7eae747e48d128c474bf3 Mon Sep 17 00:00:00 2001
2 From: Josh Stone <jistone@redhat.com>
3 Date: Thu, 26 Jul 2018 17:20:02 -0700
4 Subject: [PATCH] rustc_metadata: test loading atoi instead of cos
5
6 Some platforms don't actually have `libm` already linked in the test
7 infrastructure, and then `dynamic_lib::tests::test_loading_cosine` would
8 fail to find the "cos" symbol. Every platform running this test should
9 have `libc` and "atoi" though, so try to use that symbol instead.
10
11 Fixes #45410.
12 ---
13 src/librustc_metadata/dynamic_lib.rs | 25 ++++++++++++-------------
14 1 file changed, 12 insertions(+), 13 deletions(-)
15
16 diff --git a/src/librustc_metadata/dynamic_lib.rs b/src/librustc_metadata/dynamic_lib.rs
17 index d7da0d00012e..182a071277ec 100644
18 --- a/src/librustc_metadata/dynamic_lib.rs
19 +++ b/src/librustc_metadata/dynamic_lib.rs
20 @@ -90,30 +90,29 @@ mod tests {
21 use std::mem;
22
23 #[test]
24 - fn test_loading_cosine() {
25 + fn test_loading_atoi() {
26 if cfg!(windows) {
27 return
28 }
29
30 - // The math library does not need to be loaded since it is already
31 - // statically linked in
32 - let libm = match DynamicLibrary::open(None) {
33 + // The C library does not need to be loaded since it is already linked in
34 + let lib = match DynamicLibrary::open(None) {
35 Err(error) => panic!("Could not load self as module: {}", error),
36 - Ok(libm) => libm
37 + Ok(lib) => lib
38 };
39
40 - let cosine: extern fn(libc::c_double) -> libc::c_double = unsafe {
41 - match libm.symbol("cos") {
42 - Err(error) => panic!("Could not load function cos: {}", error),
43 - Ok(cosine) => mem::transmute::<*mut u8, _>(cosine)
44 + let atoi: extern fn(*const libc::c_char) -> libc::c_int = unsafe {
45 + match lib.symbol("atoi") {
46 + Err(error) => panic!("Could not load function atoi: {}", error),
47 + Ok(atoi) => mem::transmute::<*mut u8, _>(atoi)
48 }
49 };
50
51 - let argument = 0.0;
52 - let expected_result = 1.0;
53 - let result = cosine(argument);
54 + let argument = CString::new("1383428980").unwrap();
55 + let expected_result = 0x52757374;
56 + let result = atoi(argument.as_ptr());
57 if result != expected_result {
58 - panic!("cos({}) != {} but equaled {} instead", argument,
59 + panic!("atoi({:?}) != {} but equaled {} instead", argument,
60 expected_result, result)
61 }
62 }

  ViewVC Help
Powered by ViewVC 1.1.30