tests: add test on g_file_get_size()
This commit is contained in:
parent
a266d67fdf
commit
8e4ea49532
@ -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 \
|
||||
|
@ -5,5 +5,6 @@
|
||||
#include <check.h>
|
||||
|
||||
Suite *make_suite_test_string(void);
|
||||
Suite *make_suite_test_os_calls(void);
|
||||
|
||||
#endif /* TEST_COMMON_H */
|
@ -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, "-");
|
||||
|
55
tests/common/test_os_calls.c
Normal file
55
tests/common/test_os_calls.c
Normal file
@ -0,0 +1,55 @@
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
#include "config_ac.h"
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user