mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-06 05:07:41 +00:00
Randomized test.
This commit is contained in:
@@ -26,6 +26,26 @@ void guac_close(GUACIO* io) {
|
|||||||
free(io);
|
free(io);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ssize_t guac_write_int(GUACIO* io, unsigned int i) {
|
||||||
|
|
||||||
|
char buffer[128];
|
||||||
|
char* ptr = &(buffer[127]);
|
||||||
|
|
||||||
|
*ptr = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
|
||||||
|
ptr--;
|
||||||
|
*ptr = '0' + (i % 10);
|
||||||
|
|
||||||
|
i /= 10;
|
||||||
|
|
||||||
|
} while (i > 0 && ptr >= buffer);
|
||||||
|
|
||||||
|
return guac_write_string(io, ptr);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ssize_t guac_write_string(GUACIO* io, const char* str) {
|
ssize_t guac_write_string(GUACIO* io, const char* str) {
|
||||||
|
|
||||||
int fd = io->fd;
|
int fd = io->fd;
|
||||||
|
@@ -17,6 +17,7 @@ typedef struct GUACIO {
|
|||||||
} GUACIO;
|
} GUACIO;
|
||||||
|
|
||||||
GUACIO* guac_open(int fd);
|
GUACIO* guac_open(int fd);
|
||||||
|
ssize_t guac_write_int(GUACIO* io, unsigned int i);
|
||||||
ssize_t guac_write_string(GUACIO* io, const char* str);
|
ssize_t guac_write_string(GUACIO* io, const char* str);
|
||||||
ssize_t guac_write_base64(GUACIO* io, const void* buf, size_t count);
|
ssize_t guac_write_base64(GUACIO* io, const void* buf, size_t count);
|
||||||
ssize_t guac_flush_base64(GUACIO* io);
|
ssize_t guac_flush_base64(GUACIO* io);
|
||||||
|
@@ -28,6 +28,8 @@ void proxy(int client_fd) {
|
|||||||
|
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
|
int test_index;
|
||||||
|
|
||||||
GUACIO* io = guac_open(client_fd);
|
GUACIO* io = guac_open(client_fd);
|
||||||
|
|
||||||
/*** INIT ***/
|
/*** INIT ***/
|
||||||
@@ -35,23 +37,31 @@ void proxy(int client_fd) {
|
|||||||
/* Allocate rows for PNG */
|
/* Allocate rows for PNG */
|
||||||
png_rows = (png_byte**) malloc(100 /* height */ * sizeof(png_byte*));
|
png_rows = (png_byte**) malloc(100 /* height */ * sizeof(png_byte*));
|
||||||
|
|
||||||
/* For now, generate test white image */
|
|
||||||
for (y=0; y<100 /* height */; y++) {
|
|
||||||
|
|
||||||
row = (png_byte*) malloc(sizeof(png_byte) * 3 * 100 /* width */);
|
|
||||||
png_rows[y] = row;
|
|
||||||
|
|
||||||
for (x=0; x<100 /* width */; x++) {
|
|
||||||
*row++ = 0xFF;
|
|
||||||
*row++ = 0xFF;
|
|
||||||
*row++ = 0xFF;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
guac_write_string(io, "name:hello;size:1024,768;");
|
guac_write_string(io, "name:hello;size:1024,768;");
|
||||||
|
|
||||||
for (y=0; y<200; y++) {
|
for (test_index=0; test_index<200; test_index++) {
|
||||||
|
|
||||||
|
/* For now, generate test white image */
|
||||||
|
for (y=0; y<100 /* height */; y++) {
|
||||||
|
|
||||||
|
row = (png_byte*) malloc(sizeof(png_byte) * 3 * 100 /* width */);
|
||||||
|
png_rows[y] = row;
|
||||||
|
|
||||||
|
for (x=0; x<100 /* width */; x++) {
|
||||||
|
*row++ = random() % 0xFF;
|
||||||
|
|
||||||
|
if (test_index % 2 == 0)
|
||||||
|
*row++ = random() % 0xFF;
|
||||||
|
else
|
||||||
|
*row++ = 0x00;
|
||||||
|
|
||||||
|
if (test_index % 3 == 0)
|
||||||
|
*row++ = random() % 0xFF;
|
||||||
|
else
|
||||||
|
*row++ = 0x00;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* Write image */
|
/* Write image */
|
||||||
|
|
||||||
@@ -91,7 +101,11 @@ void proxy(int client_fd) {
|
|||||||
PNG_FILTER_TYPE_DEFAULT
|
PNG_FILTER_TYPE_DEFAULT
|
||||||
);
|
);
|
||||||
|
|
||||||
guac_write_string(io, "png:0,0,");
|
guac_write_string(io, "png:");
|
||||||
|
guac_write_int(io, random()%1024);
|
||||||
|
guac_write_string(io, ",");
|
||||||
|
guac_write_int(io, random()%768);
|
||||||
|
guac_write_string(io, ",");
|
||||||
png_set_rows(png, png_info, png_rows);
|
png_set_rows(png, png_info, png_rows);
|
||||||
png_write_png(png, png_info, PNG_TRANSFORM_IDENTITY, NULL);
|
png_write_png(png, png_info, PNG_TRANSFORM_IDENTITY, NULL);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user