diff options
| author | Ted Ross <tross@apache.org> | 2013-10-24 18:01:00 +0000 |
|---|---|---|
| committer | Ted Ross <tross@apache.org> | 2013-10-24 18:01:00 +0000 |
| commit | 61f7da33c6efd0cea9e3ccb9653edd41f6dadcb8 (patch) | |
| tree | d264b5378b40b95b14c504a1429b89ac49ecc087 /qpid/extras/dispatch/tests | |
| parent | 94d8a5c36b058b76d3e61db7d2028e395b0f2b44 (diff) | |
| download | qpid-python-61f7da33c6efd0cea9e3ccb9653edd41f6dadcb8.tar.gz | |
QPID-5257 - Removed dispatch code from its old location
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1535460 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/extras/dispatch/tests')
22 files changed, 0 insertions, 3473 deletions
diff --git a/qpid/extras/dispatch/tests/CMakeLists.txt b/qpid/extras/dispatch/tests/CMakeLists.txt deleted file mode 100644 index fc85018991..0000000000 --- a/qpid/extras/dispatch/tests/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -## -## Licensed to the Apache Software Foundation (ASF) under one -## or more contributor license agreements. See the NOTICE file -## distributed with this work for additional information -## regarding copyright ownership. The ASF licenses this file -## to you 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. -## - -## -## Build test applications -## -set(unit_test_SOURCES - alloc_test.c - compose_test.c - parse_test.c - run_unit_tests.c - server_test.c - timer_test.c - tool_test.c - ) - -add_executable(unit_tests ${unit_test_SOURCES}) -target_link_libraries(unit_tests qpid-dispatch) - -set(unit_test_size_SOURCES - field_test.c - message_test.c - run_unit_tests_size.c - ) - -add_executable(unit_tests_size ${unit_test_size_SOURCES}) -target_link_libraries(unit_tests_size qpid-dispatch) - -add_test(unit_tests_size_10000 unit_tests_size 10000) -add_test(unit_tests_size_512 unit_tests_size 512) -add_test(unit_tests_size_10 unit_tests_size 10) -add_test(unit_tests_size_7 unit_tests_size 7) -add_test(unit_tests_size_5 unit_tests_size 5) -add_test(unit_tests_size_3 unit_tests_size 3) -add_test(unit_tests_size_2 unit_tests_size 2) -add_test(unit_tests_size_1 unit_tests_size 1) -add_test(unit_tests unit_tests ${CMAKE_CURRENT_SOURCE_DIR}/threads4.conf) -add_test(router_tests python ${CMAKE_CURRENT_SOURCE_DIR}/router_engine_test.py -v) -add_test(system_tests_single python ${CMAKE_CURRENT_SOURCE_DIR}/system_tests_one_router.py -v) - -set_property(TEST system_tests_single PROPERTY - ENVIRONMENT "CTEST_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}" - ) diff --git a/qpid/extras/dispatch/tests/alloc_test.c b/qpid/extras/dispatch/tests/alloc_test.c deleted file mode 100644 index 2406048209..0000000000 --- a/qpid/extras/dispatch/tests/alloc_test.c +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -#include "test_case.h" -#include <stdio.h> -#include <string.h> -#include "alloc_private.h" - -typedef struct { - int A; - int B; -} object_t; - -dx_alloc_config_t config = {3, 7, 10}; - -ALLOC_DECLARE(object_t); -ALLOC_DEFINE_CONFIG(object_t, sizeof(object_t), 0, &config); - - -static char* check_stats(dx_alloc_stats_t *stats, uint64_t ah, uint64_t fh, uint64_t ht, uint64_t rt, uint64_t rg) -{ - if (stats->total_alloc_from_heap != ah) return "Incorrect alloc-from-heap"; - if (stats->total_free_to_heap != fh) return "Incorrect free-to-heap"; - if (stats->held_by_threads != ht) return "Incorrect held-by-threads"; - if (stats->batches_rebalanced_to_threads != rt) return "Incorrect rebalance-to-threads"; - if (stats->batches_rebalanced_to_global != rg) return "Incorrect rebalance-to-global"; - return 0; -} - - -static char* test_alloc_basic(void *context) -{ - object_t *obj[50]; - int idx; - dx_alloc_stats_t *stats; - char *error; - - for (idx = 0; idx < 20; idx++) - obj[idx] = new_object_t(); - - stats = alloc_stats_object_t(); - error = check_stats(stats, 21, 0, 21, 0, 0); - if (error) return error; - - for (idx = 0; idx < 20; idx++) - free_object_t(obj[idx]); - - error = check_stats(stats, 21, 5, 6, 0, 5); - if (error) return error; - - for (idx = 0; idx < 20; idx++) - obj[idx] = new_object_t(); - - error = check_stats(stats, 27, 5, 21, 3, 5); - if (error) return error; - - return 0; -} - - -int alloc_tests(void) -{ - int result = 0; - dx_alloc_initialize(); - - TEST_CASE(test_alloc_basic, 0); - - return result; -} - diff --git a/qpid/extras/dispatch/tests/compose_test.c b/qpid/extras/dispatch/tests/compose_test.c deleted file mode 100644 index 06292c221f..0000000000 --- a/qpid/extras/dispatch/tests/compose_test.c +++ /dev/null @@ -1,292 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -#define _GNU_SOURCE -#include <stdio.h> -#include <assert.h> -#include <string.h> -#include <inttypes.h> -#include "test_case.h" -#include <qpid/dispatch.h> -#include "compose_private.h" - - -static char *vector0 = - "\x00\x53\x77" // amqp-value - "\xd0\x00\x00\x01\x26\x00\x00\x00\x0a" // list32 with ten items - "\xd1\x00\x00\x00\x18\x00\x00\x00\x04" // map32 with two pairs - "\xa1\x06key001" // str8-utf8 - "\x52\x0a" // smalluint - "\xa1\x06key002" // str8-utf8 - "\x52\x0b" // smalluint - "\xd1\x00\x00\x00\x18\x00\x00\x00\x04" // map32 with two pairs - "\xa1\x06key001" // str8-utf8 - "\x52\x14" // smalluint - "\xa1\x06key002" // str8-utf8 - "\x52\x15" // smalluint - "\xd1\x00\x00\x00\x18\x00\x00\x00\x04" // map32 with two pairs - "\xa1\x06key001" // str8-utf8 - "\x52\x14" // smalluint - "\xa1\x06key002" // str8-utf8 - "\x52\x15" // smalluint - "\xd1\x00\x00\x00\x18\x00\x00\x00\x04" // map32 with two pairs - "\xa1\x06key001" // str8-utf8 - "\x52\x14" // smalluint - "\xa1\x06key002" // str8-utf8 - "\x52\x15" // smalluint - "\xd1\x00\x00\x00\x18\x00\x00\x00\x04" // map32 with two pairs - "\xa1\x06key001" // str8-utf8 - "\x52\x14" // smalluint - "\xa1\x06key002" // str8-utf8 - "\x52\x15" // smalluint - "\xd1\x00\x00\x00\x18\x00\x00\x00\x04" // map32 with two pairs - "\xa1\x06key001" // str8-utf8 - "\x52\x14" // smalluint - "\xa1\x06key002" // str8-utf8 - "\x52\x15" // smalluint - "\xd1\x00\x00\x00\x18\x00\x00\x00\x04" // map32 with two pairs - "\xa1\x06key001" // str8-utf8 - "\x52\x14" // smalluint - "\xa1\x06key002" // str8-utf8 - "\x52\x15" // smalluint - "\xd1\x00\x00\x00\x18\x00\x00\x00\x04" // map32 with two pairs - "\xa1\x06key001" // str8-utf8 - "\x52\x14" // smalluint - "\xa1\x06key002" // str8-utf8 - "\x52\x15" // smalluint - "\xd1\x00\x00\x00\x18\x00\x00\x00\x04" // map32 with two pairs - "\xa1\x06key001" // str8-utf8 - "\x52\x14" // smalluint - "\xa1\x06key002" // str8-utf8 - "\x52\x15" // smalluint - "\xd1\x00\x00\x00\x18\x00\x00\x00\x04" // map32 with two pairs - "\xa1\x06key001" // str8-utf8 - "\x52\x14" // smalluint - "\xa1\x06key002" // str8-utf8 - "\x52\x15" // smalluint - ; - -static int vector0_length = 302; - -static char *test_compose_list_of_maps(void *context) -{ - dx_composed_field_t *field = dx_compose(DX_PERFORMATIVE_BODY_AMQP_VALUE, 0); - - dx_compose_start_list(field); - - dx_compose_start_map(field); - dx_compose_insert_string(field, "key001"); - dx_compose_insert_uint(field, 10); - dx_compose_insert_string(field, "key002"); - dx_compose_insert_uint(field, 11); - dx_compose_end_map(field); - - for (int j = 0; j < 9; j++) { - dx_compose_start_map(field); - dx_compose_insert_string(field, "key001"); - dx_compose_insert_uint(field, 20); - dx_compose_insert_string(field, "key002"); - dx_compose_insert_uint(field, 21); - dx_compose_end_map(field); - } - - dx_compose_end_list(field); - - dx_buffer_t *buf = DEQ_HEAD(field->buffers); - - if (dx_buffer_size(buf) != vector0_length) return "Incorrect Length of Buffer"; - - char *left = vector0; - char *right = (char*) dx_buffer_base(buf); - int idx; - - for (idx = 0; idx < vector0_length; idx++) { - if (*left != *right) return "Pattern Mismatch"; - left++; - right++; - } - - dx_compose_free(field); - return 0; -} - -static char *vector1 = - "\x00\x53\x71" // delivery annotations - "\xd1\x00\x00\x00\x3d\x00\x00\x00\x04" // map32 with two item pairs - "\xa1\x06key001" // str8-utf8 - "\x52\x0a" // smalluint - "\xa1\x06key002" // str8-utf8 - "\xd0\x00\x00\x00\x22\x00\x00\x00\x04" // list32 with four items - "\xa1\x05item1" // str8-utf8 - "\xa1\x05item2" // str8-utf8 - "\xa1\x05item3" // str8-utf8 - "\xd0\x00\x00\x00\x04\x00\x00\x00\x00" // list32 empty - ; - -static int vector1_length = 69; - -static char *test_compose_nested_composites(void *context) -{ - dx_composed_field_t *field = dx_compose(DX_PERFORMATIVE_DELIVERY_ANNOTATIONS, 0); - - dx_compose_start_map(field); - - dx_compose_insert_string(field, "key001"); - dx_compose_insert_uint(field, 10); - - dx_compose_insert_string(field, "key002"); - dx_compose_start_list(field); - - dx_compose_insert_string(field, "item1"); - dx_compose_insert_string(field, "item2"); - dx_compose_insert_string(field, "item3"); - - dx_compose_start_list(field); - dx_compose_end_list(field); - - dx_compose_end_list(field); - dx_compose_end_map(field); - - dx_buffer_t *buf = DEQ_HEAD(field->buffers); - - if (dx_buffer_size(buf) != vector1_length) return "Incorrect Length of Buffer"; - - char *left = vector1; - char *right = (char*) dx_buffer_base(buf); - int idx; - - for (idx = 0; idx < vector1_length; idx++) { - if (*left != *right) return "Pattern Mismatch"; - left++; - right++; - } - - dx_compose_free(field); - return 0; -} - -static char *vector2 = - "\x00\x53\x73" // properties - "\xd0\x00\x00\x00\x83\x00\x00\x00\x1c" // list32 with 28 items - "\x40" // null - "\x42" // false - "\x41" // true - "\x43" // uint0 - "\x52\x01" // smalluint - "\x52\xff" // smalluint - "\x70\x00\x00\x01\x00" // uint - "\x70\x10\x00\x00\x00" // uint - "\x44" // ulong0 - "\x53\x01" // smallulong - "\x53\xff" // smallulong - "\x80\x00\x00\x00\x00\x00\x00\x01\x00" // ulong - "\x80\x00\x00\x00\x00\x20\x00\x00\x00" // ulong - "\x54\x00" // smallint - "\x54\x01" // smallint - "\x54\xff" // smallint - "\x71\x00\x00\x00\xff" // int - "\x71\x00\x00\x01\x00" // int - "\x55\x00" // smalllong - "\x55\x01" // smalllong - "\x55\xff" // smalllong - "\x81\x00\x00\x00\x00\x00\x00\x00\xff" // long - "\x81\x00\x00\x00\x00\x00\x00\x01\x00" // long - "\x83\x00\x11\x22\x33\x44\x55\x66\x77" // timestamp - "\x98\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x00" // uuid - "\xa0\x02\x00\x11" // vbin8 - "\xa1\x06string" // str8-utf8 - "\xa3\x06symbol" // sym8 - ; - -static int vector2_length = 139; - -static char *test_compose_scalars(void *context) -{ - dx_composed_field_t *field = dx_compose(DX_PERFORMATIVE_PROPERTIES, 0); - - dx_compose_start_list(field); - - dx_compose_insert_null(field); - - dx_compose_insert_bool(field, 0); - dx_compose_insert_bool(field, 1); - - dx_compose_insert_uint(field, 0); - dx_compose_insert_uint(field, 1); - dx_compose_insert_uint(field, 255); - dx_compose_insert_uint(field, 256); - dx_compose_insert_uint(field, 0x10000000); - - dx_compose_insert_ulong(field, 0); - dx_compose_insert_ulong(field, 1); - dx_compose_insert_ulong(field, 255); - dx_compose_insert_ulong(field, 256); - dx_compose_insert_ulong(field, 0x20000000); - - dx_compose_insert_int(field, 0); - dx_compose_insert_int(field, 1); - dx_compose_insert_int(field, -1); - dx_compose_insert_int(field, 255); - dx_compose_insert_int(field, 256); - - dx_compose_insert_long(field, 0); - dx_compose_insert_long(field, 1); - dx_compose_insert_long(field, -1); - dx_compose_insert_long(field, 255); - dx_compose_insert_long(field, 256); - - dx_compose_insert_timestamp(field, 0x0011223344556677); - dx_compose_insert_uuid(field, (uint8_t*) "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x00"); - dx_compose_insert_binary(field, (uint8_t*) "\x00\x11", 2); - dx_compose_insert_string(field, "string"); - dx_compose_insert_symbol(field, "symbol"); - - dx_compose_end_list(field); - - dx_buffer_t *buf = DEQ_HEAD(field->buffers); - - if (dx_buffer_size(buf) != vector2_length) return "Incorrect Length of Buffer"; - - char *left = vector2; - char *right = (char*) dx_buffer_base(buf); - int idx; - - for (idx = 0; idx < vector2_length; idx++) { - if (*left != *right) return "Pattern Mismatch"; - left++; - right++; - } - - dx_compose_free(field); - return 0; -} - - -int compose_tests() -{ - int result = 0; - dx_log_set_mask(LOG_NONE); - - TEST_CASE(test_compose_list_of_maps, 0); - TEST_CASE(test_compose_nested_composites, 0); - TEST_CASE(test_compose_scalars, 0); - - return result; -} - diff --git a/qpid/extras/dispatch/tests/config-1/A.conf b/qpid/extras/dispatch/tests/config-1/A.conf deleted file mode 100644 index 308d86473c..0000000000 --- a/qpid/extras/dispatch/tests/config-1/A.conf +++ /dev/null @@ -1,54 +0,0 @@ -## -## Licensed to the Apache Software Foundation (ASF) under one -## or more contributor license agreements. See the NOTICE file -## distributed with this work for additional information -## regarding copyright ownership. The ASF licenses this file -## to you 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 -## - - -## -## Container section - Configures the general operation of the AMQP container. -## -container { - ## - ## worker-threads - The number of threads that will be created to - ## process message traffic and other application work (timers, non-amqp - ## file descriptors, etc.) - ## - ## The number of threads should be related to the number of available - ## processor cores. To fully utilize a quad-core system, set the - ## number of threads to 4. - ## - worker-threads: 4 - - ## - ## container-name - The name of the AMQP container. If not specified, - ## the container name will be set to a value of the container's - ## choosing. The automatically assigned container name is not - ## guaranteed to be persistent across restarts of the container. - ## - container-name: Qpid.Dispatch.Router.A -} - - -## -## Listeners and Connectors -## -listener { - addr: 0.0.0.0 - port: 20000 - sasl-mechanisms: ANONYMOUS -} - diff --git a/qpid/extras/dispatch/tests/config-2/A.conf b/qpid/extras/dispatch/tests/config-2/A.conf deleted file mode 100644 index a3fb411018..0000000000 --- a/qpid/extras/dispatch/tests/config-2/A.conf +++ /dev/null @@ -1,59 +0,0 @@ -## -## Licensed to the Apache Software Foundation (ASF) under one -## or more contributor license agreements. See the NOTICE file -## distributed with this work for additional information -## regarding copyright ownership. The ASF licenses this file -## to you 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 -## - - -## -## Container section - Configures the general operation of the AMQP container. -## -container { - ## - ## worker-threads - The number of threads that will be created to - ## process message traffic and other application work (timers, non-amqp - ## file descriptors, etc.) - ## - ## The number of threads should be related to the number of available - ## processor cores. To fully utilize a quad-core system, set the - ## number of threads to 4. - ## - worker-threads: 4 - - ## - ## container-name - The name of the AMQP container. If not specified, - ## the container name will be set to a value of the container's - ## choosing. The automatically assigned container name is not - ## guaranteed to be persistent across restarts of the container. - ## - container-name: Qpid.Dispatch.Router.A -} - - -## -## Listeners and Connectors -## -listener { - role: inter-router - addr: 0.0.0.0 - port: 20001 - sasl-mechanisms: ANONYMOUS -} - -router { - mode: interior - router-id: QDR.A -} diff --git a/qpid/extras/dispatch/tests/config-2/B.conf b/qpid/extras/dispatch/tests/config-2/B.conf deleted file mode 100644 index 0950584c88..0000000000 --- a/qpid/extras/dispatch/tests/config-2/B.conf +++ /dev/null @@ -1,67 +0,0 @@ -## -## Licensed to the Apache Software Foundation (ASF) under one -## or more contributor license agreements. See the NOTICE file -## distributed with this work for additional information -## regarding copyright ownership. The ASF licenses this file -## to you 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 -## - - -## -## Container section - Configures the general operation of the AMQP container. -## -container { - ## - ## worker-threads - The number of threads that will be created to - ## process message traffic and other application work (timers, non-amqp - ## file descriptors, etc.) - ## - ## The number of threads should be related to the number of available - ## processor cores. To fully utilize a quad-core system, set the - ## number of threads to 4. - ## - worker-threads: 4 - - ## - ## container-name - The name of the AMQP container. If not specified, - ## the container name will be set to a value of the container's - ## choosing. The automatically assigned container name is not - ## guaranteed to be persistent across restarts of the container. - ## - container-name: Qpid.Dispatch.Router.B -} - - -## -## Listeners and Connectors -## -listener { - role: inter-router - addr: 0.0.0.0 - port: 20002 - sasl-mechanisms: ANONYMOUS -} - -connector { - label: Router Uplink - role: inter-router - addr: 0.0.0.0 - port: 20001 - sasl-mechanisms: ANONYMOUS -} - -router { - mode: interior - router-id: QDR.B -} diff --git a/qpid/extras/dispatch/tests/config-3-linear/A.conf b/qpid/extras/dispatch/tests/config-3-linear/A.conf deleted file mode 100644 index 6f0f9abce8..0000000000 --- a/qpid/extras/dispatch/tests/config-3-linear/A.conf +++ /dev/null @@ -1,69 +0,0 @@ -## -## Licensed to the Apache Software Foundation (ASF) under one -## or more contributor license agreements. See the NOTICE file -## distributed with this work for additional information -## regarding copyright ownership. The ASF licenses this file -## to you 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 -## - - -## -## Container section - Configures the general operation of the AMQP container. -## -container { - ## - ## worker-threads - The number of threads that will be created to - ## process message traffic and other application work (timers, non-amqp - ## file descriptors, etc.) - ## - ## The number of threads should be related to the number of available - ## processor cores. To fully utilize a quad-core system, set the - ## number of threads to 4. - ## - worker-threads: 4 - - ## - ## container-name - The name of the AMQP container. If not specified, - ## the container name will be set to a value of the container's - ## choosing. The automatically assigned container name is not - ## guaranteed to be persistent across restarts of the container. - ## - container-name: QDR.A -} - - -## -## Listeners and Connectors -## -listener { - addr: 0.0.0.0 - port: 20001 - sasl-mechanisms: ANONYMOUS -} - -connector { - label: Router Uplink - role: inter-router - addr: 0.0.0.0 - port: 20002 - sasl-mechanisms: ANONYMOUS -} - -router { - mode: interior - router-id: QDR.A -} - - - diff --git a/qpid/extras/dispatch/tests/config-3-linear/B.conf b/qpid/extras/dispatch/tests/config-3-linear/B.conf deleted file mode 100644 index 85c146bd58..0000000000 --- a/qpid/extras/dispatch/tests/config-3-linear/B.conf +++ /dev/null @@ -1,68 +0,0 @@ -## -## Licensed to the Apache Software Foundation (ASF) under one -## or more contributor license agreements. See the NOTICE file -## distributed with this work for additional information -## regarding copyright ownership. The ASF licenses this file -## to you 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 -## - - -## -## Container section - Configures the general operation of the AMQP container. -## -container { - ## - ## worker-threads - The number of threads that will be created to - ## process message traffic and other application work (timers, non-amqp - ## file descriptors, etc.) - ## - ## The number of threads should be related to the number of available - ## processor cores. To fully utilize a quad-core system, set the - ## number of threads to 4. - ## - worker-threads: 4 - - ## - ## container-name - The name of the AMQP container. If not specified, - ## the container name will be set to a value of the container's - ## choosing. The automatically assigned container name is not - ## guaranteed to be persistent across restarts of the container. - ## - container-name: QDR.B -} - - -## -## Listeners and Connectors -## -listener { - role: inter-router - addr: 0.0.0.0 - port: 20002 - sasl-mechanisms: ANONYMOUS -} - -connector { - label: Router Uplink - role: inter-router - addr: 0.0.0.0 - port: 20003 - sasl-mechanisms: ANONYMOUS -} - - -router { - mode: interior - router-id: QDR.B -} diff --git a/qpid/extras/dispatch/tests/config-3-linear/C.conf b/qpid/extras/dispatch/tests/config-3-linear/C.conf deleted file mode 100644 index 17971462bc..0000000000 --- a/qpid/extras/dispatch/tests/config-3-linear/C.conf +++ /dev/null @@ -1,60 +0,0 @@ -## -## Licensed to the Apache Software Foundation (ASF) under one -## or more contributor license agreements. See the NOTICE file -## distributed with this work for additional information -## regarding copyright ownership. The ASF licenses this file -## to you 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 -## - - -## -## Container section - Configures the general operation of the AMQP container. -## -container { - ## - ## worker-threads - The number of threads that will be created to - ## process message traffic and other application work (timers, non-amqp - ## file descriptors, etc.) - ## - ## The number of threads should be related to the number of available - ## processor cores. To fully utilize a quad-core system, set the - ## number of threads to 4. - ## - worker-threads: 4 - - ## - ## container-name - The name of the AMQP container. If not specified, - ## the container name will be set to a value of the container's - ## choosing. The automatically assigned container name is not - ## guaranteed to be persistent across restarts of the container. - ## - container-name: QDR.C -} - - -## -## Listeners and Connectors -## -listener { - role: inter-router - addr: 0.0.0.0 - port: 20003 - sasl-mechanisms: ANONYMOUS -} - - -router { - mode: interior - router-id: QDR.C -} diff --git a/qpid/extras/dispatch/tests/config-3-linear/topology.txt b/qpid/extras/dispatch/tests/config-3-linear/topology.txt deleted file mode 100644 index 07d6d74008..0000000000 --- a/qpid/extras/dispatch/tests/config-3-linear/topology.txt +++ /dev/null @@ -1,12 +0,0 @@ - - - +----------+ +----------+ +----------+ - |QDR.A | |QDR.B | |QDR.C | - |port: | |port: | |port: | - | 20001 |--------->| 20002 |--------->| 20003 | - | | | | | | - | | | | | | - +----------+ +----------+ +----------+ - - * The direction of the arrow shows the direction of the connection setup - Connector --> Listener diff --git a/qpid/extras/dispatch/tests/field_test.c b/qpid/extras/dispatch/tests/field_test.c deleted file mode 100644 index 77cb6d969f..0000000000 --- a/qpid/extras/dispatch/tests/field_test.c +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -#include "test_case.h" -#include <stdio.h> -#include <string.h> -#include <qpid/dispatch/iterator.h> - -#define FAIL_TEXT_SIZE 10000 -static char fail_text[FAIL_TEXT_SIZE]; - -static char* test_view_global_dns(void *context) -{ - dx_field_iterator_t *iter = dx_field_iterator_string("amqp://host/global/sub", ITER_VIEW_ALL); - if (!dx_field_iterator_equal(iter, (unsigned char*) "amqp://host/global/sub")) - return "ITER_VIEW_ALL failed"; - - dx_field_iterator_reset_view(iter, ITER_VIEW_NO_HOST); - if (!dx_field_iterator_equal(iter, (unsigned char*) "global/sub")) - return "ITER_VIEW_NO_HOST failed"; - - dx_field_iterator_reset_view(iter, ITER_VIEW_NODE_ID); - if (!dx_field_iterator_equal(iter, (unsigned char*) "global")) - return "ITER_VIEW_NODE_ID failed"; - - dx_field_iterator_reset_view(iter, ITER_VIEW_NODE_SPECIFIC); - if (!dx_field_iterator_equal(iter, (unsigned char*) "sub")) - return "ITER_VIEW_NODE_SPECIFIC failed"; - - dx_field_iterator_reset_view(iter, ITER_VIEW_ADDRESS_HASH); - if (!dx_field_iterator_equal(iter, (unsigned char*) "Mglobal/sub")) - return "ITER_VIEW_ADDRESS_HASH failed"; - - return 0; -} - - -static char* test_view_global_non_dns(void *context) -{ - dx_field_iterator_t *iter = dx_field_iterator_string("amqp:/global/sub", ITER_VIEW_ALL); - if (!dx_field_iterator_equal(iter, (unsigned char*) "amqp:/global/sub")) - return "ITER_VIEW_ALL failed"; - - dx_field_iterator_reset_view(iter, ITER_VIEW_NO_HOST); - if (!dx_field_iterator_equal(iter, (unsigned char*) "global/sub")) - return "ITER_VIEW_NO_HOST failed"; - - dx_field_iterator_reset_view(iter, ITER_VIEW_NODE_ID); - if (!dx_field_iterator_equal(iter, (unsigned char*) "global")) - return "ITER_VIEW_NODE_ID failed"; - - dx_field_iterator_reset_view(iter, ITER_VIEW_NODE_SPECIFIC); - if (!dx_field_iterator_equal(iter, (unsigned char*) "sub")) - return "ITER_VIEW_NODE_SPECIFIC failed"; - - dx_field_iterator_reset_view(iter, ITER_VIEW_ADDRESS_HASH); - if (!dx_field_iterator_equal(iter, (unsigned char*) "Mglobal/sub")) - return "ITER_VIEW_ADDRESS_HASH failed"; - - return 0; -} - - -static char* test_view_global_no_host(void *context) -{ - dx_field_iterator_t *iter = dx_field_iterator_string("global/sub", ITER_VIEW_ALL); - if (!dx_field_iterator_equal(iter, (unsigned char*) "global/sub")) - return "ITER_VIEW_ALL failed"; - - dx_field_iterator_reset_view(iter, ITER_VIEW_NO_HOST); - if (!dx_field_iterator_equal(iter, (unsigned char*) "global/sub")) - return "ITER_VIEW_NO_HOST failed"; - - dx_field_iterator_reset_view(iter, ITER_VIEW_NODE_ID); - if (!dx_field_iterator_equal(iter, (unsigned char*) "global")) - return "ITER_VIEW_NODE_ID failed"; - - dx_field_iterator_reset_view(iter, ITER_VIEW_NODE_SPECIFIC); - if (!dx_field_iterator_equal(iter, (unsigned char*) "sub")) - return "ITER_VIEW_NODE_SPECIFIC failed"; - - dx_field_iterator_reset_view(iter, ITER_VIEW_ADDRESS_HASH); - if (!dx_field_iterator_equal(iter, (unsigned char*) "Mglobal/sub")) - return "ITER_VIEW_ADDRESS_HASH failed"; - - return 0; -} - - -static char* test_view_address_hash(void *context) -{ - struct {const char *addr; const char *view;} cases[] = { - {"amqp:/_local/my-addr/sub", "Lmy-addr/sub"}, - {"amqp:/_local/my-addr", "Lmy-addr"}, - {"amqp:/_topo/area/router/local/sub", "Aarea"}, - {"amqp:/_topo/my-area/router/local/sub", "Rrouter"}, - {"amqp:/_topo/my-area/my-router/local/sub", "Llocal/sub"}, - {"amqp:/_topo/area/all/local/sub", "Aarea"}, - {"amqp:/_topo/my-area/all/local/sub", "Llocal/sub"}, - {"amqp:/_topo/all/all/local/sub", "Llocal/sub"}, - {"amqp://host:port/_local/my-addr", "Lmy-addr"}, - {"_topo/area/router/my-addr", "Aarea"}, - {"_topo/my-area/router/my-addr", "Rrouter"}, - {"_topo/my-area/my-router/my-addr", "Lmy-addr"}, - {"_topo/my-area/router", "Rrouter"}, - {0, 0} - }; - int idx; - - for (idx = 0; cases[idx].addr; idx++) { - dx_field_iterator_t *iter = dx_field_iterator_string(cases[idx].addr, ITER_VIEW_ADDRESS_HASH); - if (!dx_field_iterator_equal(iter, (unsigned char*) cases[idx].view)) { - char *got = (char*) dx_field_iterator_copy(iter); - snprintf(fail_text, FAIL_TEXT_SIZE, "Addr '%s' failed. Expected '%s', got '%s'", - cases[idx].addr, cases[idx].view, got); - return fail_text; - } - } - - return 0; -} - - -static char* test_view_node_hash(void *context) -{ - struct {const char *addr; const char *view;} cases[] = { - {"area/router", "Aarea"}, - {"my-area/router", "Rrouter"}, - {"my-area/my-router", "Rmy-router"}, - {0, 0} - }; - int idx; - - for (idx = 0; cases[idx].addr; idx++) { - dx_field_iterator_t *iter = dx_field_iterator_string(cases[idx].addr, ITER_VIEW_NODE_HASH); - if (!dx_field_iterator_equal(iter, (unsigned char*) cases[idx].view)) { - char *got = (char*) dx_field_iterator_copy(iter); - snprintf(fail_text, FAIL_TEXT_SIZE, "Addr '%s' failed. Expected '%s', got '%s'", - cases[idx].addr, cases[idx].view, got); - return fail_text; - } - } - - return 0; -} - - -int field_tests(void) -{ - int result = 0; - - dx_field_iterator_set_address("my-area", "my-router"); - - TEST_CASE(test_view_global_dns, 0); - TEST_CASE(test_view_global_non_dns, 0); - TEST_CASE(test_view_global_no_host, 0); - TEST_CASE(test_view_address_hash, 0); - TEST_CASE(test_view_node_hash, 0); - - return result; -} - diff --git a/qpid/extras/dispatch/tests/message_test.c b/qpid/extras/dispatch/tests/message_test.c deleted file mode 100644 index 59f4e444dc..0000000000 --- a/qpid/extras/dispatch/tests/message_test.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -#include "test_case.h" -#include <stdio.h> -#include <string.h> -#include "message_private.h" -#include <qpid/dispatch/iterator.h> -#include <proton/message.h> - -static char buffer[10000]; - -static size_t flatten_bufs(dx_message_content_t *content) -{ - char *cursor = buffer; - dx_buffer_t *buf = DEQ_HEAD(content->buffers); - - while (buf) { - memcpy(cursor, dx_buffer_base(buf), dx_buffer_size(buf)); - cursor += dx_buffer_size(buf); - buf = buf->next; - } - - return (size_t) (cursor - buffer); -} - - -static void set_content(dx_message_content_t *content, size_t len) -{ - char *cursor = buffer; - dx_buffer_t *buf; - - while (len > (size_t) (cursor - buffer)) { - buf = dx_buffer(); - size_t segment = dx_buffer_capacity(buf); - size_t remaining = len - (size_t) (cursor - buffer); - if (segment > remaining) - segment = remaining; - memcpy(dx_buffer_base(buf), cursor, segment); - cursor += segment; - dx_buffer_insert(buf, segment); - DEQ_INSERT_TAIL(content->buffers, buf); - } -} - - -static char* test_send_to_messenger(void *context) -{ - dx_message_t *msg = dx_message(); - dx_message_content_t *content = MSG_CONTENT(msg); - - dx_message_compose_1(msg, "test_addr_0", 0); - dx_buffer_t *buf = DEQ_HEAD(content->buffers); - if (buf == 0) return "Expected a buffer in the test message"; - - pn_message_t *pn_msg = pn_message(); - size_t len = flatten_bufs(content); - int result = pn_message_decode(pn_msg, buffer, len); - if (result != 0) return "Error in pn_message_decode"; - - if (strcmp(pn_message_get_address(pn_msg), "test_addr_0") != 0) - return "Address mismatch in received message"; - - pn_message_free(pn_msg); - dx_message_free(msg); - - return 0; -} - - -static char* test_receive_from_messenger(void *context) -{ - pn_message_t *pn_msg = pn_message(); - pn_message_set_address(pn_msg, "test_addr_1"); - - size_t size = 10000; - int result = pn_message_encode(pn_msg, buffer, &size); - if (result != 0) return "Error in pn_message_encode"; - - dx_message_t *msg = dx_message(); - dx_message_content_t *content = MSG_CONTENT(msg); - - set_content(content, size); - - int valid = dx_message_check(msg, DX_DEPTH_ALL); - if (!valid) return "dx_message_check returns 'invalid'"; - - dx_field_iterator_t *iter = dx_message_field_iterator(msg, DX_FIELD_TO); - if (iter == 0) return "Expected an iterator for the 'to' field"; - - if (!dx_field_iterator_equal(iter, (unsigned char*) "test_addr_1")) - return "Mismatched 'to' field contents"; - - ssize_t test_len = dx_message_field_length(msg, DX_FIELD_TO); - if (test_len != 11) return "Incorrect field length"; - - char test_field[15]; - test_len = dx_message_field_copy(msg, DX_FIELD_TO, test_field); - if (test_len != 11) return "Incorrect length returned from field_copy"; - test_field[test_len] = '\0'; - if (strcmp(test_field, "test_addr_1") != 0) - return "Incorrect field content returned from field_copy"; - - pn_message_free(pn_msg); - dx_message_free(msg); - - return 0; -} - - -static char* test_insufficient_check_depth(void *context) -{ - pn_message_t *pn_msg = pn_message(); - pn_message_set_address(pn_msg, "test_addr_2"); - - size_t size = 10000; - int result = pn_message_encode(pn_msg, buffer, &size); - if (result != 0) return "Error in pn_message_encode"; - - dx_message_t *msg = dx_message(); - dx_message_content_t *content = MSG_CONTENT(msg); - - set_content(content, size); - - int valid = dx_message_check(msg, DX_DEPTH_DELIVERY_ANNOTATIONS); - if (!valid) return "dx_message_check returns 'invalid'"; - - dx_field_iterator_t *iter = dx_message_field_iterator(msg, DX_FIELD_TO); - if (iter) return "Expected no iterator for the 'to' field"; - - dx_message_free(msg); - - return 0; -} - - -static char* test_check_multiple(void *context) -{ - pn_message_t *pn_msg = pn_message(); - pn_message_set_address(pn_msg, "test_addr_2"); - - size_t size = 10000; - int result = pn_message_encode(pn_msg, buffer, &size); - if (result != 0) return "Error in pn_message_encode"; - - dx_message_t *msg = dx_message(); - dx_message_content_t *content = MSG_CONTENT(msg); - - set_content(content, size); - - int valid = dx_message_check(msg, DX_DEPTH_DELIVERY_ANNOTATIONS); - if (!valid) return "dx_message_check returns 'invalid' for DELIVERY_ANNOTATIONS"; - - valid = dx_message_check(msg, DX_DEPTH_BODY); - if (!valid) return "dx_message_check returns 'invalid' for BODY"; - - valid = dx_message_check(msg, DX_DEPTH_PROPERTIES); - if (!valid) return "dx_message_check returns 'invalid' for PROPERTIES"; - - dx_message_free(msg); - - return 0; -} - - -int message_tests(void) -{ - int result = 0; - - TEST_CASE(test_send_to_messenger, 0); - TEST_CASE(test_receive_from_messenger, 0); - TEST_CASE(test_insufficient_check_depth, 0); - TEST_CASE(test_check_multiple, 0); - - return result; -} - diff --git a/qpid/extras/dispatch/tests/parse_test.c b/qpid/extras/dispatch/tests/parse_test.c deleted file mode 100644 index 124ba1c0d4..0000000000 --- a/qpid/extras/dispatch/tests/parse_test.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -#define _GNU_SOURCE -#include <stdio.h> -#include <assert.h> -#include <string.h> -#include <inttypes.h> -#include "test_case.h" -#include <qpid/dispatch.h> - -struct fs_vector_t { - const char *data; - int length; - uint8_t expected_tag; - int check_uint; - int check_ulong; - int check_int; - int check_long; - uint64_t expected_ulong; - int64_t expected_long; -} fs_vectors[] = { -{"\x40", 1, DX_AMQP_NULL, 0, 0, 0, 0, 0, 0}, // 0 -{"\x41", 1, DX_AMQP_TRUE, 1, 0, 0, 0, 1, 0}, // 1 -{"\x42", 1, DX_AMQP_FALSE, 1, 0, 0, 0, 0, 0}, // 2 -{"\x56\x00", 2, DX_AMQP_BOOLEAN, 1, 0, 0, 0, 0, 0}, // 3 -{"\x56\x01", 2, DX_AMQP_BOOLEAN, 1, 0, 0, 0, 1, 0}, // 4 -{"\x50\x45", 2, DX_AMQP_UBYTE, 1, 0, 0, 0, 0x45, 0}, // 5 -{"\x60\x02\x04", 3, DX_AMQP_USHORT, 1, 0, 0, 0, 0x0204, 0}, // 6 -{"\x70\x01\x02\x03\x04", 5, DX_AMQP_UINT, 1, 0, 0, 0, 0x01020304, 0}, // 7 -{"\x52\x06", 2, DX_AMQP_SMALLUINT, 1, 0, 0, 0, 6, 0}, // 8 -{"\x43", 1, DX_AMQP_UINT0, 1, 0, 0, 0, 0, 0}, // 9 -{"\x80\x01\x02\x03\x04\x05\x06\x07\x08", - 9, DX_AMQP_ULONG, 0, 1, 0, 0, 0x0102030405060708, 0}, // 10 -{"\x53\x08", 2, DX_AMQP_SMALLULONG, 0, 1, 0, 0, 0x08, 0}, // 11 -{"\x44", 1, DX_AMQP_ULONG0, 0, 1, 0, 0, 0, 0}, // 12 -{"\x71\x01\x02\x03\x04", 5, DX_AMQP_INT, 0, 0, 1, 0, 0, 0x01020304}, // 13 -{"\x54\x02", 2, DX_AMQP_SMALLINT, 0, 0, 1, 0, 0, 2}, // 14 -{"\x81\x01\x02\x03\x04\x05\x06\x07\x08", - 9, DX_AMQP_LONG, 0, 0, 0, 1, 0, 0x0102030405060708}, // 15 -{"\x55\x08", 2, DX_AMQP_SMALLLONG, 0, 0, 0, 1, 0, 0x08}, // 16 -{0, 0, 0, 0, 0} -}; - - -static char *test_parser_fixed_scalars(void *context) -{ - int idx = 0; - static char error[1024]; - - while (fs_vectors[idx].data) { - dx_field_iterator_t *field = dx_field_iterator_binary(fs_vectors[idx].data, - fs_vectors[idx].length, - ITER_VIEW_ALL); - dx_parsed_field_t *parsed = dx_parse(field); - if (!dx_parse_ok(parsed)) return "Unexpected Parse Error"; - if (dx_parse_tag(parsed) != fs_vectors[idx].expected_tag) { - sprintf(error, "(%d) Tag: Expected %02x, Got %02x", idx, - fs_vectors[idx].expected_tag, dx_parse_tag(parsed)); - return error; - } - if (fs_vectors[idx].check_uint && - dx_parse_as_uint(parsed) != fs_vectors[idx].expected_ulong) { - sprintf(error, "(%d) UINT: Expected %"PRIx64", Got %"PRIx32, idx, - fs_vectors[idx].expected_ulong, dx_parse_as_uint(parsed)); - return error; - } - if (fs_vectors[idx].check_ulong && - dx_parse_as_ulong(parsed) != fs_vectors[idx].expected_ulong) { - sprintf(error, "(%d) ULONG: Expected %"PRIx64", Got %"PRIx64, idx, - fs_vectors[idx].expected_ulong, dx_parse_as_ulong(parsed)); - return error; - } - if (fs_vectors[idx].check_int && - dx_parse_as_int(parsed) != fs_vectors[idx].expected_long) { - sprintf(error, "(%d) INT: Expected %"PRIx64", Got %"PRIx32, idx, - fs_vectors[idx].expected_long, dx_parse_as_int(parsed)); - return error; - } - if (fs_vectors[idx].check_long && - dx_parse_as_long(parsed) != fs_vectors[idx].expected_long) { - sprintf(error, "(%d) LONG: Expected %"PRIx64", Got %"PRIx64, idx, - fs_vectors[idx].expected_long, dx_parse_as_long(parsed)); - return error; - } - idx++; - - dx_field_iterator_free(field); - dx_parse_free(parsed); - } - - return 0; -} - - -struct err_vector_t { - const char *data; - int length; - const char *expected_error; -} err_vectors[] = { -{"", 0, "Insufficient Data to Determine Tag"}, // 0 -{"\x21", 1, "Invalid Tag - No Length Information"}, // 1 -//{"\x56", 1, "w"}, // 2 -{"\xa0", 1, "Insufficient Data to Determine Length"}, // 3 -{"\xb0", 1, "Insufficient Data to Determine Length"}, // 4 -{"\xb0\x00", 2, "Insufficient Data to Determine Length"}, // 5 -{"\xb0\x00\x00", 3, "Insufficient Data to Determine Length"}, // 6 -{"\xb0\x00\x00\x00", 4, "Insufficient Data to Determine Length"}, // 7 -{"\xc0\x04", 2, "Insufficient Data to Determine Count"}, // 8 -{"\xd0\x00\x00\x00\x00\x00\x00\x00\x01", 9, "Insufficient Length to Determine Count"}, // 9 -{0, 0, 0} -}; - -static char *test_parser_errors(void *context) -{ - int idx = 0; - static char error[1024]; - - while (err_vectors[idx].data) { - dx_field_iterator_t *field = dx_field_iterator_binary(err_vectors[idx].data, - err_vectors[idx].length, - ITER_VIEW_ALL); - dx_parsed_field_t *parsed = dx_parse(field); - if (dx_parse_ok(parsed)) { - sprintf(error, "(%d) Unexpected Parse Success", idx); - return error; - } - if (strcmp(dx_parse_error(parsed), err_vectors[idx].expected_error) != 0) { - sprintf(error, "(%d) Error: Expected %s, Got %s", idx, - err_vectors[idx].expected_error, dx_parse_error(parsed)); - return error; - } - idx++; - } - - return 0; -} - - -int parse_tests() -{ - int result = 0; - dx_log_set_mask(LOG_NONE); - - TEST_CASE(test_parser_fixed_scalars, 0); - TEST_CASE(test_parser_errors, 0); - - return result; -} - diff --git a/qpid/extras/dispatch/tests/router_engine_test.py b/qpid/extras/dispatch/tests/router_engine_test.py deleted file mode 100644 index e25ce35d22..0000000000 --- a/qpid/extras/dispatch/tests/router_engine_test.py +++ /dev/null @@ -1,651 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -# - -import unittest -from qpid.dispatch.router.router_engine import NeighborEngine, PathEngine, Configuration, NodeTracker -from qpid.dispatch.router.data import LinkState, MessageHELLO - -class Adapter(object): - def __init__(self, domain): - self._domain = domain - - def log(self, level, text): - print "Adapter.log(%d): domain=%s, text=%s" % (level, self._domain, text) - - def send(self, dest, opcode, body): - print "Adapter.send: domain=%s, dest=%s, opcode=%s, body=%s" % (self._domain, dest, opcode, body) - - def remote_bind(self, subject, peer): - print "Adapter.remote_bind: subject=%s, peer=%s" % (subject, peer) - - def remote_unbind(self, subject, peer): - print "Adapter.remote_unbind: subject=%s, peer=%s" % (subject, peer) - - def node_updated(self, address, reachable, neighbor, link_bit, router_bit): - print "Adapter.node_updated: address=%s, reachable=%r, neighbor=%r, link_bit=%d, router_bit=%d" % \ - (address, reachable, neighbor, link_bit, router_bit) - - -class DataTest(unittest.TestCase): - def test_link_state(self): - ls = LinkState(None, 'R1', 'area', 1, ['R2', 'R3']) - self.assertEqual(ls.id, 'R1') - self.assertEqual(ls.area, 'area') - self.assertEqual(ls.ls_seq, 1) - self.assertEqual(ls.peers, ['R2', 'R3']) - ls.bump_sequence() - self.assertEqual(ls.id, 'R1') - self.assertEqual(ls.area, 'area') - self.assertEqual(ls.ls_seq, 2) - self.assertEqual(ls.peers, ['R2', 'R3']) - - result = ls.add_peer('R4') - self.assertTrue(result) - self.assertEqual(ls.peers, ['R2', 'R3', 'R4']) - result = ls.add_peer('R2') - self.assertFalse(result) - self.assertEqual(ls.peers, ['R2', 'R3', 'R4']) - - result = ls.del_peer('R3') - self.assertTrue(result) - self.assertEqual(ls.peers, ['R2', 'R4']) - result = ls.del_peer('R5') - self.assertFalse(result) - self.assertEqual(ls.peers, ['R2', 'R4']) - - encoded = ls.to_dict() - new_ls = LinkState(encoded) - self.assertEqual(new_ls.id, 'R1') - self.assertEqual(new_ls.area, 'area') - self.assertEqual(new_ls.ls_seq, 2) - self.assertEqual(new_ls.peers, ['R2', 'R4']) - - - def test_hello_message(self): - msg1 = MessageHELLO(None, 'R1', 'area', ['R2', 'R3', 'R4']) - self.assertEqual(msg1.get_opcode(), "HELLO") - self.assertEqual(msg1.id, 'R1') - self.assertEqual(msg1.area, 'area') - self.assertEqual(msg1.seen_peers, ['R2', 'R3', 'R4']) - encoded = msg1.to_dict() - msg2 = MessageHELLO(encoded) - self.assertEqual(msg2.get_opcode(), "HELLO") - self.assertEqual(msg2.id, 'R1') - self.assertEqual(msg2.area, 'area') - self.assertEqual(msg2.seen_peers, ['R2', 'R3', 'R4']) - self.assertTrue(msg2.is_seen('R3')) - self.assertFalse(msg2.is_seen('R9')) - - -class NodeTrackerTest(unittest.TestCase): - def log(self, level, text): - pass - - def add_neighbor_router(self, address, router_bit, link_bit): - self.address = address - self.router_bit = router_bit - self.link_bit = link_bit - self.calls += 1 - - def del_neighbor_router(self, router_bit): - self.address = None - self.router_bit = router_bit - self.link_bit = None - self.calls += 1 - - def add_remote_router(self, address, router_bit): - self.address = address - self.router_bit = router_bit - self.link_bit = None - self.calls += 1 - - def del_remote_router(self, router_bit): - self.address = None - self.router_bit = router_bit - self.link_bit = None - self.calls += 1 - - def reset(self): - self.address = None - self.router_bit = None - self.link_bit = None - self.area = "area" - self.calls = 0 - - def test_node_tracker_limits(self): - tracker = NodeTracker(self, 5) - - self.reset() - tracker.new_neighbor('A', 1) - self.assertEqual(self.address, 'amqp:/_topo/area/A') - self.assertEqual(self.link_bit, 1) - self.assertEqual(self.router_bit, 1) - self.assertEqual(self.calls, 1) - - self.reset() - tracker.new_neighbor('B', 5) - self.assertEqual(self.address, 'amqp:/_topo/area/B') - self.assertEqual(self.link_bit, 5) - self.assertEqual(self.router_bit, 2) - self.assertEqual(self.calls, 1) - - self.reset() - tracker.new_neighbor('C', 6) - self.assertEqual(self.address, 'amqp:/_topo/area/C') - self.assertEqual(self.link_bit, 6) - self.assertEqual(self.router_bit, 3) - self.assertEqual(self.calls, 1) - - self.reset() - tracker.new_neighbor('D', 7) - self.assertEqual(self.address, 'amqp:/_topo/area/D') - self.assertEqual(self.link_bit, 7) - self.assertEqual(self.router_bit, 4) - self.assertEqual(self.calls, 1) - - self.reset() - try: - tracker.new_neighbor('E', 9) - AssertFalse("We shouldn't be here") - except: - pass - - self.reset() - tracker.lost_neighbor('C') - self.assertEqual(self.router_bit, 3) - self.assertEqual(self.calls, 1) - - self.reset() - tracker.new_neighbor('E', 9) - self.assertEqual(self.address, 'amqp:/_topo/area/E') - self.assertEqual(self.link_bit, 9) - self.assertEqual(self.router_bit, 3) - self.assertEqual(self.calls, 1) - - - def test_node_tracker_remote_neighbor(self): - tracker = NodeTracker(self, 5) - - self.reset() - tracker.new_node('A') - self.assertEqual(self.address, 'amqp:/_topo/area/A') - self.assertFalse(self.link_bit) - self.assertEqual(self.router_bit, 1) - self.assertEqual(self.calls, 1) - - self.reset() - tracker.new_neighbor('A', 3) - self.assertEqual(self.address, 'amqp:/_topo/area/A') - self.assertEqual(self.link_bit, 3) - self.assertEqual(self.router_bit, 1) - self.assertEqual(self.calls, 2) - - self.reset() - tracker.lost_node('A') - self.assertFalse(self.address) - self.assertFalse(self.link_bit) - self.assertFalse(self.router_bit) - self.assertEqual(self.calls, 0) - - self.reset() - tracker.lost_neighbor('A') - self.assertEqual(self.router_bit, 1) - self.assertEqual(self.calls, 1) - - - def test_node_tracker_neighbor_remote(self): - tracker = NodeTracker(self, 5) - - self.reset() - tracker.new_neighbor('A', 3) - self.assertEqual(self.address, 'amqp:/_topo/area/A') - self.assertEqual(self.link_bit, 3) - self.assertEqual(self.router_bit, 1) - self.assertEqual(self.calls, 1) - - self.reset() - tracker.new_node('A') - self.assertFalse(self.address) - self.assertFalse(self.link_bit) - self.assertFalse(self.router_bit) - self.assertEqual(self.calls, 0) - - self.reset() - tracker.lost_neighbor('A') - self.assertEqual(self.address, 'amqp:/_topo/area/A') - self.assertEqual(self.router_bit, 1) - self.assertEqual(self.calls, 2) - - self.reset() - tracker.lost_node('A') - self.assertEqual(self.router_bit, 1) - self.assertEqual(self.calls, 1) - - -class NeighborTest(unittest.TestCase): - def log(self, level, text): - pass - - def send(self, dest, msg): - self.sent.append((dest, msg)) - - def local_link_state_changed(self, link_state): - self.local_link_state = link_state - - def new_neighbor(self, rid, lbit): - self.neighbors[rid] = None - - def lost_neighbor(self, rid): - self.neighbors.pop(rid) - - def setUp(self): - self.sent = [] - self.local_link_state = None - self.id = "R1" - self.area = "area" - self.config = Configuration() - self.neighbors = {} - - def test_hello_sent(self): - self.sent = [] - self.local_link_state = None - self.engine = NeighborEngine(self) - self.engine.tick(0.5) - self.assertEqual(self.sent, []) - self.engine.tick(1.5) - self.assertEqual(len(self.sent), 1) - dest, msg = self.sent.pop(0) - self.assertEqual(dest, "amqp:/_local/qdxhello") - self.assertEqual(msg.get_opcode(), "HELLO") - self.assertEqual(msg.id, self.id) - self.assertEqual(msg.area, self.area) - self.assertEqual(msg.seen_peers, []) - self.assertEqual(self.local_link_state, None) - - def test_sees_peer(self): - self.sent = [] - self.local_link_state = None - self.engine = NeighborEngine(self) - self.engine.handle_hello(MessageHELLO(None, 'R2', 'area', []), 2.0, 0) - self.engine.tick(5.0) - self.assertEqual(len(self.sent), 1) - dest, msg = self.sent.pop(0) - self.assertEqual(msg.seen_peers, ['R2']) - - def test_establish_peer(self): - self.sent = [] - self.local_link_state = None - self.engine = NeighborEngine(self) - self.engine.handle_hello(MessageHELLO(None, 'R2', 'area', ['R1']), 0.5, 0) - self.engine.tick(1.0) - self.engine.tick(2.0) - self.engine.tick(3.0) - self.assertEqual(self.local_link_state.id, 'R1') - self.assertEqual(self.local_link_state.area, 'area') - self.assertEqual(self.local_link_state.ls_seq, 1) - self.assertEqual(self.local_link_state.peers, ['R2']) - - def test_establish_multiple_peers(self): - self.sent = [] - self.local_link_state = None - self.engine = NeighborEngine(self) - self.engine.handle_hello(MessageHELLO(None, 'R2', 'area', ['R1']), 0.5, 0) - self.engine.tick(1.0) - self.engine.handle_hello(MessageHELLO(None, 'R3', 'area', ['R1', 'R2']), 1.5, 0) - self.engine.tick(2.0) - self.engine.handle_hello(MessageHELLO(None, 'R4', 'area', ['R1']), 2.5, 0) - self.engine.handle_hello(MessageHELLO(None, 'R5', 'area', ['R2']), 2.5, 0) - self.engine.handle_hello(MessageHELLO(None, 'R6', 'area', ['R1']), 2.5, 0) - self.engine.tick(3.0) - self.assertEqual(self.local_link_state.id, 'R1') - self.assertEqual(self.local_link_state.area, 'area') - self.assertEqual(self.local_link_state.ls_seq, 3) - self.local_link_state.peers.sort() - self.assertEqual(self.local_link_state.peers, ['R2', 'R3', 'R4', 'R6']) - - def test_timeout_peer(self): - self.sent = [] - self.local_link_state = None - self.engine = NeighborEngine(self) - self.engine.handle_hello(MessageHELLO(None, 'R2', 'area', ['R3', 'R1']), 2.0, 0) - self.engine.tick(5.0) - self.engine.tick(17.1) - self.assertEqual(self.local_link_state.id, 'R1') - self.assertEqual(self.local_link_state.area, 'area') - self.assertEqual(self.local_link_state.ls_seq, 2) - self.assertEqual(self.local_link_state.peers, []) - - -class PathTest(unittest.TestCase): - def setUp(self): - self.id = 'R1' - self.area = 'area' - self.next_hops = None - self.valid_origins = None - self.engine = PathEngine(self) - - def log(self, level, text): - pass - - def next_hops_changed(self, nh): - self.next_hops = nh - - def valid_origins_changed(self, vo): - self.valid_origins = vo - - def test_topology1(self): - """ - - +====+ +----+ +----+ - | R1 |------| R2 |------| R3 | - +====+ +----+ +----+ - - """ - collection = { 'R1': LinkState(None, 'R1', 'area', 1, ['R2']), - 'R2': LinkState(None, 'R2', 'area', 1, ['R1', 'R3']), - 'R3': LinkState(None, 'R3', 'area', 1, ['R2']) } - self.engine.ls_collection_changed(collection) - self.engine.tick(1.0) - self.assertEqual(len(self.next_hops), 2) - self.assertEqual(self.next_hops['R2'], 'R2') - self.assertEqual(self.next_hops['R3'], 'R2') - - self.valid_origins['R2'].sort() - self.valid_origins['R3'].sort() - self.assertEqual(self.valid_origins['R2'], []) - self.assertEqual(self.valid_origins['R3'], []) - - def test_topology2(self): - """ - - +====+ +----+ +----+ - | R1 |------| R2 |------| R4 | - +====+ +----+ +----+ - | | - +----+ +----+ +----+ - | R3 |------| R5 |------| R6 | - +----+ +----+ +----+ - - """ - collection = { 'R1': LinkState(None, 'R1', 'area', 1, ['R2']), - 'R2': LinkState(None, 'R2', 'area', 1, ['R1', 'R3', 'R4']), - 'R3': LinkState(None, 'R3', 'area', 1, ['R2', 'R5']), - 'R4': LinkState(None, 'R4', 'area', 1, ['R2', 'R5']), - 'R5': LinkState(None, 'R5', 'area', 1, ['R3', 'R4', 'R6']), - 'R6': LinkState(None, 'R6', 'area', 1, ['R5']) } - self.engine.ls_collection_changed(collection) - self.engine.tick(1.0) - self.assertEqual(len(self.next_hops), 5) - self.assertEqual(self.next_hops['R2'], 'R2') - self.assertEqual(self.next_hops['R3'], 'R2') - self.assertEqual(self.next_hops['R4'], 'R2') - self.assertEqual(self.next_hops['R5'], 'R2') - self.assertEqual(self.next_hops['R6'], 'R2') - - self.valid_origins['R2'].sort() - self.valid_origins['R3'].sort() - self.valid_origins['R4'].sort() - self.valid_origins['R5'].sort() - self.valid_origins['R6'].sort() - self.assertEqual(self.valid_origins['R2'], []) - self.assertEqual(self.valid_origins['R3'], []) - self.assertEqual(self.valid_origins['R4'], []) - self.assertEqual(self.valid_origins['R5'], []) - self.assertEqual(self.valid_origins['R6'], []) - - def test_topology3(self): - """ - - +----+ +----+ +----+ - | R2 |------| R3 |------| R4 | - +----+ +----+ +----+ - | | - +====+ +----+ +----+ - | R1 |------| R5 |------| R6 | - +====+ +----+ +----+ - - """ - collection = { 'R2': LinkState(None, 'R2', 'area', 1, ['R3']), - 'R3': LinkState(None, 'R3', 'area', 1, ['R1', 'R2', 'R4']), - 'R4': LinkState(None, 'R4', 'area', 1, ['R3', 'R5']), - 'R1': LinkState(None, 'R1', 'area', 1, ['R3', 'R5']), - 'R5': LinkState(None, 'R5', 'area', 1, ['R1', 'R4', 'R6']), - 'R6': LinkState(None, 'R6', 'area', 1, ['R5']) } - self.engine.ls_collection_changed(collection) - self.engine.tick(1.0) - self.assertEqual(len(self.next_hops), 5) - self.assertEqual(self.next_hops['R2'], 'R3') - self.assertEqual(self.next_hops['R3'], 'R3') - self.assertEqual(self.next_hops['R4'], 'R3') - self.assertEqual(self.next_hops['R5'], 'R5') - self.assertEqual(self.next_hops['R6'], 'R5') - - self.valid_origins['R2'].sort() - self.valid_origins['R3'].sort() - self.valid_origins['R4'].sort() - self.valid_origins['R5'].sort() - self.valid_origins['R6'].sort() - self.assertEqual(self.valid_origins['R2'], ['R5', 'R6']) - self.assertEqual(self.valid_origins['R3'], ['R5', 'R6']) - self.assertEqual(self.valid_origins['R4'], []) - self.assertEqual(self.valid_origins['R5'], ['R2', 'R3']) - self.assertEqual(self.valid_origins['R6'], ['R2', 'R3']) - - def test_topology4(self): - """ - - +----+ +----+ +----+ - | R2 |------| R3 |------| R4 | - +----+ +----+ +----+ - | | - +====+ +----+ +----+ - | R1 |------| R5 |------| R6 |------ R7 (no ls from R7) - +====+ +----+ +----+ - - """ - collection = { 'R2': LinkState(None, 'R2', 'area', 1, ['R3']), - 'R3': LinkState(None, 'R3', 'area', 1, ['R1', 'R2', 'R4']), - 'R4': LinkState(None, 'R4', 'area', 1, ['R3', 'R5']), - 'R1': LinkState(None, 'R1', 'area', 1, ['R3', 'R5']), - 'R5': LinkState(None, 'R5', 'area', 1, ['R1', 'R4', 'R6']), - 'R6': LinkState(None, 'R6', 'area', 1, ['R5', 'R7']) } - self.engine.ls_collection_changed(collection) - self.engine.tick(1.0) - self.assertEqual(len(self.next_hops), 6) - self.assertEqual(self.next_hops['R2'], 'R3') - self.assertEqual(self.next_hops['R3'], 'R3') - self.assertEqual(self.next_hops['R4'], 'R3') - self.assertEqual(self.next_hops['R5'], 'R5') - self.assertEqual(self.next_hops['R6'], 'R5') - self.assertEqual(self.next_hops['R7'], 'R5') - - self.valid_origins['R2'].sort() - self.valid_origins['R3'].sort() - self.valid_origins['R4'].sort() - self.valid_origins['R5'].sort() - self.valid_origins['R6'].sort() - self.valid_origins['R7'].sort() - self.assertEqual(self.valid_origins['R2'], ['R5', 'R6', 'R7']) - self.assertEqual(self.valid_origins['R3'], ['R5', 'R6', 'R7']) - self.assertEqual(self.valid_origins['R4'], []) - self.assertEqual(self.valid_origins['R5'], ['R2', 'R3']) - self.assertEqual(self.valid_origins['R6'], ['R2', 'R3']) - self.assertEqual(self.valid_origins['R7'], ['R2', 'R3']) - - def test_topology5(self): - """ - - +----+ +----+ +----+ - | R2 |------| R3 |------| R4 | - +----+ +----+ +----+ - | | | - | +====+ +----+ +----+ - +--------| R1 |------| R5 |------| R6 |------ R7 (no ls from R7) - +====+ +----+ +----+ - - """ - collection = { 'R2': LinkState(None, 'R2', 'area', 1, ['R3', 'R1']), - 'R3': LinkState(None, 'R3', 'area', 1, ['R1', 'R2', 'R4']), - 'R4': LinkState(None, 'R4', 'area', 1, ['R3', 'R5']), - 'R1': LinkState(None, 'R1', 'area', 1, ['R3', 'R5', 'R2']), - 'R5': LinkState(None, 'R5', 'area', 1, ['R1', 'R4', 'R6']), - 'R6': LinkState(None, 'R6', 'area', 1, ['R5', 'R7']) } - self.engine.ls_collection_changed(collection) - self.engine.tick(1.0) - self.assertEqual(len(self.next_hops), 6) - self.assertEqual(self.next_hops['R2'], 'R2') - self.assertEqual(self.next_hops['R3'], 'R3') - self.assertEqual(self.next_hops['R4'], 'R3') - self.assertEqual(self.next_hops['R5'], 'R5') - self.assertEqual(self.next_hops['R6'], 'R5') - self.assertEqual(self.next_hops['R7'], 'R5') - - self.valid_origins['R2'].sort() - self.valid_origins['R3'].sort() - self.valid_origins['R4'].sort() - self.valid_origins['R5'].sort() - self.valid_origins['R6'].sort() - self.valid_origins['R7'].sort() - self.assertEqual(self.valid_origins['R2'], ['R5', 'R6', 'R7']) - self.assertEqual(self.valid_origins['R3'], ['R5', 'R6', 'R7']) - self.assertEqual(self.valid_origins['R4'], []) - self.assertEqual(self.valid_origins['R5'], ['R2', 'R3']) - self.assertEqual(self.valid_origins['R6'], ['R2', 'R3']) - self.assertEqual(self.valid_origins['R7'], ['R2', 'R3']) - - def test_topology5_with_asymmetry1(self): - """ - - +----+ +----+ +----+ - | R2 |------| R3 |------| R4 | - +----+ +----+ +----+ - ^ | | - ^ +====+ +----+ +----+ - +-<-<-<--| R1 |------| R5 |------| R6 |------ R7 (no ls from R7) - +====+ +----+ +----+ - - """ - collection = { 'R2': LinkState(None, 'R2', 'area', 1, ['R3']), - 'R3': LinkState(None, 'R3', 'area', 1, ['R1', 'R2', 'R4']), - 'R4': LinkState(None, 'R4', 'area', 1, ['R3', 'R5']), - 'R1': LinkState(None, 'R1', 'area', 1, ['R3', 'R5', 'R2']), - 'R5': LinkState(None, 'R5', 'area', 1, ['R1', 'R4', 'R6']), - 'R6': LinkState(None, 'R6', 'area', 1, ['R5', 'R7']) } - self.engine.ls_collection_changed(collection) - self.engine.tick(1.0) - self.assertEqual(len(self.next_hops), 6) - self.assertEqual(self.next_hops['R2'], 'R2') - self.assertEqual(self.next_hops['R3'], 'R3') - self.assertEqual(self.next_hops['R4'], 'R3') - self.assertEqual(self.next_hops['R5'], 'R5') - self.assertEqual(self.next_hops['R6'], 'R5') - self.assertEqual(self.next_hops['R7'], 'R5') - - self.valid_origins['R2'].sort() - self.valid_origins['R3'].sort() - self.valid_origins['R4'].sort() - self.valid_origins['R5'].sort() - self.valid_origins['R6'].sort() - self.valid_origins['R7'].sort() - self.assertEqual(self.valid_origins['R2'], ['R5', 'R6', 'R7']) - self.assertEqual(self.valid_origins['R3'], ['R5', 'R6', 'R7']) - self.assertEqual(self.valid_origins['R4'], []) - self.assertEqual(self.valid_origins['R5'], ['R2', 'R3']) - self.assertEqual(self.valid_origins['R6'], ['R2', 'R3']) - self.assertEqual(self.valid_origins['R7'], ['R2', 'R3']) - - def test_topology5_with_asymmetry2(self): - """ - - +----+ +----+ +----+ - | R2 |------| R3 |------| R4 | - +----+ +----+ +----+ - v | | - v +====+ +----+ +----+ - +->->->->| R1 |------| R5 |------| R6 |------ R7 (no ls from R7) - +====+ +----+ +----+ - - """ - collection = { 'R2': LinkState(None, 'R2', 'area', 1, ['R3', 'R1']), - 'R3': LinkState(None, 'R3', 'area', 1, ['R1', 'R2', 'R4']), - 'R4': LinkState(None, 'R4', 'area', 1, ['R3', 'R5']), - 'R1': LinkState(None, 'R1', 'area', 1, ['R3', 'R5']), - 'R5': LinkState(None, 'R5', 'area', 1, ['R1', 'R4', 'R6']), - 'R6': LinkState(None, 'R6', 'area', 1, ['R5', 'R7']) } - self.engine.ls_collection_changed(collection) - self.engine.tick(1.0) - self.assertEqual(len(self.next_hops), 6) - self.assertEqual(self.next_hops['R2'], 'R3') - self.assertEqual(self.next_hops['R3'], 'R3') - self.assertEqual(self.next_hops['R4'], 'R3') - self.assertEqual(self.next_hops['R5'], 'R5') - self.assertEqual(self.next_hops['R6'], 'R5') - self.assertEqual(self.next_hops['R7'], 'R5') - - self.valid_origins['R2'].sort() - self.valid_origins['R3'].sort() - self.valid_origins['R4'].sort() - self.valid_origins['R5'].sort() - self.valid_origins['R6'].sort() - self.valid_origins['R7'].sort() - self.assertEqual(self.valid_origins['R2'], ['R5', 'R6', 'R7']) - self.assertEqual(self.valid_origins['R3'], ['R5', 'R6', 'R7']) - self.assertEqual(self.valid_origins['R4'], []) - self.assertEqual(self.valid_origins['R5'], ['R2', 'R3']) - self.assertEqual(self.valid_origins['R6'], ['R2', 'R3']) - self.assertEqual(self.valid_origins['R7'], ['R2', 'R3']) - - def test_topology5_with_asymmetry3(self): - """ - - +----+ +----+ +----+ - | R2 |------| R3 |------| R4 | - +----+ +----+ +----+ - v | | - v +====+ +----+ +----+ - +->->->->| R1 |------| R5 |<-<-<-| R6 |------ R7 (no ls from R7) - +====+ +----+ +----+ - - """ - collection = { 'R2': LinkState(None, 'R2', 'area', 1, ['R3', 'R1']), - 'R3': LinkState(None, 'R3', 'area', 1, ['R1', 'R2', 'R4']), - 'R4': LinkState(None, 'R4', 'area', 1, ['R3', 'R5']), - 'R1': LinkState(None, 'R1', 'area', 1, ['R3', 'R5']), - 'R5': LinkState(None, 'R5', 'area', 1, ['R1', 'R4']), - 'R6': LinkState(None, 'R6', 'area', 1, ['R5', 'R7']) } - self.engine.ls_collection_changed(collection) - self.engine.tick(1.0) - self.assertEqual(len(self.next_hops), 4) - self.assertEqual(self.next_hops['R2'], 'R3') - self.assertEqual(self.next_hops['R3'], 'R3') - self.assertEqual(self.next_hops['R4'], 'R3') - self.assertEqual(self.next_hops['R5'], 'R5') - - self.valid_origins['R2'].sort() - self.valid_origins['R3'].sort() - self.valid_origins['R4'].sort() - self.valid_origins['R5'].sort() - self.assertEqual(self.valid_origins['R2'], ['R5']) - self.assertEqual(self.valid_origins['R3'], ['R5']) - self.assertEqual(self.valid_origins['R4'], []) - self.assertEqual(self.valid_origins['R5'], ['R2', 'R3']) - - -if __name__ == '__main__': - unittest.main() diff --git a/qpid/extras/dispatch/tests/run_unit_tests.c b/qpid/extras/dispatch/tests/run_unit_tests.c deleted file mode 100644 index 2cb75169c1..0000000000 --- a/qpid/extras/dispatch/tests/run_unit_tests.c +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -#include <qpid/dispatch/buffer.h> -#include <stdio.h> - -int tool_tests(); -int timer_tests(); -int alloc_tests(); -int server_tests(); -int parse_tests(); -int compose_tests(); - -int main(int argc, char** argv) -{ - if (argc != 2) { - fprintf(stderr, "usage: %s <config-file>\n", argv[0]); - exit(1); - } - - int result = 0; - result += tool_tests(); - result += timer_tests(); - result += alloc_tests(); - result += server_tests(argv[1]); - result += parse_tests(0); - result += compose_tests(0); - return result; -} - diff --git a/qpid/extras/dispatch/tests/run_unit_tests_size.c b/qpid/extras/dispatch/tests/run_unit_tests_size.c deleted file mode 100644 index 1c6a78c38a..0000000000 --- a/qpid/extras/dispatch/tests/run_unit_tests_size.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -#include <qpid/dispatch/buffer.h> -#include "alloc_private.h" - -int message_tests(); -int field_tests(); - -int main(int argc, char** argv) -{ - ssize_t buffer_size = 512; - - if (argc > 1) { - buffer_size = atoi(argv[1]); - if (buffer_size < 1) - return 1; - } - - dx_alloc_initialize(); - dx_buffer_set_size(buffer_size); - - int result = 0; - result += message_tests(); - result += field_tests(); - return result; -} - diff --git a/qpid/extras/dispatch/tests/server_test.c b/qpid/extras/dispatch/tests/server_test.c deleted file mode 100644 index 525d8b6a9f..0000000000 --- a/qpid/extras/dispatch/tests/server_test.c +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -#define _GNU_SOURCE -#include <stdio.h> -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> -#include <assert.h> -#include "test_case.h" -#include <qpid/dispatch.h> - -#define THREAD_COUNT 4 -#define OCTET_COUNT 100 - -static const char *config_file; -static dx_dispatch_t *dx; -static sys_mutex_t *test_lock; - -static void *expected_context; -static int call_count; -static int threads_seen[THREAD_COUNT]; -static char stored_error[512]; - -static int write_count; -static int read_count; -static int fd[2]; -static dx_user_fd_t *ufd_write; -static dx_user_fd_t *ufd_read; - - -static void thread_start_handler(void *context, int thread_id) -{ - sys_mutex_lock(test_lock); - if (context != expected_context && !stored_error[0]) - sprintf(stored_error, "Unexpected Context Value: %lx", (long) context); - if (thread_id >= THREAD_COUNT && !stored_error[0]) - sprintf(stored_error, "Thread_ID too large: %d", thread_id); - if (thread_id < 0 && !stored_error[0]) - sprintf(stored_error, "Thread_ID negative: %d", thread_id); - - call_count++; - if (thread_id >= 0 && thread_id < THREAD_COUNT) - threads_seen[thread_id]++; - - if (call_count == THREAD_COUNT) - dx_server_stop(dx); - sys_mutex_unlock(test_lock); -} - - -static void ufd_handler(void *context, dx_user_fd_t *ufd) -{ - long dir = (long) context; - char buffer; - ssize_t len; - static int in_read = 0; - static int in_write = 0; - - if (dir == 0) { // READ - in_read++; - assert(in_read == 1); - if (!dx_user_fd_is_readable(ufd_read)) { - sprintf(stored_error, "Expected Readable"); - dx_server_stop(dx); - } else { - len = read(fd[0], &buffer, 1); - if (len == 1) { - read_count++; - if (read_count == OCTET_COUNT) - dx_server_stop(dx); - } - dx_user_fd_activate_read(ufd_read); - } - in_read--; - } else { // WRITE - in_write++; - assert(in_write == 1); - if (!dx_user_fd_is_writeable(ufd_write)) { - sprintf(stored_error, "Expected Writable"); - dx_server_stop(dx); - } else { - write(fd[1], "X", 1); - - write_count++; - if (write_count < OCTET_COUNT) - dx_user_fd_activate_write(ufd_write); - } - in_write--; - } -} - - -static void fd_test_start(void *context) -{ - dx_user_fd_activate_read(ufd_read); -} - - -static char* test_start_handler(void *context) -{ - int i; - - dx = dx_dispatch(config_file); - - expected_context = (void*) 0x00112233; - stored_error[0] = 0x0; - call_count = 0; - for (i = 0; i < THREAD_COUNT; i++) - threads_seen[i] = 0; - - dx_server_set_start_handler(dx, thread_start_handler, expected_context); - dx_server_run(dx); - dx_dispatch_free(dx); - - if (stored_error[0]) return stored_error; - if (call_count != THREAD_COUNT) return "Incorrect number of thread-start callbacks"; - for (i = 0; i < THREAD_COUNT; i++) - if (threads_seen[i] != 1) return "Incorrect count on one thread ID"; - - return 0; -} - - -static char *test_server_start(void *context) -{ - dx = dx_dispatch(config_file); - dx_server_start(dx); - dx_server_stop(dx); - dx_dispatch_free(dx); - - return 0; -} - - -static char* test_user_fd(void *context) -{ - int res; - dx_timer_t *timer; - - dx = dx_dispatch(config_file); - dx_server_set_user_fd_handler(dx, ufd_handler); - timer = dx_timer(dx, fd_test_start, 0); - dx_timer_schedule(timer, 0); - - stored_error[0] = 0x0; - - res = pipe(fd); // Don't use pipe2 because it's not available on RHEL5 - if (res != 0) return "Error creating pipe2"; - - for (int i = 0; i < 2; i++) { - int flags = fcntl(fd[i], F_GETFL); - flags |= O_NONBLOCK; - if (fcntl(fd[i], F_SETFL, flags) < 0) { - perror("fcntl"); - return "Failed to set socket to non-blocking"; - } - } - - ufd_write = dx_user_fd(dx, fd[1], (void*) 1); - ufd_read = dx_user_fd(dx, fd[0], (void*) 0); - - dx_server_run(dx); - dx_timer_free(timer); - dx_dispatch_free(dx); - close(fd[0]); - close(fd[1]); - - if (stored_error[0]) return stored_error; - if (write_count - OCTET_COUNT > 2) sprintf(stored_error, "Excessively high Write Count: %d", write_count); - if (read_count != OCTET_COUNT) sprintf(stored_error, "Incorrect Read Count: %d", read_count);; - - if (stored_error[0]) return stored_error; - return 0; -} - - -int server_tests(const char *_config_file) -{ - int result = 0; - test_lock = sys_mutex(); - dx_log_set_mask(LOG_NONE); - - config_file = _config_file; - - TEST_CASE(test_server_start, 0); - TEST_CASE(test_start_handler, 0); - TEST_CASE(test_user_fd, 0); - - sys_mutex_free(test_lock); - return result; -} - diff --git a/qpid/extras/dispatch/tests/system_tests_one_router.py b/qpid/extras/dispatch/tests/system_tests_one_router.py deleted file mode 100644 index 59e2569eff..0000000000 --- a/qpid/extras/dispatch/tests/system_tests_one_router.py +++ /dev/null @@ -1,452 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you 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. -# - -import os -import time -import unittest -import subprocess -from proton import Messenger, Message, PENDING, ACCEPTED, REJECTED - -class RouterTest(unittest.TestCase): - - def setUp(self): - if 'CTEST_SOURCE_DIR' not in os.environ: - raise Exception("Environment variable 'CTEST_SOURCE_DIR' not set") - srcdir = os.environ['CTEST_SOURCE_DIR'] - self.router = subprocess.Popen(['../router/dispatch-router', '-c', '%s/config-1/A.conf' % srcdir], - stderr=subprocess.PIPE, stdout=subprocess.PIPE) - time.sleep(1) - - def tearDown(self): - self.router.terminate() - self.router.wait() - - def flush(self, messenger): - while messenger.work(0.1): - pass - - def subscribe(self, messenger, address): - messenger.subscribe(address) - self.flush(messenger) - - - def test_0_discard(self): - addr = "amqp://0.0.0.0:20000/discard/1" - M1 = Messenger() - M1.timeout = 1.0 - M1.start() - tm = Message() - tm.address = addr - for i in range(100): - tm.body = {'number': i} - M1.put(tm) - M1.send() - M1.stop() - - - def test_1_pre_settled(self): - addr = "amqp://0.0.0.0:20000/pre_settled/1" - M1 = Messenger() - M2 = Messenger() - - M1.timeout = 1.0 - M2.timeout = 1.0 - - M1.start() - M2.start() - self.subscribe(M2, addr) - - tm = Message() - rm = Message() - - tm.address = addr - for i in range(100): - tm.body = {'number': i} - M1.put(tm) - M1.send() - - for i in range(100): - M2.recv(1) - M2.get(rm) - self.assertEqual(i, rm.body['number']) - - M1.stop() - M2.stop() - - - def test_2_multicast(self): - addr = "amqp://0.0.0.0:20000/pre_settled/multicast/1" - M1 = Messenger() - M2 = Messenger() - M3 = Messenger() - M4 = Messenger() - - M1.timeout = 1.0 - M2.timeout = 1.0 - M3.timeout = 1.0 - M4.timeout = 1.0 - - M1.start() - M2.start() - M3.start() - M4.start() - self.subscribe(M2, addr) - self.subscribe(M3, addr) - self.subscribe(M4, addr) - - tm = Message() - rm = Message() - - tm.address = addr - for i in range(100): - tm.body = {'number': i} - M1.put(tm) - M1.send() - - for i in range(100): - M2.recv(1) - M2.get(rm) - self.assertEqual(i, rm.body['number']) - - M3.recv(1) - M3.get(rm) - self.assertEqual(i, rm.body['number']) - - M4.recv(1) - M4.get(rm) - self.assertEqual(i, rm.body['number']) - - M1.stop() - M2.stop() - M3.stop() - M4.stop() - - - def test_2a_multicast_unsettled(self): - addr = "amqp://0.0.0.0:20000/pre_settled/multicast/1" - M1 = Messenger() - M2 = Messenger() - M3 = Messenger() - M4 = Messenger() - - M1.timeout = 1.0 - M2.timeout = 1.0 - M3.timeout = 1.0 - M4.timeout = 1.0 - - M1.outgoing_window = 5 - M2.incoming_window = 5 - M3.incoming_window = 5 - M4.incoming_window = 5 - - M1.start() - M2.start() - M3.start() - M4.start() - self.subscribe(M2, addr) - self.subscribe(M3, addr) - self.subscribe(M4, addr) - - tm = Message() - rm = Message() - - tm.address = addr - for i in range(2): - tm.body = {'number': i} - M1.put(tm) - M1.send(0) - - for i in range(2): - M2.recv(1) - trk = M2.get(rm) - M2.accept(trk) - M2.settle(trk) - self.assertEqual(i, rm.body['number']) - - M3.recv(1) - trk = M3.get(rm) - M3.accept(trk) - M3.settle(trk) - self.assertEqual(i, rm.body['number']) - - M4.recv(1) - trk = M4.get(rm) - M4.accept(trk) - M4.settle(trk) - self.assertEqual(i, rm.body['number']) - - M1.stop() - M2.stop() - M3.stop() - M4.stop() - - - def test_3_propagated_disposition(self): - addr = "amqp://0.0.0.0:20000/unsettled/1" - M1 = Messenger() - M2 = Messenger() - - M1.timeout = 1.0 - M2.timeout = 1.0 - M1.outgoing_window = 5 - M2.incoming_window = 5 - - M1.start() - M2.start() - self.subscribe(M2, addr) - - tm = Message() - rm = Message() - - tm.address = addr - tm.body = {'number': 0} - - ## - ## Test ACCEPT - ## - tx_tracker = M1.put(tm) - M1.send(0) - M2.recv(1) - rx_tracker = M2.get(rm) - self.assertEqual(0, rm.body['number']) - self.assertEqual(PENDING, M1.status(tx_tracker)) - - M2.accept(rx_tracker) - M2.settle(rx_tracker) - - self.flush(M2) - self.flush(M1) - - self.assertEqual(ACCEPTED, M1.status(tx_tracker)) - - ## - ## Test REJECT - ## - tx_tracker = M1.put(tm) - M1.send(0) - M2.recv(1) - rx_tracker = M2.get(rm) - self.assertEqual(0, rm.body['number']) - self.assertEqual(PENDING, M1.status(tx_tracker)) - - M2.reject(rx_tracker) - M2.settle(rx_tracker) - - self.flush(M2) - self.flush(M1) - - self.assertEqual(REJECTED, M1.status(tx_tracker)) - - M1.stop() - M2.stop() - - - def test_4_unsettled_undeliverable(self): - addr = "amqp://0.0.0.0:20000/unsettled_undeliverable/1" - M1 = Messenger() - - M1.timeout = 1.0 - M1.outgoing_window = 5 - - M1.start() - tm = Message() - tm.address = addr - tm.body = {'number': 200} - - tx_tracker = M1.put(tm) - M1.send(0) - self.flush(M1) - self.assertEqual(PENDING, M1.status(tx_tracker)) ## Is this right??? - - M1.stop() - - - def test_5_three_ack(self): - addr = "amqp://0.0.0.0:20000/three_ack/1" - M1 = Messenger() - M2 = Messenger() - - M1.timeout = 1.0 - M2.timeout = 1.0 - M1.outgoing_window = 5 - M2.incoming_window = 5 - - M1.start() - M2.start() - self.subscribe(M2, addr) - - tm = Message() - rm = Message() - - tm.address = addr - tm.body = {'number': 200} - - tx_tracker = M1.put(tm) - M1.send(0) - M2.recv(1) - rx_tracker = M2.get(rm) - self.assertEqual(200, rm.body['number']) - self.assertEqual(PENDING, M1.status(tx_tracker)) - - M2.accept(rx_tracker) - - self.flush(M2) - self.flush(M1) - - self.assertEqual(ACCEPTED, M1.status(tx_tracker)) - - M1.settle(tx_tracker) - - self.flush(M1) - self.flush(M2) - - ## - ## We need a way to verify on M2 (receiver) that the tracker has been - ## settled on the M1 (sender). [ See PROTON-395 ] - ## - - M2.settle(rx_tracker) - - self.flush(M2) - self.flush(M1) - - M1.stop() - M2.stop() - - -# def test_6_link_route_sender(self): -# pass - -# def test_7_link_route_receiver(self): -# pass - - - def test_8_delivery_annotations(self): - addr = "amqp://0.0.0.0:20000/da/1" - M1 = Messenger() - M2 = Messenger() - - M1.timeout = 1.0 - M2.timeout = 1.0 - - M1.start() - M2.start() - self.subscribe(M2, addr) - - tm = Message() - rm = Message() - - tm.address = addr - - - ## - ## No inbound delivery annotations - ## - for i in range(10): - tm.body = {'number': i} - M1.put(tm) - M1.send() - - for i in range(10): - M2.recv(1) - M2.get(rm) - self.assertEqual(i, rm.body['number']) - da = rm.instructions - self.assertEqual(da.__class__, dict) - self.assertEqual(da['qdx.ingress'], '0/Qpid.Dispatch.Router.A') - self.assertEqual(da['qdx.trace'], ['0/Qpid.Dispatch.Router.A']) - - ## - ## Pre-existing ingress - ## - tm.instructions = {'qdx.ingress': 'ingress-router'} - for i in range(10): - tm.body = {'number': i} - M1.put(tm) - M1.send() - - for i in range(10): - M2.recv(1) - M2.get(rm) - self.assertEqual(i, rm.body['number']) - da = rm.instructions - self.assertEqual(da.__class__, dict) - self.assertEqual(da['qdx.ingress'], 'ingress-router') - self.assertEqual(da['qdx.trace'], ['0/Qpid.Dispatch.Router.A']) - - ## - ## Invalid trace type - ## - tm.instructions = {'qdx.trace' : 45} - for i in range(10): - tm.body = {'number': i} - M1.put(tm) - M1.send() - - for i in range(10): - M2.recv(1) - M2.get(rm) - self.assertEqual(i, rm.body['number']) - da = rm.instructions - self.assertEqual(da.__class__, dict) - self.assertEqual(da['qdx.ingress'], '0/Qpid.Dispatch.Router.A') - self.assertEqual(da['qdx.trace'], ['0/Qpid.Dispatch.Router.A']) - - ## - ## Empty trace - ## - tm.instructions = {'qdx.trace' : []} - for i in range(10): - tm.body = {'number': i} - M1.put(tm) - M1.send() - - for i in range(10): - M2.recv(1) - M2.get(rm) - self.assertEqual(i, rm.body['number']) - da = rm.instructions - self.assertEqual(da.__class__, dict) - self.assertEqual(da['qdx.ingress'], '0/Qpid.Dispatch.Router.A') - self.assertEqual(da['qdx.trace'], ['0/Qpid.Dispatch.Router.A']) - - ## - ## Non-empty trace - ## - tm.instructions = {'qdx.trace' : ['0/first.hop']} - for i in range(10): - tm.body = {'number': i} - M1.put(tm) - M1.send() - - for i in range(10): - M2.recv(1) - M2.get(rm) - self.assertEqual(i, rm.body['number']) - da = rm.instructions - self.assertEqual(da.__class__, dict) - self.assertEqual(da['qdx.ingress'], '0/Qpid.Dispatch.Router.A') - self.assertEqual(da['qdx.trace'], ['0/first.hop', '0/Qpid.Dispatch.Router.A']) - - M1.stop() - M2.stop() - - -if __name__ == '__main__': - unittest.main() diff --git a/qpid/extras/dispatch/tests/test_case.h b/qpid/extras/dispatch/tests/test_case.h deleted file mode 100644 index 6e36b440a5..0000000000 --- a/qpid/extras/dispatch/tests/test_case.h +++ /dev/null @@ -1,36 +0,0 @@ -#ifndef _nexus_test_case_h_ -#define _nexus_test_case_h_ 1 -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -typedef char* (*testcase_t)(void *context); - -#define TEST_CASE(T,C) do { \ - char *r = T(C); \ - printf("Test Case %s.%s: ", __FUNCTION__, #T); \ - if (r) { \ - printf("FAIL: %s\n", r); \ - result++; \ - } else \ - printf("PASS\n"); \ -} while(0); - - -#endif - diff --git a/qpid/extras/dispatch/tests/threads4.conf b/qpid/extras/dispatch/tests/threads4.conf deleted file mode 100644 index 1466e11cca..0000000000 --- a/qpid/extras/dispatch/tests/threads4.conf +++ /dev/null @@ -1,26 +0,0 @@ -## -## Licensed to the Apache Software Foundation (ASF) under one -## or more contributor license agreements. See the NOTICE file -## distributed with this work for additional information -## regarding copyright ownership. The ASF licenses this file -## to you 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 -## - - -## -## Container section - Configures the general operation of the AMQP container. -## -container { - worker-threads: 4 -} diff --git a/qpid/extras/dispatch/tests/timer_test.c b/qpid/extras/dispatch/tests/timer_test.c deleted file mode 100644 index 93725dde4b..0000000000 --- a/qpid/extras/dispatch/tests/timer_test.c +++ /dev/null @@ -1,413 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -#include <stdio.h> -#include <qpid/dispatch/timer.h> -#include "alloc_private.h" -#include "timer_private.h" -#include "test_case.h" -#include <qpid/dispatch/threading.h> - - -static unsigned long fire_mask; -static dx_timer_list_t pending_timers; -static sys_mutex_t *lock; -static long time; -static dx_timer_t *timers[16]; - - -void dx_server_timer_pending_LH(dx_timer_t *timer) -{ - DEQ_INSERT_TAIL(pending_timers, timer); -} - - -void dx_server_timer_cancel_LH(dx_timer_t *timer) -{ - if (timer->state == TIMER_PENDING) - DEQ_REMOVE(pending_timers, timer); -} - - -static int fire_head() -{ - sys_mutex_lock(lock); - int result = DEQ_SIZE(pending_timers); - dx_timer_t *timer = DEQ_HEAD(pending_timers); - if (timer) { - DEQ_REMOVE_HEAD(pending_timers); - dx_timer_idle_LH(timer); - fire_mask |= (unsigned long) timer->context; - } - sys_mutex_unlock(lock); - return result; -} - - -static char* test_quiet(void *context) -{ - fire_mask = 0; - - sys_mutex_lock(lock); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - sys_mutex_unlock(lock); - - while(fire_head()); - - if (fire_mask != 0) - return "Expected zero timers fired"; - return 0; -} - -static char* test_immediate(void *context) -{ - while(fire_head()); - fire_mask = 0; - - dx_timer_schedule(timers[0], 0); - - if (fire_mask != 0) return "Premature firing"; - if (fire_head() > 1) return "Too many firings"; - if (fire_mask != 1) return "Incorrect fire mask"; - - return 0; -} - - -static char* test_immediate_reschedule(void *context) -{ - while(fire_head()); - fire_mask = 0; - - dx_timer_schedule(timers[0], 0); - dx_timer_schedule(timers[0], 0); - - if (fire_mask != 0) return "pass 1 - Premature firing"; - if (fire_head() > 1) return "pass 1 - Too many firings"; - if (fire_mask != 1) return "pass 1 - Incorrect fire mask"; - - fire_mask = 0; - dx_timer_schedule(timers[0], 0); - dx_timer_schedule(timers[0], 0); - - if (fire_mask != 0) return "pass 2 - Premature firing"; - if (fire_head() > 1) return "pass 2 - Too many firings"; - if (fire_mask != 1) return "pass 2 - Incorrect fire mask"; - - return 0; -} - - -static char* test_immediate_plus_delayed(void *context) -{ - while(fire_head()); - fire_mask = 0; - - dx_timer_schedule(timers[0], 0); - dx_timer_schedule(timers[1], 5); - - if (fire_mask != 0) return "Premature firing"; - if (fire_head() > 1) return "Too many firings"; - if (fire_mask != 1) return "Incorrect fire mask 1"; - - sys_mutex_lock(lock); - dx_timer_visit_LH(time++); - time += 8; - dx_timer_visit_LH(time++); - sys_mutex_unlock(lock); - - if (fire_head() < 1) return "Delayed Failed to fire"; - if (fire_mask != 3) return "Incorrect fire mask 3"; - - return 0; -} - - -static char* test_single(void *context) -{ - while(fire_head()); - fire_mask = 0; - - dx_timer_schedule(timers[0], 2); - if (fire_head() > 0) return "Premature firing 1"; - - sys_mutex_lock(lock); - dx_timer_visit_LH(time++); - sys_mutex_unlock(lock); - if (fire_head() > 0) return "Premature firing 2"; - - sys_mutex_lock(lock); - dx_timer_visit_LH(time++); - sys_mutex_unlock(lock); - if (fire_head() < 1) return "Failed to fire"; - - sys_mutex_lock(lock); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - sys_mutex_unlock(lock); - if (fire_head() != 0) return "Spurious fires"; - - if (fire_mask != 1) return "Incorrect fire mask"; - if (timers[0]->state != TIMER_IDLE) return "Expected idle timer state"; - - return 0; -} - - -static char* test_two_inorder(void *context) -{ - while(fire_head()); - fire_mask = 0; - - dx_timer_schedule(timers[0], 2); - dx_timer_schedule(timers[1], 4); - - sys_mutex_lock(lock); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - sys_mutex_unlock(lock); - int count = fire_head(); - if (count < 1) return "First failed to fire"; - if (count > 1) return "Second fired prematurely"; - if (fire_mask != 1) return "Incorrect fire mask 1"; - - sys_mutex_lock(lock); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - sys_mutex_unlock(lock); - if (fire_head() < 1) return "Second failed to fire"; - if (fire_mask != 3) return "Incorrect fire mask 3"; - - return 0; -} - - -static char* test_two_reverse(void *context) -{ - while(fire_head()); - fire_mask = 0; - - dx_timer_schedule(timers[0], 4); - dx_timer_schedule(timers[1], 2); - - sys_mutex_lock(lock); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - sys_mutex_unlock(lock); - int count = fire_head(); - if (count < 1) return "First failed to fire"; - if (count > 1) return "Second fired prematurely"; - if (fire_mask != 2) return "Incorrect fire mask 2"; - - sys_mutex_lock(lock); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - sys_mutex_unlock(lock); - if (fire_head() < 1) return "Second failed to fire"; - if (fire_mask != 3) return "Incorrect fire mask 3"; - - return 0; -} - - -static char* test_two_duplicate(void *context) -{ - while(fire_head()); - fire_mask = 0; - - dx_timer_schedule(timers[0], 2); - dx_timer_schedule(timers[1], 2); - - sys_mutex_lock(lock); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - sys_mutex_unlock(lock); - int count = fire_head(); - if (count != 2) return "Expected two firings"; - fire_head(); - if (fire_mask != 3) return "Incorrect fire mask 3"; - - sys_mutex_lock(lock); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - sys_mutex_unlock(lock); - if (fire_head() > 0) return "Spurious timer fires"; - - return 0; -} - - -static char* test_separated(void *context) -{ - int count; - - while(fire_head()); - fire_mask = 0; - - dx_timer_schedule(timers[0], 2); - dx_timer_schedule(timers[1], 4); - - sys_mutex_lock(lock); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - sys_mutex_unlock(lock); - count = fire_head(); - if (count < 1) return "First failed to fire"; - if (count > 1) return "Second fired prematurely"; - if (fire_mask != 1) return "Incorrect fire mask 1"; - - dx_timer_schedule(timers[2], 2); - dx_timer_schedule(timers[3], 4); - - sys_mutex_lock(lock); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - sys_mutex_unlock(lock); - count = fire_head(); - fire_head(); - if (count < 1) return "Second failed to fire"; - if (count < 2) return "Third failed to fire"; - if (fire_mask != 7) return "Incorrect fire mask 7"; - - sys_mutex_lock(lock); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - sys_mutex_unlock(lock); - count = fire_head(); - if (count < 1) return "Fourth failed to fire"; - if (fire_mask != 15) return "Incorrect fire mask 15"; - - sys_mutex_lock(lock); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - dx_timer_visit_LH(time++); - sys_mutex_unlock(lock); - count = fire_head(); - if (count > 0) return "Spurious fire"; - - return 0; -} - - -static char* test_big(void *context) -{ - while(fire_head()); - fire_mask = 0; - - long durations[16] = - { 5, 8, 7, 6, - 14, 10, 16, 15, - 11, 12, 9, 12, - 1, 2, 3, 4}; - unsigned long masks[18] = { - 0x1000, - 0x3000, - 0x7000, - 0xf000, - 0xf001, - 0xf009, - 0xf00d, - 0xf00f, - 0xf40f, - 0xf42f, - 0xf52f, - 0xff2f, - 0xff2f, - 0xff3f, - 0xffbf, - 0xffff, - 0xffff, - 0xffff - }; - - int i; - for (i = 0; i < 16; i++) - dx_timer_schedule(timers[i], durations[i]); - for (i = 0; i < 18; i++) { - sys_mutex_lock(lock); - dx_timer_visit_LH(time++); - sys_mutex_unlock(lock); - while(fire_head()); - if (fire_mask != masks[i]) { - static char error[100]; - sprintf(error, "Iteration %d: expected mask %04lx, got %04lx", i, masks[i], fire_mask); - return error; - } - } - - return 0; -} - - -int timer_tests(void) -{ - int result = 0; - dx_alloc_initialize(); - - fire_mask = 0; - DEQ_INIT(pending_timers); - lock = sys_mutex(); - dx_timer_initialize(lock); - time = 1; - - timers[0] = dx_timer(0, 0, (void*) 0x00000001); - timers[1] = dx_timer(0, 0, (void*) 0x00000002); - timers[2] = dx_timer(0, 0, (void*) 0x00000004); - timers[3] = dx_timer(0, 0, (void*) 0x00000008); - timers[4] = dx_timer(0, 0, (void*) 0x00000010); - timers[5] = dx_timer(0, 0, (void*) 0x00000020); - timers[6] = dx_timer(0, 0, (void*) 0x00000040); - timers[7] = dx_timer(0, 0, (void*) 0x00000080); - timers[8] = dx_timer(0, 0, (void*) 0x00000100); - timers[9] = dx_timer(0, 0, (void*) 0x00000200); - timers[10] = dx_timer(0, 0, (void*) 0x00000400); - timers[11] = dx_timer(0, 0, (void*) 0x00000800); - timers[12] = dx_timer(0, 0, (void*) 0x00001000); - timers[13] = dx_timer(0, 0, (void*) 0x00002000); - timers[14] = dx_timer(0, 0, (void*) 0x00004000); - timers[15] = dx_timer(0, 0, (void*) 0x00008000); - - TEST_CASE(test_quiet, 0); - TEST_CASE(test_immediate, 0); - TEST_CASE(test_immediate_reschedule, 0); - TEST_CASE(test_immediate_plus_delayed, 0); - TEST_CASE(test_single, 0); - TEST_CASE(test_two_inorder, 0); - TEST_CASE(test_two_reverse, 0); - TEST_CASE(test_two_duplicate, 0); - TEST_CASE(test_separated, 0); - TEST_CASE(test_big, 0); - - int i; - for (i = 0; i < 16; i++) - dx_timer_free(timers[i]); - - dx_timer_finalize(); - - return result; -} - diff --git a/qpid/extras/dispatch/tests/tool_test.c b/qpid/extras/dispatch/tests/tool_test.c deleted file mode 100644 index 2c90714b3d..0000000000 --- a/qpid/extras/dispatch/tests/tool_test.c +++ /dev/null @@ -1,233 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you 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. - */ - -#include "test_case.h" -#include <stdio.h> -#include <string.h> -#include <qpid/dispatch/ctools.h> -#include <qpid/dispatch/bitmask.h> -#include "alloc_private.h" - -typedef struct item_t { - DEQ_LINKS(struct item_t); - char letter; -} item_t; - -DEQ_DECLARE(item_t, item_list_t); - - -static char* list_well_formed(item_list_t list, char *key) -{ - item_t *ptr; - item_t *last = 0; - int size = DEQ_SIZE(list); - int count = 0; - char str[32]; - - ptr = DEQ_HEAD(list); - while (ptr) { - str[count] = ptr->letter; - count++; - if (DEQ_PREV(ptr) != last) return "Corrupt previous link"; - last = ptr; - ptr = DEQ_NEXT(ptr); - } - str[count] = '\0'; - if (strcmp(str, key) != 0) return "Invalid key"; - - if (count != size) return "Size different from number of items (forward)"; - - count = 0; - last = 0; - ptr = DEQ_TAIL(list); - while (ptr) { - count++; - if (DEQ_NEXT(ptr) != last) return "Corrupt next link"; - last = ptr; - ptr = DEQ_PREV(ptr); - } - - if (count != size) return "Size different from number of items (backward)"; - - return 0; -} - - -static char* test_deq_basic(void *context) -{ - item_list_t list; - item_t item[10]; - item_t *ptr; - int idx; - char *subtest; - - DEQ_INIT(list); - if (DEQ_SIZE(list) != 0) return "Expected zero initial size"; - - for (idx = 0; idx < 10; idx++) { - DEQ_ITEM_INIT(&item[idx]); - item[idx].letter = 'A' + idx; - DEQ_INSERT_TAIL(list, &item[idx]); - } - if (DEQ_SIZE(list) != 10) return "Expected 10 items in list"; - - ptr = DEQ_HEAD(list); - if (!ptr) return "Expected valid head item"; - if (DEQ_PREV(ptr)) return "Head item has non-null previous link"; - if (ptr->letter != 'A') return "Expected item A at the head"; - if (DEQ_NEXT(ptr) == 0) return "Head item has null next link"; - subtest = list_well_formed(list, "ABCDEFGHIJ"); - if (subtest) return subtest; - - DEQ_REMOVE_HEAD(list); - if (DEQ_SIZE(list) != 9) return "Expected 9 items in list"; - ptr = DEQ_HEAD(list); - if (ptr->letter != 'B') return "Expected item B at the head"; - subtest = list_well_formed(list, "BCDEFGHIJ"); - if (subtest) return subtest; - - DEQ_REMOVE_TAIL(list); - if (DEQ_SIZE(list) != 8) return "Expected 8 items in list"; - ptr = DEQ_TAIL(list); - if (ptr->letter != 'I') return "Expected item I at the tail"; - subtest = list_well_formed(list, "BCDEFGHI"); - if (subtest) return subtest; - - DEQ_REMOVE(list, &item[4]); - if (DEQ_SIZE(list) != 7) return "Expected 7 items in list"; - subtest = list_well_formed(list, "BCDFGHI"); - if (subtest) return subtest; - - DEQ_REMOVE(list, &item[1]); - if (DEQ_SIZE(list) != 6) return "Expected 6 items in list"; - subtest = list_well_formed(list, "CDFGHI"); - if (subtest) return subtest; - - DEQ_REMOVE(list, &item[8]); - if (DEQ_SIZE(list) != 5) return "Expected 5 items in list"; - subtest = list_well_formed(list, "CDFGH"); - if (subtest) return subtest; - - DEQ_INSERT_HEAD(list, &item[8]); - if (DEQ_SIZE(list) != 6) return "Expected 6 items in list"; - ptr = DEQ_HEAD(list); - if (ptr->letter != 'I') return "Expected item I at the head"; - subtest = list_well_formed(list, "ICDFGH"); - if (subtest) return subtest; - - DEQ_INSERT_AFTER(list, &item[4], &item[7]); - if (DEQ_SIZE(list) != 7) return "Expected 7 items in list"; - ptr = DEQ_TAIL(list); - if (ptr->letter != 'E') return "Expected item E at the head"; - subtest = list_well_formed(list, "ICDFGHE"); - if (subtest) return subtest; - - DEQ_INSERT_AFTER(list, &item[1], &item[5]); - if (DEQ_SIZE(list) != 8) return "Expected 8 items in list"; - subtest = list_well_formed(list, "ICDFBGHE"); - if (subtest) return subtest; - - if (item[0].prev || item[0].next) return "Unlisted item A has non-null pointers"; - if (item[9].prev || item[9].next) return "Unlisted item J has non-null pointers"; - - return 0; -} - - -static char* test_deq_basic2(void *context) -{ - item_list_t list; - item_t item[10]; - item_t *ptr; - int idx; - char *subtest; - - DEQ_INIT(list); - if (DEQ_SIZE(list) != 0) return "Expected zero initial size"; - - for (idx = 0; idx < 10; idx++) { - DEQ_ITEM_INIT(&item[idx]); - item[idx].letter = '0' + idx; - } - - DEQ_INSERT_TAIL(list, &item[0]); - if (DEQ_SIZE(list) != 1) return "Expected 1 items in list"; - subtest = list_well_formed(list, "0"); - if (subtest) return subtest; - - ptr = DEQ_HEAD(list); - DEQ_REMOVE_HEAD(list); - if (ptr->letter != '0') return "Expected item '0'"; - if (DEQ_SIZE(list) != 0) return "Expected 0 items in list"; - - DEQ_INSERT_TAIL(list, &item[0]); - if (DEQ_SIZE(list) != 1) return "Expected 1 items in list"; - subtest = list_well_formed(list, "0"); - if (subtest) return subtest; - - ptr = DEQ_HEAD(list); - DEQ_REMOVE_HEAD(list); - if (ptr->letter != '0') return "Expected item '0'"; - if (DEQ_SIZE(list) != 0) return "Expected 0 items in list"; - - return 0; -} - - -static char* test_bitmask(void *context) -{ - dx_bitmask_t *bm; - int num; - - bm = dx_bitmask(0); - if (!bm) return "Can't allocate a bit mask"; - if (dx_bitmask_first_set(bm, &num)) return "Expected no first set bit"; - - dx_bitmask_set_bit(bm, 3); - dx_bitmask_set_bit(bm, 500); - - if (!dx_bitmask_first_set(bm, &num)) return "Expected first set bit"; - if (num != 3) return "Expected first set bit to be 3"; - - dx_bitmask_clear_bit(bm, num); - - if (!dx_bitmask_first_set(bm, &num)) return "Expected first set bit (2)"; - if (num != 500) return "Expected first set bit to be 500"; - - dx_bitmask_clear_bit(bm, num); - if (dx_bitmask_first_set(bm, &num)) return "Expected no first set bit (2)"; - - dx_bitmask_free(bm); - - return 0; -} - - -int tool_tests(void) -{ - int result = 0; - dx_alloc_initialize(); - - TEST_CASE(test_deq_basic, 0); - TEST_CASE(test_deq_basic2, 0); - TEST_CASE(test_bitmask, 0); - - return result; -} - |
