It covers:
osal_file_default_ops()osal_file_ops_t::open()osal_file_ops_t::write()osal_file_ops_t::read()osal_file_ops_t::flush()osal_file_ops_t::close()See osal_file_default_ops() specifications
| WHEN | EXPECT |
|---|---|
osal_file_default_ops() is called | returns a non-NULL pointer to an osal_file_ops_t;ret->open != NULL;ret->read != NULL;ret->write != NULL;ret->flush != NULL;ret->close != NULL |
See osal_file_ops_t::open specifications
osal_mem_test_fake_ops()fake_memory| WHEN | EXPECT |
|---|---|
osal_file_ops_t::open() is called with out == NULL | returns OSAL_FILE_STATUS_INVALID;no OSAL_FILE handle is produced |
osal_file_ops_t::open() is called with pathname == NULL | returns OSAL_FILE_STATUS_INVALID;leaves *out unchanged if out != NULL;no OSAL_FILE handle is produced |
osal_file_ops_t::open() is called with ‘pathname[0] == ’\0'\ilinebr </td> <td class="markdownTableBodyNone"> returnsOSAL_FILE_STATUS_INVALID;<br>leaves*outunchanged ifout != NULL;<br>noOSAL_FILEhandle is produced \ilinebr </td> </tr> <tr class="markdownTableRowEven"> <td class="markdownTableBodyNone">osal_file_ops_t::open()is called withmode == NULL\ilinebr </td> <td class="markdownTableBodyNone"> returnsOSAL_FILE_STATUS_INVALID;<br>leaves*outunchanged ifout != NULL;<br>noOSAL_FILEhandle is produced \ilinebr </td> </tr> <tr class="markdownTableRowOdd"> <td class="markdownTableBodyNone">osal_file_ops_t::open()is called with an unsupported mode \ilinebr </td> <td class="markdownTableBodyNone"> returnsOSAL_FILE_STATUS_INVALID;<br>leaves*outunchanged ifout != NULL;<br>noOSAL_FILEhandle is produced \ilinebr </td> </tr> <tr class="markdownTableRowEven"> <td class="markdownTableBodyNone">osal_file_ops_t::open()is called withmem_ops == NULL\ilinebr </td> <td class="markdownTableBodyNone"> returnsOSAL_FILE_STATUS_INVALID;<br>leaves*outunchanged ifout != NULL;<br>noOSAL_FILEhandle is produced \ilinebr </td> </tr> <tr class="markdownTableRowOdd"> <td class="markdownTableBodyNone"> allocation of the OSAL wrapper fails duringosal_file_ops_t::open()\ilinebr </td> <td class="markdownTableBodyNone"> returnsOSAL_FILE_STATUS_OOM;<br>leaves*outunchanged ifout != NULL;<br>noOSAL_FILEhandle is produced \ilinebr </td> </tr> <tr class="markdownTableRowEven"> <td class="markdownTableBodyNone">osal_file_ops_t::open()is called with valid arguments \ilinebr </td> <td class="markdownTableBodyNone"> returnsOSAL_FILE_STATUS_OK;<br>stores a non-NULLOSAL_FILEhandle in*out` |
osal_file_ops_t::open().fake_memory fail injection."rb", "wb", and "ab".See osal_file_ops_t::read specifications
osal_mem_test_fake_ops()fake_memory| WHEN | EXPECT |
|---|---|
osal_file_ops_t::read() is called with ptr == NULL | returns 0;sets *st to OSAL_FILE_STATUS_INVALID if st != NULL |
osal_file_ops_t::read() is called with st == NULL | returns 0;no status is written |
osal_file_ops_t::read() is called with stream == NULL | returns 0;sets *st to OSAL_FILE_STATUS_INVALID if st != NULL |
osal_file_ops_t::read() is called with valid arguments and the requested element count is smaller than the available file content | returns nmemb;copies the requested elements into ptr;sets *st to OSAL_FILE_STATUS_OK |
osal_file_ops_t::read() is called with valid arguments and the requested element count exactly matches the available file content | returns nmemb;copies the requested elements into ptr;sets *st to OSAL_FILE_STATUS_OK |
osal_file_ops_t::read() is called with valid arguments and the requested element count is greater than the available file content | returns a value smaller than nmemb;copies the available elements into ptr;sets *st to OSAL_FILE_STATUS_OK |
osal_file_ops_t::read() is called with valid arguments and the file is empty | returns 0;sets *st to OSAL_FILE_STATUS_OK |
osal_file_ops_t::read() is called multiple times on the same open OSAL_FILE, first with a request smaller than the available file content, then again with another request smaller than the remaining file content | the first call returns the requested element count; the second call returns the requested element count; each call copies the expected data from the current file position into ptr;each call sets *st to OSAL_FILE_STATUS_OK |
osal_file_ops_t::read() is called after end-of-file has already been reached on the same open OSAL_FILE | returns 0;reads no additional data into ptr;sets *st to OSAL_FILE_STATUS_OK |
osal_file_ops_t::read() is called with valid arguments and size == 0 | returns 0;reads no data into ptr;sets *st to OSAL_FILE_STATUS_OK |
osal_file_ops_t::read() is called with valid arguments and nmemb == 0 | returns 0;reads no data into ptr;sets *st to OSAL_FILE_STATUS_OK |
osal_file_ops_t::read() is called with valid arguments, size > 1, and the requested element count is smaller than the number of complete elements available in the file | returns nmemb;copies the requested complete elements into ptr;sets *st to OSAL_FILE_STATUS_OK |
osal_file_ops_t::read() is called with valid arguments, size > 1, and the requested element count exactly matches the number of complete elements available in the file | returns nmemb;copies the requested complete elements into ptr;sets *st to OSAL_FILE_STATUS_OK |
osal_file_ops_t::read() is called with valid arguments, size > 1, and the requested element count is greater than the number of complete elements available in the file | returns a value smaller than nmemb;copies the available complete elements into ptr;sets *st to OSAL_FILE_STATUS_OK |
osal_file_ops_t::read().read() calls are exercised through the default operations table returned by osal_file_default_ops().size > 1 scenarios, expectations are expressed in complete elements, not bytes.See osal_file_ops_t::write specifications
osal_mem_test_fake_ops()fake_memory| WHEN | EXPECT |
|---|---|
osal_file_ops_t::write() is called with ptr == NULL | returns 0;sets *st to OSAL_FILE_STATUS_INVALID if st != NULL |
osal_file_ops_t::write() is called with stream == NULL | returns 0;sets *st to OSAL_FILE_STATUS_INVALID if st != NULL |
osal_file_ops_t::write() is called with st == NULL | returns 0;no status can be stored |
osal_file_ops_t::write() is called with size == 0 | returns 0;sets *st to OSAL_FILE_STATUS_OK;writes no data |
osal_file_ops_t::write() is called with nmemb == 0 | returns 0;sets *st to OSAL_FILE_STATUS_OK;writes no data |
osal_file_ops_t::write() is called with nmemb == 1 on a valid writable stream | returns 1;sets *st to OSAL_FILE_STATUS_OK;writes the requested data |
osal_file_ops_t::write() is called with multiple elements of size 1 on a valid writable stream | returns nmemb;sets *st to OSAL_FILE_STATUS_OK;writes the requested data |
osal_file_ops_t::write() is called with multiple elements of size greater than 1 on a valid writable stream | returns nmemb;sets *st to OSAL_FILE_STATUS_OK;writes the requested data |
osal_file_ops_t::write() is called twice successively on the same valid writable stream | each call returns its requested element count; each call sets *st to OSAL_FILE_STATUS_OK;the final file content reflects both writes in order |
osal_file_ops_t::write().write() calls are exercised through the default operations table returned by osal_file_default_ops().size > 1 scenarios, expectations are expressed in complete elements, not bytes.write() calls.See osal_file_ops_t::flush specifications
osal_mem_test_fake_ops()fake_memory| WHEN | EXPECT |
|---|---|
osal_file_ops_t::flush() is called with stream == NULL | returns OSAL_FILE_STATUS_INVALID |
osal_file_ops_t::flush() is called on a valid writable stream | returns OSAL_FILE_STATUS_OK |
osal_file_ops_t::flush().flush() call when the scenario uses a valid writable stream.flush() call is exercised through the default operations table returned by osal_file_default_ops().flush(); it does not attempt to prove backend-specific buffering effects beyond that public result.See osal_file_ops_t::close specifications
osal_mem_test_fake_ops()fake_memory| WHEN | EXPECT |
|---|---|
osal_file_ops_t::close() is called with stream == NULL | returns OSAL_FILE_STATUS_INVALID |
osal_file_ops_t::close() is called on a valid open stream | returns OSAL_FILE_STATUS_OK |
osal_file_ops_t::close().close() call is exercised through the default operations table returned by osal_file_default_ops().osal_file_ops_t::open().close() call.close(); it does not attempt to prove backend-specific close failure mappings beyond that public result.