Author: rfm
Date: Fri Mar 28 09:07:59 2014
New Revision: 37774
URL: http://svn.gna.org/viewcvs/gnustep?rev=37774&view=rev
Log:
testing additions
Added:
libs/ec/trunk/EcTest.h
libs/ec/trunk/EcTest.m
Modified:
libs/ec/trunk/ChangeLog
libs/ec/trunk/EcProcess.m
libs/ec/trunk/GNUmakefile
Modified: libs/ec/trunk/ChangeLog
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/ChangeLog?rev=37774&r1=37773&r2=37774&view=diff
==============================================================================
--- libs/ec/trunk/ChangeLog (original)
+++ libs/ec/trunk/ChangeLog Fri Mar 28 09:07:59 2014
@@ -1,6 +1,17 @@
+2014-03-28 Richard Frith-Macdonald <[email protected]>
+
+ * EcTest.h:
+ * EcTest.m:
+ * EcProcess.m:
+ * GNUmakefile:
+ Add a few simple functions to connect to a process, set/get the
+ config of a running process, and issue commands (and get back
+ the response) so that regression test software can relatively
+ easily exercie an entire system.
+
2014-03-26 Richard Frith-Macdonald <[email protected]>
- EcControl.m: Add option to allow any user to log in.
+ * EcControl.m: Add option to allow any user to log in.
2014-03-25 Richard Frith-Macdonald <[email protected]>
Modified: libs/ec/trunk/EcProcess.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcProcess.m?rev=37774&r1=37773&r2=37774&view=diff
==============================================================================
--- libs/ec/trunk/EcProcess.m (original)
+++ libs/ec/trunk/EcProcess.m Fri Mar 28 09:07:59 2014
@@ -4294,3 +4294,61 @@
@end
+@implementation EcProcess (Test)
+
+- (bycopy NSString*) ecTestCommand: (in bycopy NSString*)command
+{
+ NSEnumerator *enumerator;
+ NSMutableArray *words;
+ NSString *word;
+
+ command = [command stringByTrimmingSpaces];
+ words = [NSMutableArray arrayWithCapacity: 16];
+ enumerator = [[command componentsSeparatedByString: @" "] objectEnumerator];
+ while ((word = [enumerator nextObject]) != nil)
+ {
+ [words addObject: [word stringByTrimmingSpaces]];
+ }
+ if ([words count] == 0)
+ {
+ return nil;
+ }
+ return [self cmdMesg: words];
+}
+
+- (bycopy NSData*) ecTestConfigForKey: (in bycopy NSString*)key
+{
+ id result = [cmdDefs objectForKey: key];
+
+ if (nil != result)
+ {
+ result = [NSPropertyListSerialization
+ dataFromPropertyList: result
+ format: NSPropertyListBinaryFormat_v1_0
+ errorDescription: 0];
+ }
+ return result;
+}
+
+- (void) ecTestSetConfig: (in bycopy NSData*)data
+ forKey: (in bycopy NSString*)key
+{
+ id val;
+
+ if (nil == data)
+ {
+ val = data;
+ }
+ else
+ {
+ val = [NSPropertyListSerialization
+ propertyListWithData: data
+ options: NSPropertyListMutableContainers
+ format: 0
+ error: 0];
+ }
+ [cmdDefs setCommand: val forKey: key];
+}
+
+@end
+
Added: libs/ec/trunk/EcTest.h
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcTest.h?rev=37774&view=auto
==============================================================================
--- libs/ec/trunk/EcTest.h (added)
+++ libs/ec/trunk/EcTest.h Fri Mar 28 09:07:59 2014
@@ -0,0 +1,88 @@
+/** Enterprise Control Configuration and Logging
+
+ Copyright (C) 2014 Free Software Foundation, Inc.
+
+ Written by: Richard Frith-Macdonald <[email protected]>
+ Date: March 2014
+ Originally developed from 1996 to 2014 by Brainstorm, and donated to
+ the FSF.
+
+ This file is part of the GNUstep project.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02111 USA.
+
+ */
+
+#import <Foundation/NSObject.h>
+
+@class NSData;
+@class NSString;
+
+
+/* The EcTest protocol provides remote diagnostic tools to use from
+ * one program to test the operation of an EcProcess based server.
+ */
+@protocol EcTest <NSObject>
+
+/** Sends a command to the remote process and returns the string output.<br />
+ * Similar to issueing the command string at the console.
+ */
+- (bycopy NSString*) ecTestCommand: (in bycopy NSString*)command;
+
+/* Gets the current configuration value in use by the process for the
+ * specified key.
+ */
+- (bycopy NSData*) ecTestConfigForKey: (in bycopy NSString*)key;
+
+/* Sets a configuration value to be used by the remote process, overriding
+ * any existing value. Changes to the process configuration in Control.plist
+ * will NOT override this for the running process, though changes explicitly
+ * made from the Console may.<br />
+ * The supplied data is a serialised property list.<br />
+ * NB. This method is NOT oneway, it waits for the remote process to handle
+ * the configuration change before it returns, so the caller knows that the
+ * configuration update has taken place.
+ */
+- (void) ecTestSetConfig: (in bycopy NSData*)data
+ forKey: (in bycopy NSString*)key;
+@end
+
+/** This function obtains a Distributed Objects proxy to the EcProcess
+ * instance controlling the server with the specified name and host.<br />
+ * A nil or empty string for the host is taken to mean the local host,
+ * while an asterisk denotes any host on the local network.<br />
+ * The timeout is a time limit on how long it may take to get the
+ * connection (a value less than or equal to zero wiull cause the
+ * function to keep on trying indefinitely).
+ */
+extern id<EcTest>
+EcTestConnect(NSString *name, NSString *host, NSTimeInterval timeout);
+
+/** This function gets process configuration for the specified key
+ * and deserialises it to a property list object (returned) or nil
+ * if no value is configured for the specified key.
+ */
+extern id
+EcTestGetConfig(id<EcTest> process, NSString *key);
+
+/** This function sets process configuration by serialising the property
+ * list value and passing the resulting data to the remote process.<br />
+ * If the value is nil then the configuration for the remote process
+ * reverts to its default setting.
+ */
+extern void
+EcTestSetConfig(id<EcTest> process, NSString *key, id value);
+
Added: libs/ec/trunk/EcTest.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/EcTest.m?rev=37774&view=auto
==============================================================================
--- libs/ec/trunk/EcTest.m (added)
+++ libs/ec/trunk/EcTest.m Fri Mar 28 09:07:59 2014
@@ -0,0 +1,107 @@
+
+/** Enterprise Control Configuration and Logging
+
+ Copyright (C) 2014 Free Software Foundation, Inc.
+
+ Written by: Richard Frith-Macdonald <[email protected]>
+ Date: March 2014
+ Originally developed from 1996 to 2012 by Brainstorm, and donated to
+ the FSF.
+
+ This file is part of the GNUstep project.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 3 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Library General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ Boston, MA 02111 USA.
+
+ */
+
+#import <Foundation/Foundation.h>
+#import "EcProcess.h"
+#import "EcTest.h"
+
+id<EcTest>
+EcTestConnect(NSString *name, NSString *host, NSTimeInterval timeout)
+{
+ CREATE_AUTORELEASE_POOL(pool);
+ id<EcTest> proxy = nil;
+ NSDate *when;
+
+ if (nil == host) host = @"";
+ if (timeout > 0)
+ {
+ when = [NSDate dateWithTimeIntervalSinceNow: timeout];
+ }
+ else
+ {
+ when = [NSDate distantFuture];
+ }
+
+ while (nil == proxy && [when timeIntervalSinceNow] > 0.0)
+ {
+ NS_DURING
+ {
+ proxy = (id<EcTest>)[NSConnection
+ rootProxyForConnectionWithRegisteredName: name
+ host: @""
+ usingNameServer: [NSSocketPortNameServer sharedInstance]];
+ }
+ NS_HANDLER
+ {
+ proxy = nil;
+ }
+ NS_ENDHANDLER
+ if (nil == proxy)
+ {
+ [NSThread sleepForTimeInterval: 0.1];
+ }
+ }
+ [proxy retain];
+ DESTROY(pool);
+ return [proxy autorelease];
+}
+
+id
+EcTestGetConfig(id<EcTest> process, NSString *key)
+{
+ id val;
+
+ NSCAssert([key isKindOfClass: [NSString class]], NSInvalidArgumentException);
+ val = [process ecTestConfigForKey: key];
+ if (nil != val)
+ {
+ val = [NSPropertyListSerialization
+ propertyListWithData: val
+ options: NSPropertyListMutableContainers
+ format: 0
+ error: 0];
+ }
+ return val;
+}
+
+void
+EcTestSetConfig(id<EcTest> process, NSString *key, id value)
+{
+ NSCAssert([key isKindOfClass: [NSString class]], NSInvalidArgumentException);
+ if (nil != value)
+ {
+ value = [NSPropertyListSerialization
+ dataFromPropertyList: value
+ format: NSPropertyListBinaryFormat_v1_0
+ errorDescription: 0];
+ }
+ [process ecTestSetConfig: value forKey: key];
+
+}
+
Modified: libs/ec/trunk/GNUmakefile
URL:
http://svn.gna.org/viewcvs/gnustep/libs/ec/trunk/GNUmakefile?rev=37774&r1=37773&r2=37774&view=diff
==============================================================================
--- libs/ec/trunk/GNUmakefile (original)
+++ libs/ec/trunk/GNUmakefile Fri Mar 28 09:07:59 2014
@@ -46,6 +46,7 @@
EcHost.m \
EcLogger.m \
EcProcess.m \
+ EcTest.m \
EcUserDefaults.m \
ECCL_HEADER_FILES = \
@@ -57,6 +58,7 @@
EcHost.h \
EcLogger.h \
EcProcess.h \
+ EcTest.h \
EcUserDefaults.h \
@@ -109,6 +111,7 @@
EcHost.h \
EcLogger.h \
EcProcess.h \
+ EcTest.h \
EcUserDefaults.h \
EcCommand.m \
EcControl.m \
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs