Added test identity generation script

This commit is contained in:
Joseph Henry
2017-11-13 16:46:33 -08:00
parent 8e89aa39f4
commit fbfcd05a9a
6 changed files with 28 additions and 11 deletions

View File

@@ -1 +0,0 @@
**alice's** identity files and keys go here

View File

@@ -1 +0,0 @@
**bob's** identity files and keys go here

View File

@@ -1 +0,0 @@
**carol's** identity files and keys go here

10
test/create_test_identities.sh Executable file
View File

@@ -0,0 +1,10 @@
# !/bin/bash
NWID=""
mkdir -p test/alice test/bob test/carol test/ted
./build/darwin/selftest generate_id ${NWID} test/alice
./build/darwin/selftest generate_id ${NWID} test/bob
./build/darwin/selftest generate_id ${NWID} test/carol
./build/darwin/selftest generate_id ${NWID} test/ted

View File

@@ -1984,8 +1984,8 @@ int ZT_control_semantics_test(bool *passed)
sleep(1); sleep(1);
*/ */
zts_start(path, false); zts_start(path, false);
zts_join(strtoll(nwid,NULL,16)); zts_join(strtoull(nwid,NULL,16));
zts_leave(strtoll(nwid,NULL,16)); zts_leave(strtoull(nwid,NULL,16));
zts_stop(); zts_stop();
DEBUG_TEST("---\n"); DEBUG_TEST("---\n");
@@ -2683,13 +2683,24 @@ int trigger_address_sanitizer()
int main(int argc , char *argv[]) int main(int argc , char *argv[])
{ {
#if defined(__SELFTEST__) #if defined(__SELFTEST__)
if (argc == 3) { if (argc == 4) {
DEBUG_TEST("generating id...");
if (!strcmp(argv[1],"generate_id")) if (!strcmp(argv[1],"generate_id"))
{ {
DEBUG_TEST("generating ZeroTier identity for testing purposes..."); DEBUG_TEST("generating ZeroTier identity for testing purposes...");
if (strlen(argv[2]) > 0) { if (strlen(argv[2]) <= 0) {
zts_start(argv[2], true); // blocking call DEBUG_ERROR("invalid <nwid> was given");
exit(-1);
} }
if (strlen(argv[3]) <= 0) {
DEBUG_ERROR("invalid pathname was given");
exit(-1);
}
uint64_t nwid = strtoull(argv[2],NULL,16);
zts_start(argv[3], true);
zts_join(nwid);
uint64_t nodeId = zts_get_node_id();
DEBUG_TEST("generated id: %llx", nodeId);
exit(0); exit(0);
} }
} }
@@ -2697,7 +2708,7 @@ int main(int argc , char *argv[])
if (argc < 6) { if (argc < 6) {
fprintf(stderr, "usage: selftest <num_repeats> <selftest.conf> <alice|bob|ted|carol> to <bob|alice|ted|carol>\n"); fprintf(stderr, "usage: selftest <num_repeats> <selftest.conf> <alice|bob|ted|carol> to <bob|alice|ted|carol>\n");
fprintf(stderr, "usage: selftest generate_id <alice|bob...>\n"); fprintf(stderr, "usage: selftest generate_id <nwid> <alice|bob...>\n");
fprintf(stderr, "e.g. : selftest 3 test/test.conf alice to bob\n"); fprintf(stderr, "e.g. : selftest 3 test/test.conf alice to bob\n");
return 1; return 1;
} }
@@ -2770,7 +2781,7 @@ int main(int argc , char *argv[])
if (me != "dummy") { // used for testing ZT service wrapper API (before, during, and after coming online) 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 // set start time here since we need to wait for both libzt instances to be online
DEBUG_TEST("app-thread, waiting for libzt to come online...\n"); DEBUG_TEST("app-thread, waiting for libzt to come online...\n");
uint64_t nwid = strtoll(nwidstr.c_str(),NULL,16); uint64_t nwid = strtoull(nwidstr.c_str(),NULL,16);
zts_startjoin(path.c_str(), nwid); zts_startjoin(path.c_str(), nwid);
uint64_t nodeId = zts_get_node_id(); uint64_t nodeId = zts_get_node_id();
DEBUG_TEST("I am %x, %s", nodeId, me.c_str()); DEBUG_TEST("I am %x, %s", nodeId, me.c_str());

View File

@@ -1 +0,0 @@
**ted's** identity files and keys go here