| 5154 | // Basic test harness |
| 5155 | #if !defined(TARGET_OS_IPHONE) |
| 5156 | int main(int argc, char** argv) |
| 5157 | { |
| 5158 | bool disablePrompt = false; |
| 5159 | unsigned int iterations = 8; |
| 5160 | std::vector<std::string> selectedTests; |
| 5161 | |
| 5162 | // Disable buffering (so that when run in, e.g., Sublime Text, the output appears as it is written) |
| 5163 | std::setvbuf(stdout, nullptr, _IONBF, 0); |
| 5164 | |
| 5165 | // Isolate the executable name |
| 5166 | std::string progName = argv[0]; |
| 5167 | auto slash = progName.find_last_of("/\\"); |
| 5168 | if (slash != std::string::npos) { |
| 5169 | progName = progName.substr(slash + 1); |
| 5170 | } |
| 5171 | |
| 5172 | ConcurrentQueueTests tests; |
| 5173 | |
| 5174 | // Parse command line options |
| 5175 | if (argc > 1) { |
| 5176 | bool printHelp = false; |
| 5177 | bool printedTests = false; |
| 5178 | bool error = false; |
| 5179 | for (int i = 1; i < argc; ++i) { |
| 5180 | if (std::strcmp(argv[i], "--help") == 0) { |
| 5181 | printHelp = true; |
| 5182 | } |
| 5183 | else if (std::strcmp(argv[i], "--disable-prompt") == 0) { |
| 5184 | disablePrompt = true; |
| 5185 | } |
| 5186 | else if (std::strcmp(argv[i], "--run") == 0) { |
| 5187 | if (i + 1 == argc || argv[i + 1][0] == '-') { |
| 5188 | std::printf("Expected test name argument for --run option.\n"); |
| 5189 | if (!printedTests) { |
| 5190 | printTests(tests); |
| 5191 | printedTests = true; |
| 5192 | } |
| 5193 | error = true; |
| 5194 | continue; |
| 5195 | } |
| 5196 | |
| 5197 | if (!tests.validateTestName(argv[++i])) { |
| 5198 | std::printf("Unrecognized test '%s'.\n", argv[i]); |
| 5199 | if (!printedTests) { |
| 5200 | printTests(tests); |
| 5201 | printedTests = true; |
| 5202 | } |
| 5203 | error = true; |
| 5204 | continue; |
| 5205 | } |
| 5206 | |
| 5207 | selectedTests.push_back(argv[i]); |
| 5208 | } |
| 5209 | else if (std::strcmp(argv[i], "--iterations") == 0) { |
| 5210 | if (i + 1 == argc || argv[i + 1][0] == '-') { |
| 5211 | std::printf("Expected iteration count argument for --iterations option.\n"); |
| 5212 | error = true; |
| 5213 | continue; |
nothing calls this directly
no test coverage detected