Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Preliminary Haiku port #3796

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

Merged
merged 1 commit into from
Jun 1, 2016
Merged

Preliminary Haiku port #3796

merged 1 commit into from
Jun 1, 2016

Conversation

mmuman
Copy link
Contributor

@mmuman mmuman commented May 22, 2016

This makes libgit2 compile on Haiku.

  • CMakeLists: Add libnetwork for Haiku

Currently make test fails due to calling inet_pton() with dst=NULL, which assert()s our implementation. I'm not sure whether I should fix our code or the test though...

@ethomson
Copy link
Member

Neat!

Yeah, our tests look quite dumb. I suppose that you're looking at

cl_git_fail(p_inet_pton(12, "52.472", NULL)); /* AF_DECnet */
and
cl_git_fail(p_inet_pton(5, "315.124", NULL)); /* AF_CHAOS */
failing. It's unfortunate that we're testing what-should-be-systems-libraries, but of course we had to roll our own for deficient operating systems, so there we go.

Passing NULL there seems pretty sketchy. The standard says:

The dst argument points to a buffer into which the function stores the numeric address; this shall be large enough to hold the numeric address (32 bits for AF_INET, 128 bits for AF_INET6).

I passed NULL there in the bizarre case that a system might actually have DECnet... I have no idea how big the buffer should be!

This brings up the question of why we're bothering to test this and I think that the short answer is that we shouldn't be, nobody cares. If you pushed up a PR that removed those two stupid tests about address families that don't matter to anybody anywhere then I think that would be the easiest way to go forward.

@mmuman
Copy link
Contributor Author

mmuman commented May 23, 2016

Yeah, those ones.
Indeed, I suppose a system supporting those would return another error anyway.
Btw, it seems we took it from NetBSD (although I couldn't find it at lxr.watson, but I suppose they don't index their libc):
http://cgit.haiku-os.org/haiku/tree/src/kits/network/netresolv/inet/inet_pton.c

Now another test that fails is stat() on directories:
st.st_mode != (GIT_FILEMODE_TREE | 0701) & ~um
100040701 != 0040701
Directories in BFS are implemented as B+Trees indexing strings (filenames), and BFS does report the type of index in addition to the inode type, cf.
http://cgit.haiku-os.org/haiku/tree/headers/posix/sys/stat.h#n42
I suspect Hurd might also report some funky stuff in stat() :-D
I believe the test should actually mask with S_IFMT | S_IUMSK before the comparison.

@ethomson
Copy link
Member

I believe the test should actually mask with S_IFMT | S_IUMSK before the comparison.

Agreed. A PR that fixed this up would be 👌

@mmuman
Copy link
Contributor Author

mmuman commented May 24, 2016

Indeed, Hurd uses other st_mode bits too:
http://osxr.org:8080/glibc/source/sysdeps/mach/hurd/bits/stat.h?v=glibc-2.16.0
I'll make a PR for this.

@mmuman
Copy link
Contributor Author

mmuman commented May 24, 2016

It seems like libgit2 is doing some black magic on the st_mode fields when passing it around though, using custom value S_IFGITLINK...
Also, while the code seems to use proper macros, the tests actually use hardcoded values...

@mmuman
Copy link
Contributor Author

mmuman commented May 24, 2016

Ok, next tests...
I'm afraid BFS doesn't support hardlinks. I just hope it's not a requirement. Same for atime, it's not maintained by default IIRC.

@carlosmn
Copy link
Member

S_IFGITLINK is not libgit2 magic but introduced by Git. Filemodes in the index and trees are almost, but not quite unix modes.

@mmuman
Copy link
Contributor Author

mmuman commented May 24, 2016

Yeah ok it handles them as virtual files, but it's confusing. One more example of Linux coders thinking they are alone in the universe and they are always right... Besides BSD uses the value for whiteout entries: http://man7.org/linux/man-pages/man2/fstat.2.html Anyway, shouldn't do any harm as long as it doesn't collide with an even weirder OS where it'd be used for IFREG or IFDIR :-D

@mmuman
Copy link
Contributor Author

mmuman commented May 24, 2016

Ok, here is the full test log now:

Start testing: May 24 18:54 GMT+2
----------------------------------------------------------
1/4 Testing: libgit2_clar
1/4 Test: libgit2_clar
Command: "/work/libgit2/libgit2/build/libgit2_clar" "-ionline"
Directory: /work/libgit2/libgit2/build
"libgit2_clar" start time: May 24 18:54 GMT+2
Output:
----------------------------------------------------------
Loaded 313 suites: 
Started

attr::file....
attr::flags...
attr::ignore.............
attr::lookup.....
attr::repo..........
blame::buffer......
blame::getters..
blame::harder....
blame::simple.........
buf::basic...
buf::oom..
buf::splice.........
checkout::binaryunicode..
checkout::conflict.................
checkout::crlf..............
checkout::head..
checkout::icaseSSSSSSSSSSSSS
checkout::index............umask: 22
./testrepo/a: 100040701
wanted: 40701
.................
checkout::nasty..............................
checkout::tree.......................................
checkout::typechange..
cherrypick::bare...
cherrypick::workdir..........
clone::empty...
clone::local.F..
clone::nonetwork...................
clone::transport.
commit::commit.....
commit::parent.
commit::parse........
commit::signature.........
commit::write.......
config::add..
config::backend.
config::configlevel....
config::global...
config::include.......
config::multivar.........
config::new.
config::read..................................
config::rename...
config::snapshot..
config::stress......
config::validkeyname.
config::write.........................
core::array.
core::bitvec.
core::buffer........................
core::copy..F
core::dirent.........
core::env...
core::errors........
core::features.
core::filebuf......S..S.
core::ftruncateSS
core::futils.S
core::hex.
core::iconv...
core::init.
core::link...............FF.......
core::mkdir......
core::oid...
core::oidmap..
core::opts..
core::path................
core::pool....
core::posixFF
core::pqueue....
core::rmdir....
core::sortedcache...
core::stat..
core::stream.
core::string.....
core::strmap....
core::strtol..
core::structinitS
core::useragent.
core::vector.......
core::zstream...
date::date.
date::rfc2822....
describe::describe..
describe::t6120.......
diff::binary............
diff::blob..................
diff::diffiter.........
diff::drivers....
diff::format::email.........
diff::index.......
diff::notify.......
diff::patch......
diff::pathspec.
diff::racediffiter..
diff::rename..........................
diff::stats.............
diff::submodules.........
diff::tree...........
diff::workdir............................S
fetchhead::nonetwork.............
filter::blob...
filter::crlf......
filter::custom.....
filter::file..
filter::ident..
filter::query....
filter::stream.S
filter::wildcard...
graph::descendant::of..
index::add.
index::addall......
index::bypath....SSSSS...S
index::cache.....
index::collision...
index::conflicts...........
index::crlf.......
index::filemodes.....
index::inmemory..
index::names.......
index::nsec...
index::racy..F......
index::read::index.
index::read::tree.
index::rename..
index::reuc..............
index::stage..
index::tests..........................
iterator::index.......................
iterator::tree........................
iterator::workdir.................SS..........
merge::driver............
merge::files..........
merge::trees::automerge....
merge::trees::commits....
merge::trees::modeconflict.
merge::trees::recursive................
merge::trees::renames..
merge::trees::treediff.....
merge::trees::trivial.............
merge::trees::whitespace...
merge::workdir::analysis.......
merge::workdir::dirty......
merge::workdir::recursive..
merge::workdir::renames...
merge::workdir::setup................................
merge::workdir::simple...............
merge::workdir::submodules..
merge::workdir::trivial.............
network::cred...
network::fetchlocalF...........
network::matchhost.
network::refspecs.....
network::remote::createthenload.
network::remote::defaultbranch......
network::remote::delete...
network::remote::isvalidname..
network::remote::local..................
network::remote::push..
network::remote::remotes..........................
network::remote::rename.............
network::urlparse..................
notes::notes..............
notes::notesref.
object::blob::filter...
object::blob::fromstream..
object::blob::write...
object::cache..FF
object::commit::commitstagedfile..
object::lookup....
object::lookupbypath....
object::message................
object::peel......
object::raw::chars..
object::raw::compare.......
object::raw::convert...
object::raw::fromstr..
object::raw::hash...........
object::raw::short...
object::raw::size.
object::raw::type2string...
object::raw::write.......
object::shortid.
object::tag::list..
object::tag::peel...
object::tag::read.....
object::tag::write..........
object::tree::attributes.....
object::tree::duplicateentries..
object::tree::frompath..
object::tree::read..
object::tree::update.....
object::tree::walk...
object::tree::write........
odb::alternates..
odb::backend::nobackend.
odb::backend::nonrefreshing.........
odb::emptyobjects...
odb::foreach....
odb::loose....
odb::mixed...
odb::packed...
odb::packed::one..
odb::sorting..
odb::streamwrite...
online::badssl....
online::clone.......SSS..FS.SS.F..SS
online::fetch...........
online::fetchhead...
online::pushSSSSSSSSSSSSSSSSSSSSS
online::remotes..
pack::indexer..
pack::packbuilder.......
pack::sharingF
path::core...............
path::win32..........
perf::mergeS
rebase::abort.......
rebase::inmemory...
rebase::iterator..
rebase::merge.................
rebase::setup..............
refs::branches::create.........
refs::branches::delete........
refs::branches::ishead......
refs::branches::iterator.....
refs::branches::lookup....
refs::branches::move...........
refs::branches::name...
refs::branches::remote....
refs::branches::upstream..........
refs::branches::upstreamname..
refs::crashes.
refs::create.........
refs::createwithlog.
refs::delete...
refs::dup..
refs::foreachglob.....
refs::isvalidname..
refs::iterator.......
refs::list..
refs::listall...
refs::lookup.....
refs::normalize......
refs::overwrite....
refs::pack...
refs::peel......
refs::races.....
refs::read...............
refs::reflog::drop.......
refs::reflog::reflog.................
refs::rename............
refs::revparse.................................
refs::settargetwithlog.
refs::setter....
refs::shorthand.
refs::transactions......
refs::unicode.
refs::update.
remote::insteadof.....
repo::config...
repo::discover.
repo::getters...
repo::hashfile..
repo::head......................
repo::headtree....
repo::init........................S
repo::message..
repo::new..
repo::open.............
repo::pathspec..........
repo::reservedname.....
repo::setters.....
repo::shallow....
repo::state.............
reset::default.....
reset::hard......
reset::mixed...
reset::soft.........
revert::bare...
revert::workdir...............
revwalk::basic...............
revwalk::hidecb......
revwalk::mergebase..............
revwalk::signatureparsing.
revwalk::simplify.
stash::apply...................
stash::drop.......
stash::foreach..
stash::save................
stash::submodules..
status::ignore..........................
status::renames............F...
status::single..
status::submodules...........
status::worktree.....................................S....
status::worktree::init........
submodule::add....
submodule::init...
submodule::lookup.........
submodule::modify.......
submodule::nosubs.....
submodule::repository::init.
submodule::status.......
submodule::update.......
threads::basic...
threads::diff..
threads::iterator.
threads::refdb..
trace::traceSSSSSS
trace::windows::stacktrace...
transport::register....
win32::forbidden..........
win32::longpath.

  1) Failure:
clone::local::hardlinks [/work/libgit2/libgit2/tests/clone/local.c:122]
  2 != st.st_nlink
  2 != 1

  2) Failure:
core::copy::tree [/work/libgit2/libgit2/tests/core/copy.c:136]
  Function call failed: (git_futils_cp_r("src", "t3", GIT_CPDIR_CREATE_EMPTY_DIRS | GIT_CPDIR_LINK_FILES, 0))
  error -1 - failed to link 'src/b/f2': Operation not allowed

  3) Failure:
core::link::stat_hardlink [/work/libgit2/libgit2/tests/core/link.c:66]
  Function call failed: link(old, new)

  4) Failure:
core::link::lstat_hardlink [/work/libgit2/libgit2/tests/core/link.c:66]
  Function call failed: link(old, new)

  5) Failure:
core::posix::inet_pton [/work/libgit2/libgit2/tests/core/posix.c:97]
  Expected function call to fail: inet_pton(5, "315.124", &addr)

  6) Failure:
core::posix::utimes [/work/libgit2/libgit2/tests/core/posix.c:118]
  1234567890 != st.st_atime
  1234567890 != 1464108966

  7) Failure:
index::racy::smudges_index_entry_on_save [/work/libgit2/libgit2/tests/index/racy.c:152]
  0 != entry->file_size
  0 != 1

  8) Failure:
network::fetchlocal::complete [/work/libgit2/libgit2/tests/network/fetchlocal.c:43]
  Function call failed: (git_repository_init(&repo, "foo", 1))
  error -4 - Failed to make directory 'foo': directory exists

  9) Failure:
object::cache::threadmania [/work/libgit2/libgit2/tests/object/cache.c:232]
  Function call failed: (pthread_join((&t[th])->thread, &data))
  error -2147454963 - <no message>

  10) Failure:
object::cache::fast_thread_rush [/work/libgit2/libgit2/tests/object/cache.c:279]
  Function call failed: (pthread_join((&t[th])->thread, &rval))
  error -2147454963 - <no message>

  11) Failure:
online::clone::ssh_auth_methods [/work/libgit2/libgit2/tests/online/clone.c:434]
  git_clone(&g_repo, "ssh://github.com/libgit2/TestGitRepository", "./foo", &g_options) != GIT_EUSER
  -1 != -7

  12) Failure:
online::clone::certificate_invalid [/work/libgit2/libgit2/tests/online/clone.c:637]
  GIT_ECERTIFICATE != git_clone(&g_repo, "ssh://github.com/libgit2/TestGitRepository", "./foo", &g_options)
  -17 != -1

  13) Failure:
pack::sharing::open_two_repos [/work/libgit2/libgit2/tests/pack/sharing.c:30]
  2 != pack->refcount.val
  2 != 1

  14) Failure:
status::renames::both_casechange_two [/work/libgit2/libgit2/tests/status/renames.c:33]
  Function call failed: (p_rename(oldpath.ptr, newpath.ptr))
  error -1 - <no message>

<end of output>
Test time = 480.64 sec
----------------------------------------------------------
Test Failed.
"libgit2_clar" end time: May 24 19:02 GMT+2
"libgit2_clar" time elapsed: 00:08:00
----------------------------------------------------------

2/4 Testing: libgit2_clar-cred_callback
2/4 Test: libgit2_clar-cred_callback
Command: "/work/libgit2/libgit2/build/libgit2_clar" "-v" "-sonline::clone::cred_callback"
Directory: /work/libgit2/libgit2/build
"libgit2_clar-cred_callback" start time: May 24 19:02 GMT+2
Output:
----------------------------------------------------------
Loaded 313 suites: 
Started

online::cloneSS

<end of output>
Test time =   0.11 sec
----------------------------------------------------------
Test Passed.
"libgit2_clar-cred_callback" end time: May 24 19:02 GMT+2
"libgit2_clar-cred_callback" time elapsed: 00:00:00
----------------------------------------------------------

3/4 Testing: libgit2_clar-proxy_credentials_in_url
3/4 Test: libgit2_clar-proxy_credentials_in_url
Command: "/work/libgit2/libgit2/build/libgit2_clar" "-v" "-sonline::clone::proxy_credentials_in_url"
Directory: /work/libgit2/libgit2/build
"libgit2_clar-proxy_credentials_in_url" start time: May 24 19:02 GMT+2
Output:
----------------------------------------------------------
Loaded 313 suites: 
Started

online::cloneS

<end of output>
Test time =   0.07 sec
----------------------------------------------------------
Test Passed.
"libgit2_clar-proxy_credentials_in_url" end time: May 24 19:02 GMT+2
"libgit2_clar-proxy_credentials_in_url" time elapsed: 00:00:00
----------------------------------------------------------

4/4 Testing: libgit2_clar-proxy_credentials_request
4/4 Test: libgit2_clar-proxy_credentials_request
Command: "/work/libgit2/libgit2/build/libgit2_clar" "-v" "-sonline::clone::proxy_credentials_request"
Directory: /work/libgit2/libgit2/build
"libgit2_clar-proxy_credentials_request" start time: May 24 19:02 GMT+2
Output:
----------------------------------------------------------
Loaded 313 suites: 
Started

online::cloneS

<end of output>
Test time =   0.08 sec
----------------------------------------------------------
Test Passed.
"libgit2_clar-proxy_credentials_request" end time: May 24 19:02 GMT+2
"libgit2_clar-proxy_credentials_request" time elapsed: 00:00:00
----------------------------------------------------------

End testing: May 24 19:02 GMT+2
  • error -2147454963 is: 0x8000700d: No such process

@mmuman
Copy link
Contributor Author

mmuman commented May 24, 2016

Just opened PR #3798.

@ethomson
Copy link
Member

One more example of Linux coders thinking they are alone in the universe and they are always right... Besides BSD uses the value for whiteout entries: http://man7.org/linux/man-pages/man2/fstat.2.html

That doesn't matter, these values are never written to disk, they're only used internally in the index. As @carlosmn mentioned, those look like Unix modes (and are stored in a stat structure, usually) but they are not, they are hardcoded values, so there's nothing to collide.

@mmuman
Copy link
Contributor Author

mmuman commented May 24, 2016

@ethomson yeah I got that, still quite ugly though 😁

@ethomson
Copy link
Member

ethomson commented Jun 1, 2016

I'm going to go ahead and merge this - if you have further incremental improvements for haiku, we'd be happy to see new PRs. Thanks!

@ethomson ethomson merged commit 0aaba44 into libgit2:master Jun 1, 2016
@mmuman mmuman deleted the haiku branch June 1, 2016 20:37
@mmuman
Copy link
Contributor Author

mmuman commented Jun 1, 2016

Thanks!
I'll be away for some weeks but I'll look at it when I'm back.

@mmuman
Copy link
Contributor Author

mmuman commented Jul 24, 2016

Btw, I just checked again, and 5 is actually AF_INET6 on Haiku, so one of the expected fails doesn't happen even when passing non-null pointer. The hardcoded numbers are not even correct on Linux, where 5 is AF_APPLETALK.

@ethomson
Copy link
Member

Btw, I just checked again, and 5 is actually AF_INET6 on Haiku, so one of the expected fails doesn't happen even when passing non-null pointer. The hardcoded numbers are not even correct on Linux, where 5 is AF_APPLETALK.

I don't know what you're talking about. Can you link to the code snippet that you're referring to?

@mmuman
Copy link
Contributor Author

mmuman commented Jul 24, 2016

@ethomson
Copy link
Member

I see. You're welcome to submit a PR that changes that to a different bogus number.

@mmuman
Copy link
Contributor Author

mmuman commented Jul 26, 2016

I'd rather remove them anyway.
I could remove the asserts in Haiku's inet_pton(), as there are asserts in inet_pton4 and 6 also, but it doesn't change the fact that the numbers are wrong. I've open #3872.

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.

3 participants