diff --git a/Tests/base/NSConnection/Resources/Client.m b/Tests/base/NSConnection/Resources/Client.m new file mode 100644 index 000000000..e5e2b9ac9 --- /dev/null +++ b/Tests/base/NSConnection/Resources/Client.m @@ -0,0 +1,42 @@ +#import +#import + +@interface TestServer : NSObject +{ +} +- (int) doIt; +@end + +int +main() +{ + ENTER_POOL + NSSocketPortNameServer *ns = [NSSocketPortNameServer sharedInstance]; + NSString *name = @"TestServer"; + NSConnection *conn; + NSDistantObject *proxy; + TestServer *test; + int result; + + [NSSocketPort setOptionsForTLS: [NSDictionary dictionaryWithObjectsAndKeys: + @"9", GSTLSDebug, + nil]]; + + conn = [NSConnection connectionWithRegisteredName: name + host: @"" + usingNameServer: ns]; + proxy = [conn rootProxy]; + test = (TestServer*)proxy; + result = [test doIt]; + printf("Result is %d\n", result); + LEAVE_POOL + exit(0); +} + +@implementation TestServer +- (int) doIt +{ + return 42; +} +@end + diff --git a/Tests/base/NSConnection/Resources/GNUmakefile b/Tests/base/NSConnection/Resources/GNUmakefile index f09c5065b..c5a890865 100644 --- a/Tests/base/NSConnection/Resources/GNUmakefile +++ b/Tests/base/NSConnection/Resources/GNUmakefile @@ -2,6 +2,13 @@ include $(GNUSTEP_MAKEFILES)/common.make BUNDLE_NAME=TestConnection TestConnection_NEEDS_GUI = NO TestConnection_OBJC_FILES=Connection.m + +TEST_TOOL_NAME=Client Server +Client_NEEDS_GUI = NO +Client_OBJC_FILES=Client.m +Server_NEEDS_GUI = NO +Server_OBJC_FILES=Server.m + include $(GNUSTEP_MAKEFILES)/bundle.make include $(GNUSTEP_MAKEFILES)/test-tool.make diff --git a/Tests/base/NSConnection/Resources/Server.m b/Tests/base/NSConnection/Resources/Server.m new file mode 100644 index 000000000..8f1fc843b --- /dev/null +++ b/Tests/base/NSConnection/Resources/Server.m @@ -0,0 +1,48 @@ +#import +#import + +@interface TestServer : NSObject +{ +} +- (int) doIt; +@end + +int +main() +{ + ENTER_POOL + NSSocketPortNameServer *ns = [NSSocketPortNameServer sharedInstance]; + NSString *name = @"TestServer"; + NSConnection *conn; + NSPort *port; + TestServer *test = AUTORELEASE([TestServer new]); + + port = [NSSocketPort port]; + [(NSSocketPort*)port setOptionsForTLS: + [NSDictionary dictionaryWithObjectsAndKeys: + @"9", GSTLSDebug, + nil]]; + conn = [[NSConnection alloc] initWithReceivePort: port + sendPort: nil]; + [conn setRootObject: test]; + if ([conn registerName: name withNameServer: ns] == NO) + { + NSPort *p = [ns portForName: name onHost: @""]; + + DESTROY(conn); + NSLog(@"There is already a process: %@, on %@", name, p); + return NO; + } + + [[NSRunLoop currentRunLoop] run]; + LEAVE_POOL + exit(0); +} + +@implementation TestServer +- (int) doIt +{ + return 42; +} +@end +