static int run_one_test(int dropMode, int serverFinishedPermute, int serverHelloPermute, int clientFinishedPermute) { int fnIdx = 0; int res, filterIdx; filter_fn* local_filters = full ? filters_full : filters; const char** local_filter_names = full ? filter_names_full : filter_names; const char** permutation_namesX = full ? permutation_names5 : permutation_names3; int filter_count = full ? 12 : 8; run_id = ((dropMode * 2 + serverFinishedPermute) * (full ? 120 : 6) + serverHelloPermute) * (full ? 120 : 6) + clientFinishedPermute; filter_clear_state(); if (full) { filter_chain[fnIdx++] = filter_permute_ServerHelloFull; state_permute_ServerHelloFull.order = permutations5[serverHelloPermute]; filter_chain[fnIdx++] = filter_permute_ClientFinishedFull; state_permute_ClientFinishedFull.order = permutations5[clientFinishedPermute]; } else { filter_chain[fnIdx++] = filter_permute_ServerHello; state_permute_ServerHello.order = permutations3[serverHelloPermute]; filter_chain[fnIdx++] = filter_permute_ClientFinished; state_permute_ClientFinished.order = permutations3[clientFinishedPermute]; } filter_chain[fnIdx++] = filter_permute_ServerFinished; state_permute_ServerFinished.order = permutations2[serverFinishedPermute]; if (dropMode) { for (filterIdx = 0; filterIdx < filter_count; filterIdx++) { if (dropMode & (1 << filterIdx)) { filter_chain[fnIdx++] = local_filters[filterIdx]; } } } filter_chain[fnIdx++] = NULL; res = run_test(); switch (res) { case 0: fprintf(stdout, "%i ++ ", run_id); break; case 1: fprintf(stdout, "%i -- ", run_id); break; case 2: fprintf(stdout, "%i !! ", run_id); break; case 3: fprintf(stdout, "%i TT ", run_id); break; } fprintf(stdout, "SHello(%s), ", permutation_namesX[serverHelloPermute]); fprintf(stdout, "SFinished(%s), ", permutation_names2[serverFinishedPermute]); fprintf(stdout, "CFinished(%s) :- ", permutation_namesX[clientFinishedPermute]); if (dropMode) { for (filterIdx = 0; filterIdx < filter_count; filterIdx++) { if (dropMode & (1 << filterIdx)) { if (dropMode & ((1 << filterIdx) - 1)) { fprintf(stdout, ", "); } fprintf(stdout, "%s", local_filter_names[filterIdx]); } } } fprintf(stdout, "\n"); return res; }
void run_tests(int childcount) { static int permutations2[2][2] = { { 0, 1 }, { 1, 0 } }; static const char* permutations2names[2] = { "01", "10" }; static int permutations3[6][3] = { { 0, 1, 2 }, { 0, 2, 1 }, { 1, 0, 2 }, { 1, 2, 0 }, { 2, 0, 1 }, { 2, 1, 0 } }; static const char* permutations3names[6] = { "012", "021", "102", "120", "201", "210" }; static filter_fn filters[8] = { filter_packet_ServerHello, filter_packet_ServerKeyExchange, filter_packet_ServerHelloDone, filter_packet_ClientKeyExchange, filter_packet_ClientChangeCipherSpec, filter_packet_ClientFinished, filter_packet_ServerChangeCipherSpec, filter_packet_ServerFinished }; static const char* filter_names[8] = { "SHello", "SKeyExchange", "SHelloDone", "CKeyExchange", "CChangeCipherSpec", "CFinished", "SChangeCipherSpec", "SFinished" }; int children = 0; for (int dropMode = 0; dropMode != 1 << 8; dropMode++) for (int serverFinishedPermute = 0; serverFinishedPermute < 2; serverFinishedPermute++) for (int serverHelloPermute = 0; serverHelloPermute < 6; serverHelloPermute++) for (int clientFinishedPermute = 0; clientFinishedPermute < 6; clientFinishedPermute++) { int fnIdx = 0; filter_clear_state(); filter_chain[fnIdx++] = filter_permute_ServerHello; state_permute_ServerHello.order = permutations3[serverHelloPermute]; filter_chain[fnIdx++] = filter_permute_ServerFinished; state_permute_ServerFinished.order = permutations2[serverFinishedPermute]; filter_chain[fnIdx++] = filter_permute_ClientFinished; state_permute_ClientFinished.order = permutations3[clientFinishedPermute]; if (dropMode) { for (int filterIdx = 0; filterIdx < 8; filterIdx++) { if (dropMode & (1 << filterIdx)) { filter_chain[fnIdx++] = filters[filterIdx]; } } } filter_chain[fnIdx++] = NULL; if (!fork()) { int res = run_test(); switch (res) { case 0: fprintf(stdout, "++ "); break; case 1: fprintf(stdout, "-- "); break; case 2: fprintf(stdout, "!! "); break; } fprintf(stdout, "SHello(%s), ", permutations3names[serverHelloPermute]); fprintf(stdout, "SFinished(%s), ", permutations2names[serverFinishedPermute]); fprintf(stdout, "CFinished(%s) :- ", permutations3names[clientFinishedPermute]); if (dropMode) { for (int filterIdx = 0; filterIdx < 8; filterIdx++) { if (dropMode & (1 << filterIdx)) { if (dropMode & ((1 << filterIdx) - 1)) { fprintf(stdout, ", "); } fprintf(stdout, "%s", filter_names[filterIdx]); } } } fprintf(stdout, "\n"); if (res && debug) { exit(1); } else { exit(0); } } else { children++; while (children >= childcount) { wait(0); children--; } } } while (children > 0) { wait(0); children--; } }