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 #include <string.h>
0035 #include <stdio.h>
0036 #include <stdlib.h>
0037
0038 #include <ndrstandard.h>
0039 #include <ndebug.h>
0040 #include <nstdutil.h>
0041 #include <expluginbase.h>
0042 #include <sys_unix.h>
0043 #include <test.fd.h>
0044 #include <lcf.h>
0045 #include <sys_test.h>
0046
0047 #include "atmi_int.h"
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059 exprivate int custom_tcrash(ndrx_lcf_command_t *cmd, long *p_flags)
0060 {
0061
0062 G_atmi_env.test_tmsrv_commit_crash = atoi(cmd->arg_a);
0063 NDRX_LOG(log_error, "G_atmi_env.test_tmsrv_commit_crash=%d",
0064 G_atmi_env.test_tmsrv_commit_crash);
0065
0066
0067 sleep(1);
0068 return 0;
0069 }
0070
0071
0072
0073
0074 exprivate int custom_qwriterr(ndrx_lcf_command_t *cmd, long *p_flags)
0075 {
0076
0077 G_atmi_env.test_qdisk_write_fail = atoi(cmd->arg_a);
0078 NDRX_LOG(log_error, "G_atmi_env.test_qdisk_write_fail=%d",
0079 G_atmi_env.test_qdisk_write_fail);
0080
0081 sleep(1);
0082 return 0;
0083 }
0084
0085
0086
0087
0088 exprivate int custom_twriterr(ndrx_lcf_command_t *cmd, long *p_flags)
0089 {
0090
0091 G_atmi_env.test_tmsrv_write_fail = atoi(cmd->arg_a);
0092 NDRX_LOG(log_error, "G_atmi_env.test_tmsrv_write_fail=%d",
0093 G_atmi_env.test_tmsrv_write_fail);
0094
0095
0096 sleep(1);
0097 return 0;
0098 }
0099
0100
0101
0102
0103 exprivate void test_advertise_crash_exit(void)
0104 {
0105 NDRX_LOG(log_error, "TEST: Crash is happening");
0106 exit(1);
0107 }
0108
0109
0110
0111
0112 exprivate void test_advertise_crash_sleep(void)
0113 {
0114 NDRX_LOG(log_error, "TEST: Seep 20 is happening");
0115 sleep(20);
0116 }
0117
0118
0119
0120
0121 exprivate int custom_advcrash(ndrx_lcf_command_t *cmd, long *p_flags)
0122 {
0123
0124 switch (atoi(cmd->arg_a))
0125 {
0126 case 1:
0127 G_atmi_env.test_advertise_crash = test_advertise_crash_exit;
0128 break;
0129 case 2:
0130 G_atmi_env.test_advertise_crash = test_advertise_crash_sleep;
0131 break;
0132 }
0133
0134
0135 sleep(1);
0136 return 0;
0137 }
0138
0139
0140
0141
0142
0143 exprivate int custom_lockloss(ndrx_lcf_command_t *cmd, long *p_flags)
0144 {
0145 ndrx_G_systest_lockloss = atoi(cmd->arg_a);
0146
0147 sleep(1);
0148 return 0;
0149 }
0150
0151
0152
0153
0154
0155
0156
0157
0158 expublic long ndrx_plugin_init(char *provider_name, int provider_name_bufsz)
0159 {
0160 int ret = EXSUCCEED;
0161 ndrx_lcf_reg_func_t cfunc;
0162 ndrx_lcf_reg_xadmin_t xfunc;
0163
0164
0165
0166
0167 memset(&cfunc, 0, sizeof(cfunc));
0168 NDRX_STRCPY_SAFE(cfunc.cmdstr, "qwriterr");
0169 cfunc.command=1001;
0170 cfunc.version=NDRX_LCF_CCMD_VERSION;
0171 cfunc.pf_callback=custom_qwriterr;
0172
0173 if (EXSUCCEED!=ndrx_lcf_func_add(&cfunc))
0174 {
0175 NDRX_LOG_EARLY(log_error, "TESTERROR: Failed to add func: %s", Nstrerror(Nerror));
0176 EXFAIL_OUT(ret);
0177 }
0178
0179 memset(&xfunc, 0, sizeof(xfunc));
0180 NDRX_STRCPY_SAFE(xfunc.cmdstr, "qwriterr");
0181 xfunc.command=1001;
0182 xfunc.version = cfunc.version=NDRX_LCF_XCMD_VERSION;
0183 NDRX_STRCPY_SAFE(xfunc.helpstr, "Queue write error simulation");
0184 xfunc.dfltflags=(NDRX_LCF_FLAG_ARGA);
0185 xfunc.dfltslot=3;
0186
0187 if (EXSUCCEED!=ndrx_lcf_xadmin_add(&xfunc))
0188 {
0189 NDRX_LOG_EARLY(log_error, "TESTERROR: Failed to add func: %s", Nstrerror(Nerror));
0190 EXFAIL_OUT(ret);
0191 }
0192
0193
0194
0195
0196 memset(&cfunc, 0, sizeof(cfunc));
0197 NDRX_STRCPY_SAFE(cfunc.cmdstr, "twriterr");
0198 cfunc.command=1002;
0199 cfunc.version=NDRX_LCF_CCMD_VERSION;
0200 cfunc.pf_callback=custom_twriterr;
0201
0202 if (EXSUCCEED!=ndrx_lcf_func_add(&cfunc))
0203 {
0204 NDRX_LOG_EARLY(log_error, "TESTERROR: Failed to add func: %s", Nstrerror(Nerror));
0205 EXFAIL_OUT(ret);
0206 }
0207
0208 memset(&xfunc, 0, sizeof(xfunc));
0209 NDRX_STRCPY_SAFE(xfunc.cmdstr, "twriterr");
0210 xfunc.command=1002;
0211 xfunc.version = cfunc.version=NDRX_LCF_XCMD_VERSION;
0212 NDRX_STRCPY_SAFE(xfunc.helpstr, "Tmsrv write error simulation");
0213 xfunc.dfltflags=(NDRX_LCF_FLAG_ARGA);
0214 xfunc.dfltslot=4;
0215
0216 if (EXSUCCEED!=ndrx_lcf_xadmin_add(&xfunc))
0217 {
0218 NDRX_LOG_EARLY(log_error, "TESTERROR: Failed to add func: %s", Nstrerror(Nerror));
0219 EXFAIL_OUT(ret);
0220 }
0221
0222
0223
0224
0225 memset(&cfunc, 0, sizeof(cfunc));
0226 NDRX_STRCPY_SAFE(cfunc.cmdstr, "tcrash");
0227 cfunc.command=1003;
0228 cfunc.version=NDRX_LCF_CCMD_VERSION;
0229 cfunc.pf_callback=custom_tcrash;
0230
0231 if (EXSUCCEED!=ndrx_lcf_func_add(&cfunc))
0232 {
0233 NDRX_LOG_EARLY(log_error, "TESTERROR: Failed to add func: %s", Nstrerror(Nerror));
0234 EXFAIL_OUT(ret);
0235 }
0236
0237 memset(&xfunc, 0, sizeof(xfunc));
0238 NDRX_STRCPY_SAFE(xfunc.cmdstr, "tcrash");
0239 xfunc.command=1003;
0240 xfunc.version = cfunc.version=NDRX_LCF_XCMD_VERSION;
0241 NDRX_STRCPY_SAFE(xfunc.helpstr, "Tmsrv write error simulation");
0242 xfunc.dfltflags=(NDRX_LCF_FLAG_ARGA);
0243 xfunc.dfltslot=5;
0244
0245 if (EXSUCCEED!=ndrx_lcf_xadmin_add(&xfunc))
0246 {
0247 NDRX_LOG_EARLY(log_error, "TESTERROR: Failed to add func: %s", Nstrerror(Nerror));
0248 EXFAIL_OUT(ret);
0249 }
0250
0251
0252
0253
0254 memset(&cfunc, 0, sizeof(cfunc));
0255 NDRX_STRCPY_SAFE(cfunc.cmdstr, "advcrash");
0256 cfunc.command=1004;
0257 cfunc.version=NDRX_LCF_CCMD_VERSION;
0258 cfunc.pf_callback=custom_advcrash;
0259
0260 if (EXSUCCEED!=ndrx_lcf_func_add(&cfunc))
0261 {
0262 NDRX_LOG_EARLY(log_error, "TESTERROR: Failed to add func: %s", Nstrerror(Nerror));
0263 EXFAIL_OUT(ret);
0264 }
0265
0266 memset(&xfunc, 0, sizeof(xfunc));
0267 NDRX_STRCPY_SAFE(xfunc.cmdstr, "advcrash");
0268 xfunc.command=1004;
0269 xfunc.version = cfunc.version=NDRX_LCF_XCMD_VERSION;
0270 NDRX_STRCPY_SAFE(xfunc.helpstr, "XATMI advertise error simulation");
0271 xfunc.dfltflags=(NDRX_LCF_FLAG_ARGA);
0272 xfunc.dfltslot=6;
0273
0274 if (EXSUCCEED!=ndrx_lcf_xadmin_add(&xfunc))
0275 {
0276 NDRX_LOG_EARLY(log_error, "TESTERROR: Failed to add func: %s", Nstrerror(Nerror));
0277 EXFAIL_OUT(ret);
0278 }
0279
0280
0281
0282
0283 memset(&cfunc, 0, sizeof(cfunc));
0284 NDRX_STRCPY_SAFE(cfunc.cmdstr, "lockloss");
0285 cfunc.command=1005;
0286 cfunc.version=NDRX_LCF_CCMD_VERSION;
0287 cfunc.pf_callback=custom_lockloss;
0288
0289 if (EXSUCCEED!=ndrx_lcf_func_add(&cfunc))
0290 {
0291 NDRX_LOG_EARLY(log_error, "TESTERROR: Failed to add func: %s", Nstrerror(Nerror));
0292 EXFAIL_OUT(ret);
0293 }
0294
0295 memset(&xfunc, 0, sizeof(xfunc));
0296 NDRX_STRCPY_SAFE(xfunc.cmdstr, "lockloss");
0297 xfunc.command=1005;
0298 xfunc.version = cfunc.version=NDRX_LCF_XCMD_VERSION;
0299 NDRX_STRCPY_SAFE(xfunc.helpstr, "XATMI advertise error simulation");
0300 xfunc.dfltflags=(NDRX_LCF_FLAG_ARGA);
0301 xfunc.dfltslot=6;
0302
0303 if (EXSUCCEED!=ndrx_lcf_xadmin_add(&xfunc))
0304 {
0305 NDRX_LOG_EARLY(log_error, "TESTERROR: Failed to add func: %s", Nstrerror(Nerror));
0306 EXFAIL_OUT(ret);
0307 }
0308
0309
0310 out:
0311
0312 return ret;
0313 }
0314
0315