Commit graph

4 commits

Author SHA1 Message Date
Mark Salyzyn
52bd37e633 libcutils: move cutils/files.h to cutils/android_get_control_file.h
files.[h|cpp] is bound to be abused with junk, replace with
android_get_control_file.[h|cpp]. Plus some sundry cleanup.

Test: gTest libcutils-tests, logd-unit-tests, liblog-unit-tests,
      logcat-unit-tests and init_tests
Bug: 32450474
Change-Id: Ibd4a7aa4624ea19a43d1f98a3c71ac37805d36b5
2016-11-16 15:56:56 -08:00
Mark Salyzyn
547e0dc45a libcutils: add android_get_control_socket() test
android_get_control_socket() checks if the resulting file descriptor
is valid, open and matches the socket bound name reference, which on
purpose will fail if a symbolic link is in the path rather than using
a fully qualified path.  If there are any non-alpha and non-numeric
characters in the name, they are replaced with _.  Add unit test.

Test: gTest libcutils_test --gtest_filter=SocketTest.android_get_control_socket
Bug: 32450474
Change-Id: I27a6419012033ef8bd6ca04f3e479d01264d8c49
2016-11-03 13:34:13 -07:00
Colin Cross
e8ffa449fd Move android_get_control_socket out of line
android_get_control_socket has a warning from the implicit cast from
long to int.  The warning was being hidden because cutils/sockets.h was
included with -isystem.  Move android_get_control_socket to sockets.cpp,
since we don't want header only dependencies anyways, and fix the
warning with a range check and a static_cast.

Bug: 31492149
Test: m -j <module that uses sockets.h and -Wall>
Change-Id: I1f394ab26d4ec8a7dd0e7907c10416d7f8647624
2016-09-23 11:26:08 -07:00
David Pursell
756e1c81e8 libcutils: add socket_get_local_port().
Tests that require a local server currently hardcode a test value,
which can run into conflicts depending on what's currently running on
the machine.

This CL adds socket_get_local_port(), which lets us pass 0 so the
system picks an open port and we can query which port it chose.

Bug: http://b/26236380
Change-Id: I01d1558884e7636081d9a357db6faa86929934f6
2016-02-02 09:52:02 -08:00