Commit Graph

26 Commits

Author SHA1 Message Date
Simonas Kazlauskas 6d0f9bd0b5 Construct a PathBuf
Representing what's the data here holistically.
2022-01-18 14:25:18 +02:00
Simonas Kazlauskas a6334c080b Simplify lib_path
Since these are the tests, I'm sure we can afford to pay 1 allocation
per test for a path.
2022-01-18 14:20:36 +02:00
James McCoy 40b5ea3fae Honor Cargo's target directory when building LIBPATH
Running the tests with “cargo test --target-dir <path>” fails because
"target/" doesn't exist.

Rust 1.57.0 added $CARGO_TARGET_TMPDIR as a scratch directory for
integration tests to use, which Cargo itself won't touch.

Therefore, use $CARGO_TARGET_TMPDIR if it's available, $CARGO_TARGET_DIR
otherwise, and fallback to "target" as a last resort.
2022-01-18 14:17:29 +02:00
Simonas Kazlauskas 3ff0188486 Library & Symbol exist on supported platforms only
This makes the error messages and use of this library on targets such as
wasm32-unknown-unknown much more straightforward.
2021-11-15 21:44:39 +02:00
William Henderson 41a81fafef Made documentation spelling consistent
It was previously a mix of British and American English, it is now just British English
2021-10-08 20:56:51 +01:00
Simonas Kazlauskas ebf363ea72 Make various library loading functions unsafe 2021-01-31 21:32:14 +02:00
Ivan Molodetskikh ff4ebe7615 Add os::windows::Library::open_already_loaded() 2020-12-30 19:45:39 +03:00
Simonas Kazlauskas 86b5095f75 Don't neglect to forget self in close
Otherwise it leads to a double-free, once in `close` and another time in
`drop`. Curiously this was only a bug on Windows, and Unix code was
fine. Not sure how this happened.
2020-12-03 15:05:35 +02:00
Simonas Kazlauskas cd2771bf32 Tests read TARGET environment variable for helpers 2020-10-10 18:09:55 +03:00
Simonas Kazlauskas e0b5392aea Remove superfluous use of build.rs
This should make building of this crate significantly faster.

At the same time we also correctly annotate the linkage on the `extern`
block, the way it ought to be.

Sadly there's a regression in tests – the helper scripts no longer
specify the target for which tests are being built. This shall be
addressed in a subsequent commit.
2020-10-10 17:44:39 +03:00
Simonas Kazlauskas 7e5f290148 Make resolve_name a stand-alone function. 2020-08-23 18:45:41 +00:00
Simonas Kazlauskas 23c25400da Export constants for flags to be used with calls
This should make use of the target-specific `Library::open` calls
significantly more palatable.
2020-08-22 23:36:37 +00:00
Simonas Kazlauskas f75a0d0606 Do not encourage use of libloading for TLS
On MSVC Windows loading a TLS symbol will give an address to the
initializer (which when overwritten simply changes the default value new
threads gain for the variable).

On macOS thread locals are misimplemented entirely.

On Linux things "just work", but unknown to what extent, really.

Since the behaviour of using thread local variables as if they were
plain global variables is mostly undefined, lets just not make any
claims of this working.
2020-08-22 19:53:18 +00:00
Simonas Kazlauskas bbc5028a88 Improve tests
* Don’t forget to CI the thread-local support;
* Clean up some tests;
* Properly pass thorugh the target to use for the test helper.
2020-08-22 19:53:18 +00:00
Simonas Kazlauskas 32368c0de5 Implement the Error type
This allows us to:

a) remove the panics in this library and give the control over what to
do to the user;
b) expose the error conditions to the user better, even if just slightly;
c) implement the modern error handling currently implemented in many of
the modern Rust libraries.
2020-04-05 22:25:39 +03:00
Simonas Kazlauskas 77c7b40ba7 Don’t rely on OPT_LEVEL == 0 as indicator…
for whether test helpers are necessary, because otherwise `cargo test
--release` won’t work.
2017-12-07 21:24:03 +02:00
Simonas Kazlauskas f23493e47d Add test for named function types 2017-03-25 00:22:37 +02:00
Simonas Kazlauskas a63d156e97 Ensure incompatibly-sized types do not get loaded
This is a programming error and so it panics. Ideally it would be a type error,
but Rust cannot do that currently.
2017-03-24 23:58:48 +02:00
Simonas Kazlauskas 408e7c3beb Fix windows tests 2016-10-01 04:19:43 +03:00
Simonas Kazlauskas 38eded0509 Make Windows Library Sync
See the comments near the impl for reasoning.
2016-10-01 01:52:10 +03:00
Simonas Kazlauskas 72702a55bc Fix bounds on markers and expand tests 2016-10-01 01:17:48 +03:00
Artem V. Navrotskiy 2d01e0cf98 Make Library implement Sync (unix only) 2016-09-30 07:46:04 +03:00
Artem V. Navrotskiy b7cc6a0918 Make Symbol implement Sync 2016-09-30 07:38:37 +03:00
Simonas Kazlauskas 2487d27ca8 Add tests for ordinals
These tests include binary .dll files into the tests directory, because rustc does not allow us to
export symbols through ordinal numbers on Windows, sadly.

Both DLLs contain exactly 1 function (other than DllMain) each, with signature `fn() -> *const
c_char` returning a pointer to "bunny\0".

Thanks to WindowsBunny (aka. retep998) for building the DLLs.
2016-07-28 16:33:18 +03:00
Simonas Kazlauskas b05f8b8bd1 Add examples to the new conversion funcs 2016-07-27 16:54:42 +03:00
Simonas Kazlauskas 2526537f80 Overhaul the tests 2016-07-26 23:23:02 +03:00