joyent / libuv

Go to
https://github.com/libuv/libuv
3.27k stars 653 forks source link

`make check` failed: get_currentexe; but, succeeded with gyp ## get_currentexe is not support symlink yet #1559

Closed usagi closed 9 years ago

usagi commented 10 years ago

version: current HEAD a4f88760be1838603fe2eae89a651066cc42eedd environment: ubuntu-14.04/x86_64, g++-4.8.2

make is succeeded, but make check is failed.

./autogen.sh
./configure
make
make check
=============================================================
[%  58|+ 142|-   0|T   0|S   0]: get_currentexe
`get_currentexe` failed: exit code 134
Output from process `get_currentexe`:
Assertion failed in test/test-get-currentexe.c on line 53: match && !strcmp(match, path)
=============================================================
[% 100|+ 242|-   1|T   0|S   0]: Done.
FAIL: test/run-tests
=======================================================
1 of 1 test failed
Please report to https://github.com/joyent/libuv/issues
=======================================================

But, it is succeeded use gyp.

./gyp_uv.py -f make
make -C out
./out/Debug/run-tests
=============================================================
[% 100|+ 243|-   0|T   0|S   0]: Done.
usagi commented 10 years ago

I got the cause and the answer for the issue.

I was injected the debugging code into the test code:

FILE* f = fopen("/tmp/log", "w");
fprintf(f, "%s\n", executable_path);
fprintf(f, "%s\n", path);
fprintf(f, "%s\n", buffer);
fclose(f);

I got the result with ./autogen && ./configure && make && make check:

/home/usagi/repos/libuv/test/.libs/lt-run-tests
/home/usagi/repos/libuv/test/.libs/lt-run-tests
/home/usagi/Dropbox/repos/libuv/test/.libs/lt-run-tests

And, ./gyp_uv.py -f make && make -C out && ./out/Debug/run-tests:

./out/Debug/run-tests
out/Debug/run-tests
/home/usagi/Dropbox/repos/libuv/out/Debug/run-tests

The cause is current implement of executable_path. executable_path is not support symlinks. "/home/usagi/repos" in my environment is symlink, it is link to "Dropbox/repos".

Then, I propose a fixup to the test code test-get-currentexe.c:

The source of executable_path change from argv[0] to /proc/self/exe in GNU/Linux or /proc/curproc/file in BSD(and Darwin) and read it with support symlink resolver as readlink by unistd.h. But, I don't know how to solve in Windows.

Have somebody any more better idea? And about the solution in Windows.

saghul commented 10 years ago

I haven't looked into it, but your analysis suggests uv_exepath doesn't support symlinks, which IIRC is not the case. Maybe the test needs to be relaxed?

usagi commented 10 years ago
current(1.0.0-rc2) symlink supporting example
path (argv[0]) in get_currentexe.c no /some-symlink-dir/some-executable
uv_exepath in libuv API yes /symlink-resolved-path/some-executable

This leads to a failure in the test unexpected. (Assertion failed in test/test-get-currentexe.c on line 58: match && !strcmp(match, path))

Therefore, I think it should be change better how to get path in the test case. The test need to be strict, use symlink resolved path. So, I was propose, use readlink and /proc/self/exe instead of argv[0] in the test case test-get-currentexe.c.

saghul commented 10 years ago

Ah, I see what you mean. It's the runner which saves argv[0] as executable_path. I'll see if we can relax the test. If you have a patch which fixes the test without modifying the runner it would be awesome :-)

usagi commented 10 years ago

OK, I'll write a patch later :)

saghul commented 9 years ago

Closing.continues in #1565