diff options
author | Jiyoung Yun <jy910.yun@samsung.com> | 2016-11-23 19:09:09 +0900 |
---|---|---|
committer | Jiyoung Yun <jy910.yun@samsung.com> | 2016-11-23 19:09:09 +0900 |
commit | 4b4aad7217d3292650e77eec2cf4c198ea9c3b4b (patch) | |
tree | 98110734c91668dfdbb126fcc0e15ddbd93738ca /src/pal/tests/palsuite/file_io/ReadFile | |
parent | fa45f57ed55137c75ac870356a1b8f76c84b229c (diff) | |
download | coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.gz coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.tar.bz2 coreclr-4b4aad7217d3292650e77eec2cf4c198ea9c3b4b.zip |
Imported Upstream version 1.1.0upstream/1.1.0
Diffstat (limited to 'src/pal/tests/palsuite/file_io/ReadFile')
14 files changed, 751 insertions, 0 deletions
diff --git a/src/pal/tests/palsuite/file_io/ReadFile/CMakeLists.txt b/src/pal/tests/palsuite/file_io/ReadFile/CMakeLists.txt new file mode 100644 index 0000000000..a3847f8ca9 --- /dev/null +++ b/src/pal/tests/palsuite/file_io/ReadFile/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +add_subdirectory(test1) +add_subdirectory(test2) +add_subdirectory(test3) +add_subdirectory(test4) + diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test1/CMakeLists.txt b/src/pal/tests/palsuite/file_io/ReadFile/test1/CMakeLists.txt new file mode 100644 index 0000000000..7b166e17b0 --- /dev/null +++ b/src/pal/tests/palsuite/file_io/ReadFile/test1/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + ReadFile.c +) + +add_executable(paltest_readfile_test1 + ${SOURCES} +) + +add_dependencies(paltest_readfile_test1 coreclrpal) + +target_link_libraries(paltest_readfile_test1 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test1/NonReadableFile.txt b/src/pal/tests/palsuite/file_io/ReadFile/test1/NonReadableFile.txt new file mode 100644 index 0000000000..a8a940627d --- /dev/null +++ b/src/pal/tests/palsuite/file_io/ReadFile/test1/NonReadableFile.txt @@ -0,0 +1 @@ +this is a test
\ No newline at end of file diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test1/ReadFile.c b/src/pal/tests/palsuite/file_io/ReadFile/test1/ReadFile.c new file mode 100644 index 0000000000..a59e29212e --- /dev/null +++ b/src/pal/tests/palsuite/file_io/ReadFile/test1/ReadFile.c @@ -0,0 +1,82 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: ReadFile.c (test 1) +** +** Purpose: Tests the PAL implementation of the ReadFile function. +** This test will attempt to read from a NULL handle and from +** a file without read permissions set. +** +** +**===================================================================*/ + +#include <palsuite.h> + + +int __cdecl main(int argc, char *argv[]) +{ + HANDLE hFile = NULL; + DWORD dwByteCount = 0; + DWORD dwBytesRead = 0; + BOOL bRc = FALSE; + char szBuffer[256]; + char* szNonReadableFile = {"nonreadablefile.txt"}; + + if (0 != PAL_Initialize(argc,argv)) + { + return FAIL; + } + + memset(szBuffer, 0, 256); + + /* Read from a NULL handle + */ + + bRc = ReadFile(hFile, szBuffer, 20, &dwBytesRead, NULL); + + if (bRc == TRUE) + { + Fail("ReadFile: ERROR -> Able to read from a NULL handle\n"); + } + + + /* Read from a file without read permissions + */ + +#if WIN32 + +#else + /* attempt to read from the unreadable file + * open a file without read permissions + */ + hFile = CreateFile(szNonReadableFile, + GENERIC_WRITE, + FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if(hFile == INVALID_HANDLE_VALUE) + { + dwByteCount = GetLastError(); + Fail("ReadFile: ERROR -> Unable to create file \"%s\".\n", + szNonReadableFile); + } + + bRc = ReadFile(hFile, szBuffer, 20, &dwBytesRead, NULL); + + if (bRc == TRUE) + { + Fail("ReadFile: ERROR -> Able to read from a file without read " + "permissions\n"); + } +#endif + + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test1/testinfo.dat b/src/pal/tests/palsuite/file_io/ReadFile/test1/testinfo.dat new file mode 100644 index 0000000000..b0df11a3ab --- /dev/null +++ b/src/pal/tests/palsuite/file_io/ReadFile/test1/testinfo.dat @@ -0,0 +1,13 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = file_io +Function = ReadFile +Name = Positive Test for ReadFile +Type = DEFAULT +EXE1 = readfile +Description +=Attempt to read from a NULL handle and a file without read permissions + diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test2/CMakeLists.txt b/src/pal/tests/palsuite/file_io/ReadFile/test2/CMakeLists.txt new file mode 100644 index 0000000000..fc4870e73d --- /dev/null +++ b/src/pal/tests/palsuite/file_io/ReadFile/test2/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + ReadFile.c +) + +add_executable(paltest_readfile_test2 + ${SOURCES} +) + +add_dependencies(paltest_readfile_test2 coreclrpal) + +target_link_libraries(paltest_readfile_test2 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test2/ReadFile.c b/src/pal/tests/palsuite/file_io/ReadFile/test2/ReadFile.c new file mode 100644 index 0000000000..f16858e573 --- /dev/null +++ b/src/pal/tests/palsuite/file_io/ReadFile/test2/ReadFile.c @@ -0,0 +1,198 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: ReadFile.c (test 2) +** +** Purpose: Tests the PAL implementation of the ReadFile function. +** Creates a test file and performs an array of read tests. +** +** Assumes successful: +** CreateFile +** CloseHandle +** WriteFile +** GetLastError +** +** +**===================================================================*/ + + +#include <palsuite.h> + + +const char* szStringTest = "The quick fox jumped over the lazy dog's back.\0"; +const char* szEmptyString = ""; +const char* szReadableFile = "Readable.txt"; +const char* szResultsFile = "Results.txt"; + +//Previously number of tests was 6, now 4 refer VSW 312690 +#define NOOFTESTS 4 + +#ifdef __sparc__ +const int PAGESIZE = 8192; +#else // __sparc__ +const int PAGESIZE = 4096; +#endif // __sparc__ + +char *readBuffer; + +BOOL validateResults(const char* szString, // string read + DWORD dwByteCount, // amount requested + DWORD dwBytesRead) // amount read +{ + // were the correct number of bytes read? + if (dwBytesRead > dwByteCount) + { + Trace("bytes read > bytes asked for\n"); + return FALSE; + } + if (dwBytesRead != strlen(szString)) + { + Trace("bytes read != length of read string\n"); + return FALSE; + } + + // + // compare results + // + + if (memcmp(szString, szStringTest, dwBytesRead) != 0) + { + Trace("read = %s string = %s", szString, szStringTest); + return FALSE; + } + + return TRUE; +} + +BOOL readTest(DWORD dwByteCount, char cResult) +{ + HANDLE hFile = NULL; + DWORD dwBytesRead; + BOOL bRc = FALSE; + + // open the test file + hFile = CreateFile(szReadableFile, + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + if(hFile == INVALID_HANDLE_VALUE) + { + Trace("ReadFile: ERROR -> Unable to open file \"%s\".\n", + szReadableFile); + return FALSE; + } + + memset(readBuffer, 0, PAGESIZE); + + bRc = ReadFile(hFile, readBuffer, dwByteCount, &dwBytesRead, NULL); + + if (bRc == FALSE) + { + // if it failed, was it supposed to fail? + if (cResult == '1') + { + Trace("\nbRc = %d\n", bRc); + Trace("readBuffer = [%s] dwByteCount = %d dwBytesRead = %d\n", readBuffer, dwByteCount, dwBytesRead); + Trace("cresult = 1\n"); + Trace("getlasterror = %d\n", GetLastError()); + CloseHandle(hFile); + return FALSE; + } + } + else + { + CloseHandle(hFile); + // if it passed, was it supposed to pass? + if (cResult == '0') + { + Trace("cresult = 0\n"); + return FALSE; + } + else + { + return (validateResults(readBuffer, dwByteCount, dwBytesRead)); + } + } + + CloseHandle(hFile); + return TRUE; +} + +int __cdecl main(int argc, char *argv[]) +{ + HANDLE hFile = NULL; + const int BUFFER_SIZE = 2 * PAGESIZE; + + DWORD dwByteCount[] = { 0, + 10, + strlen(szStringTest), + PAGESIZE + // Commented out two negative test cases : Refer VSW 312690 + // 2 * PAGESIZE, + // -1 + }; + + DWORD oldProt; + char szResults[] = "1111"; // Was "111100": Refer VSW 312690 + int i; + BOOL bRc = FALSE; + DWORD dwBytesWritten = 0; + + if (0 != PAL_Initialize(argc,argv)) + { + return FAIL; + } + + /* aloocate read-write memery for readBuffer */ + if (!(readBuffer = (char*) VirtualAlloc(NULL, BUFFER_SIZE, MEM_COMMIT, PAGE_READWRITE))) + { + Fail("VirtualAlloc failed: GetLastError returns %d\n", GetLastError()); + return FAIL; + } + + /* write protect the second page of readBuffer */ + if (!VirtualProtect(&readBuffer[PAGESIZE], PAGESIZE, PAGE_NOACCESS, &oldProt)) + { + Fail("VirtualProtect failed: GetLastError returns %d\n", GetLastError()); + return FAIL; + } + + // create the test file + hFile = CreateFile(szReadableFile, + GENERIC_WRITE, + FILE_SHARE_WRITE, + NULL, + CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if(hFile == INVALID_HANDLE_VALUE) + { + Fail("ReadFile: ERROR -> Unable to create file \"%s\" (%d).\n", + szReadableFile, GetLastError()); + } + + bRc = WriteFile(hFile, szStringTest, strlen(szStringTest), &dwBytesWritten, NULL); + CloseHandle(hFile); + + + for (i = 0; i< NOOFTESTS; i++) + { + bRc = readTest(dwByteCount[i], szResults[i]); + if (bRc != TRUE) + { + Fail("ReadFile: ERROR -> Failed on test[%d]\n", i); + } + } + + VirtualFree(readBuffer, BUFFER_SIZE, MEM_RELEASE); + PAL_Terminate(); + return PASS; +} + diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test2/testinfo.dat b/src/pal/tests/palsuite/file_io/ReadFile/test2/testinfo.dat new file mode 100644 index 0000000000..82b6326170 --- /dev/null +++ b/src/pal/tests/palsuite/file_io/ReadFile/test2/testinfo.dat @@ -0,0 +1,13 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = file_io +Function = ReadFile +Name = Positive Test for ReadFile +Type = DEFAULT +EXE1 = readfile +Description +=Multiple tests of reads of varying sizes with verification + diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test3/CMakeLists.txt b/src/pal/tests/palsuite/file_io/ReadFile/test3/CMakeLists.txt new file mode 100644 index 0000000000..77397743d4 --- /dev/null +++ b/src/pal/tests/palsuite/file_io/ReadFile/test3/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + ReadFile.c +) + +add_executable(paltest_readfile_test3 + ${SOURCES} +) + +add_dependencies(paltest_readfile_test3 coreclrpal) + +target_link_libraries(paltest_readfile_test3 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test3/ReadFile.c b/src/pal/tests/palsuite/file_io/ReadFile/test3/ReadFile.c new file mode 100644 index 0000000000..c5d6b1d155 --- /dev/null +++ b/src/pal/tests/palsuite/file_io/ReadFile/test3/ReadFile.c @@ -0,0 +1,184 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: ReadFile.c (test 3) +** +** Purpose: Tests the PAL implementation of the ReadFile function. +** Creates a test file and performs an array of sequential read +** tests. +** +** Assumes successful: +** CreateFile +** CloseHandle +** memset +** WriteFile +** CreateFile +** CloseHandle +** GetLastError +** +** +**===================================================================*/ + +#include <palsuite.h> + +const char* szStringTest = "The quick fox jumped over the lazy dog's back.\0"; +const char* szEmptyString = ""; +const char* szReadableFile = "Readable.txt"; +const char* szResultsFile = "Results.txt"; + + +BOOL validateResults(const char* szString, // string read + DWORD dwByteCount, // amount requested + DWORD dwBytesRead) // amount read +{ + // were the correct number of bytes read? + if (dwBytesRead > dwByteCount) + { + Trace("bytes read > bytes asked for\n"); + return FALSE; + } + if (dwBytesRead != strlen(szString)) + { + Trace("bytes read != length of read string\n"); + return FALSE; + } + + + // + // compare results + // + + if (memcmp(szString, szStringTest, dwByteCount) != 0) + { + Trace("read = %s string = %s", szString, szStringTest); + return FALSE; + } + + return TRUE; +} + + + + +BOOL readTest(DWORD dwByteCount, char cResult) +{ + HANDLE hFile = NULL; + DWORD dwBytesRead = 0; + DWORD dwTotal = 0; + DWORD dwRequested = 0; + BOOL bRc = FALSE; + char szString[100]; + char* szPtr = szString; + int i = 0; + + // open the test file + hFile = CreateFile(szReadableFile, + GENERIC_READ, + FILE_SHARE_READ, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, + NULL); + if(hFile == INVALID_HANDLE_VALUE) + { + Trace("ReadFile: ERROR -> Unable to open file \"%s\".\n", + szReadableFile); + return FALSE; + } + + memset(szString, 0, 100); + + for (i = 0; i < 5; i++) + { + bRc = ReadFile(hFile, szPtr, dwByteCount, &dwBytesRead, NULL); + szPtr += dwByteCount; + dwTotal += dwBytesRead; + dwRequested += dwByteCount; + } + + if (bRc == FALSE) + { + // if it failed, was it supposed to fail? + if (cResult == '1') + { + Trace("\nbRc = %d\n", bRc); + Trace("szString = [%s] dwByteCount = %d dwBytesRead = %d\n", + szString, + dwByteCount, + dwBytesRead); + Trace ("cresult = 1\n"); + Trace ("getlasterror = %d\n", GetLastError()); + CloseHandle(hFile); + return FALSE; + } + } + else + { + CloseHandle(hFile); + // if it passed, was it supposed to pass? + if (cResult == '0') + { + Trace ("cresult = 0\n"); + return FALSE; + } + else + { + return (validateResults(szString, dwRequested, dwTotal)); + } + } + + CloseHandle(hFile); + return TRUE; +} + + + +int __cdecl main(int argc, char **argv) +{ + HANDLE hFile = NULL; + DWORD dwByteCount[4] = {0, 1, 2, 3}; + char szResults[4] = {'1', '1', '1', '1'}; + int i; + BOOL bRc = FALSE; + DWORD dwBytesWritten = 0; + + if (0 != PAL_Initialize(argc,argv)) + { + return FAIL; + } + + + // create the test file + hFile = CreateFile(szReadableFile, + GENERIC_WRITE, + FILE_SHARE_WRITE, + NULL, + CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + NULL); + if(hFile == INVALID_HANDLE_VALUE) + { + Fail("ReadFile: ERROR -> Unable to create file \"%s\".\n", + szReadableFile); + } + + bRc = WriteFile(hFile, szStringTest, strlen(szStringTest), + &dwBytesWritten, + NULL); + CloseHandle(hFile); + + for (i = 0; i < 4; i++) + { + bRc = readTest(dwByteCount[i], szResults[i]); + if (bRc != TRUE) + { + Fail("ReadFile: ERROR -> Failed on test[%d]\n", i); + } + } + + PAL_Terminate(); + return PASS; +} diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test3/testinfo.dat b/src/pal/tests/palsuite/file_io/ReadFile/test3/testinfo.dat new file mode 100644 index 0000000000..82b6326170 --- /dev/null +++ b/src/pal/tests/palsuite/file_io/ReadFile/test3/testinfo.dat @@ -0,0 +1,13 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = file_io +Function = ReadFile +Name = Positive Test for ReadFile +Type = DEFAULT +EXE1 = readfile +Description +=Multiple tests of reads of varying sizes with verification + diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test4/CMakeLists.txt b/src/pal/tests/palsuite/file_io/ReadFile/test4/CMakeLists.txt new file mode 100644 index 0000000000..37f227aced --- /dev/null +++ b/src/pal/tests/palsuite/file_io/ReadFile/test4/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 2.8.12.2) + +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +set(SOURCES + readfile.c +) + +add_executable(paltest_readfile_test4 + ${SOURCES} +) + +add_dependencies(paltest_readfile_test4 coreclrpal) + +target_link_libraries(paltest_readfile_test4 + pthread + m + coreclrpal +) diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test4/readfile.c b/src/pal/tests/palsuite/file_io/ReadFile/test4/readfile.c new file mode 100644 index 0000000000..3ec939f63a --- /dev/null +++ b/src/pal/tests/palsuite/file_io/ReadFile/test4/readfile.c @@ -0,0 +1,147 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +/*===================================================================== +** +** Source: ReadFile.c (test 4) +** +** Purpose: Tests the PAL implementation of the ReadFile function. +** Creates a file and writes a small string to it, attempt +** to read many more characters that exist. The returned +** number of chars should be the amount written originally +** not the number requested. +** +** +**===================================================================*/ +#include <palsuite.h> + +int __cdecl main(int argc, char *argv[]) +{ + HANDLE hFile = NULL; + DWORD dwBytesWritten; + BOOL bRc = FALSE; + char szBuffer[256]; + DWORD dwBytesRead = 0; + int szRequestSize = 256; + char testFile[] = "testfile.tmp"; + char testString[] = "people stop and stare"; + DWORD res = 0; + + /* Initialize the PAL. + */ + if (0 != PAL_Initialize(argc,argv)) + { + return FAIL; + } + + /* Initialize the buffer. + */ + memset(szBuffer, 0, 256); + + /* Create a file to test with. + */ + hFile = CreateFile(testFile, + GENERIC_WRITE|GENERIC_READ, + FILE_SHARE_WRITE|FILE_SHARE_READ, + NULL, + CREATE_ALWAYS, + FILE_ATTRIBUTE_NORMAL, + NULL); + + if(hFile == INVALID_HANDLE_VALUE) + { + Fail("ERROR:%u: Unable to create file \"%s\".\n", + GetLastError(), + testFile); + } + + /* Write to the File handle. + */ + bRc = WriteFile(hFile, + testString, + strlen(testString), + &dwBytesWritten, + NULL); + + if (bRc == FALSE) + { + Trace("ERROR:%u: Unable to write to file handle " + "hFile=0x%lx\n", + GetLastError(), + hFile); + if (!CloseHandle(hFile)) + { + Trace("ERROR:%u%: Unable to close handle 0x%lx.\n", + GetLastError(), + hFile); + } + Fail(""); + } + + /* Set the file pointer to beginning of file. + */ + res = SetFilePointer(hFile, (LONG)NULL, NULL, FILE_BEGIN); + + if( (res == INVALID_SET_FILE_POINTER) && + (GetLastError() != NO_ERROR)) + { + Trace("ERROR:%u: Unable to set file pointer to the beginning of file.", + GetLastError()); + + if (!CloseHandle(hFile)) + { + Trace("ERROR:%u%: Unable to close handle 0x%lx.\n", + GetLastError(), + hFile); + } + Fail(""); + } + + + /* Attempt to read 256 characters from a file + * that does not contain that many. + */ + bRc = ReadFile(hFile, + szBuffer, + szRequestSize, + &dwBytesRead, + NULL); + + if (bRc == FALSE) + { + Trace("ERROR:%u: Unable to read from file handle 0x%lx.\n", + GetLastError(), + hFile); + if (!CloseHandle(hFile)) + { + Trace("ERROR:%u%: Unable to close handle 0x%lx.\n", + GetLastError(), + hFile); + } + Fail(""); + } + + /* Confirm the number of bytes read with that requested. + */ + if (dwBytesRead != strlen(testString)) + { + Trace("ERROR: The number of bytes read \"%d\" is not equal to the " + "number originally written \"%d\" to the file.\n", + dwBytesRead, + strlen(testString)); + if (!CloseHandle(hFile)) + { + Trace("ERROR:%u%: Unable to close handle 0x%lx.\n", + GetLastError(), + hFile); + } + Fail(""); + } + + /* Terminate the PAL. + */ + PAL_Terminate(); + return PASS; +} + diff --git a/src/pal/tests/palsuite/file_io/ReadFile/test4/testinfo.dat b/src/pal/tests/palsuite/file_io/ReadFile/test4/testinfo.dat new file mode 100644 index 0000000000..6f3267d591 --- /dev/null +++ b/src/pal/tests/palsuite/file_io/ReadFile/test4/testinfo.dat @@ -0,0 +1,17 @@ +# Licensed to the .NET Foundation under one or more agreements. +# The .NET Foundation licenses this file to you under the MIT license. +# See the LICENSE file in the project root for more information. + +Version = 1.0 +Section = file_io +Function = ReadFile +Name = Positive Test for ReadFile +Type = DEFAULT +EXE1 = readfile +Description += Tests the PAL implementation of the ReadFile function. += Creates a file and writes a small string to it, attempt += to read many more characters that exist. The returned += number of chars should be the amount written originally += not the number requested. + |