From: YongHao Hu Subject: [3/4] msvcp120/tests: Add file_size test. Message-Id: <55084B3F.4050203@gmail.com> Date: Tue, 17 Mar 2015 23:41:51 +0800 --- dlls/msvcp120/tests/msvcp120.c | 66 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c index e51f0a9..645e10d 100644 --- a/dlls/msvcp120/tests/msvcp120.c +++ b/dlls/msvcp120/tests/msvcp120.c @@ -16,6 +16,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ +#include +#include + #include "wine/test.h" #include "winbase.h" @@ -30,6 +33,9 @@ typedef struct { static MSVCRT_long (__cdecl *p__Xtime_diff_to_millis2)(const xtime*, const xtime*); static int (__cdecl *p_xtime_get)(xtime*, int); +/* filesystem */ +static unsigned long long (*__cdecl p_tr2_sys_file_size)(char const*); + static HMODULE msvcp; #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y) #define SET(x,y) do { SETNOFAIL(x,y); ok(x != NULL, "Export '%s' not found\n", y); } while(0) @@ -47,17 +53,26 @@ static BOOL init(void) "_Xtime_diff_to_millis2"); SET(p_xtime_get, "xtime_get"); + + SET(p_tr2_sys_file_size, + "?_File_size@sys@tr2@std@@YA_KPEBD@Z"); } else { #ifdef __arm__ SET(p__Xtime_diff_to_millis2, "_Xtime_diff_to_millis2"); SET(p_xtime_get, "xtime_get"); + + SET(p_tr2_sys_file_size, + "?_File_size@sys@tr2@std@@YA_KPBD@Z"); #else SET(p__Xtime_diff_to_millis2, "_Xtime_diff_to_millis2"); SET(p_xtime_get, "xtime_get"); + + SET(p_tr2_sys_file_size, + "?_File_size@sys@tr2@std@@YA_KPBD@Z"); #endif } @@ -148,11 +163,62 @@ static void test_xtime_get(void) "xtime_get() should have modified the xtime struct with the given option\n"); } +/* create a directory tree that can be used by subsequent tests + * ├── dir + * │   ├── d1 + * │   │   └── d1f1 an empty file + * │   ├── f0 an empty file + * │   └── f1 a file containing "file f1" + */ +static void create_tree(void) +{ + FILE *file; + mkdir("dir"); + mkdir("dir/d1"); + file = fopen("dir/d1/d1f1", "wt"); + fprintf(file, ""); + fclose(file); + + file = fopen("dir/f0", "wt"); + fprintf(file, ""); + fclose(file); + + file = fopen("dir/f1", "wt"); + fprintf(file, "file f1"); + fclose(file); +} + +static void test_tr2_sys_file_size(void) +{ + unsigned long long val; + val = p_tr2_sys_file_size("dir/d1/d1f1"); + ok(val==0, "test fail: file_size is %llu\n", val); + + val = p_tr2_sys_file_size("dir/f0"); + ok(val==0, "test fail: file_size is %llu\n", val); + + val = p_tr2_sys_file_size("dir/f1"); + ok(val==7, "test fail: file_size is %llu\n", val); +} + +static void remove_tree(void) +{ + unlink("dir/f0"); + unlink("dir/f1"); + unlink("dir/d1/d1f1"); + rmdir("dir/d1"); + rmdir("dir"); +} + START_TEST(msvcp120) { if(!init()) return; test__Xtime_diff_to_millis2(); test_xtime_get(); + create_tree(); + test_tr2_sys_file_size(); + remove_tree(); + FreeLibrary(msvcp); }