diff --git a/tests/common/Makefile.am b/tests/common/Makefile.am index bf3cf7e6..5a5ca8d5 100644 --- a/tests/common/Makefile.am +++ b/tests/common/Makefile.am @@ -12,10 +12,12 @@ check_PROGRAMS = test_common test_common_SOURCES = \ test_common.h \ test_common_main.c \ - test_string_calls.c + test_string_calls.c \ + test_os_calls.c test_common_CFLAGS = \ - @CHECK_CFLAGS@ + @CHECK_CFLAGS@ \ + -D TOP_SRCDIR=\"$(top_srcdir)\" test_common_LDADD = \ $(top_builddir)/common/libcommon.la \ diff --git a/tests/common/test_common.h b/tests/common/test_common.h index 7370c838..b9db8373 100644 --- a/tests/common/test_common.h +++ b/tests/common/test_common.h @@ -5,5 +5,6 @@ #include Suite *make_suite_test_string(void); +Suite *make_suite_test_os_calls(void); -#endif /* TEST_COMMON_H */ \ No newline at end of file +#endif /* TEST_COMMON_H */ diff --git a/tests/common/test_common_main.c b/tests/common/test_common_main.c index a6cf6b68..694a827a 100644 --- a/tests/common/test_common_main.c +++ b/tests/common/test_common_main.c @@ -13,6 +13,7 @@ int main (void) SRunner *sr; sr = srunner_create (make_suite_test_string()); + srunner_add_suite(sr, make_suite_test_os_calls()); // srunner_add_suite(sr, make_list_suite()); srunner_set_tap(sr, "-"); diff --git a/tests/common/test_os_calls.c b/tests/common/test_os_calls.c new file mode 100644 index 00000000..e9f0adff --- /dev/null +++ b/tests/common/test_os_calls.c @@ -0,0 +1,55 @@ + +#if defined(HAVE_CONFIG_H) +#include "config_ac.h" +#endif + +#include +#include "test_common.h" +#include "os_calls.h" + +#ifndef TOP_SRCDIR +#define TOP_SRCDIR "." +#endif + +START_TEST(test_g_file_get_size__returns_file_size) +{ + unsigned long long size; + + size = g_file_get_size(TOP_SRCDIR "/xrdp/xrdp256.bmp"); + ck_assert_int_eq(size, 49278); + + + size = g_file_get_size(TOP_SRCDIR "/xrdp/ad256.bmp"); + ck_assert_int_eq(size, 19766); + +} +END_TEST + +START_TEST(test_g_file_get_size__more_than_4GiB) +{ + unsigned long long size; + + system("dd if=/dev/zero of=./file_5GiB.dat bs=4k count=1310720"); + + size = g_file_get_size("./file_5GiB.dat"); + ck_assert_int_eq(size, 5368709120); +} +END_TEST + + +/******************************************************************************/ +Suite * +make_suite_test_os_calls(void) +{ + Suite *s; + TCase *tc_os_calls; + + s = suite_create("OS-Calls"); + + tc_os_calls = tcase_create("oscalls-file"); + suite_add_tcase(s, tc_os_calls); + tcase_add_test(tc_os_calls, test_g_file_get_size__returns_file_size); + tcase_add_test(tc_os_calls, test_g_file_get_size__more_than_4GiB); + + return s; +}