From 9b07f5efe364bc52b80eff83389ee4bf4a1e0c40 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Mon, 26 Jun 2017 08:20:15 +0200 Subject: newlib01: Use fopen() instead of freopen() With global stdio streams, a freopen() would close the global stream object. Update #3012. --- testsuites/libtests/newlib01/init.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/testsuites/libtests/newlib01/init.c b/testsuites/libtests/newlib01/init.c index f9d39368d2..af2dc355a7 100644 --- a/testsuites/libtests/newlib01/init.c +++ b/testsuites/libtests/newlib01/init.c @@ -19,6 +19,7 @@ #include #include +#include #include #include @@ -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( -- cgit v1.2.3