Finished porting the Auth Client Test to linux.
This commit is contained in:
		| @@ -505,7 +505,7 @@ DestroyUserMutex( | |||||||
|       // is not a resource leak. If someone has an issue with this, then it can |       // is not a resource leak. If someone has an issue with this, then it can | ||||||
|       // be solved by installing a cron job that cleans up the semaphores for |       // be solved by installing a cron job that cleans up the semaphores for | ||||||
|       // deleted users. |       // deleted users. | ||||||
|       if (LocalSem_close(g_userNamedSem) != 0) |       if (Local_sem_close(g_userNamedSem) != 0) | ||||||
|       { |       { | ||||||
|          DbgTrace(0, "-DestroyUserMutex- Error returned by sem_close(), errno = %d\n", errno); |          DbgTrace(0, "-DestroyUserMutex- Error returned by sem_close(), errno = %d\n", errno); | ||||||
|       } |       } | ||||||
|   | |||||||
| @@ -32,7 +32,7 @@ extern | |||||||
| int      serverPort; | int      serverPort; | ||||||
|  |  | ||||||
| extern | extern | ||||||
| BOOLEAN  execHttpTest; | bool     execHttpTest; | ||||||
|  |  | ||||||
| extern | extern | ||||||
| char     serviceName[]; | char     serviceName[]; | ||||||
| @@ -184,7 +184,7 @@ void NonHttpTest(void) | |||||||
|                               (struct sockaddr*) &remoteAddr, |                               (struct sockaddr*) &remoteAddr, | ||||||
|                               sizeof(struct sockaddr_in)) == SOCKET_ERROR) |                               sizeof(struct sockaddr_in)) == SOCKET_ERROR) | ||||||
|                   { |                   { | ||||||
|                      printf("-NonHttpTest- Connection creation failed, error = %d\n", WSAGetLastError()); |                      printf("-NonHttpTest- Connection creation failed, error = %d\n", errno); | ||||||
|                   } |                   } | ||||||
|                   else |                   else | ||||||
|                   { |                   { | ||||||
| @@ -303,7 +303,7 @@ void HttpTest(void) | |||||||
|                               (struct sockaddr*) &remoteAddr, |                               (struct sockaddr*) &remoteAddr, | ||||||
|                               sizeof(struct sockaddr_in)) == SOCKET_ERROR) |                               sizeof(struct sockaddr_in)) == SOCKET_ERROR) | ||||||
|                   { |                   { | ||||||
|                      printf("-HttpTest- Connection creation failed, error = %d\n", WSAGetLastError()); |                      printf("-HttpTest- Connection creation failed, error = %d\n", errno); | ||||||
|                   } |                   } | ||||||
|                   else |                   else | ||||||
|                   { |                   { | ||||||
|   | |||||||
							
								
								
									
										171
									
								
								CASA-auth-token/non-java/client/test/linux/main.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										171
									
								
								CASA-auth-token/non-java/client/test/linux/main.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,171 @@ | |||||||
|  | /*********************************************************************** | ||||||
|  |  *  | ||||||
|  |  *  Copyright (C) 2006 Novell, Inc. All Rights Reserved. | ||||||
|  |  * | ||||||
|  |  *  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; version 2.1 | ||||||
|  |  *  of the License. | ||||||
|  |  * | ||||||
|  |  *  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 Lesser 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, Novell, Inc. | ||||||
|  |  *  | ||||||
|  |  *  To contact Novell about this file by physical or electronic mail,  | ||||||
|  |  *  you may find current contact information at www.novell.com. | ||||||
|  |  *  | ||||||
|  |  *  Author: Juan Carlos Luciani <jluciani@novell.com> | ||||||
|  |  * | ||||||
|  |  ***********************************************************************/ | ||||||
|  |  | ||||||
|  | #include "platform.h" | ||||||
|  |  | ||||||
|  |  | ||||||
|  | // Extern functions | ||||||
|  | extern | ||||||
|  | void NonHttpTest(void); | ||||||
|  |  | ||||||
|  | extern | ||||||
|  | void HttpTest(void); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | // Globals | ||||||
|  | char usageString[] = "usage: test -a serverAddress -p serverPort [-s serviceName] [-h]\n"; | ||||||
|  |  | ||||||
|  | char     *pServerAddress = NULL; | ||||||
|  | int      serverPort = 0; | ||||||
|  | bool     execHttpTest = false; | ||||||
|  |  | ||||||
|  | char     serviceName[] = "testService"; | ||||||
|  | char     *pServiceName = serviceName; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /*********************************************************************** | ||||||
|  |  * | ||||||
|  |  * dtoul() | ||||||
|  |  * | ||||||
|  |  ***********************************************************************/ | ||||||
|  | int | ||||||
|  | dtoul( | ||||||
|  |    IN    char *cp, | ||||||
|  |    IN    int len) | ||||||
|  | { | ||||||
|  |    int   n = 0; | ||||||
|  |    int   i; | ||||||
|  |  | ||||||
|  |    for (i = 0; i < len; i++, cp++) | ||||||
|  |    { | ||||||
|  |       // Verify that we are dealing with a valid digit | ||||||
|  |       if (*cp >= '0' && *cp <= '9') | ||||||
|  |       { | ||||||
|  |          n = 10 * n + (*cp - '0'); | ||||||
|  |       } | ||||||
|  |       else | ||||||
|  |       { | ||||||
|  |          printf("-dtoul- Found invalid digit\n"); | ||||||
|  |          break; | ||||||
|  |       } | ||||||
|  |    } | ||||||
|  |        | ||||||
|  |    return n; | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /*********************************************************************** | ||||||
|  |  * | ||||||
|  |  * main() | ||||||
|  |  * | ||||||
|  |  ***********************************************************************/ | ||||||
|  | int main(int argc, char* argv[]) | ||||||
|  | { | ||||||
|  |    // Process input parameters | ||||||
|  |    int i = 1; | ||||||
|  |    while(argv[i] != NULL) | ||||||
|  |    { | ||||||
|  |       if (strcasecmp(argv[i], "-a") == 0) | ||||||
|  |       { | ||||||
|  |          // Server Address option, the next argument should | ||||||
|  |          // contain the address. | ||||||
|  |          i++; | ||||||
|  |          if (argv[i] != NULL) | ||||||
|  |          { | ||||||
|  |             pServerAddress = argv[i]; | ||||||
|  |          } | ||||||
|  |          else | ||||||
|  |          { | ||||||
|  |             printf(usageString); | ||||||
|  |             return -1; | ||||||
|  |          } | ||||||
|  |       } | ||||||
|  |       else if (strcasecmp(argv[i], "-p") == 0) | ||||||
|  |       { | ||||||
|  |          // Server port option, the next argument should | ||||||
|  |          // contain the port. | ||||||
|  |          i++; | ||||||
|  |          if (argv[i] != NULL) | ||||||
|  |          { | ||||||
|  |             serverPort = htons(dtoul(argv[i], strlen(argv[i]))); | ||||||
|  |          } | ||||||
|  |          else | ||||||
|  |          { | ||||||
|  |             printf(usageString); | ||||||
|  |             return -1; | ||||||
|  |          } | ||||||
|  |       } | ||||||
|  |       else if (strcasecmp(argv[i], "-s") == 0) | ||||||
|  |       { | ||||||
|  |          // Service name option, the next argument should | ||||||
|  |          // contain the name of the service to be targeted. | ||||||
|  |          i++; | ||||||
|  |          if (argv[i] != NULL) | ||||||
|  |          { | ||||||
|  |             pServiceName = argv[i]; | ||||||
|  |          } | ||||||
|  |          else | ||||||
|  |          { | ||||||
|  |             printf(usageString); | ||||||
|  |             return -1; | ||||||
|  |          } | ||||||
|  |       } | ||||||
|  |       else if (strcasecmp(argv[i], "-h") == 0) | ||||||
|  |       { | ||||||
|  |          // Perform http test option | ||||||
|  |          execHttpTest = true; | ||||||
|  |       } | ||||||
|  |  | ||||||
|  |       // Advance to the next argument | ||||||
|  |       i++; | ||||||
|  |    } | ||||||
|  |  | ||||||
|  |    // Verify that the server address and port were specified | ||||||
|  |    if (pServerAddress && serverPort != 0) | ||||||
|  |    { | ||||||
|  |       // Repeat the test when indicated | ||||||
|  |       printf("Press 'Enter' to run test or 'n + Enter' to stop.\n"); | ||||||
|  |       while(getchar() != 'n') | ||||||
|  |       { | ||||||
|  |          // Execute the appropriate test | ||||||
|  |          if (execHttpTest) | ||||||
|  |          { | ||||||
|  |             HttpTest(); | ||||||
|  |          } | ||||||
|  |          else | ||||||
|  |          { | ||||||
|  |             NonHttpTest(); | ||||||
|  |          } | ||||||
|  |          printf("Press 'Enter' to run test or 'n + Enter' to stop.\n"); | ||||||
|  |       } | ||||||
|  |    } | ||||||
|  |    else | ||||||
|  |    { | ||||||
|  |       printf(usageString); | ||||||
|  |       return -1; | ||||||
|  |    } | ||||||
|  |  | ||||||
|  |    return 0; | ||||||
|  | } | ||||||
|  |  | ||||||
							
								
								
									
										2
									
								
								CASA-auth-token/non-java/client/test/linux/make.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										2
									
								
								CASA-auth-token/non-java/client/test/linux/make.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,2 @@ | |||||||
|  | #!/bin/bash | ||||||
|  | g++ -o authClientTest ../CASA_Auth.cpp main.cpp -g -DN_PLAT_UNIX -I. -I../../../include -L"../../../lib/Release" -lcasa_c_authtoken -Xlinker -rpath -Xlinker ../../../lib/Release | ||||||
							
								
								
									
										54
									
								
								CASA-auth-token/non-java/client/test/linux/platform.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								CASA-auth-token/non-java/client/test/linux/platform.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,54 @@ | |||||||
|  | /*********************************************************************** | ||||||
|  |  *  | ||||||
|  |  *  Copyright (C) 2006 Novell, Inc. All Rights Reserved. | ||||||
|  |  * | ||||||
|  |  *  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; version 2.1 | ||||||
|  |  *  of the License. | ||||||
|  |  * | ||||||
|  |  *  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 Lesser 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, Novell, Inc. | ||||||
|  |  *  | ||||||
|  |  *  To contact Novell about this file by physical or electronic mail,  | ||||||
|  |  *  you may find current contact information at www.novell.com. | ||||||
|  |  *  | ||||||
|  |  *  Author: Juan Carlos Luciani <jluciani@novell.com> | ||||||
|  |  * | ||||||
|  |  ***********************************************************************/ | ||||||
|  |  | ||||||
|  | #include <stdio.h> | ||||||
|  | #include <stdlib.h> | ||||||
|  | #include <stdbool.h> | ||||||
|  | #include <string.h> | ||||||
|  | #include <syslog.h> | ||||||
|  | #include <pthread.h> | ||||||
|  | #include <string.h> | ||||||
|  | #include <errno.h> | ||||||
|  | #include <unistd.h> | ||||||
|  | #include <sys/types.h> | ||||||
|  | #include <sys/socket.h> | ||||||
|  | #include <netinet/in.h> | ||||||
|  | #include <netinet/tcp.h> | ||||||
|  | #include <netdb.h> | ||||||
|  |  | ||||||
|  | #include <micasa_types.h> | ||||||
|  | #include <casa_status.h> | ||||||
|  | #include "casa_c_authtoken.h" | ||||||
|  |  | ||||||
|  | // | ||||||
|  | // Socket Mapping definitions | ||||||
|  | // | ||||||
|  | #undef SOCKET | ||||||
|  | #define SOCKET int | ||||||
|  | #define INVALID_SOCKET -1 | ||||||
|  | #define SOCKET_ERROR -1 | ||||||
|  | #define LINGER struct linger | ||||||
|  | #define SOCKADDR_IN struct sockaddr_in | ||||||
|  | #define closesocket close | ||||||
|  |  | ||||||
| @@ -25,3 +25,5 @@ | |||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <windows.h> | #include <windows.h> | ||||||
| #include "casa_c_authtoken.h" | #include "casa_c_authtoken.h" | ||||||
|  |  | ||||||
|  | #define errno WSAGetLastError() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user