1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
|
/*
* Copyright 1999-2006 University of Chicago
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* Test inserting/removing plugins from handle attributes and handles */
#include "globus_common.h"
#include "globus_ftp_client.h"
#include "globus_ftp_client_restart_plugin.h"
#include "globus_ftp_client_debug_plugin.h"
#include "globus_preload.h"
#include <stdio.h>
int main()
{
int rc = 0;
int count=0;
globus_ftp_client_handle_t handle;
globus_ftp_client_plugin_t restart_plugin;
globus_ftp_client_plugin_t debug_plugin;
globus_result_t result;
globus_ftp_client_handleattr_t handleattr;
LTDL_SET_PRELOADED_SYMBOLS();
globus_module_activate(GLOBUS_FTP_CLIENT_MODULE);
globus_module_activate(GLOBUS_FTP_CLIENT_RESTART_PLUGIN_MODULE);
globus_module_activate(GLOBUS_FTP_CLIENT_DEBUG_PLUGIN_MODULE);
/* Test using attributes */
result = globus_ftp_client_handleattr_init(&handleattr);
globus_assert(result == GLOBUS_SUCCESS);
result = globus_ftp_client_restart_plugin_init(
&restart_plugin,
0,
GLOBUS_NULL,
GLOBUS_NULL);
globus_assert(result == GLOBUS_SUCCESS);
result = globus_ftp_client_debug_plugin_init(
&debug_plugin,
stderr,
"hello");
globus_assert(result == GLOBUS_SUCCESS);
/* Test 1: insert restart plugin into handle attr */
count++;
result = globus_ftp_client_handleattr_add_plugin(&handleattr,
&restart_plugin);
if(result != GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 2: insert restart plugin into handle attr (fail) */
count++;
result = globus_ftp_client_handleattr_add_plugin(&handleattr,
&restart_plugin);
if(result == GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 3: create/destroy handle with attr */
count++;
result = globus_ftp_client_handle_init(&handle, &handleattr);
if(result != GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
else if(globus_ftp_client_handle_destroy(&handle) != GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 4: insert debug plugin into handle attr */
count++;
result = globus_ftp_client_handleattr_add_plugin(&handleattr,
&debug_plugin);
if(result != GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 5: create/destroy handle with attr */
count++;
result = globus_ftp_client_handle_init(&handle, &handleattr);
if(result != GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
else if(globus_ftp_client_handle_destroy(&handle) != GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 6: remove restart plugin from handle attr */
count++;
result = globus_ftp_client_handleattr_remove_plugin(&handleattr,
&restart_plugin);
if(result != GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 7: remove restart plugin from handle attr (fail) */
count++;
result = globus_ftp_client_handleattr_remove_plugin(&handleattr,
&restart_plugin);
if(result == GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 8: insert debug plugin into handle attr (fail) */
count++;
result = globus_ftp_client_handleattr_add_plugin(&handleattr,
&debug_plugin);
if(result == GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 9: remove debug plugin from handle attr */
count++;
result = globus_ftp_client_handleattr_remove_plugin(&handleattr,
&debug_plugin);
if(result != GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 10: remove restart plugin from handle attr (fail) */
count++;
result = globus_ftp_client_handleattr_remove_plugin(&handleattr,
&restart_plugin);
if(result == GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 11: create/destroy handle with attr */
count++;
result = globus_ftp_client_handle_init(&handle, &handleattr);
if(result != GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
else if(globus_ftp_client_handle_destroy(&handle) != GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test without attributes */
/* Test 12: create handle without attr */
count++;
result = globus_ftp_client_handle_init(&handle, GLOBUS_NULL);
if(result != GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 13: add restart plugin into handle */
count++;
result = globus_ftp_client_handle_add_plugin(&handle, &restart_plugin);
if(result != GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 14: add restart plugin into handle (fail) */
count++;
result = globus_ftp_client_handle_add_plugin(&handle, &restart_plugin);
if(result == GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 15: add debug plugin into handle */
count++;
result = globus_ftp_client_handle_add_plugin(&handle, &debug_plugin);
if(result != GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 16: remove restart plugin from handle */
count++;
result = globus_ftp_client_handle_remove_plugin(&handle, &restart_plugin);
if(result != GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 17: remove restart plugin from handle (fail) */
count++;
result = globus_ftp_client_handle_remove_plugin(&handle, &restart_plugin);
if(result == GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 18: add debug plugin into handle (fail) */
count++;
result = globus_ftp_client_handle_add_plugin(&handle, &debug_plugin);
if(result == GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 19: remove debug plugin into handle */
count++;
result = globus_ftp_client_handle_remove_plugin(&handle, &debug_plugin);
if(result != GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 20: remove restart plugin into handle (fail) */
count++;
result = globus_ftp_client_handle_remove_plugin(&handle, &restart_plugin);
if(result == GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
/* Test 21: destroy handle */
count++;
result = globus_ftp_client_handle_destroy(&handle);
if(result != GLOBUS_SUCCESS)
{
printf("Failed test %d\n", count);
rc++;
}
globus_module_deactivate_all();
return rc;
}
|