[PATCH 1/2] msvcrt/tests: Add tests for _creat.
Lauri Kenttä
lauri.kentta at gmail.com
Mon Feb 6 11:27:59 CST 2017
Signed-off-by: Lauri Kenttä <lauri.kentta at gmail.com>
---
dlls/msvcrt/tests/file.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 46 insertions(+)
diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c
index 9e2beee27e..82ba16f2f4 100644
--- a/dlls/msvcrt/tests/file.c
+++ b/dlls/msvcrt/tests/file.c
@@ -2386,6 +2386,51 @@ static void test_close(void)
DeleteFileA( "fdopen.tst" );
}
+static void test__creat(void)
+{
+ int fd, pos, count, readonly, old_fmode = _fmode;
+ char buf[6], testdata[4] = {'a', '\n', 'b', '\n'};
+
+ _fmode = _O_TEXT;
+ fd = _creat("_creat.tst", 0);
+ ok(fd > 0, "_creat failed\n");
+ _write(fd, testdata, 4);
+ pos = _tell(fd);
+ ok(pos == 6, "expected pos 6 (text mode), got %d\n", pos);
+ ok(_lseek(fd, SEEK_SET, 0) == 0, "_lseek failed\n");
+ count = _read(fd, buf, 6);
+todo_wine
+ ok(count == 4, "_read returned %d, expected 4\n", count);
+ count = count > 0 ? count > 4 ? 4 : count : 0;
+ ok(memcmp(buf, testdata, count) == 0, "_read returned wrong contents\n");
+ _close(fd);
+ readonly = GetFileAttributesA("_creat.tst") & FILE_ATTRIBUTE_READONLY;
+ ok(readonly, "expected read-only file\n");
+ SetFileAttributesA("_creat.tst", FILE_ATTRIBUTE_NORMAL);
+ DeleteFileA("_creat.tst");
+
+ _fmode = _O_BINARY;
+ fd = _creat("_creat.tst", _S_IREAD | _S_IWRITE);
+ ok(fd > 0, "_creat failed\n");
+ _write(fd, testdata, 4);
+ pos = _tell(fd);
+ ok(pos == 4, "expected pos 4 (binary mode), got %d\n", pos);
+ ok(_lseek(fd, SEEK_SET, 0) == 0, "_lseek failed\n");
+ count = _read(fd, buf, 6);
+todo_wine
+ ok(count == 4, "_read returned %d, expected 4\n", count);
+ count = count > 0 ? count > 4 ? 4 : count : 0;
+ ok(memcmp(buf, testdata, count) == 0, "_read returned wrong contents\n");
+ _close(fd);
+ readonly = GetFileAttributesA("_creat.tst") & FILE_ATTRIBUTE_READONLY;
+todo_wine
+ ok(!readonly, "expected rw file\n");
+ SetFileAttributesA("_creat.tst", FILE_ATTRIBUTE_NORMAL);
+ DeleteFileA("_creat.tst");
+
+ _fmode = old_fmode;
+}
+
START_TEST(file)
{
int arg_c;
@@ -2453,6 +2498,7 @@ START_TEST(file)
test__open_osfhandle();
test_write_flush();
test_close();
+ test__creat();
/* Wait for the (_P_NOWAIT) spawned processes to finish to make sure the report
* file contains lines in the correct order
--
2.11.1
More information about the wine-patches
mailing list