newlib01: Use fopen() instead of freopen()

With global stdio streams, a freopen() would close the global stream
object.

Update #3012.
This commit is contained in:
Sebastian Huber
2017-06-30 14:57:25 +02:00
parent 7adf4941a8
commit 9b07f5efe3
+11 -3
View File
@@ -19,6 +19,7 @@
#include <stdio.h>
#include <rtems.h>
#include <rtems/console.h>
#include <rtems/imfs.h>
#include <rtems/libcsupport.h>
@@ -62,13 +63,13 @@ static void wait(void)
static void worker_task(rtems_task_argument arg)
{
test_context *ctx = &test_instance;
FILE *file = freopen(&file_path[0], "r+", stdout);
char buf[1] = { 'x' };
size_t n;
rtems_test_assert(file != NULL);
stdout = fopen(&file_path[0], "r+");
rtems_test_assert(stdout != NULL);
n = fwrite(&buf[0], sizeof(buf), 1, file);
n = fwrite(&buf[0], sizeof(buf), 1, stdout);
rtems_test_assert(n == 1);
rtems_test_assert(ctx->current == OPEN);
@@ -244,9 +245,16 @@ static void test(void)
rtems_status_code sc;
int rv;
rtems_resource_snapshot snapshot;
FILE *file;
ctx->main_task_id = rtems_task_self();
/* Fill dynamic file pool in Newlib _GLOBAL_REENT */
file = fopen(CONSOLE_DEVICE_NAME, "r+");
rtems_test_assert(file != NULL);
rv = fclose(file);
rtems_test_assert(rv == 0);
rtems_resource_snapshot_take(&snapshot);
rv = IMFS_make_generic_node(