cunit: cleanup
authorMarc-André Moreau <marcandre.moreau@gmail.com>
Tue, 14 Feb 2012 02:02:09 +0000 (21:02 -0500)
committerMarc-André Moreau <marcandre.moreau@gmail.com>
Tue, 14 Feb 2012 02:02:09 +0000 (21:02 -0500)
cunit/CMakeLists.txt
cunit/test_channels.c
cunit/test_channels.h
cunit/test_freerdp.c
cunit/test_gdi.c [moved from cunit/test_libgdi.c with 99% similarity]
cunit/test_gdi.h [moved from cunit/test_libgdi.h with 94% similarity]
cunit/test_rfx.c [moved from cunit/test_librfx.c with 99% similarity]
cunit/test_rfx.h [moved from cunit/test_librfx.h with 91% similarity]

index 7dbb6e9..863ee0b 100644 (file)
@@ -38,8 +38,8 @@ add_executable(test_freerdp
        test_color.h
        test_bitmap.c
        test_bitmap.h
-       test_libgdi.c
-       test_libgdi.h
+       test_gdi.c
+       test_gdi.h
        test_list.c
        test_list.h
        test_orders.c
@@ -58,8 +58,8 @@ add_executable(test_freerdp
        test_cliprdr.h
        test_drdynvc.c
        test_drdynvc.h
-       test_librfx.c
-       test_librfx.h
+       test_rfx.c
+       test_rfx.h
        test_freerdp.c
        test_freerdp.h
        test_rail.c
index da2cd63..6ef97cd 100644 (file)
 
 #include "test_channels.h"
 
-int init_chanman_suite(void)
+int init_channels_suite(void)
 {
        freerdp_channels_global_init();
        return 0;
 }
 
-int clean_chanman_suite(void)
+int clean_channels_suite(void)
 {
        freerdp_channels_global_uninit();
        return 0;
 }
 
-int add_chanman_suite(void)
+int add_channels_suite(void)
 {
-       add_test_suite(chanman);
+       add_test_suite(channels);
 
-       add_test_function(chanman);
+       add_test_function(channels);
 
        return 0;
 }
@@ -54,7 +54,7 @@ static int test_rdp_channel_data(freerdp* instance, int chan_id, uint8* data, in
        return 0;
 }
 
-void test_chanman(void)
+void test_channels(void)
 {
        rdpChannels* chan_man;
        rdpSettings settings = { 0 };
index 0022d30..678a5c0 100644 (file)
@@ -19,8 +19,8 @@
 
 #include "test_freerdp.h"
 
-int init_chanman_suite(void);
-int clean_chanman_suite(void);
-int add_chanman_suite(void);
+int init_channels_suite(void);
+int clean_channels_suite(void);
+int add_channels_suite(void);
 
-void test_chanman(void);
+void test_channels(void);
index 33c4539..ab99e98 100644 (file)
@@ -25,7 +25,7 @@
 #include "test_mcs.h"
 #include "test_color.h"
 #include "test_bitmap.h"
-#include "test_libgdi.h"
+#include "test_gdi.h"
 #include "test_list.h"
 #include "test_stream.h"
 #include "test_utils.h"
@@ -34,7 +34,7 @@
 #include "test_channels.h"
 #include "test_cliprdr.h"
 #include "test_drdynvc.h"
-#include "test_librfx.h"
+#include "test_rfx.h"
 #include "test_freerdp.h"
 #include "test_rail.h"
 #include "test_pcap.h"
@@ -107,109 +107,79 @@ void assert_stream(STREAM* s, uint8* data, int length, const char* func, int lin
        }
 }
 
+typedef boolean (*pInitTestSuite)(void);
+
+struct _test_suite
+{
+       char name[32];
+       pInitTestSuite Init;
+};
+typedef struct _test_suite test_suite;
+
+static test_suite suites[] =
+{
+       { "ber", add_ber_suite },
+       { "bitmap", add_bitmap_suite },
+       { "channels", add_channels_suite },
+       { "cliprdr", add_cliprdr_suite },
+       { "color", add_color_suite },
+       { "drdynvc", add_drdynvc_suite },
+       { "gcc", add_gcc_suite },
+       { "gdi", add_gdi_suite },
+       { "license", add_license_suite },
+       { "list", add_list_suite },
+       { "mcs", add_mcs_suite },
+       { "mppc", add_mppc_suite },
+       { "orders", add_orders_suite },
+       { "pcap", add_pcap_suite },
+       { "per", add_per_suite },
+       { "rail", add_rail_suite },
+       { "rfx", add_rfx_suite },
+       { "stream", add_stream_suite },
+       { "utils", add_utils_suite },
+       { "", NULL }
+};
+
 int main(int argc, char* argv[])
 {
+       int k;
        int index = 1;
        int *pindex = &index;
-       int ret = 0;
+       int status = 0;
 
        if (CU_initialize_registry() != CUE_SUCCESS)
                return CU_get_error();
 
        if (argc < *pindex + 1)
        {
-               add_per_suite();
-               add_ber_suite();
-               add_gcc_suite();
-               add_mcs_suite();
-               add_color_suite();
-               add_bitmap_suite();
-               add_libgdi_suite();
-               add_list_suite();
-               add_orders_suite();
-               add_license_suite();
-               add_stream_suite();
-               add_mppc_suite();
+               k = 0;
+
+               printf("\ntest suites:\n\n");
+               while (suites[k].Init != NULL)
+               {
+                       printf("\t%s\n", suites[k].name);
+                       k++;
+               }
+
+               printf("\nusage: ./test_freerdp <suite-1> <suite-2> ... <suite-n>\n");
+
+               return 0;
        }
        else
        {
                while (*pindex < argc)
                {
-                       if (strcmp("rail", argv[*pindex]) == 0)
-                       {
-                               add_rail_suite();
-                       }
-                       if (strcmp("color", argv[*pindex]) == 0)
-                       {
-                               add_color_suite();
-                       }
-                       if (strcmp("bitmap", argv[*pindex]) == 0)
-                       {
-                               add_bitmap_suite();
-                       }
-                       else if (strcmp("libgdi", argv[*pindex]) == 0)
-                       {
-                               add_libgdi_suite();
-                       }
-                       else if (strcmp("list", argv[*pindex]) == 0)
-                       {
-                               add_list_suite();
-                       }
-                       else if (strcmp("orders", argv[*pindex]) == 0)
-                       {
-                               add_orders_suite();
-                       }
-                       else if (strcmp("license", argv[*pindex]) == 0)
-                       {
-                               add_license_suite();
-                       }
-                       else if (strcmp("stream", argv[*pindex]) == 0)
-                       {
-                               add_stream_suite();
-                       }
-                       else if (strcmp("utils", argv[*pindex]) == 0)
-                       {
-                               add_utils_suite();
-                       }
-                       else if (strcmp("chanman", argv[*pindex]) == 0)
-                       {
-                               add_chanman_suite();
-                       }
-                       else if (strcmp("cliprdr", argv[*pindex]) == 0)
-                       {
-                               add_cliprdr_suite();
-                       }
-                       else if (strcmp("drdynvc", argv[*pindex]) == 0)
-                       {
-                               add_drdynvc_suite();
-                       }
-                       else if (strcmp("librfx", argv[*pindex]) == 0)
-                       {
-                               add_librfx_suite();
-                       }
-                       else if (strcmp("per", argv[*pindex]) == 0)
-                       {
-                               add_per_suite();
-                       }
-                       else if (strcmp("pcap", argv[*pindex]) == 0)
-                       {
-                               add_pcap_suite();
-                       }
-                       else if (strcmp("ber", argv[*pindex]) == 0)
-                       {
-                               add_ber_suite();
-                       }
-                       else if (strcmp("gcc", argv[*pindex]) == 0)
-                       {
-                               add_gcc_suite();
-                       }
-                       else if (strcmp("mcs", argv[*pindex]) == 0)
-                       {
-                               add_mcs_suite();
-                       }
-                       else if (strcmp("mppc", argv[*pindex]) == 0)
+                       k = 0;
+
+                       while (suites[k].Init != NULL)
                        {
-                               add_mppc_suite();
+                               if (strcmp(suites[k].name, argv[*pindex]) == 0)
+                               {
+                                       suites[k].Init();
+                                       break;
+                               }
+
+                               k++;
                        }
 
                        *pindex = *pindex + 1;
@@ -218,9 +188,10 @@ int main(int argc, char* argv[])
 
        CU_basic_set_mode(CU_BRM_VERBOSE);
        CU_basic_run_tests();
-       ret = CU_get_number_of_failure_records();
+
+       status = CU_get_number_of_failure_records();
        CU_cleanup_registry();
 
-       return ret;
+       return status;
 }
 
similarity index 99%
rename from cunit/test_libgdi.c
rename to cunit/test_gdi.c
index df352df..fe598fa 100644 (file)
 #include <freerdp/gdi/clipping.h>
 #include <freerdp/gdi/32bpp.h>
 
-#include "test_libgdi.h"
+#include "test_gdi.h"
 
-int init_libgdi_suite(void)
+int init_gdi_suite(void)
 {
        return 0;
 }
 
-int clean_libgdi_suite(void)
+int clean_gdi_suite(void)
 {
        return 0;
 }
 
-int add_libgdi_suite(void)
+int add_gdi_suite(void)
 {
-       add_test_suite(libgdi);
+       add_test_suite(gdi);
 
        add_test_function(gdi_GetDC);
        add_test_function(gdi_CreateCompatibleDC);
similarity index 94%
rename from cunit/test_libgdi.h
rename to cunit/test_gdi.h
index 7b181b1..14e0fd1 100644 (file)
@@ -19,9 +19,9 @@
 
 #include "test_freerdp.h"
 
-int init_libgdi_suite(void);
-int clean_libgdi_suite(void);
-int add_libgdi_suite(void);
+int init_gdi_suite(void);
+int clean_gdi_suite(void);
+int add_gdi_suite(void);
 
 void test_gdi_GetDC(void);
 void test_gdi_CreateCompatibleDC(void);
similarity index 99%
rename from cunit/test_librfx.c
rename to cunit/test_rfx.c
index 8799959..bfd2370 100644 (file)
@@ -39,7 +39,7 @@
 #include "rfx_decode.h"
 #include "rfx_encode.h"
 
-#include "test_librfx.h"
+#include "test_rfx.h"
 
 static const uint8 y_data[] =
 {
@@ -159,19 +159,19 @@ static const uint8 rgb_scanline_data[] =
 
 static uint8* rgb_data;
 
-int init_librfx_suite(void)
+int init_rfx_suite(void)
 {
        return 0;
 }
 
-int clean_librfx_suite(void)
+int clean_rfx_suite(void)
 {
        return 0;
 }
 
-int add_librfx_suite(void)
+int add_rfx_suite(void)
 {
-       add_test_suite(librfx);
+       add_test_suite(rfx);
 
        add_test_function(bitstream);
        add_test_function(bitstream_enc);
similarity index 91%
rename from cunit/test_librfx.h
rename to cunit/test_rfx.h
index f007816..0f95969 100644 (file)
@@ -19,9 +19,9 @@
 
 #include "test_freerdp.h"
 
-int init_librfx_suite(void);
-int clean_librfx_suite(void);
-int add_librfx_suite(void);
+int init_rfx_suite(void);
+int clean_rfx_suite(void);
+int add_rfx_suite(void);
 
 void test_bitstream(void);
 void test_bitstream_enc(void);