2 * Copyright (c) 2008 Novell, Inc. (http://www.novell.com)
5 * Moonlight List (moonlight-list@lists.ximian.com)
7 * Permission is hereby granted, free of charge, to any person
8 * obtaining a copy of this software and associated documentation
9 * files (the "Software"), to deal in the Software without
10 * restriction, including without limitation the rights to use,
11 * copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
21 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
23 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
24 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26 * OTHER DEALINGS IN THE SOFTWARE.
34 using Mono
.GetOptions
;
36 namespace PerfSuiteRunner
{
38 public static class PerfSuiteRunner
{
40 public static int AllTestsMode (Options opts
)
42 Console
.WriteLine ("*** Pass name is '{0}'...", opts
.ShortName
);
44 Database
.Initialize (opts
.DatabaseFile
);
45 Database
.BeginTransaction ();
47 PassDbEntry passEntry
= new PassDbEntry ();
48 passEntry
.ShortName
= opts
.ShortName
;
49 passEntry
.Author
= opts
.Author
;
50 passEntry
.ChangeLog
= opts
.ChangeLog
;
51 passEntry
.Date
= DateTime
.Now
;
53 Database
.Put (passEntry
);
55 DrtStore store
= new DrtStore ("perf-suite-set/drtlist.xml");
56 foreach (DrtItem item
in store
.Items
) {
57 Console
.WriteLine ("*** Running [{0}]", item
);
59 ItemDbEntry itemEntry
= Database
.GetItemEntryByUniqueId (item
.UniqueId
);
60 if (itemEntry
== null) {
61 Console
.WriteLine ("*** [{0}] not yet in the database, adding...", item
);
62 itemEntry
= new ItemDbEntry ();
63 itemEntry
.UniqueId
= item
.UniqueId
;
64 itemEntry
.Name
= item
.Name
;
65 itemEntry
.InputFile
= item
.InputFile
;
66 Database
.Put (itemEntry
);
69 DrtResult r
= item
.Run ();
71 ResultDbEntry resultEntry
= new ResultDbEntry ();
72 resultEntry
.Pass
= passEntry
;
73 resultEntry
.Item
= itemEntry
;
77 Console
.WriteLine ("*** Averaged result: 0 (FAILURE)");
79 resultEntry
.Time
= r
.AveragedTime
;
80 Console
.WriteLine ("*** Averaged result: {0}usec", r
.AveragedTime
);
83 Database
.Put (resultEntry
);
86 Database
.CommitTransaction ();
92 public static int SingleTestMode (Options opts
)
94 Console
.WriteLine ("*** Running single test with id '{0}' not storing results in database...", opts
.TestId
);
96 DrtStore store
= new DrtStore ("perf-suite-set/drtlist.xml");
97 DrtItem item
= store
.GetDrtItemForId (opts
.TestId
);
100 Console
.WriteLine ("*** Test '{0}' not found!", opts
.TestId
);
104 Console
.WriteLine ("*** Running [{0}]", item
);
106 DrtResult r
= item
.Run ();
108 ResultDbEntry resultEntry
= new ResultDbEntry ();
111 resultEntry
.Time
= 0;
112 Console
.WriteLine ("*** Averaged result: 0 (FAILURE)");
114 resultEntry
.Time
= r
.AveragedTime
;
115 Console
.WriteLine ("*** Averaged result: {0}usec", r
.AveragedTime
);
122 public static int Main (string [] args
)
124 Options opts
= new Options ();
125 opts
.ProcessArgs (args
);
127 if (opts
.TestId
!= String
.Empty
)
128 return SingleTestMode (opts
);
130 return AllTestsMode (opts
);