diff options
author | Benoit Foucher <benoit@zeroc.com> | 2006-01-31 14:20:11 +0000 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2006-01-31 14:20:11 +0000 |
commit | cd73f6d57ba8f99a6c8558548623e12c3b9dbcef (patch) | |
tree | 447ab8eab38888c9749b30e0cb6a4428c8f7f0e7 | |
parent | Fixed minor bugs in IceUtil.Options.split() and added inputUtil tests. (diff) | |
download | ice-cd73f6d57ba8f99a6c8558548623e12c3b9dbcef.tar.bz2 ice-cd73f6d57ba8f99a6c8558548623e12c3b9dbcef.tar.xz ice-cd73f6d57ba8f99a6c8558548623e12c3b9dbcef.zip |
Fixed minor bug in IceUtil.Options.split, added inputUtil tests.
-rw-r--r-- | cs/src/Ice/Options.cs | 4 | ||||
-rw-r--r-- | cs/test/IceUtil/Makefile | 24 | ||||
-rwxr-xr-x | cs/test/IceUtil/inputUtil/Client.cs | 108 | ||||
-rw-r--r-- | cs/test/IceUtil/inputUtil/Makefile | 25 | ||||
-rwxr-xr-x | cs/test/IceUtil/inputUtil/inputUtilC.csproj | 90 | ||||
-rwxr-xr-x | cs/test/IceUtil/inputUtil/run.py | 54 | ||||
-rw-r--r-- | cs/test/Makefile | 2 |
7 files changed, 306 insertions, 1 deletions
diff --git a/cs/src/Ice/Options.cs b/cs/src/Ice/Options.cs index 165b721f05e..d633ff8aa4e 100644 --- a/cs/src/Ice/Options.cs +++ b/cs/src/Ice/Options.cs @@ -29,6 +29,10 @@ namespace IceUtil string IFS = " \t\n"; string l = line.Trim(); + if(l.Length == 0) + { + return new string[0]; + } State state = State.Normal; diff --git a/cs/test/IceUtil/Makefile b/cs/test/IceUtil/Makefile new file mode 100644 index 00000000000..cfd5e4cbea4 --- /dev/null +++ b/cs/test/IceUtil/Makefile @@ -0,0 +1,24 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +top_srcdir = ../.. + +include $(top_srcdir)/config/Make.rules.cs + +SUBDIRS = inputUtil + +$(EVERYTHING):: + @for subdir in $(SUBDIRS); \ + do \ + echo "making $@ in $$subdir"; \ + ( cd $$subdir && $(MAKE) $@ ) || exit 1; \ + done + +test:: + @python $(top_srcdir)/allTests.py diff --git a/cs/test/IceUtil/inputUtil/Client.cs b/cs/test/IceUtil/inputUtil/Client.cs new file mode 100755 index 00000000000..ddf18de1f16 --- /dev/null +++ b/cs/test/IceUtil/inputUtil/Client.cs @@ -0,0 +1,108 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +using System; + +public class Client +{ + private static void test(bool b) + { + if (!b) + { + throw new Exception(); + } + } + + public static void Main(string[] argvs) + { + System.Console.Out.Write("testing string to command line arguments... "); + System.Console.Out.Flush(); + string[] args; + + try + { + test(IceUtil.Options.split("").Length == 0); + + args = IceUtil.Options.split("\"\""); + test(args.Length == 1 && args[0].Equals("")); + args = IceUtil.Options.split("''"); + test(args.Length == 1 && args[0].Equals("")); + args = IceUtil.Options.split("$''"); + test(args.Length == 1 && args[0].Equals("")); + + args = IceUtil.Options.split("-a -b -c"); + test(args.Length == 3 && args[0].Equals("-a") && args[1].Equals("-b") && args[2].Equals("-c")); + args = IceUtil.Options.split("\"-a\" '-b' $'-c'"); + test(args.Length == 3 && args[0].Equals("-a") && args[1].Equals("-b") && args[2].Equals("-c")); + args = IceUtil.Options.split(" '-b' \"-a\" $'-c' "); + test(args.Length == 3 && args[0].Equals("-b") && args[1].Equals("-a") && args[2].Equals("-c")); + args = IceUtil.Options.split(" $'-c' '-b' \"-a\" "); + test(args.Length == 3 && args[0].Equals("-c") && args[1].Equals("-b") && args[2].Equals("-a")); + + // Testing single quote + args = IceUtil.Options.split("-Dir='C:\\\\test\\\\file'"); // -Dir='C:\\test\\file' + test(args.Length == 1 && args[0].Equals("-Dir=C:\\\\test\\\\file")); // -Dir=C:\\test\\file + args = IceUtil.Options.split("-Dir='C:\\test\\file'"); // -Dir='C:\test\file' + test(args.Length == 1 && args[0].Equals("-Dir=C:\\test\\file")); // -Dir=C:\test\file + args = IceUtil.Options.split("-Dir='C:\\test\\filewith\"quote'"); // -Dir='C:\test\filewith"quote' + test(args.Length == 1 && args[0].Equals("-Dir=C:\\test\\filewith\"quote")); // -Dir=C:\test\filewith"quote + + // Testing double quote + args = IceUtil.Options.split("-Dir=\"C:\\\\test\\\\file\""); // -Dir="C:\\test\\file" + test(args.Length == 1 && args[0].Equals("-Dir=C:\\test\\file")); // -Dir=C:\test\file + args = IceUtil.Options.split("-Dir=\"C:\\test\\file\""); // -Dir="C:\test\file" + test(args.Length == 1 && args[0].Equals("-Dir=C:\\test\\file")); // -Dir=C:\test\file + args = IceUtil.Options.split("-Dir=\"C:\\test\\filewith\\\"quote\""); // -Dir="C:\test\filewith\"quote" + test(args.Length == 1 && args[0].Equals("-Dir=C:\\test\\filewith\"quote")); // -Dir=C:\test\filewith"quote + + // Testing ANSI quote + args = IceUtil.Options.split("-Dir=$'C:\\\\test\\\\file'"); // -Dir=$'C:\\test\\file' + test(args.Length == 1 && args[0].Equals("-Dir=C:\\test\\file")); // -Dir=C:\test\file + args = IceUtil.Options.split("-Dir=$'C:\\oest\\oile'"); // -Dir='C:\oest\oile' + test(args.Length == 1 && args[0].Equals("-Dir=C:\\oest\\oile")); // -Dir=C:\oest\oile + args = IceUtil.Options.split("-Dir=$'C:\\oest\\oilewith\"quote'"); // -Dir=$'C:\oest\oilewith"quote' + test(args.Length == 1 && args[0].Equals("-Dir=C:\\oest\\oilewith\"quote")); // -Dir=C:\oest\oilewith"quote + args = IceUtil.Options.split("-Dir=$'\\103\\072\\134\\164\\145\\163\\164\\134\\146\\151\\154\\145'"); + test(args.Length == 1 && args[0].Equals("-Dir=C:\\test\\file")); // -Dir=C:\test\file + args = IceUtil.Options.split("-Dir=$'\\x43\\x3A\\x5C\\x74\\x65\\x73\\x74\\x5C\\x66\\x69\\x6C\\x65'"); + test(args.Length == 1 && args[0].Equals("-Dir=C:\\test\\file")); // -Dir=C:\test\file + args = IceUtil.Options.split("-Dir=$'\\cM\\c_'"); // Control characters + test(args.Length == 1 && args[0].Equals("-Dir=\x0D\x1F")); + args = IceUtil.Options.split("-Dir=$'C:\\\\\\146\\x66\\cMi'"); // -Dir=$'C:\\\146\x66i\cMi' + test(args.Length == 1 && args[0].Equals("-Dir=C:\\ff\x0Di")); + args = IceUtil.Options.split("-Dir=$'C:\\\\\\cM\\x66\\146i'"); // -Dir=$'C:\\\cM\x66\146i' + test(args.Length == 1 && args[0].Equals("-Dir=C:\\\x000Dffi")); + } + catch(IceUtil.Options.BadQuote) + { + test(false); + } + + string[] badQuoteCommands = new string[6]; + badQuoteCommands[0] = "\""; + badQuoteCommands[1] = "'"; + badQuoteCommands[2] = "\\$'"; + badQuoteCommands[3] = "-Dir=\"test"; + badQuoteCommands[4] = "-Dir='test"; + badQuoteCommands[5] = "-Dir=$'test"; + for(int i = 0; i < 6; ++i) + { + try + { + IceUtil.Options.split(badQuoteCommands[i]); + test(false); + } + catch(IceUtil.Options.BadQuote) + { + } + } + + System.Console.Out.WriteLine("ok"); + } +} diff --git a/cs/test/IceUtil/inputUtil/Makefile b/cs/test/IceUtil/inputUtil/Makefile new file mode 100644 index 00000000000..c31e67eba54 --- /dev/null +++ b/cs/test/IceUtil/inputUtil/Makefile @@ -0,0 +1,25 @@ +# ********************************************************************** +# +# Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +top_srcdir = ../../.. + +TARGETS = client.exe + +C_SRCS = Client.cs + +SDIR = . + +GDIR = generated + +include $(top_srcdir)/config/Make.rules.cs + +MCSFLAGS := $(MCSFLAGS) -target:exe + +client.exe: $(C_SRCS) + $(MCS) $(MCSFLAGS) -out:$@ $(call ref,icecs) $^ diff --git a/cs/test/IceUtil/inputUtil/inputUtilC.csproj b/cs/test/IceUtil/inputUtil/inputUtilC.csproj new file mode 100755 index 00000000000..c235fe6043d --- /dev/null +++ b/cs/test/IceUtil/inputUtil/inputUtilC.csproj @@ -0,0 +1,90 @@ +<VisualStudioProject> + <CSHARP + ProjectType = "Local" + ProductVersion = "7.10.3077" + SchemaVersion = "2.0" + ProjectGuid = "{86CEBBC9-5ED4-4BE6-BC80-577F5F361677}" + > + <Build> + <Settings + ApplicationIcon = "" + AssemblyKeyContainerName = "" + AssemblyName = "client" + AssemblyOriginatorKeyFile = "" + DefaultClientScript = "JScript" + DefaultHTMLPageLayout = "Grid" + DefaultTargetSchema = "IE50" + DelaySign = "false" + OutputType = "Exe" + PreBuildEvent = "" + PostBuildEvent = "" + RootNamespace = "" + RunPostBuildEvent = "OnBuildSuccess" + StartupObject = "" + > + <Config + Name = "Debug" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "DEBUG;TRACE" + DocumentationFile = "" + DebugSymbols = "true" + FileAlignment = "4096" + IncrementalBuild = "true" + NoStdLib = "false" + NoWarn = "" + Optimize = "false" + OutputPath = ".\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "true" + WarningLevel = "4" + /> + <Config + Name = "Release" + AllowUnsafeBlocks = "false" + BaseAddress = "285212672" + CheckForOverflowUnderflow = "false" + ConfigurationOverrideFile = "" + DefineConstants = "TRACE" + DocumentationFile = "" + DebugSymbols = "false" + FileAlignment = "4096" + IncrementalBuild = "true" + NoStdLib = "false" + NoWarn = "" + Optimize = "true" + OutputPath = ".\" + RegisterForComInterop = "false" + RemoveIntegerChecks = "false" + TreatWarningsAsErrors = "true" + WarningLevel = "4" + /> + </Settings> + <References> + <Reference + Name = "System" + AssemblyName = "System" + HintPath = "..\..\..\..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll" + /> + <Reference + Name = "Ice" + Project = "{C3630502-8F67-42BF-B4CA-A21D2EA8049E}" + Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" + /> + </References> + </Build> + <Files> + <Include> + <File + RelPath = "Client.cs" + SubType = "Code" + BuildAction = "Compile" + /> + </Include> + </Files> + </CSHARP> +</VisualStudioProject> + diff --git a/cs/test/IceUtil/inputUtil/run.py b/cs/test/IceUtil/inputUtil/run.py new file mode 100755 index 00000000000..1f164d28854 --- /dev/null +++ b/cs/test/IceUtil/inputUtil/run.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python +# ********************************************************************** +# +# Copyright (c) 2003-2005 ZeroC, Inc. All rights reserved. +# +# This copy of Ice is licensed to you under the terms described in the +# ICE_LICENSE file included in this distribution. +# +# ********************************************************************** + +import os, sys, getopt + +for toplevel in [".", "..", "../..", "../../..", "../../../.."]: + toplevel = os.path.normpath(toplevel) + if os.path.exists(os.path.join(toplevel, "config", "TestUtil.py")): + break +else: + raise "can't find toplevel directory!" + +sys.path.append(os.path.join(toplevel, "config")) +import TestUtil + +def usage(): + print "usage: " + sys.argv[0] + " [-m]" + sys.exit(2) + +try: + opts, args = getopt.getopt(sys.argv[1:], "m") +except getopt.GetoptError: + usage() + +mono = 0 +for o, a in opts: + if o == "-m": + mono = 1 + +if not TestUtil.isWin32(): + mono = 1 + +name = os.path.join("IceUtil", "inputUtil") +testdir = os.path.join(toplevel, "test", name) +client = os.path.join(testdir, "client") + +print TestUtil.createMsg(mono, "client"), +clientPipe = os.popen(TestUtil.createCmd(mono, client)) +print "ok" + +TestUtil.printOutputFromPipe(clientPipe) + +clientStatus = clientPipe.close() +if clientStatus: + sys.exit(1) + +sys.exit(0) diff --git a/cs/test/Makefile b/cs/test/Makefile index c5fa87e2dfa..48b25fe4e1f 100644 --- a/cs/test/Makefile +++ b/cs/test/Makefile @@ -11,7 +11,7 @@ top_srcdir = .. include $(top_srcdir)/config/Make.rules.cs -SUBDIRS = Ice Glacier2 IceGrid +SUBDIRS = IceUtil Ice Glacier2 IceGrid $(EVERYTHING):: @for subdir in $(SUBDIRS); \ |