mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-22 16:33:29 +00:00
New testcase
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@17948 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
29e0a39d46
commit
bbb3b1786b
5 changed files with 81 additions and 2 deletions
|
@ -1,3 +1,12 @@
|
|||
Tue Oct 21 15:25:00 2003 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Testing/nsconnection_client.m: Add -r option.
|
||||
* Testing/nsconnection_server.m: support registration/degeristration
|
||||
* Testing/server.h: New methods.
|
||||
Add a test (-r) to have the client repeated register/unregister
|
||||
with server, and have server do a callback to the registered object.
|
||||
Should cause a crash if the retain counts of proxies get out of sync.
|
||||
|
||||
Mon Oct 20 16:50:00 2003 Richard Frith-Macdonald <rfm@gnu.org>
|
||||
|
||||
* Headers/Additions/GNUstepBase/GSMime.h: Fix missing copying method
|
||||
|
|
|
@ -74,6 +74,8 @@ ADDITIONAL_TOOLS = \
|
|||
nsconnection_client \
|
||||
nsconnection_server \
|
||||
|
||||
// TEST_TOOL_NAME += nsconnection_client nsconnection_server
|
||||
|
||||
# The tool Objective-C source files to be compiled
|
||||
awake_OBJC_FILES = awake.m
|
||||
basic_OBJC_FILES = basic.m
|
||||
|
|
|
@ -25,6 +25,18 @@
|
|||
- (id) quietBycopy: (id byref)a;
|
||||
@end
|
||||
|
||||
@interface CallbackClient : NSObject <ClientProtocol>
|
||||
- (BOOL) callback;
|
||||
@end
|
||||
|
||||
@implementation CallbackClient
|
||||
- (BOOL) callback
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
@end
|
||||
|
||||
|
||||
@interface Auth : NSObject
|
||||
@end
|
||||
|
||||
|
@ -413,6 +425,29 @@ con_objects (id prx)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
con_callback (id prx)
|
||||
{
|
||||
int j, k;
|
||||
id localObj;
|
||||
|
||||
localObj = [CallbackClient new];
|
||||
[prx registerClient: localObj];
|
||||
k = 10000;
|
||||
for (j = 0; j < k; j++)
|
||||
{
|
||||
[prx unregisterClient: localObj];
|
||||
[prx registerClient: localObj];
|
||||
[prx tryClientCallback];
|
||||
if (j < 10 || j %10 == 0)
|
||||
printf("repeated client registration and callback %d\n", j);
|
||||
|
||||
}
|
||||
printf("repeated client registration and callback %d\n", j);
|
||||
RELEASE(localObj);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
usage(const char *program)
|
||||
{
|
||||
|
@ -425,11 +460,12 @@ usage(const char *program)
|
|||
printf(" -l - Loop test\n");
|
||||
printf(" -o - Objects test\n");
|
||||
printf(" -c - Connect test\n");
|
||||
printf(" -r - Registration and callback test\n");
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
NO_TEST, TYPE_TEST, BENCHMARK_TEST, MESSAGE_TEST,
|
||||
LOOP_TEST, OBJECT_TEST, CONNECT_TEST
|
||||
LOOP_TEST, OBJECT_TEST, CONNECT_TEST, CALLBACK_TEST
|
||||
} test_t;
|
||||
|
||||
int main (int argc, char *argv[], char **env)
|
||||
|
@ -453,7 +489,7 @@ int main (int argc, char *argv[], char **env)
|
|||
debug = 0;
|
||||
type_test = 0;
|
||||
stats = 0;
|
||||
while ((c = getopt(argc, argv, "hdtbmsloc")) != EOF)
|
||||
while ((c = getopt(argc, argv, "hdtbmslocr")) != EOF)
|
||||
switch (c)
|
||||
{
|
||||
case 'd':
|
||||
|
@ -480,6 +516,9 @@ int main (int argc, char *argv[], char **env)
|
|||
case 'c':
|
||||
type_test = CONNECT_TEST;
|
||||
break;
|
||||
case 'r':
|
||||
type_test = CALLBACK_TEST;
|
||||
break;
|
||||
case 'h':
|
||||
usage(argv[0]);
|
||||
exit(0);
|
||||
|
@ -555,6 +594,9 @@ int main (int argc, char *argv[], char **env)
|
|||
case OBJECT_TEST:
|
||||
con_objects (prx);
|
||||
break;
|
||||
case CALLBACK_TEST:
|
||||
con_callback (prx);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -431,6 +431,22 @@
|
|||
[newConn setDelegate: self];
|
||||
return newConn;
|
||||
}
|
||||
|
||||
- (oneway void) registerClient: (id<ClientProtocol>)client
|
||||
{
|
||||
ASSIGN(registered_client, client);
|
||||
}
|
||||
|
||||
- (oneway void) unregisterClient: (id<ClientProtocol>)client
|
||||
{
|
||||
DESTROY(registered_client);
|
||||
}
|
||||
|
||||
- (BOOL) tryClientCallback
|
||||
{
|
||||
return [registered_client callback];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
void
|
||||
|
|
|
@ -22,6 +22,10 @@ struct myarray {
|
|||
|
||||
#define ADD_CONST 47
|
||||
|
||||
@protocol ClientProtocol
|
||||
- (BOOL) callback;
|
||||
@end
|
||||
|
||||
@protocol ServerProtocol
|
||||
- (BOOL) sendBoolean: (BOOL)b;
|
||||
- (void) getBoolean: (BOOL*)bp;
|
||||
|
@ -73,6 +77,10 @@ struct myarray {
|
|||
- (int) exceptionTest1;
|
||||
- (void) exceptionTest2;
|
||||
- (oneway void) exceptionTest3;
|
||||
|
||||
- (oneway void) registerClient: (id<ClientProtocol>)client;
|
||||
- (oneway void) unregisterClient: (id<ClientProtocol>)client;
|
||||
- (BOOL) tryClientCallback;
|
||||
@end
|
||||
|
||||
#ifdef IN_SERVER
|
||||
|
@ -86,12 +94,14 @@ struct myarray {
|
|||
@interface Server : NSObject <ServerProtocol,privateServer>
|
||||
{
|
||||
id the_array;
|
||||
id<ClientProtocol> registered_client;
|
||||
}
|
||||
@end
|
||||
#else
|
||||
@interface Server : NSObject <ServerProtocol>
|
||||
{
|
||||
id the_array;
|
||||
id<ClientProtocol> registered_client;
|
||||
}
|
||||
@end
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue