[posix-app] enhance virtual time for posix app (#3016)

This commit is contained in:
Yakun Xu
2018-09-05 18:08:36 -07:00
committed by Jonathan Hui
parent 2742886134
commit bdffbe5671
28 changed files with 1035 additions and 305 deletions
+1
View File
@@ -157,6 +157,7 @@ TESTS = \
# made available to all programs and scripts in TESTS.
TESTS_ENVIRONMENT = \
top_srcdir='$(top_srcdir)' \
$(NULL)
# Source, compiler, and linker options for test programs.
+17
View File
@@ -29,7 +29,10 @@
#include <openthread/diag.h>
#include <openthread/platform/radio.h>
#include <signal.h>
#include <stdlib.h>
#include <sys/prctl.h>
#include <unistd.h>
#include "utils/wrap_string.h"
@@ -231,6 +234,20 @@ void TestDiag(void)
// initialize platform layer
#if OPENTHREAD_ENABLE_POSIX_APP
char *argv[] = {(char *)"test_diag", getenv("RADIO_DEVICE"), (char *)"1"};
#if OPENTHREAD_POSIX_VIRTUAL_TIME
char simulator[128];
sprintf(simulator, "%s/tests/scripts/thread-cert/simulator.py", getenv("top_srcdir"));
if (0 == fork())
{
prctl(PR_SET_PDEATHSIG, SIGHUP);
exit(execlp("python", "python", simulator, NULL));
}
setenv("NODE_ID", "1", 0);
sleep(2);
#endif // OPENTHREAD_POSIX_VIRTUAL_TIME
#else
char *argv[] = {(char *)"test_diag", (char *)"1"};
#endif