[posix] implement virtual time and update tests to utilize virtual time (#2508)

This commit adds the following features:

- Example posix drivers to support virtual time simulation, allowing tests
  to run faster than real time.

- A python-based simulation driver that coordinates the virtual time
  simulations.  Each alarm event and message transmission across all nodes
  are scheduled in a single discrete time event queue.  As a result, only
  a single node is making forward progress at a time.

- Updated tests to utilize new virtual-time simulator, allowing them to run
  faster than real time.

- To enable virtual time feature, define VIRTUAL_TIME=1 env var and set
  CPPFLAGS=-DOPENTHREAD_POSIX_VIRTUAL_TIME=1.
This commit is contained in:
Jonathan Hui
2018-01-29 19:30:46 +00:00
committed by GitHub
parent 0403a1baf5
commit d426d7cfbd
107 changed files with 2600 additions and 882 deletions
+9
View File
@@ -37,6 +37,7 @@ import mle
import net_crypto
import network_data
import network_layer
import simulator
import sniffer
MESH_LOCAL_PREFIX = 'fdde:ad00:beef::/64'
@@ -67,6 +68,8 @@ INFINITE_COST_TIMEOUT = 90
MAX_ADVERTISEMENT_INTERVAL = 32
MLE_END_DEVICE_TIMEOUT = 100
VIRTUAL_TIME = bool(os.getenv('VIRTUAL_TIME', False))
def create_default_network_data_prefix_sub_tlvs_factories():
return {
network_data.TlvType.HAS_ROUTE: network_data.HasRouteFactory(
@@ -331,3 +334,9 @@ def create_default_thread_message_factory(master_key=DEFAULT_MASTER_KEY):
def create_default_thread_sniffer(nodeid=SNIFFER_ID):
return sniffer.Sniffer(nodeid, create_default_thread_message_factory())
def create_default_simulator():
if VIRTUAL_TIME:
return simulator.VirtualTime()
return simulator.RealTime()