Re: [PATCH v2] testsuite/newlib: Check newlib does not touch an assigned std FILE pointer

2020-02-16 Thread Chris Johns
Please ignore this patch, it is the same patch as v1. I will create a v3.

Chris

On 17/2/20 8:58 am, chr...@rtems.org wrote:
> From: Chris Johns 
> 
> Update #3870
> ---
>  testsuites/libtests/newlib01/init.c | 16 +++-
>  1 file changed, 15 insertions(+), 1 deletion(-)
> 
> diff --git a/testsuites/libtests/newlib01/init.c 
> b/testsuites/libtests/newlib01/init.c
> index 74e648799e..1bff052363 100644
> --- a/testsuites/libtests/newlib01/init.c
> +++ b/testsuites/libtests/newlib01/init.c
> @@ -23,6 +23,8 @@
>  #include 
>  #include 
>  
> +#include 
> +
>  #include "tmacros.h"
>  
>  const char rtems_test_name[] = "NEWLIB 1";
> @@ -63,12 +65,24 @@ static void wait(void)
>  static void worker_task(rtems_task_argument arg)
>  {
>test_context *ctx = _instance;
> +  struct _reent *reent = __getreent();
> +  FILE *output;
>char buf[1] = { 'x' };
>size_t n;
>  
> -  stdout = fopen(_path[0], "r+");
> +  rtems_test_assert(reent->__sdidinit == 0);
> +
> +  output = stdout = fopen(_path[0], "r+");
>rtems_test_assert(stdout != NULL);
>  
> +  /*
> +   * Check newlib's __sinit does not touch our assigned file pointer.
> +   */
> +  rtems_test_assert(reent->__sdidinit == 0);
> +  fflush(stdout);
> +  rtems_test_assert(reent->__sdidinit != 0);
> +  rtems_test_assert(stdout == output);
> +
>n = fwrite([0], sizeof(buf), 1, stdout);
>rtems_test_assert(n == 1);
>  
> 
___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel


[PATCH v2] testsuite/newlib: Check newlib does not touch an assigned std FILE pointer

2020-02-16 Thread chrisj
From: Chris Johns 

Update #3870
---
 testsuites/libtests/newlib01/init.c | 16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/testsuites/libtests/newlib01/init.c 
b/testsuites/libtests/newlib01/init.c
index 74e648799e..1bff052363 100644
--- a/testsuites/libtests/newlib01/init.c
+++ b/testsuites/libtests/newlib01/init.c
@@ -23,6 +23,8 @@
 #include 
 #include 
 
+#include 
+
 #include "tmacros.h"
 
 const char rtems_test_name[] = "NEWLIB 1";
@@ -63,12 +65,24 @@ static void wait(void)
 static void worker_task(rtems_task_argument arg)
 {
   test_context *ctx = _instance;
+  struct _reent *reent = __getreent();
+  FILE *output;
   char buf[1] = { 'x' };
   size_t n;
 
-  stdout = fopen(_path[0], "r+");
+  rtems_test_assert(reent->__sdidinit == 0);
+
+  output = stdout = fopen(_path[0], "r+");
   rtems_test_assert(stdout != NULL);
 
+  /*
+   * Check newlib's __sinit does not touch our assigned file pointer.
+   */
+  rtems_test_assert(reent->__sdidinit == 0);
+  fflush(stdout);
+  rtems_test_assert(reent->__sdidinit != 0);
+  rtems_test_assert(stdout == output);
+
   n = fwrite([0], sizeof(buf), 1, stdout);
   rtems_test_assert(n == 1);
 
-- 
2.23.0

___
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel