0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #include <sys/socket.h>
0036 #include <sys/time.h>
0037 #include <sys/types.h>
0038 #include <arpa/inet.h>
0039 #include <netinet/in.h>
0040 #include <errno.h>
0041 #include <fcntl.h>
0042 #include <netdb.h>
0043 #include <string.h>
0044 #include <unistd.h>
0045
0046 #include <stdio.h>
0047 #include <stdlib.h>
0048 #include <ndebug.h>
0049 #include <atmi.h>
0050 #include <ndrstandard.h>
0051 #include <ubf.h>
0052 #include <test.fd.h>
0053
0054
0055 #define LONG_SLEEP 3600
0056
0057 exprivate int M_long_shut = 0;
0058
0059
0060
0061
0062
0063 void TESTSVFN (TPSVCINFO *p_svc)
0064 {
0065 int ret=EXSUCCEED;
0066 UBFH *p_ub = (UBFH *)p_svc->data;
0067
0068 NDRX_LOG(log_debug, "TESTSVFN got call");
0069
0070 out:
0071 tpreturn( ret==EXSUCCEED?TPSUCCESS:TPFAIL,
0072 0L,
0073 (char *)p_ub,
0074 0L,
0075 0L);
0076 }
0077
0078
0079
0080 int NDRX_INTEGRA(tpsvrinit)(int argc, char **argv)
0081 {
0082
0083 FILE *f;
0084 char str[100]={EXEOS,EXEOS};
0085 NDRX_LOG(log_debug, "tpsvrinit called");
0086
0087 if (argc<10)
0088 {
0089 NDRX_LOG(log_error, "tpsvrinit: 10th arg should be test case name!");
0090 }
0091 else
0092 {
0093 NDRX_LOG(log_debug, "argv[9]=[%s]", argv[9]);
0094 }
0095
0096 if (NULL==(f=NDRX_FOPEN("case_type", "r")))
0097 {
0098 NDRX_LOG(log_error, "Failed to open case_type: %s", strerror(errno));
0099 exit(EXFAIL);
0100 }
0101
0102 if (NULL==fgets (str, sizeof(str) , f))
0103 {
0104 NDRX_LOG(log_error, "Failed to read case_type: %s", strerror(errno));
0105 exit(EXFAIL);
0106 }
0107
0108 NDRX_FCLOSE(f);
0109
0110 if ('1' == str[0])
0111 {
0112 if (0==strcmp(argv[9], "x__long_start"))
0113 {
0114 NDRX_LOG(log_error, "Doing long sleep for start");
0115 sleep(LONG_SLEEP);
0116 }
0117 else if (0==strcmp(argv[9], "x__long_stop"))
0118 {
0119 NDRX_LOG(log_error, "Will do long sleep in shutdown!");
0120 M_long_shut = EXTRUE;
0121 }
0122 }
0123 else
0124 {
0125 NDRX_LOG(log_error, "Normal process");
0126 }
0127
0128 if (EXSUCCEED!=tpadvertise("TESTSVFN", TESTSVFN))
0129 {
0130 NDRX_LOG(log_error, "TESTERROR: Failed to initialize TESTSV (first)!");
0131 }
0132
0133 return EXSUCCEED;
0134 }
0135
0136
0137
0138
0139 void NDRX_INTEGRA(tpsvrdone)(void)
0140 {
0141
0142 if (M_long_shut)
0143 {
0144 sleep(LONG_SLEEP);
0145 }
0146
0147 NDRX_LOG(log_debug, "tpsvrdone called");
0148 }
0149