Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add haiku support #42

Merged
merged 3 commits into from
Feb 3, 2022
Merged

add haiku support #42

merged 3 commits into from
Feb 3, 2022

Conversation

hoanga
Copy link
Contributor

@hoanga hoanga commented Jan 29, 2022

this pr adds haiku support

below is a sample excerpt showing a build and test run on a haiku system

> uname -a
Haiku shredder 1 hrev55795 Jan 23 2022 07:04:09 x86_64 x86_64 Haiku

> cargo test
   Compiling libc v0.2.79
   Compiling errno v0.2.8 (/boot/home/src/git/rust-libs/rust-errno)
    Finished test [unoptimized + debuginfo] target(s) in 2.33s
     Running unittests (target/debug/deps/errno-dcb60f68e1c4165d)

running 4 tests
test check_error_into_errno ... ok
test it_works ... ok
test it_works_with_to_string ... ok
test check_description ... FAILED

failures:

---- check_description stdout ----
thread 'check_description' panicked at 'assertion failed: `(left == right)`
  left: `"OS error 1 (strerror_r returned error 1)"`,
 right: `"Operation not permitted"`', src/lib.rs:137:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace


failures:
    check_description

test result: FAILED. 3 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

error: test failed, to rerun pass '--lib'

i have left the test that is not passing on haiku as is. getting the test to pass as is on haiku is most likely not possible as strerror_r behaves differently on haiku. rather than modify the test logic too much, it might be better to suppress this test for haiku. the following is an example to help illustrate the behavior difference.

> cat main.c
#include <stdio.h>
#include <string.h>
#include <errno.h>

int main(int argc, char **argv){
	char buf[1024]; 
	int i;
	buf[0] = 0;
	
	i = strerror_r(1, buf, 2048);
	printf("strerror_r(1) returns: %d buf contents:: %s\n", i, buf);

	i = strerror_r(EPERM, buf, 2048);
	printf("strerror_r(%d) returns: %d buf contents:: %s\n", EPERM, i, buf);
}

> gcc -Wall main.c 
> ./a.out 
strerror_r(1) returns: -2147483643 buf contents:: 
strerror_r(-2147483633) returns: 0 buf contents:: Operation not allowed

@lambda-fairy
Copy link
Owner

Thanks @hoanga!

Two thoughts:

  1. I'd rather we make the test pass. It's not a big deal to add e.g.

    let errno_code = if cfg!(target_os = "haiku") { -2147483633 } else { 1 };
  2. Is there an easy way to add CI? No worries if we don't.

@hoanga
Copy link
Contributor Author

hoanga commented Feb 2, 2022

no worries on wanting the test to pass, i pushed an update that should make the test pass for haiku as well. a sample run (feels nicer that it passes all tests on haiku too) is below:

> cargo test
   Compiling libc v0.2.79
   Compiling errno v0.2.8 (/boot/home/src/git/rust-libs/rust-errno)
    Finished test [unoptimized + debuginfo] target(s) in 6.87s
     Running unittests (target/debug/deps/errno-dcb60f68e1c4165d)

running 4 tests
test check_description ... ok
test check_error_into_errno ... ok
test it_works ... ok
test it_works_with_to_string ... ok

test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

   Doc-tests errno

running 1 test
test src/lib.rs - (line 4) ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.22s

> uname -a
Haiku shredder 1 hrev55602 Oct 29 2021 07:10:38 x86_64 x86_64 Haiku

i do not know of an easy way to add ci support for haiku, sorry.

@lambda-fairy
Copy link
Owner

Thanks! LGTM.

Would you like to add an entry to the changelog as well? (Sorry forgot to mention earlier)

Happy to merge after that.

@hoanga
Copy link
Contributor Author

hoanga commented Feb 3, 2022

added a new entry for changelog. hope the format looks okay!

@lambda-fairy lambda-fairy merged commit 17296c2 into lambda-fairy:main Feb 3, 2022
@lambda-fairy
Copy link
Owner

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants