Updated zts_start* API naming convention

This commit is contained in:
Joseph Henry
2017-10-12 12:07:33 -07:00
parent b78662dd9b
commit 9473b6f74a
17 changed files with 262 additions and 49 deletions

View File

@@ -1759,7 +1759,84 @@ void tcp_perf_rx_echo_4(TCP_UNIT_TEST_SIG_4)
}
int ZT_control_semantics_test(bool *passed)
{
// TODO: Each discrete operation should be tested in random order among every other discrete operation for a sustained period
/*
std::vector<ZT_VirtualNetworkRoute> *zts_get_network_routes(char *nwid);
int zts_get_device_id_from_file(const char *filepath, char *devID);
void *zts_start_service(void *thread_id);
void disableTaps();
void zts_get_ipv4_address(const char *nwid, char *addrstr, const size_t addrlen);
void zts_get_ipv6_address(const char *nwid, char *addrstr, const size_t addrlen);
int zts_has_ipv4_address(const char *nwid);
int zts_has_ipv6_address(const char *nwid);
int zts_has_address(const char *nwid);
void zts_get_6plane_addr(char *addr, const char *nwid, const char *devID);
void zts_get_rfc4193_addr(char *addr, const char *nwid, const char *devID);
void zts_join(const char * nwid);
void zts_leave(const char * nwid);
int zts_running();
int zts_start(const char *path);
int zts_start(const char *path, const char *nwid);
void zts_stop();
void zts_get_homepath(char *homePath, size_t len);
int zts_get_device_id(char *devID);
unsigned long zts_get_peer_count();
int zts_get_peer_address(char *peer, const char *devID);
*/
int n_times = 5;
char *nwid = "17d709436c2c5367";
char *path = "fake_path";
/*
// Perform operations on ZeroTier before calling zts_start(). Doing this makes absolutely no sense but could happen
zts_stop();
zts_join(nwid);
zts_leave(nwid);
DEBUG_TEST("---\n");
sleep(1);
// Perform operations on ZeroTier immediately upon startup, try to catch it with its pants down
// Ideally, the service wrapper should perform necessary checks to prevent any sort of issue
zts_start(path);
zts_join(nwid);
zts_leave(nwid);
zts_stop();
DEBUG_TEST("---\n");
sleep(1);
*/
zts_start(path);
zts_join(nwid);
zts_leave(nwid);
zts_stop();
DEBUG_TEST("---\n");
sleep(1);
/*
// start the ZeroTier service many times
for (int i=0; i<n_times; i++) { zts_start(path); }
// join the same network many times
for (int i=0; i<n_times; i++) { zts_join(nwid); }
// leave the same network many times
for (int i=0; i<n_times; i++) { zts_leave(nwid); }
// stop the ZeroTier service many times
for (int i=0; i<n_times; i++) { zts_stop(); }
*/
DEBUG_TEST("---\n");
sleep(1);
sleep(30); // wait for any aftermath
*passed = true;
DEBUG_TEST("PASSED");
}
/****************************************************************************/
/* OBSCURE API CALL TESTS */
@@ -2620,36 +2697,38 @@ int main(int argc , char *argv[])
fprintf(stderr, "\tremote_echo_ipv4 = %s\n", remote_echo_ipv4.c_str());
#if defined(__SELFTEST__)
// set start time here since we need to wait for both libzt instances to be online
long int selftest_start_time = get_now_ts();
subtest_expected_duration = 5;
DEBUG_TEST("Waiting for libzt to come online...\n");
zts_simple_start(path.c_str(), nwid.c_str());
char device_id[ZTO_ID_LEN];
zts_get_device_id(device_id);
DEBUG_TEST("I am %s, %s", device_id, me.c_str());
if (mode == TEST_MODE_SERVER) {
DEBUG_TEST("Ready. You should start selftest program on second host now...\n\n");
}
if (mode == TEST_MODE_CLIENT) {
DEBUG_TEST("Ready. Contacting selftest program on first host.\n\n");
if (me != "dummy") { // used for testing ZT service wrapper API (before, during, and after coming online)
// set start time here since we need to wait for both libzt instances to be online
DEBUG_TEST("Waiting for libzt to come online...\n");
zts_startjoin(path.c_str(), nwid.c_str());
char device_id[ZTO_ID_LEN];
zts_get_device_id(device_id);
DEBUG_TEST("I am %s, %s", device_id, me.c_str());
if (mode == TEST_MODE_SERVER) {
DEBUG_TEST("Ready. You should start selftest program on second host now...\n\n");
}
if (mode == TEST_MODE_CLIENT) {
DEBUG_TEST("Ready. Contacting selftest program on first host.\n\n");
}
// What follows is a long-form of zts_start():
/*
zts_start(path.c_str());
printf("waiting for service to start...\n");
while (zts_running() == false)
sleep(1);
printf("joining network...\n");
zts_join(nwid.c_str());
printf("waiting for address assignment...\n");
while (zts_has_address(nwid.c_str()) == false)
sleep(1);
*/
}
#endif // __SELFTEST__
// What follows is a long-form of zts_simple_start():
/*
zts_start(path.c_str());
printf("waiting for service to start...\n");
while (zts_running() == false)
sleep(1);
printf("joining network...\n");
zts_join(nwid.c_str());
printf("waiting for address assignment...\n");
while (zts_has_address(nwid.c_str()) == false)
sleep(1);
*/
for (int i=0; i<num_repeats; i++)
{
DEBUG_TEST("\n\n\n --- COMPREHENSIVE TEST ITERATION: %d out of %d ---\n\n\n", i, num_repeats);
@@ -2693,6 +2772,12 @@ for (int i=0; i<num_repeats; i++)
obscure_api_test(&passed);
}
// Test things like zts_start(), zts_stop(), zts_join(), etc
if (true) {
ZT_control_semantics_test(&passed);
}
exit(0);
// Spam a SOCK_DGRAM socket from many threads
if (false) {
ipv = 4;