forked from Imagelibrary/rtems
testsuite/newlib: Check newlib does not touch an assigned std FILE pointer
Update #3870
This commit is contained in:
@@ -18,6 +18,8 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <sys/reent.h>
|
||||||
|
|
||||||
#include <rtems.h>
|
#include <rtems.h>
|
||||||
#include <rtems/console.h>
|
#include <rtems/console.h>
|
||||||
#include <rtems/imfs.h>
|
#include <rtems/imfs.h>
|
||||||
@@ -63,12 +65,24 @@ static void wait(void)
|
|||||||
static void worker_task(rtems_task_argument arg)
|
static void worker_task(rtems_task_argument arg)
|
||||||
{
|
{
|
||||||
test_context *ctx = &test_instance;
|
test_context *ctx = &test_instance;
|
||||||
|
struct _reent *reent = _REENT;
|
||||||
|
FILE *output;
|
||||||
char buf[1] = { 'x' };
|
char buf[1] = { 'x' };
|
||||||
size_t n;
|
size_t n;
|
||||||
|
|
||||||
stdout = fopen(&file_path[0], "r+");
|
rtems_test_assert(reent->__sdidinit == 0);
|
||||||
|
|
||||||
|
output = stdout = fopen(&file_path[0], "r+");
|
||||||
rtems_test_assert(stdout != NULL);
|
rtems_test_assert(stdout != NULL);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Check newlib's __sinit does not touch our assigned file pointer.
|
||||||
|
*/
|
||||||
|
rtems_test_assert(reent->__sdidinit == 0);
|
||||||
|
rtems_test_assert(fflush(stdout) == 0);
|
||||||
|
rtems_test_assert(reent->__sdidinit != 0);
|
||||||
|
rtems_test_assert(stdout == output);
|
||||||
|
|
||||||
n = fwrite(&buf[0], sizeof(buf), 1, stdout);
|
n = fwrite(&buf[0], sizeof(buf), 1, stdout);
|
||||||
rtems_test_assert(n == 1);
|
rtems_test_assert(n == 1);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user