The concurrent interpreter supports a `time` directive that
lets testers ensure some instruction has taken at least some
amount of time. This is useful when testing that some
callback didn't arrive before it was sent, for example.
Unfortunately, there is some unavoidable uncertainty in how
time is measured. Because the thread that measures time
needs a very small amount of time before it starts measuring
the time taken by its instruction, it is possible that the
time that is intended to be measured actually took X, but
because the measuring thread took Ɛ before it started
measuring time, the measured time is X - Ɛ, which may fail
the test because it didn't take enough time.
Because there is no way at all to know how much time passed
between the measuring thread being woken up and it measuring
start time, it's not possible to fix this as long as the
measure for the minimum time is taken after the wait. So
instead, take the measure before the wait.
It's always technically possible that there is a bug where
the code doesn't take enough time, but the test doesn't
catch it because the device happened to run slowly as it
ran the test (e.g. other stuff running at the same time),
and this patch makes it a little worse – there will be more
true negatives, but this is the only way to ensure no false
positives and it should still catch the "too fast" cases
most of the time.
Now, each thread has its own "blocked" time. It would be
possible to store that time in a local and pass it down to
all instructions, but that would require all instructions
to take the blocked time as an argument, while only the
`time` instruction can have any meaningful use of it.
Therefore, store it in a thread local instead of adding an
argument to all instructions for all interpreters.
Test: atest --iterations 100 'TestableNetworkCallbackTest#testPollForNextCallback'
...although I can't get it to fail locally, so the
proof will be in a dying out of the flakes.
Also checked that increasing the minimum time on an
existing test does fail as expected
Bug: 185735163
Change-Id: I0afb651337a8b10a864cc5bc793d65d2ce56ab20
std::result_of is deprecated in C++17 and removed in C++20.
std::invoke_result is added in C++17.
Upstream libc++ has started removing the declaration of std::result_of
when a new-enough C++ dialect is selected, so switch to the supported
type.
Bug: http://b/175635923
Test: treehugger
Change-Id: Ie2db3e092b4300e20858097ac4e88ebaedc7ae07
Upcoming CL will modify StructInetDiagSockId.
So, as a preparation, this CL adds test for existing behavior of
StructInetDiagSockId.
Bug: 217624062
Test: atest NetworkStaticLibTests
Change-Id: I6ef475bec050ba2689a8df6182be36a6fccd9bfb
Instead of only checking that a sim card that supports data connectivity
is inserted, also check that there is an available cellular network.
This helps ensure that the device is setup with a working data plan and
APN configuration.
Bug: 242628522
Test: atest CtsNetTestCases
Change-Id: Id47d49de77da5d9f7a87ff34b954c61662965c9e
This is useful as an array version of Collections.indexOfSubList().
Bug: 242630963
Test: atest NetworkStaticLibTests
Change-Id: I36724791ceece1348826a51cb2a975e169dfecc6
EthernetTetheringTest has parseMapKeyValue that decodes the string
encoded by BpfDump#toBase64EncodedString
Upcoming CL also wants to decode the encoded string.
So this CL renames parseMapKeyValue to fromBase64EncodedString and moves
to BpfDump with refactoring
Bug: 217624062
Test: atest NetworkStaticLibTests
Change-Id: I6ec302aaaa3e8779119cf153567cb032828f5daf
This is needed by ConnectivityServiceTest, refer to the
counter part CL in the module git.
This CL also fix guarded by annotation and remove the
increment/decrement method with count methods, which
is not very useful.
Test: TH
Bug: 235771502
Change-Id: Iaab681bf456e14afb4c6ddf700eb3308abead35f
...and rename ExceptionUtils to FunctionalUtils as the old name
would no longer be appropriate.
Test: FrameworksNetTests
Change-Id: I2affd69fb84d7f250b4a45497eec6c052bf6ec50
The ArrayEquals, ArrayHashCode, ArrayToString, and
ArraysAsListPrimitiveArray errorprone findings were
demoted from errors to warnings. Fix existing
occurrences of them so they can be made errors again.
Bug: 242630963
Test: RUN_ERROR_PRONE=true m javac-check
Change-Id: I6132205b0e86e3ec73c78d54ce2a8c334b81c5ed
(also note the program in p/m/C netd.C is not optional or kernel version dependent)
Bug: 237030932
Test: TreeHugger
Signed-off-by: Maciej Żenczykowski <maze@google.com>
Change-Id: Ia984f6a1ce0ab14a204fe47ec295db1363879b7b
Move the NetworkMonitorUtils class from NetworkStack module to
frameworks/libs/net, then we can remove the filegroups defined
in NetworkStack module which are shared with Connectivity module.
Import the net-utils-device-common lib instead.
Update the NetworkMonitorUtils#isValidationRequired() first param type
to make the migration easier, change the NetworkAgentConfigShim type
param to boolean, which can be passed by the caller directly such as in
ConnectivityServiceTest or NetworkMonitor, then we don't need to add
static lib to support NetworkAgentConfigShim, not easy to support.
Bug: 238960524
Test: m
Change-Id: I72dfb5902dea0e7ddb2c33a08f874fe36adcbeec
Currently RouterAdvertisementResponder always uses a prefix of
2001:db8::/64, even if there are multiple instances on different
interfaces. Randomize the prefix instead.
Test: TH
Bug: 240323229
Change-Id: I585ca804845f4278187602a6c9816470dcea04f8
Throwing an exception in RaResponder crashes the test process (as it
runs in a secondary thread). This is not very useful as that will fail
the execution of all the other tests.
Adding a log statement instead of throwing an exception makes more sense
as the tests will most likely fail anyways.
Test: atest EthernetManagerTest
Change-Id: I9c5f5dc417dad7df1c7f729caa4e0259ed71591f
stop() calls interrupt which does not terminate the thread instantly.
Therefore, it should wait for the thread to join, as otherwise the
caller has no way of knowing when it is safe to close the underlying fd.
This led to frequent test process crashes during EthernetManagerTest
runs.
Test: atest EthernetManagerTest
Change-Id: I28f0d46c4f0295acffa5ec9f04964cd73d3de928