[Box Backup-commit] COMMIT r3383 - box/trunk/infrastructure

subversion at boxbackup.org subversion at boxbackup.org
Thu Sep 4 02:36:26 BST 2014


Author: chris
Date: 2014-09-04 02:36:26 +0100 (Thu, 04 Sep 2014)
New Revision: 3383

Modified:
   box/trunk/infrastructure/buildenv-testmain-template.cpp
Log:
Add support for all logging options in test executables.

Merged back changes from the test refactor branch to reduce diffs.

Modified: box/trunk/infrastructure/buildenv-testmain-template.cpp
===================================================================
--- box/trunk/infrastructure/buildenv-testmain-template.cpp	2014-09-04 01:36:23 UTC (rev 3382)
+++ box/trunk/infrastructure/buildenv-testmain-template.cpp	2014-09-04 01:36:26 UTC (rev 3383)
@@ -244,13 +244,16 @@
 		{ "execute-only",	required_argument, NULL, 'e' },
 		{ NULL,			0,                 NULL,  0  }
 	};
-	
-	int ch;
-	
-	while ((ch = getopt_long(argc, argv, "c:d:e:qs:t:vPTUVW:", longopts, NULL))
+
+	int c;
+	std::string options("c:d:e:s:");
+	options += Logging::OptionParser::GetOptionString();
+	Logging::OptionParser LogLevel;
+
+	while ((c = getopt_long(argc, argv, options.c_str(), longopts, NULL))
 		!= -1)
 	{
-		switch(ch)
+		switch(c)
 		{
 			case 'c':
 			{
@@ -272,13 +275,6 @@
 			}
 			break;
 
-			case 's':
-			{
-				bbstored_args += " ";
-				bbstored_args += optarg;
-			}
-			break;
-
 			case 'e':
 			{
 				run_only_named_tests.push_back(optarg);
@@ -285,95 +281,28 @@
 			}
 			break;
 
-			#ifndef WIN32
-			case 'P':
+			case 's':
 			{
-				Console::SetShowPID(true);
+				bbstored_args += " ";
+				bbstored_args += optarg;
 			}
 			break;
-			#endif
 
-			case 'q':
+			default:
 			{
-				if(logLevel == Log::NOTHING)
+				int ret = LogLevel.ProcessOption(c);
+				if(ret != 0)
 				{
-					BOX_FATAL("Too many '-q': "
-						"Cannot reduce logging "
-						"level any more");
-					return 2;
+					fprintf(stderr, "Unknown option code "
+						"'%c'\n", c);
+					exit(2);
 				}
-				logLevel--;
 			}
-			break;
-
-			case 'v':
-			{
-				if(logLevel == Log::EVERYTHING)
-				{
-					BOX_FATAL("Too many '-v': "
-						"Cannot increase logging "
-						"level any more");
-					return 2;
-				}
-				logLevel++;
-			}
-			break;
-
-			case 'V':
-			{
-				logLevel = Log::EVERYTHING;
-			}
-			break;
-
-			case 'W':
-			{
-				logLevel = Logging::GetNamedLevel(optarg);
-				if (logLevel == Log::INVALID)
-				{
-					BOX_FATAL("Invalid logging level: " << optarg);
-					return 2;
-				}
-			}
-			break;
-
-			case 't':
-			{
-				Logging::SetProgramName(optarg);
-				Console::SetShowTag(true);
-			}
-			break;
-
-			case 'T':
-			{
-				Console::SetShowTime(true);
-			}
-			break;
-
-			case 'U':
-			{
-				Console::SetShowTime(true);
-				Console::SetShowTimeMicros(true);
-			}
-			break;
-
-			case '?':
-			{
-				fprintf(stderr, "Unknown option: '%c'\n",
-					optopt);
-				exit(2);
-			}
-
-			default:
-			{
-				fprintf(stderr, "Unknown option code '%c'\n",
-					ch);
-				exit(2);
-			}
 		}
 	}
 
 	Logging::FilterSyslog(Log::NOTHING);
-	Logging::FilterConsole((Log::Level)logLevel);
+	Logging::FilterConsole(LogLevel.GetCurrentLevel());
 
 	argc -= optind - 1;
 	argv += optind - 1;




More information about the Boxbackup-commit mailing list