You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@guacamole.apache.org by vn...@apache.org on 2019/01/07 00:43:36 UTC
[5/7] guacamole-server git commit: GUACAMOLE-662: Migrate tests to
test runners generated by new convenience script. Remove unnecessary test
runners.
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/client/client_suite.h
----------------------------------------------------------------------
diff --git a/tests/client/client_suite.h b/tests/client/client_suite.h
deleted file mode 100644
index da1bc22..0000000
--- a/tests/client/client_suite.h
+++ /dev/null
@@ -1,32 +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.
- */
-
-
-#ifndef _GUAC_TEST_CLIENT_SUITE_H
-#define _GUAC_TEST_CLIENT_SUITE_H
-
-#include "config.h"
-
-int register_client_suite();
-
-void test_layer_pool();
-void test_buffer_pool();
-
-#endif
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/client/layer_pool.c
----------------------------------------------------------------------
diff --git a/tests/client/layer_pool.c b/tests/client/layer_pool.c
deleted file mode 100644
index 8b61c86..0000000
--- a/tests/client/layer_pool.c
+++ /dev/null
@@ -1,73 +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 "config.h"
-
-#include "client_suite.h"
-
-#include <CUnit/Basic.h>
-#include <guacamole/client.h>
-#include <guacamole/layer.h>
-
-void test_layer_pool() {
-
- guac_client* client;
-
- int i;
- int seen[GUAC_BUFFER_POOL_INITIAL_SIZE] = {0};
-
- guac_layer* layer;
-
- /* Get client */
- client = guac_client_alloc();
- CU_ASSERT_PTR_NOT_NULL_FATAL(client);
-
- /* Fill pool */
- for (i=0; i<GUAC_BUFFER_POOL_INITIAL_SIZE; i++) {
-
- /* Allocate and throw away a buffer (should not disturb layer alloc) */
- CU_ASSERT_PTR_NOT_NULL_FATAL(guac_client_alloc_buffer(client));
-
- layer = guac_client_alloc_layer(client);
-
- /* Index should be within pool size */
- CU_ASSERT_PTR_NOT_NULL_FATAL(layer);
- CU_ASSERT_FATAL(layer->index > 0);
- CU_ASSERT_FATAL(layer->index <= GUAC_BUFFER_POOL_INITIAL_SIZE);
-
- /* This should be a layer we have not seen yet */
- CU_ASSERT_FALSE(seen[layer->index - 1]);
- seen[layer->index - 1] = 1;
-
- guac_client_free_layer(client, layer);
-
- }
-
- /* Now that pool is filled, we should get a previously seen layer */
- layer = guac_client_alloc_layer(client);
-
- CU_ASSERT_FATAL(layer->index > 0);
- CU_ASSERT_FATAL(layer->index <= GUAC_BUFFER_POOL_INITIAL_SIZE);
- CU_ASSERT_TRUE(seen[layer->index - 1]);
-
- /* Free client */
- guac_client_free(client);
-
-}
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/common/common_suite.c
----------------------------------------------------------------------
diff --git a/tests/common/common_suite.c b/tests/common/common_suite.c
deleted file mode 100644
index 58ca799..0000000
--- a/tests/common/common_suite.c
+++ /dev/null
@@ -1,57 +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 "config.h"
-
-#include "common_suite.h"
-
-#include <CUnit/Basic.h>
-
-int common_suite_init() {
- return 0;
-}
-
-int common_suite_cleanup() {
- return 0;
-}
-
-int register_common_suite() {
-
- /* Add common test suite */
- CU_pSuite suite = CU_add_suite("common",
- common_suite_init, common_suite_cleanup);
- if (suite == NULL) {
- CU_cleanup_registry();
- return CU_get_error();
- }
-
- /* Add tests */
- if (
- CU_add_test(suite, "guac-iconv", test_guac_iconv) == NULL
- || CU_add_test(suite, "guac-string", test_guac_string) == NULL
- || CU_add_test(suite, "guac-rect", test_guac_rect) == NULL
- ) {
- CU_cleanup_registry();
- return CU_get_error();
- }
-
- return 0;
-
-}
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/common/common_suite.h
----------------------------------------------------------------------
diff --git a/tests/common/common_suite.h b/tests/common/common_suite.h
deleted file mode 100644
index 60dbe9a..0000000
--- a/tests/common/common_suite.h
+++ /dev/null
@@ -1,55 +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.
- */
-
-
-#ifndef _GUAC_TEST_COMMON_SUITE_H
-#define _GUAC_TEST_COMMON_SUITE_H
-
-/**
- * Test suite containing unit tests for the "common" utility library included
- * for the sake of simplifying guacamole-server development, but not included
- * as part of libguac.
- *
- * @file common_suite.h
- */
-
-#include "config.h"
-
-/**
- * Registers the common test suite with CUnit.
- */
-int register_common_suite();
-
-/**
- * Unit test for string utility functions.
- */
-void test_guac_string();
-
-/**
- * Unit test for character conversion functions.
- */
-void test_guac_iconv();
-
-/**
- * Unit test for rectangle calculation functions.
- */
-void test_guac_rect();
-
-#endif
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/common/guac_iconv.c
----------------------------------------------------------------------
diff --git a/tests/common/guac_iconv.c b/tests/common/guac_iconv.c
deleted file mode 100644
index 6af706f..0000000
--- a/tests/common/guac_iconv.c
+++ /dev/null
@@ -1,128 +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 "config.h"
-
-#include "common_suite.h"
-#include "common/iconv.h"
-
-#include <stdlib.h>
-#include <CUnit/Basic.h>
-
-static void test_conversion(
- guac_iconv_read* reader, unsigned char* in_string, int in_length,
- guac_iconv_write* writer, unsigned char* out_string, int out_length) {
-
- char output[4096];
- char input[4096];
-
- const char* current_input = input;
- char* current_output = output;
-
- memcpy(input, in_string, in_length);
- guac_iconv(reader, ¤t_input, sizeof(input),
- writer, ¤t_output, sizeof(output));
-
- /* Verify output length */
- CU_ASSERT_EQUAL(out_length, current_output - output);
-
- /* Verify entire input read */
- CU_ASSERT_EQUAL(in_length, current_input - input);
-
- /* Verify output content */
- CU_ASSERT_EQUAL(0, memcmp(output, out_string, out_length));
-
-}
-
-void test_guac_iconv() {
-
- /* UTF8 for "papà è bello" */
- unsigned char test_string_utf8[] = {
- 'p', 'a', 'p', 0xC3, 0xA0, ' ',
- 0xC3, 0xA8, ' ',
- 'b', 'e', 'l', 'l', 'o',
- 0x00
- };
-
- /* UTF16 for "papà è bello" */
- unsigned char test_string_utf16[] = {
- 'p', 0x00, 'a', 0x00, 'p', 0x00, 0xE0, 0x00, ' ', 0x00,
- 0xE8, 0x00, ' ', 0x00,
- 'b', 0x00, 'e', 0x00, 'l', 0x00, 'l', 0x00, 'o', 0x00,
- 0x00, 0x00
- };
-
- /* ISO-8859-1 for "papà è bello" */
- unsigned char test_string_iso8859_1[] = {
- 'p', 'a', 'p', 0xE0, ' ',
- 0xE8, ' ',
- 'b', 'e', 'l', 'l', 'o',
- 0x00
- };
-
- /* CP1252 for "papà è bello" */
- unsigned char test_string_cp1252[] = {
- 'p', 'a', 'p', 0xE0, ' ',
- 0xE8, ' ',
- 'b', 'e', 'l', 'l', 'o',
- 0x00
- };
-
- /* UTF8 identity */
- test_conversion(
- GUAC_READ_UTF8, test_string_utf8, sizeof(test_string_utf8),
- GUAC_WRITE_UTF8, test_string_utf8, sizeof(test_string_utf8));
-
- /* UTF16 identity */
- test_conversion(
- GUAC_READ_UTF16, test_string_utf16, sizeof(test_string_utf16),
- GUAC_WRITE_UTF16, test_string_utf16, sizeof(test_string_utf16));
-
- /* UTF8 to UTF16 */
- test_conversion(
- GUAC_READ_UTF8, test_string_utf8, sizeof(test_string_utf8),
- GUAC_WRITE_UTF16, test_string_utf16, sizeof(test_string_utf16));
-
- /* UTF16 to UTF8 */
- test_conversion(
- GUAC_READ_UTF16, test_string_utf16, sizeof(test_string_utf16),
- GUAC_WRITE_UTF8, test_string_utf8, sizeof(test_string_utf8));
-
- /* UTF16 to ISO-8859-1 */
- test_conversion(
- GUAC_READ_UTF16, test_string_utf16, sizeof(test_string_utf16),
- GUAC_WRITE_ISO8859_1, test_string_iso8859_1, sizeof(test_string_iso8859_1));
-
- /* UTF16 to CP1252 */
- test_conversion(
- GUAC_READ_UTF16, test_string_utf16, sizeof(test_string_utf16),
- GUAC_WRITE_CP1252, test_string_cp1252, sizeof(test_string_cp1252));
-
- /* CP1252 to UTF8 */
- test_conversion(
- GUAC_READ_CP1252, test_string_cp1252, sizeof(test_string_cp1252),
- GUAC_WRITE_UTF8, test_string_utf8, sizeof(test_string_utf8));
-
- /* ISO-8859-1 to UTF8 */
- test_conversion(
- GUAC_READ_ISO8859_1, test_string_iso8859_1, sizeof(test_string_iso8859_1),
- GUAC_WRITE_UTF8, test_string_utf8, sizeof(test_string_utf8));
-
-}
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/common/guac_rect.c
----------------------------------------------------------------------
diff --git a/tests/common/guac_rect.c b/tests/common/guac_rect.c
deleted file mode 100644
index a45ee38..0000000
--- a/tests/common/guac_rect.c
+++ /dev/null
@@ -1,289 +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 "config.h"
-
-#include "common_suite.h"
-#include "common/rect.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <CUnit/Basic.h>
-
-void test_guac_rect() {
-
- guac_common_rect max;
-
- /*
- * Test init method
- */
- guac_common_rect_init(&max, 0, 0, 100, 100);
- CU_ASSERT_EQUAL(0, max.x);
- CU_ASSERT_EQUAL(0, max.y);
- CU_ASSERT_EQUAL(100, max.width);
- CU_ASSERT_EQUAL(100, max.height);
-
- /*
- * Test constrain method
- */
- guac_common_rect rect;
- guac_common_rect_init(&rect, -10, -10, 110, 110);
- guac_common_rect_init(&max, 0, 0, 100, 100);
- guac_common_rect_constrain(&rect, &max);
- CU_ASSERT_EQUAL(0, rect.x);
- CU_ASSERT_EQUAL(0, rect.y);
- CU_ASSERT_EQUAL(100, rect.width);
- CU_ASSERT_EQUAL(100, rect.height);
-
- /*
- * Test extend method
- */
- guac_common_rect_init(&rect, 10, 10, 90, 90);
- guac_common_rect_init(&max, 0, 0, 100, 100);
- guac_common_rect_extend(&rect, &max);
- CU_ASSERT_EQUAL(0, rect.x);
- CU_ASSERT_EQUAL(0, rect.y);
- CU_ASSERT_EQUAL(100, rect.width);
- CU_ASSERT_EQUAL(100, rect.height);
-
- /*
- * Test adjust method
- */
- int cell_size = 16;
-
- /* Simple adjustment */
- guac_common_rect_init(&rect, 0, 0, 25, 25);
- guac_common_rect_init(&max, 0, 0, 100, 100);
- guac_common_rect_expand_to_grid(cell_size, &rect, &max);
- CU_ASSERT_EQUAL(0, rect.x);
- CU_ASSERT_EQUAL(0, rect.y);
- CU_ASSERT_EQUAL(32, rect.width);
- CU_ASSERT_EQUAL(32, rect.height);
-
- /* Adjustment with moving of rect */
- guac_common_rect_init(&rect, 75, 75, 25, 25);
- guac_common_rect_init(&max, 0, 0, 100, 100);
- guac_common_rect_expand_to_grid(cell_size, &rect, &max);
- CU_ASSERT_EQUAL(max.width - 32, rect.x);
- CU_ASSERT_EQUAL(max.height - 32, rect.y);
- CU_ASSERT_EQUAL(32, rect.width);
- CU_ASSERT_EQUAL(32, rect.height);
-
- guac_common_rect_init(&rect, -5, -5, 25, 25);
- guac_common_rect_init(&max, 0, 0, 100, 100);
- guac_common_rect_expand_to_grid(cell_size, &rect, &max);
- CU_ASSERT_EQUAL(0, rect.x);
- CU_ASSERT_EQUAL(0, rect.y);
- CU_ASSERT_EQUAL(32, rect.width);
- CU_ASSERT_EQUAL(32, rect.height);
-
- /* Adjustment with moving and clamping of rect */
- guac_common_rect_init(&rect, 0, 0, 25, 15);
- guac_common_rect_init(&max, 0, 5, 32, 15);
- guac_common_rect_expand_to_grid(cell_size, &rect, &max);
- CU_ASSERT_EQUAL(max.x, rect.x);
- CU_ASSERT_EQUAL(max.y, rect.y);
- CU_ASSERT_EQUAL(max.width, rect.width);
- CU_ASSERT_EQUAL(max.height, rect.height);
-
- /*
- * Rectangle intersection tests
- */
- guac_common_rect min;
- guac_common_rect_init(&min, 10, 10, 10, 10);
-
- /* Rectangle intersection - empty
- * rectangle is outside */
- guac_common_rect_init(&rect, 25, 25, 5, 5);
- int res = guac_common_rect_intersects(&rect, &min);
- CU_ASSERT_EQUAL(0, res);
-
- /* Rectangle intersection - complete
- * rectangle is completely inside */
- guac_common_rect_init(&rect, 11, 11, 5, 5);
- res = guac_common_rect_intersects(&rect, &min);
- CU_ASSERT_EQUAL(2, res);
-
- /* Rectangle intersection - partial
- * rectangle intersects UL */
- guac_common_rect_init(&rect, 8, 8, 5, 5);
- res = guac_common_rect_intersects(&rect, &min);
- CU_ASSERT_EQUAL(1, res);
-
- /* Rectangle intersection - partial
- * rectangle intersects LR */
- guac_common_rect_init(&rect, 18, 18, 5, 5);
- res = guac_common_rect_intersects(&rect, &min);
- CU_ASSERT_EQUAL(1, res);
-
- /* Rectangle intersection - complete
- * rect intersects along UL but inside */
- guac_common_rect_init(&rect, 10, 10, 5, 5);
- res = guac_common_rect_intersects(&rect, &min);
- CU_ASSERT_EQUAL(2, res);
-
- /* Rectangle intersection - partial
- * rectangle intersects along L but outside */
- guac_common_rect_init(&rect, 5, 10, 5, 5);
- res = guac_common_rect_intersects(&rect, &min);
- CU_ASSERT_EQUAL(1, res);
-
- /* Rectangle intersection - complete
- * rectangle intersects along LR but rest is inside */
- guac_common_rect_init(&rect, 15, 15, 5, 5);
- res = guac_common_rect_intersects(&rect, &min);
- CU_ASSERT_EQUAL(2, res);
-
- /* Rectangle intersection - partial
- * rectangle intersects along R but rest is outside */
- guac_common_rect_init(&rect, 20, 10, 5, 5);
- res = guac_common_rect_intersects(&rect, &min);
- CU_ASSERT_EQUAL(1, res);
-
- /* Rectangle intersection - partial
- * rectangle encloses min; which is a partial intersection */
- guac_common_rect_init(&rect, 5, 5, 20, 20);
- res = guac_common_rect_intersects(&rect, &min);
- CU_ASSERT_EQUAL(1, res);
-
- /*
- * Basic test of clip and split method
- */
- guac_common_rect_init(&min, 10, 10, 10, 10);
- guac_common_rect cut;
-
- /* Clip top */
- guac_common_rect_init(&rect, 10, 5, 10, 10);
- res = guac_common_rect_clip_and_split(&rect, &min, &cut);
- CU_ASSERT_EQUAL(1, res);
- CU_ASSERT_EQUAL(10, cut.x);
- CU_ASSERT_EQUAL(5, cut.y);
- CU_ASSERT_EQUAL(10, cut.width);
- CU_ASSERT_EQUAL(5, cut.height);
-
- CU_ASSERT_EQUAL(10, rect.x);
- CU_ASSERT_EQUAL(10, rect.y);
- CU_ASSERT_EQUAL(10, rect.width);
- CU_ASSERT_EQUAL(5, rect.height);
-
- /* Clip bottom */
- guac_common_rect_init(&rect, 10, 15, 10, 10);
- res = guac_common_rect_clip_and_split(&rect, &min, &cut);
- CU_ASSERT_EQUAL(1, res);
- CU_ASSERT_EQUAL(10, cut.x);
- CU_ASSERT_EQUAL(20, cut.y);
- CU_ASSERT_EQUAL(10, cut.width);
- CU_ASSERT_EQUAL(5, cut.height);
-
- CU_ASSERT_EQUAL(10, rect.x);
- CU_ASSERT_EQUAL(15, rect.y);
- CU_ASSERT_EQUAL(10, rect.width);
- CU_ASSERT_EQUAL(5, rect.height);
-
- /* Clip left */
- guac_common_rect_init(&rect, 5, 10, 10, 10);
- res = guac_common_rect_clip_and_split(&rect, &min, &cut);
- CU_ASSERT_EQUAL(1, res);
- CU_ASSERT_EQUAL(5, cut.x);
- CU_ASSERT_EQUAL(10, cut.y);
- CU_ASSERT_EQUAL(5, cut.width);
- CU_ASSERT_EQUAL(10, cut.height);
-
- CU_ASSERT_EQUAL(10, rect.x);
- CU_ASSERT_EQUAL(10, rect.y);
- CU_ASSERT_EQUAL(5, rect.width);
- CU_ASSERT_EQUAL(10, rect.height);
-
- /* Clip right */
- guac_common_rect_init(&rect, 15, 10, 10, 10);
- res = guac_common_rect_clip_and_split(&rect, &min, &cut);
- CU_ASSERT_EQUAL(1, res);
- CU_ASSERT_EQUAL(20, cut.x);
- CU_ASSERT_EQUAL(10, cut.y);
- CU_ASSERT_EQUAL(5, cut.width);
- CU_ASSERT_EQUAL(10, cut.height);
-
- CU_ASSERT_EQUAL(15, rect.x);
- CU_ASSERT_EQUAL(10, rect.y);
- CU_ASSERT_EQUAL(5, rect.width);
- CU_ASSERT_EQUAL(10, rect.height);
-
- /*
- * Test a rectangle which completely covers the hole.
- * Clip and split until done.
- */
- guac_common_rect_init(&rect, 5, 5, 20, 20);
-
- /* Clip top */
- res = guac_common_rect_clip_and_split(&rect, &min, &cut);
- CU_ASSERT_EQUAL(1, res);
- CU_ASSERT_EQUAL(5, cut.x);
- CU_ASSERT_EQUAL(5, cut.y);
- CU_ASSERT_EQUAL(20, cut.width);
- CU_ASSERT_EQUAL(5, cut.height);
-
- CU_ASSERT_EQUAL(5, rect.x);
- CU_ASSERT_EQUAL(10, rect.y);
- CU_ASSERT_EQUAL(20, rect.width);
- CU_ASSERT_EQUAL(15, rect.height);
-
- /* Clip left */
- res = guac_common_rect_clip_and_split(&rect, &min, &cut);
- CU_ASSERT_EQUAL(1, res);
- CU_ASSERT_EQUAL(5, cut.x);
- CU_ASSERT_EQUAL(10, cut.y);
- CU_ASSERT_EQUAL(5, cut.width);
- CU_ASSERT_EQUAL(15, cut.height);
-
- CU_ASSERT_EQUAL(10, rect.x);
- CU_ASSERT_EQUAL(10, rect.y);
- CU_ASSERT_EQUAL(15, rect.width);
- CU_ASSERT_EQUAL(15, rect.height);
-
- /* Clip bottom */
- res = guac_common_rect_clip_and_split(&rect, &min, &cut);
- CU_ASSERT_EQUAL(1, res);
- CU_ASSERT_EQUAL(10, cut.x);
- CU_ASSERT_EQUAL(20, cut.y);
- CU_ASSERT_EQUAL(15, cut.width);
- CU_ASSERT_EQUAL(5, cut.height);
-
- CU_ASSERT_EQUAL(10, rect.x);
- CU_ASSERT_EQUAL(10, rect.y);
- CU_ASSERT_EQUAL(15, rect.width);
- CU_ASSERT_EQUAL(10, rect.height);
-
- /* Clip right */
- res = guac_common_rect_clip_and_split(&rect, &min, &cut);
- CU_ASSERT_EQUAL(20, cut.x);
- CU_ASSERT_EQUAL(10, cut.y);
- CU_ASSERT_EQUAL(5, cut.width);
- CU_ASSERT_EQUAL(10, cut.height);
-
- CU_ASSERT_EQUAL(10, rect.x);
- CU_ASSERT_EQUAL(10, rect.y);
- CU_ASSERT_EQUAL(10, rect.width);
- CU_ASSERT_EQUAL(10, rect.height);
-
- /* Make sure nothing is left to do */
- res = guac_common_rect_clip_and_split(&rect, &min, &cut);
- CU_ASSERT_EQUAL(0, res);
-
-}
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/common/guac_string.c
----------------------------------------------------------------------
diff --git a/tests/common/guac_string.c b/tests/common/guac_string.c
deleted file mode 100644
index 543a41b..0000000
--- a/tests/common/guac_string.c
+++ /dev/null
@@ -1,70 +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 "config.h"
-
-#include "common_suite.h"
-#include "common/string.h"
-
-#include <stdlib.h>
-#include <CUnit/Basic.h>
-
-void test_guac_string() {
-
- char** tokens;
-
- /* Test occurrence counting */
- CU_ASSERT_EQUAL(4, guac_count_occurrences("this is a test string", 's'));
- CU_ASSERT_EQUAL(3, guac_count_occurrences("this is a test string", 'i'));
- CU_ASSERT_EQUAL(0, guac_count_occurrences("", 's'));
-
- /* Split test string */
- tokens = guac_split("this is a test string", ' ');
-
- CU_ASSERT_PTR_NOT_NULL(tokens);
-
- /* Check resulting tokens */
- CU_ASSERT_PTR_NOT_NULL_FATAL(tokens[0]);
- CU_ASSERT_STRING_EQUAL("this", tokens[0]);
-
- CU_ASSERT_PTR_NOT_NULL_FATAL(tokens[1]);
- CU_ASSERT_STRING_EQUAL("is", tokens[1]);
-
- CU_ASSERT_PTR_NOT_NULL_FATAL(tokens[2]);
- CU_ASSERT_STRING_EQUAL("a", tokens[2]);
-
- CU_ASSERT_PTR_NOT_NULL_FATAL(tokens[3]);
- CU_ASSERT_STRING_EQUAL("test", tokens[3]);
-
- CU_ASSERT_PTR_NOT_NULL_FATAL(tokens[4]);
- CU_ASSERT_STRING_EQUAL("string", tokens[4]);
-
- CU_ASSERT_PTR_NULL(tokens[5]);
-
-
- /* Clean up */
- free(tokens[0]);
- free(tokens[1]);
- free(tokens[2]);
- free(tokens[3]);
- free(tokens[4]);
- free(tokens);
-
-}
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/protocol/base64_decode.c
----------------------------------------------------------------------
diff --git a/tests/protocol/base64_decode.c b/tests/protocol/base64_decode.c
deleted file mode 100644
index 9f8b7b7..0000000
--- a/tests/protocol/base64_decode.c
+++ /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.
- */
-
-#include "config.h"
-
-#include "suite.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <CUnit/Basic.h>
-#include <guacamole/protocol.h>
-
-void test_base64_decode() {
-
- /* Test strings */
- char test_HELLO[] = "SEVMTE8=";
- char test_AVOCADO[] = "QVZPQ0FETw==";
- char test_GUACAMOLE[] = "R1VBQ0FNT0xF";
-
- /* Invalid strings */
- char invalid1[] = "====";
- char invalid2[] = "";
-
- /* Test one character of padding */
- CU_ASSERT_EQUAL(guac_protocol_decode_base64(test_HELLO), 5);
- CU_ASSERT_NSTRING_EQUAL(test_HELLO, "HELLO", 5);
-
- /* Test two characters of padding */
- CU_ASSERT_EQUAL(guac_protocol_decode_base64(test_AVOCADO), 7);
- CU_ASSERT_NSTRING_EQUAL(test_AVOCADO, "AVOCADO", 7);
-
- /* Test three characters of padding */
- CU_ASSERT_EQUAL(guac_protocol_decode_base64(test_GUACAMOLE), 9);
- CU_ASSERT_NSTRING_EQUAL(test_GUACAMOLE, "GUACAMOLE", 9);
-
- /* Verify invalid strings stop early as expected */
- CU_ASSERT_EQUAL(guac_protocol_decode_base64(invalid1), 0);
- CU_ASSERT_EQUAL(guac_protocol_decode_base64(invalid2), 0);
-
-}
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/protocol/instruction_parse.c
----------------------------------------------------------------------
diff --git a/tests/protocol/instruction_parse.c b/tests/protocol/instruction_parse.c
deleted file mode 100644
index ec67985..0000000
--- a/tests/protocol/instruction_parse.c
+++ /dev/null
@@ -1,76 +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 "config.h"
-
-#include "suite.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <CUnit/Basic.h>
-#include <guacamole/parser.h>
-
-void test_instruction_parse() {
-
- /* Allocate parser */
- guac_parser* parser = guac_parser_alloc();
- CU_ASSERT_PTR_NOT_NULL_FATAL(parser);
-
- /* Instruction input */
- char buffer[] = "4.test,8.testdata,5.zxcvb,13.guacamoletest;XXXXXXXXXXXXXXXXXX";
- char* current = buffer;
-
- /* While data remains */
- int remaining = sizeof(buffer)-1;
- while (remaining > 18) {
-
- /* Parse more data */
- int parsed = guac_parser_append(parser, current, remaining);
- if (parsed == 0)
- break;
-
- current += parsed;
- remaining -= parsed;
-
- }
-
- CU_ASSERT_EQUAL(remaining, 18);
- CU_ASSERT_EQUAL(parser->state, GUAC_PARSE_COMPLETE);
-
- /* Parse is complete - no more data should be read */
- CU_ASSERT_EQUAL(guac_parser_append(parser, current, 18), 0);
- CU_ASSERT_EQUAL(parser->state, GUAC_PARSE_COMPLETE);
-
- /* Validate resulting structure */
- CU_ASSERT_EQUAL(parser->argc, 3);
- CU_ASSERT_PTR_NOT_NULL_FATAL(parser->opcode);
- CU_ASSERT_PTR_NOT_NULL_FATAL(parser->argv[0]);
- CU_ASSERT_PTR_NOT_NULL_FATAL(parser->argv[1]);
- CU_ASSERT_PTR_NOT_NULL_FATAL(parser->argv[2]);
-
- /* Validate resulting content */
- CU_ASSERT_STRING_EQUAL(parser->opcode, "test");
- CU_ASSERT_STRING_EQUAL(parser->argv[0], "testdata");
- CU_ASSERT_STRING_EQUAL(parser->argv[1], "zxcvb");
- CU_ASSERT_STRING_EQUAL(parser->argv[2], "guacamoletest");
-
-}
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/protocol/instruction_read.c
----------------------------------------------------------------------
diff --git a/tests/protocol/instruction_read.c b/tests/protocol/instruction_read.c
deleted file mode 100644
index 930b5b5..0000000
--- a/tests/protocol/instruction_read.c
+++ /dev/null
@@ -1,108 +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 "config.h"
-
-#include "suite.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <CUnit/Basic.h>
-#include <guacamole/error.h>
-#include <guacamole/parser.h>
-#include <guacamole/protocol.h>
-#include <guacamole/socket.h>
-
-void test_instruction_read() {
-
- int rfd, wfd;
- int fd[2], childpid;
-
- char test_string[] = "4.test,6.a" UTF8_4 "b,"
- "5.12345,10.a" UTF8_8 "c;"
- "5.test2,10.hellohello,15.worldworldworld;";
-
- /* Create pipe */
- CU_ASSERT_EQUAL_FATAL(pipe(fd), 0);
-
- /* File descriptors */
- rfd = fd[0];
- wfd = fd[1];
-
- /* Fork */
- if ((childpid = fork()) == -1) {
- /* ERROR */
- perror("fork");
- return;
- }
-
- /* Child (pipe writer) */
- if (childpid == 0) {
- close(rfd);
- CU_ASSERT_EQUAL(
- write(wfd, test_string, sizeof(test_string)),
- sizeof(test_string)
- );
- exit(0);
- }
-
- /* Parent (unit test) */
- else {
-
- guac_socket* socket;
- guac_parser* parser;
-
- close(wfd);
-
- /* Open guac socket */
- socket = guac_socket_open(rfd);
- CU_ASSERT_PTR_NOT_NULL_FATAL(socket);
-
- /* Allocate parser */
- parser = guac_parser_alloc();
- CU_ASSERT_PTR_NOT_NULL_FATAL(parser);
-
- /* Read instruction */
- CU_ASSERT_EQUAL_FATAL(guac_parser_read(parser, socket, 1000000), 0);
-
- /* Validate contents */
- CU_ASSERT_STRING_EQUAL(parser->opcode, "test");
- CU_ASSERT_EQUAL_FATAL(parser->argc, 3);
- CU_ASSERT_STRING_EQUAL(parser->argv[0], "a" UTF8_4 "b");
- CU_ASSERT_STRING_EQUAL(parser->argv[1], "12345");
- CU_ASSERT_STRING_EQUAL(parser->argv[2], "a" UTF8_8 "c");
-
- /* Read another instruction */
- CU_ASSERT_EQUAL_FATAL(guac_parser_read(parser, socket, 1000000), 0);
-
- /* Validate contents */
- CU_ASSERT_STRING_EQUAL(parser->opcode, "test2");
- CU_ASSERT_EQUAL_FATAL(parser->argc, 2);
- CU_ASSERT_STRING_EQUAL(parser->argv[0], "hellohello");
- CU_ASSERT_STRING_EQUAL(parser->argv[1], "worldworldworld");
-
- guac_parser_free(parser);
- guac_socket_free(socket);
-
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/protocol/instruction_write.c
----------------------------------------------------------------------
diff --git a/tests/protocol/instruction_write.c b/tests/protocol/instruction_write.c
deleted file mode 100644
index 8e12dfc..0000000
--- a/tests/protocol/instruction_write.c
+++ /dev/null
@@ -1,101 +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 "config.h"
-
-#include "suite.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <CUnit/Basic.h>
-#include <guacamole/error.h>
-#include <guacamole/protocol.h>
-#include <guacamole/socket.h>
-
-void test_instruction_write() {
-
- int rfd, wfd;
- int fd[2], childpid;
-
- /* Create pipe */
- CU_ASSERT_EQUAL_FATAL(pipe(fd), 0);
-
- /* File descriptors */
- rfd = fd[0];
- wfd = fd[1];
-
- /* Fork */
- if ((childpid = fork()) == -1) {
- /* ERROR */
- perror("fork");
- return;
- }
-
- /* Child (pipe writer) */
- if (childpid == 0) {
-
- guac_socket* socket;
-
- close(rfd);
-
- /* Open guac socket */
- socket = guac_socket_open(wfd);
-
- /* Write instruction */
- guac_protocol_send_name(socket, "a" UTF8_4 "b" UTF8_4 "c");
- guac_protocol_send_sync(socket, 12345);
- guac_socket_flush(socket);
-
- guac_socket_free(socket);
- exit(0);
- }
-
- /* Parent (unit test) */
- else {
-
- char expected[] =
- "4.name,11.a" UTF8_4 "b" UTF8_4 "c;"
- "4.sync,5.12345;";
-
- int numread;
- char buffer[1024];
- int offset = 0;
-
- close(wfd);
-
- /* Read everything available into buffer */
- while ((numread =
- read(rfd,
- &(buffer[offset]),
- sizeof(buffer)-offset)) != 0) {
- offset += numread;
- }
-
- /* Add NULL terminator */
- buffer[offset] = '\0';
-
- /* Read value should be equal to expected value */
- CU_ASSERT_STRING_EQUAL(buffer, expected);
-
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/protocol/nest_write.c
----------------------------------------------------------------------
diff --git a/tests/protocol/nest_write.c b/tests/protocol/nest_write.c
deleted file mode 100644
index e1b885b..0000000
--- a/tests/protocol/nest_write.c
+++ /dev/null
@@ -1,109 +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 "config.h"
-
-#include "suite.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include <CUnit/Basic.h>
-#include <guacamole/error.h>
-#include <guacamole/protocol.h>
-#include <guacamole/socket.h>
-
-void test_nest_write() {
-
- int rfd, wfd;
- int fd[2], childpid;
-
- /* Create pipe */
- CU_ASSERT_EQUAL_FATAL(pipe(fd), 0);
-
- /* File descriptors */
- rfd = fd[0];
- wfd = fd[1];
-
- /* Fork */
- if ((childpid = fork()) == -1) {
- /* ERROR */
- perror("fork");
- return;
- }
-
- /* Child (pipe writer) */
- if (childpid == 0) {
-
- guac_socket* nested_socket;
- guac_socket* socket;
-
- close(rfd);
-
- /* Open guac socket */
- socket = guac_socket_open(wfd);
-
- /* Nest socket */
- nested_socket = guac_socket_nest(socket, 0);
-
- /* Write instruction */
- guac_protocol_send_name(nested_socket, "a" UTF8_4 "b" UTF8_4 "c");
- guac_protocol_send_sync(nested_socket, 12345);
- guac_socket_flush(nested_socket);
- guac_socket_flush(socket);
-
- guac_socket_free(nested_socket);
- guac_socket_free(socket);
- exit(0);
- }
-
- /* Parent (unit test) */
- else {
-
- char expected[] =
- "4.nest,1.0,37."
- "4.name,11.a" UTF8_4 "b" UTF8_4 "c;"
- "4.sync,5.12345;"
- ";";
-
- int numread;
- char buffer[1024];
- int offset = 0;
-
- close(wfd);
-
- /* Read everything available into buffer */
- while ((numread =
- read(rfd,
- &(buffer[offset]),
- sizeof(buffer)-offset)) != 0) {
- offset += numread;
- }
-
- /* Add NULL terminator */
- buffer[offset] = '\0';
-
- /* Read value should be equal to expected value */
- CU_ASSERT_STRING_EQUAL(buffer, expected);
-
- }
-
-}
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/protocol/suite.c
----------------------------------------------------------------------
diff --git a/tests/protocol/suite.c b/tests/protocol/suite.c
deleted file mode 100644
index 14cfc40..0000000
--- a/tests/protocol/suite.c
+++ /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.
- */
-
-#include "config.h"
-
-#include "suite.h"
-
-#include <CUnit/Basic.h>
-
-int protocol_suite_init() {
- return 0;
-}
-
-int protocol_suite_cleanup() {
- return 0;
-}
-
-int register_protocol_suite() {
-
- /* Add protocol test suite */
- CU_pSuite suite = CU_add_suite("protocol",
- protocol_suite_init, protocol_suite_cleanup);
- if (suite == NULL) {
- CU_cleanup_registry();
- return CU_get_error();
- }
-
- /* Add tests */
- if (
- CU_add_test(suite, "base64-decode", test_base64_decode) == NULL
- || CU_add_test(suite, "instruction-parse", test_instruction_parse) == NULL
- || CU_add_test(suite, "instruction-read", test_instruction_read) == NULL
- || CU_add_test(suite, "instruction-write", test_instruction_write) == NULL
- || CU_add_test(suite, "nest-write", test_nest_write) == NULL
- ) {
- CU_cleanup_registry();
- return CU_get_error();
- }
-
- return 0;
-
-}
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/protocol/suite.h
----------------------------------------------------------------------
diff --git a/tests/protocol/suite.h b/tests/protocol/suite.h
deleted file mode 100644
index 01345fa..0000000
--- a/tests/protocol/suite.h
+++ /dev/null
@@ -1,43 +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.
- */
-
-
-#ifndef _GUAC_TEST_PROTOCOL_SUITE_H
-#define _GUAC_TEST_PROTOCOL_SUITE_H
-
-#include "config.h"
-
-/* Unicode (UTF-8) strings */
-
-#define UTF8_1 "\xe7\x8a\xac" /* One character */
-#define UTF8_2 UTF8_1 "\xf0\x90\xac\x80" /* Two characters */
-#define UTF8_3 UTF8_2 "z" /* Three characters */
-#define UTF8_4 UTF8_3 "\xc3\xa1" /* Four characters */
-#define UTF8_8 UTF8_4 UTF8_4 /* Eight characters */
-
-int register_protocol_suite();
-
-void test_base64_decode();
-void test_instruction_parse();
-void test_instruction_read();
-void test_instruction_write();
-void test_nest_write();
-
-#endif
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/test_libguac.c
----------------------------------------------------------------------
diff --git a/tests/test_libguac.c b/tests/test_libguac.c
deleted file mode 100644
index 06223ce..0000000
--- a/tests/test_libguac.c
+++ /dev/null
@@ -1,47 +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 "config.h"
-
-#include "client/client_suite.h"
-#include "common/common_suite.h"
-#include "protocol/suite.h"
-#include "util/util_suite.h"
-
-#include <CUnit/Basic.h>
-
-int main() {
-
- /* Init registry */
- if (CU_initialize_registry() != CUE_SUCCESS)
- return CU_get_error();
-
- /* Register suites */
- register_protocol_suite();
- register_client_suite();
- register_util_suite();
-
- /* Run tests */
- CU_basic_set_mode(CU_BRM_VERBOSE);
- CU_basic_run_tests();
- CU_cleanup_registry();
- return CU_get_error();
-
-}
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/util/guac_pool.c
----------------------------------------------------------------------
diff --git a/tests/util/guac_pool.c b/tests/util/guac_pool.c
deleted file mode 100644
index e24d8fc..0000000
--- a/tests/util/guac_pool.c
+++ /dev/null
@@ -1,89 +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 "config.h"
-
-#include "util_suite.h"
-
-#include <CUnit/Basic.h>
-#include <guacamole/pool.h>
-
-#define UNSEEN 0
-#define SEEN_PHASE_1 1
-#define SEEN_PHASE_2 2
-
-#define POOL_SIZE 128
-
-void test_guac_pool() {
-
- guac_pool* pool;
-
- int i;
- int seen[POOL_SIZE] = {0};
- int value;
-
- /* Get pool */
- pool = guac_pool_alloc(POOL_SIZE);
- CU_ASSERT_PTR_NOT_NULL_FATAL(pool);
-
- /* Fill pool */
- for (i=0; i<POOL_SIZE; i++) {
-
- /* Get value from pool */
- value = guac_pool_next_int(pool);
-
- /* Value should be within pool size */
- CU_ASSERT_FATAL(value >= 0);
- CU_ASSERT_FATAL(value < POOL_SIZE);
-
- /* This should be an integer we have not seen yet */
- CU_ASSERT_EQUAL(UNSEEN, seen[value]);
- seen[value] = SEEN_PHASE_1;
-
- /* Return value to pool */
- guac_pool_free_int(pool, value);
-
- }
-
- /* Now that pool is filled, we should get ONLY previously seen integers */
- for (i=0; i<POOL_SIZE; i++) {
-
- /* Get value from pool */
- value = guac_pool_next_int(pool);
-
- /* Value should be within pool size */
- CU_ASSERT_FATAL(value >= 0);
- CU_ASSERT_FATAL(value < POOL_SIZE);
-
- /* This should be an integer we have seen already */
- CU_ASSERT_EQUAL(SEEN_PHASE_1, seen[value]);
- seen[value] = SEEN_PHASE_2;
-
- }
-
- /* Pool is filled to minimum now. Next value should be equal to size. */
- value = guac_pool_next_int(pool);
-
- CU_ASSERT_EQUAL(POOL_SIZE, value);
-
- /* Free pool */
- guac_pool_free(pool);
-
-}
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/util/guac_unicode.c
----------------------------------------------------------------------
diff --git a/tests/util/guac_unicode.c b/tests/util/guac_unicode.c
deleted file mode 100644
index 62f5887..0000000
--- a/tests/util/guac_unicode.c
+++ /dev/null
@@ -1,81 +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 "config.h"
-
-#include "util_suite.h"
-
-#include <CUnit/Basic.h>
-#include <guacamole/unicode.h>
-
-void test_guac_unicode() {
-
- int codepoint;
- char buffer[16];
-
- /* Test character length */
- CU_ASSERT_EQUAL(1, guac_utf8_charsize(UTF8_1b[0]));
- CU_ASSERT_EQUAL(2, guac_utf8_charsize(UTF8_2b[0]));
- CU_ASSERT_EQUAL(3, guac_utf8_charsize(UTF8_3b[0]));
- CU_ASSERT_EQUAL(4, guac_utf8_charsize(UTF8_4b[0]));
-
- /* Test string length */
- CU_ASSERT_EQUAL(0, guac_utf8_strlen(""));
- CU_ASSERT_EQUAL(1, guac_utf8_strlen(UTF8_4b));
- CU_ASSERT_EQUAL(2, guac_utf8_strlen(UTF8_4b UTF8_1b));
- CU_ASSERT_EQUAL(2, guac_utf8_strlen(UTF8_2b UTF8_3b));
- CU_ASSERT_EQUAL(3, guac_utf8_strlen(UTF8_1b UTF8_3b UTF8_4b));
- CU_ASSERT_EQUAL(3, guac_utf8_strlen(UTF8_2b UTF8_1b UTF8_3b));
- CU_ASSERT_EQUAL(3, guac_utf8_strlen(UTF8_4b UTF8_2b UTF8_1b));
- CU_ASSERT_EQUAL(3, guac_utf8_strlen(UTF8_3b UTF8_4b UTF8_2b));
- CU_ASSERT_EQUAL(5, guac_utf8_strlen("hello"));
- CU_ASSERT_EQUAL(9, guac_utf8_strlen("guacamole"));
-
- /* Test writes */
- CU_ASSERT_EQUAL(1, guac_utf8_write(0x00065, &(buffer[0]), 10));
- CU_ASSERT_EQUAL(2, guac_utf8_write(0x00654, &(buffer[1]), 9));
- CU_ASSERT_EQUAL(3, guac_utf8_write(0x00876, &(buffer[3]), 7));
- CU_ASSERT_EQUAL(4, guac_utf8_write(0x12345, &(buffer[6]), 4));
- CU_ASSERT_EQUAL(0, guac_utf8_write(0x00066, &(buffer[10]), 0));
-
- /* Test result of write */
- CU_ASSERT(memcmp("\x65", &(buffer[0]), 1) == 0); /* U+0065 */
- CU_ASSERT(memcmp("\xD9\x94", &(buffer[1]), 2) == 0); /* U+0654 */
- CU_ASSERT(memcmp("\xE0\xA1\xB6", &(buffer[3]), 3) == 0); /* U+0876 */
- CU_ASSERT(memcmp("\xF0\x92\x8D\x85", &(buffer[6]), 4) == 0); /* U+12345 */
-
- /* Test reads */
-
- CU_ASSERT_EQUAL(1, guac_utf8_read(&(buffer[0]), 10, &codepoint));
- CU_ASSERT_EQUAL(0x0065, codepoint);
-
- CU_ASSERT_EQUAL(2, guac_utf8_read(&(buffer[1]), 9, &codepoint));
- CU_ASSERT_EQUAL(0x0654, codepoint);
-
- CU_ASSERT_EQUAL(3, guac_utf8_read(&(buffer[3]), 7, &codepoint));
- CU_ASSERT_EQUAL(0x0876, codepoint);
-
- CU_ASSERT_EQUAL(4, guac_utf8_read(&(buffer[6]), 4, &codepoint));
- CU_ASSERT_EQUAL(0x12345, codepoint);
-
- CU_ASSERT_EQUAL(0, guac_utf8_read(&(buffer[10]), 0, &codepoint));
- CU_ASSERT_EQUAL(0x12345, codepoint);
-
-}
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/util/util_suite.c
----------------------------------------------------------------------
diff --git a/tests/util/util_suite.c b/tests/util/util_suite.c
deleted file mode 100644
index 7213a0f..0000000
--- a/tests/util/util_suite.c
+++ /dev/null
@@ -1,56 +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 "config.h"
-
-#include "util_suite.h"
-
-#include <CUnit/Basic.h>
-
-int util_suite_init() {
- return 0;
-}
-
-int util_suite_cleanup() {
- return 0;
-}
-
-int register_util_suite() {
-
- /* Add util test suite */
- CU_pSuite suite = CU_add_suite("util",
- util_suite_init, util_suite_cleanup);
- if (suite == NULL) {
- CU_cleanup_registry();
- return CU_get_error();
- }
-
- /* Add tests */
- if (
- CU_add_test(suite, "guac-pool", test_guac_pool) == NULL
- || CU_add_test(suite, "guac-unicode", test_guac_unicode) == NULL
- ) {
- CU_cleanup_registry();
- return CU_get_error();
- }
-
- return 0;
-
-}
-
http://git-wip-us.apache.org/repos/asf/guacamole-server/blob/476b4310/tests/util/util_suite.h
----------------------------------------------------------------------
diff --git a/tests/util/util_suite.h b/tests/util/util_suite.h
deleted file mode 100644
index 3e3253b..0000000
--- a/tests/util/util_suite.h
+++ /dev/null
@@ -1,75 +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.
- */
-
-
-#ifndef _GUAC_TEST_UTIL_SUITE_H
-#define _GUAC_TEST_UTIL_SUITE_H
-
-/**
- * Test suite containing unit tests for utility functions built into libguac.
- * These utility functions are included for convenience rather as integral
- * requirements of the core.
- *
- * @file util_suite.h
- */
-
-#include "config.h"
-
-/**
- * A single Unicode character encoded as one byte with UTF-8.
- */
-#define UTF8_1b "g"
-
-/**
- * A single Unicode character encoded as two bytes with UTF-8.
- */
-#define UTF8_2b "\xc4\xa3"
-
-/**
- * A single Unicode character encoded as three bytes with UTF-8.
- */
-#define UTF8_3b "\xe7\x8a\xac"
-
-/**
- * A single Unicode character encoded as four bytes with UTF-8.
- */
-#define UTF8_4b "\xf0\x90\x84\xa3"
-
-/**
- * Registers the utility test suite with CUnit.
- */
-int register_util_suite();
-
-/**
- * Unit test for the guac_pool structure and related functions. The guac_pool
- * structure provides a consistent source of pooled integers. This unit test
- * checks that the associated functions behave as documented (returning
- * integers in the proper order, allocating new integers as necessary, etc.).
- */
-void test_guac_pool();
-
-/**
- * Unit test for libguac's Unicode convenience functions. This test checks that
- * the functions provided for determining string length, character length, and
- * for reading and writing UTF-8 behave as specified in the documentation.
- */
-void test_guac_unicode();
-
-#endif
-