aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/mass test client/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--tools/mass test client/Program.cs218
1 files changed, 218 insertions, 0 deletions
diff --git a/tools/mass test client/Program.cs b/tools/mass test client/Program.cs
new file mode 100644
index 0000000..6274011
--- /dev/null
+++ b/tools/mass test client/Program.cs
@@ -0,0 +1,218 @@
1using System;
2using System.Collections.Generic;
3using System.IO;
4using CommandLine.Utility;
5
6namespace libsecondlife.TestClient
7{
8 public class CommandLineArgumentsException : Exception
9 {
10 }
11
12 public class Program
13 {
14
15 private static void Usage()
16 {
17 Console.WriteLine("Usage: " + Environment.NewLine +
18 "MassTestClient.exe --first \"firstname\" --last \"lastname\" --pass \"password\" --contact \"youremail\" [--startpos \"sim/x/y/z\"] [--master \"master name\"] [--masterkey \"master uuid\"] [--loginuri \"loginuri\"] [--masscommandfile \"filename\"]" +
19 Environment.NewLine + Environment.NewLine + "MassTestClient.exe --loginfile \"filename\" --contact \"youremail\" [--master \"master name\"] [--masterkey \"master uuid\"] [--loginuri \"loginuri\"] [--masscommandfile \"filename\"]");
20 Console.ReadLine();
21 }
22
23 private static List<string> getMassTestCommands()
24 {
25 List<string> givenCommands = new List<string>();
26 Console.WriteLine("Please enter mass test commands to run in an infinite loop. Press enter to end the current command. Entering a blank command represents that you are done.");
27 Console.WriteLine("");
28
29 int curCommand = 0;
30 string lastCommand = "NULL";
31 while (lastCommand.Length > 0)
32 {
33 Console.Write("Command #" + curCommand + ">");
34 lastCommand = Console.ReadLine().Trim();
35 if (lastCommand.Length > 0)
36 {
37 givenCommands.Add(lastCommand);
38 curCommand++;
39 }
40 }
41
42 return givenCommands;
43 }
44
45 static void Main(string[] args)
46 {
47 Arguments arguments = new Arguments(args);
48
49 ClientManager manager;
50 List<LoginDetails> accounts = new List<LoginDetails>();
51 LoginDetails account;
52 string masterName = String.Empty;
53 LLUUID masterKey = LLUUID.Zero;
54 string file = String.Empty;
55 string contact = String.Empty;
56 string loginURI = "https://login.agni.lindenlab.com/cgi-bin/login.cgi";
57 try
58 {
59 if (arguments["masterkey"] != null)
60 {
61 masterKey = LLUUID.Parse(arguments["masterkey"]);
62 }
63
64 if (arguments["master"] != null)
65 {
66 masterName = arguments["master"];
67 }
68
69 if (arguments["contact"] == null)
70 throw new CommandLineArgumentsException();
71
72 contact = arguments["contact"];
73
74 if (arguments["file"] != null)
75 {
76 file = arguments["file"];
77
78 // Loading names from a file
79 try
80 {
81 using (StreamReader reader = new StreamReader(file))
82 {
83 string line;
84 int lineNumber = 0;
85
86 while ((line = reader.ReadLine()) != null)
87 {
88 lineNumber++;
89 string[] tokens = line.Trim().Split(new char[] { ' ', ',' });
90
91 if (tokens.Length >= 3)
92 {
93 account = new LoginDetails();
94 account.FirstName = tokens[0];
95 account.LastName = tokens[1];
96 account.Password = tokens[2];
97
98 accounts.Add(account);
99
100 // Leaving this out until we have per-account masters (if that
101 // is desirable). For now the command-line option can
102 // specify the single master that TestClient supports
103
104 //if (tokens.Length == 5)
105 //{
106 // master = tokens[3] + " " + tokens[4];
107 //}
108 }
109 else
110 {
111 Console.WriteLine("Invalid data on line " + lineNumber +
112 ", must be in the format of: FirstName LastName Password");
113 }
114 }
115 }
116 }
117 catch (Exception e)
118 {
119 Console.WriteLine("Error reading from " + args[1]);
120 Console.WriteLine(e.ToString());
121 Console.ReadLine();
122 return;
123 }
124 }
125 else if (arguments["first"] != null && arguments["last"] != null && arguments["pass"] != null)
126 {
127 // Taking a single login off the command-line
128 account = new LoginDetails();
129 account.FirstName = arguments["first"];
130 account.LastName = arguments["last"];
131 account.Password = arguments["pass"];
132
133 accounts.Add(account);
134 }
135 else
136 {
137 throw new CommandLineArgumentsException();
138 }
139 }
140
141 catch (CommandLineArgumentsException)
142 {
143 Usage();
144 return;
145 }
146
147 if(arguments["loginuri"] != null)
148 {
149 loginURI = arguments["loginuri"];
150 }
151
152 List<string> massTestCommands = new List<string>();
153 if(arguments["masscommandfile"] != null)
154 {
155 string massCommandFile = arguments["masscommandfile"];
156 try
157 {
158 using (StreamReader reader = new StreamReader(massCommandFile))
159 {
160 string line;
161
162 while ((line = reader.ReadLine()) != null)
163 {
164
165 line = line.Trim();
166 if(line.Length > 0)
167 {
168 massTestCommands.Add(line);
169 }
170 }
171 }
172 }
173 catch (Exception e)
174 {
175 Console.WriteLine("Error reading from " + args[1]);
176 Console.WriteLine(e.ToString());
177 Console.ReadLine();
178 return;
179 }
180 }
181 else
182 {
183 Console.Clear();
184 massTestCommands = getMassTestCommands();
185 }
186
187 Console.Clear();
188 if (massTestCommands.Count == 0)
189 {
190 Console.WriteLine("No mass commands entered; Normal 'TestClient' operation will be used");
191 }
192 else
193 {
194 Console.WriteLine("Detected " + massTestCommands.Count + " mass commands; MassTestClient operation will be used");
195 }
196
197 foreach (LoginDetails a in accounts)
198 {
199 a.MasterName = masterName;
200 a.MasterKey = masterKey;
201 a.LoginURI = loginURI;
202 }
203
204 // Login the accounts and run the input loop
205 if (arguments["startpos"] != null)
206 {
207 manager = new ClientManager(accounts, contact, arguments["startpos"]);
208 }
209 else
210 {
211 manager = new ClientManager(accounts, contact);
212 }
213
214
215 manager.Run(massTestCommands);
216 }
217 }
218}