summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--common/rfb/VNCServerST.cxx2
-rw-r--r--common/rfb/util.cxx32
-rw-r--r--tests/CMakeLists.txt49
-rw-r--r--tests/perf/CMakeLists.txt40
-rw-r--r--tests/perf/convperf.cxx (renamed from tests/convperf.cxx)0
-rw-r--r--tests/perf/decperf.cxx (renamed from tests/decperf.cxx)0
-rw-r--r--tests/perf/encperf.cxx (renamed from tests/encperf.cxx)0
-rw-r--r--tests/perf/fbperf.cxx (renamed from tests/fbperf.cxx)0
-rw-r--r--tests/perf/results/multicore/README (renamed from tests/results/multicore/README)0
-rw-r--r--tests/perf/results/multicore/multicore.ods (renamed from tests/results/multicore/multicore.ods)bin42291 -> 42291 bytes
-rw-r--r--tests/perf/results/notrans/README (renamed from tests/results/notrans/README)0
-rw-r--r--tests/perf/results/notrans/armhf.csv (renamed from tests/results/notrans/armhf.csv)0
-rw-r--r--tests/perf/results/notrans/i386.csv (renamed from tests/results/notrans/i386.csv)0
-rw-r--r--tests/perf/results/notrans/x86_64.csv (renamed from tests/results/notrans/x86_64.csv)0
-rw-r--r--tests/perf/util.cxx (renamed from tests/util.cxx)0
-rw-r--r--tests/perf/util.h (renamed from tests/util.h)0
-rw-r--r--tests/unit/CMakeLists.txt10
-rw-r--r--tests/unit/conv.cxx (renamed from tests/conv.cxx)0
-rw-r--r--tests/unit/convertlf.cxx124
-rw-r--r--tests/unit/hostport.cxx (renamed from tests/hostport.cxx)0
-rw-r--r--win/rfb_win32/SDisplay.cxx2
21 files changed, 196 insertions, 63 deletions
diff --git a/common/rfb/VNCServerST.cxx b/common/rfb/VNCServerST.cxx
index a764f1bc..b3cc7a1f 100644
--- a/common/rfb/VNCServerST.cxx
+++ b/common/rfb/VNCServerST.cxx
@@ -313,7 +313,7 @@ void VNCServerST::setPixelBuffer(PixelBuffer* pb_)
// Make sure that we have at least one screen
if (layout.num_screens() == 0)
- layout.add_screen(Screen(0, 0, 0, pb->width(), pb->height(), 0));
+ layout.add_screen(Screen(0, 0, 0, pb_->width(), pb_->height(), 0));
setPixelBuffer(pb_, layout);
}
diff --git a/common/rfb/util.cxx b/common/rfb/util.cxx
index fc4f4ca4..6284bb81 100644
--- a/common/rfb/util.cxx
+++ b/common/rfb/util.cxx
@@ -127,7 +127,7 @@ namespace rfb {
// Compute output size
in = src;
in_len = bytes;
- while ((*in != '\0') && (in_len > 0)) {
+ while ((in_len > 0) && (*in != '\0')) {
if (*in != '\r') {
sz++;
in++;
@@ -135,7 +135,7 @@ namespace rfb {
continue;
}
- if ((in_len == 0) || (*(in+1) != '\n'))
+ if ((in_len < 2) || (*(in+1) != '\n'))
sz++;
in++;
@@ -150,14 +150,14 @@ namespace rfb {
out = buffer;
in = src;
in_len = bytes;
- while ((*in != '\0') && (in_len > 0)) {
+ while ((in_len > 0) && (*in != '\0')) {
if (*in != '\r') {
*out++ = *in++;
in_len--;
continue;
}
- if ((in_len == 0) || (*(in+1) != '\n'))
+ if ((in_len < 2) || (*(in+1) != '\n'))
*out++ = '\n';
in++;
@@ -182,11 +182,11 @@ namespace rfb {
// Compute output size
in = src;
in_len = bytes;
- while ((*in != '\0') && (in_len > 0)) {
+ while ((in_len > 0) && (*in != '\0')) {
sz++;
if (*in == '\r') {
- if ((in_len == 0) || (*(in+1) != '\n'))
+ if ((in_len < 2) || (*(in+1) != '\n'))
sz++;
} else if (*in == '\n') {
if ((in == src) || (*(in-1) != '\r'))
@@ -205,7 +205,7 @@ namespace rfb {
out = buffer;
in = src;
in_len = bytes;
- while ((*in != '\0') && (in_len > 0)) {
+ while ((in_len > 0) && (*in != '\0')) {
if (*in == '\n') {
if ((in == src) || (*(in-1) != '\r'))
*out++ = '\r';
@@ -214,7 +214,7 @@ namespace rfb {
*out = *in;
if (*in == '\r') {
- if ((in_len == 0) || (*(in+1) != '\n')) {
+ if ((in_len < 2) || (*(in+1) != '\n')) {
out++;
*out = '\n';
}
@@ -376,7 +376,7 @@ namespace rfb {
// Compute output size
in = src;
in_len = bytes;
- while ((*in != '\0') && (in_len > 0)) {
+ while ((in_len > 0) && (*in != '\0')) {
char buf[5];
sz += ucs4ToUTF8(*in, buf);
in++;
@@ -391,7 +391,7 @@ namespace rfb {
out = buffer;
in = src;
in_len = bytes;
- while ((*in != '\0') && (in_len > 0)) {
+ while ((in_len > 0) && (*in != '\0')) {
out += ucs4ToUTF8(*in, out);
in++;
in_len--;
@@ -414,7 +414,7 @@ namespace rfb {
// Compute output size
in = src;
in_len = bytes;
- while ((*in != '\0') && (in_len > 0)) {
+ while ((in_len > 0) && (*in != '\0')) {
size_t len;
unsigned ucs;
@@ -432,7 +432,7 @@ namespace rfb {
out = buffer;
in = src;
in_len = bytes;
- while ((*in != '\0') && (in_len > 0)) {
+ while ((in_len > 0) && (*in != '\0')) {
size_t len;
unsigned ucs;
@@ -464,7 +464,7 @@ namespace rfb {
// Compute output size
in = src;
in_len = units;
- while ((*in != '\0') && (in_len > 0)) {
+ while ((in_len > 0) && (*in != '\0')) {
size_t len;
unsigned ucs;
char buf[5];
@@ -484,7 +484,7 @@ namespace rfb {
out = buffer;
in = src;
in_len = units;
- while ((*in != '\0') && (in_len > 0)) {
+ while ((in_len > 0) && (*in != '\0')) {
size_t len;
unsigned ucs;
@@ -513,7 +513,7 @@ namespace rfb {
// Compute output size
in = src;
in_len = bytes;
- while ((*in != '\0') && (in_len > 0)) {
+ while ((in_len > 0) && (*in != '\0')) {
size_t len;
unsigned ucs;
wchar_t buf[3];
@@ -533,7 +533,7 @@ namespace rfb {
out = buffer;
in = src;
in_len = bytes;
- while ((*in != '\0') && (in_len > 0)) {
+ while ((in_len > 0) && (*in != '\0')) {
size_t len;
unsigned ucs;
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 7e006815..4399dad0 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,46 +1,5 @@
-include_directories(${FLTK_INCLUDE_DIR})
-include_directories(${GETTEXT_INCLUDE_DIR})
+# Benchmarking tools
+add_subdirectory(perf)
-include_directories(${CMAKE_SOURCE_DIR}/common)
-
-add_library(test_util STATIC util.cxx)
-
-add_executable(convperf convperf.cxx)
-target_link_libraries(convperf test_util rfb)
-
-add_executable(conv conv.cxx)
-target_link_libraries(conv rfb)
-
-add_executable(decperf decperf.cxx)
-target_link_libraries(decperf test_util rfb)
-
-add_executable(encperf encperf.cxx)
-target_link_libraries(encperf test_util rfb)
-
-add_executable(hostport hostport.cxx)
-target_link_libraries(hostport rfb)
-
-set(FBPERF_SOURCES
- fbperf.cxx
- ../vncviewer/PlatformPixelBuffer.cxx
- ../vncviewer/Surface.cxx)
-if(WIN32)
- set(FBPERF_SOURCES ${FBPERF_SOURCES} ../vncviewer/Surface_Win32.cxx)
-elseif(APPLE)
- set(FBPERF_SOURCES
- ${FBPERF_SOURCES} ../vncviewer/Surface_OSX.cxx
- ${FBPERF_SOURCES} ../vncviewer/keysym2ucs.c
- ${FBPERF_SOURCES} ../vncviewer/cocoa.mm)
-else()
- set(FBPERF_SOURCES ${FBPERF_SOURCES} ../vncviewer/Surface_X11.cxx)
-endif()
-add_executable(fbperf ${FBPERF_SOURCES})
-target_link_libraries(fbperf test_util rfb ${FLTK_LIBRARIES} ${GETTEXT_LIBRARIES})
-if(WIN32)
- target_link_libraries(fbperf msimg32)
-endif()
-if(APPLE)
- target_link_libraries(fbperf "-framework Cocoa")
- target_link_libraries(fbperf "-framework Carbon")
- target_link_libraries(fbperf "-framework IOKit")
-endif()
+# Unit tests
+add_subdirectory(unit)
diff --git a/tests/perf/CMakeLists.txt b/tests/perf/CMakeLists.txt
new file mode 100644
index 00000000..053bfaae
--- /dev/null
+++ b/tests/perf/CMakeLists.txt
@@ -0,0 +1,40 @@
+include_directories(${FLTK_INCLUDE_DIR})
+include_directories(${GETTEXT_INCLUDE_DIR})
+
+include_directories(${CMAKE_SOURCE_DIR}/common)
+
+add_library(test_util STATIC util.cxx)
+
+add_executable(convperf convperf.cxx)
+target_link_libraries(convperf test_util rfb)
+
+add_executable(decperf decperf.cxx)
+target_link_libraries(decperf test_util rfb)
+
+add_executable(encperf encperf.cxx)
+target_link_libraries(encperf test_util rfb)
+
+set(FBPERF_SOURCES
+ fbperf.cxx
+ ${CMAKE_SOURCE_DIR}/vncviewer/PlatformPixelBuffer.cxx
+ ${CMAKE_SOURCE_DIR}/vncviewer/Surface.cxx)
+if(WIN32)
+ set(FBPERF_SOURCES ${FBPERF_SOURCES} ${CMAKE_SOURCE_DIR}/vncviewer/Surface_Win32.cxx)
+elseif(APPLE)
+ set(FBPERF_SOURCES
+ ${FBPERF_SOURCES} ${CMAKE_SOURCE_DIR}/vncviewer/Surface_OSX.cxx
+ ${FBPERF_SOURCES} ${CMAKE_SOURCE_DIR}/vncviewer/keysym2ucs.c
+ ${FBPERF_SOURCES} ${CMAKE_SOURCE_DIR}/vncviewer/cocoa.mm)
+else()
+ set(FBPERF_SOURCES ${FBPERF_SOURCES} ${CMAKE_SOURCE_DIR}/vncviewer/Surface_X11.cxx)
+endif()
+add_executable(fbperf ${FBPERF_SOURCES})
+target_link_libraries(fbperf test_util rfb ${FLTK_LIBRARIES} ${GETTEXT_LIBRARIES})
+if(WIN32)
+ target_link_libraries(fbperf msimg32)
+endif()
+if(APPLE)
+ target_link_libraries(fbperf "-framework Cocoa")
+ target_link_libraries(fbperf "-framework Carbon")
+ target_link_libraries(fbperf "-framework IOKit")
+endif()
diff --git a/tests/convperf.cxx b/tests/perf/convperf.cxx
index e4a3fd52..e4a3fd52 100644
--- a/tests/convperf.cxx
+++ b/tests/perf/convperf.cxx
diff --git a/tests/decperf.cxx b/tests/perf/decperf.cxx
index df5214f2..df5214f2 100644
--- a/tests/decperf.cxx
+++ b/tests/perf/decperf.cxx
diff --git a/tests/encperf.cxx b/tests/perf/encperf.cxx
index e461197e..e461197e 100644
--- a/tests/encperf.cxx
+++ b/tests/perf/encperf.cxx
diff --git a/tests/fbperf.cxx b/tests/perf/fbperf.cxx
index a19ee479..a19ee479 100644
--- a/tests/fbperf.cxx
+++ b/tests/perf/fbperf.cxx
diff --git a/tests/results/multicore/README b/tests/perf/results/multicore/README
index c93b2d7a..c93b2d7a 100644
--- a/tests/results/multicore/README
+++ b/tests/perf/results/multicore/README
diff --git a/tests/results/multicore/multicore.ods b/tests/perf/results/multicore/multicore.ods
index 42e024d6..42e024d6 100644
--- a/tests/results/multicore/multicore.ods
+++ b/tests/perf/results/multicore/multicore.ods
Binary files differ
diff --git a/tests/results/notrans/README b/tests/perf/results/notrans/README
index 3723e67d..3723e67d 100644
--- a/tests/results/notrans/README
+++ b/tests/perf/results/notrans/README
diff --git a/tests/results/notrans/armhf.csv b/tests/perf/results/notrans/armhf.csv
index 3ccb6d9b..3ccb6d9b 100644
--- a/tests/results/notrans/armhf.csv
+++ b/tests/perf/results/notrans/armhf.csv
diff --git a/tests/results/notrans/i386.csv b/tests/perf/results/notrans/i386.csv
index bb9247d3..bb9247d3 100644
--- a/tests/results/notrans/i386.csv
+++ b/tests/perf/results/notrans/i386.csv
diff --git a/tests/results/notrans/x86_64.csv b/tests/perf/results/notrans/x86_64.csv
index 18fc03f3..18fc03f3 100644
--- a/tests/results/notrans/x86_64.csv
+++ b/tests/perf/results/notrans/x86_64.csv
diff --git a/tests/util.cxx b/tests/perf/util.cxx
index 17a83698..17a83698 100644
--- a/tests/util.cxx
+++ b/tests/perf/util.cxx
diff --git a/tests/util.h b/tests/perf/util.h
index 2b8ab4a8..2b8ab4a8 100644
--- a/tests/util.h
+++ b/tests/perf/util.h
diff --git a/tests/unit/CMakeLists.txt b/tests/unit/CMakeLists.txt
new file mode 100644
index 00000000..c847238d
--- /dev/null
+++ b/tests/unit/CMakeLists.txt
@@ -0,0 +1,10 @@
+include_directories(${CMAKE_SOURCE_DIR}/common)
+
+add_executable(conv conv.cxx)
+target_link_libraries(conv rfb)
+
+add_executable(convertlf convertlf.cxx)
+target_link_libraries(convertlf rfb)
+
+add_executable(hostport hostport.cxx)
+target_link_libraries(hostport rfb)
diff --git a/tests/conv.cxx b/tests/unit/conv.cxx
index 3901b9d1..3901b9d1 100644
--- a/tests/conv.cxx
+++ b/tests/unit/conv.cxx
diff --git a/tests/unit/convertlf.cxx b/tests/unit/convertlf.cxx
new file mode 100644
index 00000000..6bd98fe2
--- /dev/null
+++ b/tests/unit/convertlf.cxx
@@ -0,0 +1,124 @@
+/* Copyright 2019 Pierre Ossman <ossman@cendio.se> for Cendio AB
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+#include <stdio.h>
+
+#include <rfb/util.h>
+
+static const char* escape(const char* input)
+{
+ static char output[4096];
+
+ const char* in;
+ char* out;
+
+ in = input;
+ out = output;
+ do {
+ if (*in == '\r') {
+ *out++ = '\\';
+ *out++ = 'r';
+ } else if (*in == '\n') {
+ *out++ = '\\';
+ *out++ = 'n';
+ } else {
+ *out++ = *in;
+ }
+ } while (*in++ != '\0');
+
+ return output;
+}
+
+static void testLF(const char* input, const char* expected)
+{
+ char* output;
+
+ printf("convertLF(\"%s\"): ", escape(input));
+
+ output = rfb::convertLF(input);
+
+ if (strcmp(output, expected) != 0)
+ printf("FAILED: got \"%s\"", escape(output));
+ else
+ printf("OK");
+ printf("\n");
+ fflush(stdout);
+
+ rfb::strFree(output);
+}
+
+static void testCRLF(const char* input, const char* expected)
+{
+ char* output;
+
+ printf("convertCRLF(\"%s\"): ", escape(input));
+
+ output = rfb::convertCRLF(input);
+
+ if (strcmp(output, expected) != 0)
+ printf("FAILED: got \"%s\"", escape(output));
+ else
+ printf("OK");
+ printf("\n");
+ fflush(stdout);
+
+ rfb::strFree(output);
+}
+
+int main(int argc, char** argv)
+{
+ testLF("", "");
+ testLF("no EOL", "no EOL");
+
+ testLF("\n", "\n");
+ testLF("already correct\n", "already correct\n");
+ testLF("multiple\nlines\n", "multiple\nlines\n");
+ testLF("empty lines\n\n", "empty lines\n\n");
+ testLF("\ninitial line", "\ninitial line");
+
+ testLF("\r\n", "\n");
+ testLF("one line\r\n", "one line\n");
+ testLF("multiple\r\nlines\r\n", "multiple\nlines\n");
+ testLF("empty lines\r\n\r\n", "empty lines\n\n");
+ testLF("\r\ninitial line", "\ninitial line");
+ testLF("mixed\r\nlines\n", "mixed\nlines\n");
+
+ testLF("cropped\r", "cropped\n");
+ testLF("old\rmac\rformat", "old\nmac\nformat");
+
+ testCRLF("", "");
+ testCRLF("no EOL", "no EOL");
+
+ testCRLF("\r\n", "\r\n");
+ testCRLF("already correct\r\n", "already correct\r\n");
+ testCRLF("multiple\r\nlines\r\n", "multiple\r\nlines\r\n");
+ testCRLF("empty lines\r\n\r\n", "empty lines\r\n\r\n");
+ testCRLF("\r\ninitial line", "\r\ninitial line");
+
+ testCRLF("\n", "\r\n");
+ testCRLF("one line\n", "one line\r\n");
+ testCRLF("multiple\nlines\n", "multiple\r\nlines\r\n");
+ testCRLF("empty lines\n\n", "empty lines\r\n\r\n");
+ testCRLF("\ninitial line", "\r\ninitial line");
+ testCRLF("mixed\r\nlines\n", "mixed\r\nlines\r\n");
+
+ testCRLF("cropped\r", "cropped\r\n");
+ testCRLF("old\rmac\rformat", "old\r\nmac\r\nformat");
+
+ return 0;
+}
diff --git a/tests/hostport.cxx b/tests/unit/hostport.cxx
index 00026e61..00026e61 100644
--- a/tests/hostport.cxx
+++ b/tests/unit/hostport.cxx
diff --git a/win/rfb_win32/SDisplay.cxx b/win/rfb_win32/SDisplay.cxx
index be33ff15..06eccd9a 100644
--- a/win/rfb_win32/SDisplay.cxx
+++ b/win/rfb_win32/SDisplay.cxx
@@ -45,7 +45,7 @@ static LogWriter vlog("SDisplay");
// - SDisplay-specific configuration options
IntParameter rfb::win32::SDisplay::updateMethod("UpdateMethod",
- "How to discover desktop updates; 0 - Polling, 1 - Application hooking, 2 - Driver hooking.", 1);
+ "How to discover desktop updates; 0 - Polling, 1 - Application hooking, 2 - Driver hooking.", 0);
BoolParameter rfb::win32::SDisplay::disableLocalInputs("DisableLocalInputs",
"Disable local keyboard and pointer input while the server is in use", false);
StringParameter rfb::win32::SDisplay::disconnectAction("DisconnectAction",