<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Feb 3, 2021 at 3:46 PM Eshan Dhawan <<a href="mailto:eshandhawan51@gmail.com">eshandhawan51@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">From: Eshan dhawan <<a href="mailto:eshandhawan51@gmail.com" target="_blank">eshandhawan51@gmail.com</a>><br>
<br>
Signed-off-by: Eshan Dhawan <<a href="mailto:eshandhawan51@gmail.com" target="_blank">eshandhawan51@gmail.com</a>><br>
---<br>
 cpukit/Makefile.am                            |   1 +<br>
 cpukit/posix/src/confstr.c                    | 103 +++++++++++++<br>
 spec/build/cpukit/librtemscpu.yml             |   1 +<br>
 spec/build/testsuites/psxtests/grp.yml        |   2 +<br>
 spec/build/testsuites/psxtests/psxconfstr.yml |  20 +++<br>
 testsuites/psxtests/Makefile.am               |   9 ++<br>
 testsuites/psxtests/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a>              |   1 +<br>
 testsuites/psxtests/psxconfstr/init.c         | 143 ++++++++++++++++++<br>
 testsuites/psxtests/psxconfstr/psxconfstr.doc |  17 +++<br>
 testsuites/psxtests/psxconfstr/psxconfstr.scn |   4 +<br>
 10 files changed, 301 insertions(+)<br>
 create mode 100644 cpukit/posix/src/confstr.c<br>
 create mode 100644 spec/build/testsuites/psxtests/psxconfstr.yml<br>
 create mode 100644 testsuites/psxtests/psxconfstr/init.c<br>
 create mode 100644 testsuites/psxtests/psxconfstr/psxconfstr.doc<br>
 create mode 100644 testsuites/psxtests/psxconfstr/psxconfstr.scn<br>
<br>
diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am<br>
index 565aa66ce1..469754ab84 100644<br>
--- a/cpukit/Makefile.am<br>
+++ b/cpukit/Makefile.am<br>
@@ -511,6 +511,7 @@ librtemscpu_a_SOURCES += posix/src/condsignalsupp.c<br>
 librtemscpu_a_SOURCES += posix/src/condtimedwait.c<br>
 librtemscpu_a_SOURCES += posix/src/condwait.c<br>
 librtemscpu_a_SOURCES += posix/src/condwaitsupp.c<br>
+librtemscpu_a_SOURCES += posix/src/confstr.c<br>
 librtemscpu_a_SOURCES += posix/src/_execve.c<br>
 librtemscpu_a_SOURCES += posix/src/fork.c<br>
 librtemscpu_a_SOURCES += posix/src/key.c<br>
diff --git a/cpukit/posix/src/confstr.c b/cpukit/posix/src/confstr.c<br>
new file mode 100644<br>
index 0000000000..337c4f471d<br>
--- /dev/null<br>
+++ b/cpukit/posix/src/confstr.c<br>
@@ -0,0 +1,103 @@<br>
+/*-<br>
+ * SPDX-License-Identifier: BSD-3-Clause<br>
+ *<br>
+ * Copyright (c) 1993<br>
+ *     The Regents of the University of California.  All rights reserved.<br>
+ *<br>
+ * Redistribution and use in source and binary forms, with or without<br>
+ * modification, are permitted provided that the following conditions<br>
+ * are met:<br>
+ * 1. Redistributions of source code must retain the above copyright<br>
+ *    notice, this list of conditions and the following disclaimer.<br>
+ * 2. Redistributions in binary form must reproduce the above copyright<br>
+ *    notice, this list of conditions and the following disclaimer in the<br>
+ *    documentation and/or other materials provided with the distribution.<br>
+ * 3. Neither the name of the University nor the names of its contributors<br>
+ *    may be used to endorse or promote products derived from this software<br>
+ *    without specific prior written permission.<br>
+ *<br>
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND<br>
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br>
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br>
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE<br>
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL<br>
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS<br>
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)<br>
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT<br>
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY<br>
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF<br>
+ * SUCH DAMAGE.<br>
+ */<br>
+<br>
+#include <sys/cdefs.h><br>
+/* Reduced to make sense in RTEMS */</blockquote><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br>
+__SCCSID("@(#)confstr.c        8.1 (Berkeley) 6/4/93");<br>
+__FBSDID("$FreeBSD$");<br></blockquote><div><br></div><div>I don't recall if we comment these out or have macros which turn them to nothing.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+#include <sys/param.h><br>
+<br>
+#include <errno.h><br>
+#include <limits.h><br>
+#include <string.h><br>
+#include <unistd.h><br></blockquote><div><br></div><div>You may not need limits.h. Check.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+/* Many programming environment flags have same values <br>
+* this block is added to raise error if the flags value change<br>
+*/<br>
+<br>
+#if (_CS_V6_ENV != _CS_V7_ENV)<br>
+#error "_CS_V6_XXX and _CS_V7_XXX flag values not equal"<br>
+#endif<br></blockquote><div><br></div><div>This was intended to be representative of a pattern of adding a check to </div><div>ensure every V6 and V7 constant with the same meaning and return value</div><div>actually had the same value. This should be repeated for each of these:<br><br>    case _CS_POSIX_V6_ILP32_OFF32_CFLAGS:<br>    case _CS_POSIX_V6_ILP32_OFF32_LDFLAGS:<br>    case _CS_POSIX_V6_ILP32_OFF32_LIBS:<br>    case _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS:<br>    case _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS:<br>    case _CS_POSIX_V6_LPBIG_OFFBIG_LIBS:<br>    case _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS:<br>    case _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS:<br>    case _CS_POSIX_V6_ILP32_OFFBIG_LIBS:<br>    case _CS_POSIX_V6_LP64_OFF64_CFLAGS:<br>    case _CS_POSIX_V6_LP64_OFF64_LDFLAGS:<br>    case _CS_POSIX_V6_LP64_OFF64_LIBS:<br></div><div><br></div><div>And the #error should use the right name not XXX.</div><div><br></div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+size_t<br>
+confstr(int name, char *buf, size_t len)<br>
+{<br>
+  const char *p;<br>
+  const char UPE[] = "unsupported programming environment";<br>
+<br>
+  switch (name) {<br>
+<br>
+    case _CS_PATH:<br>
+      errno = EINVAL;<br>
+      return (0);<br></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
+/*<br>
+ * POSIX/SUS ``Programming Environments'' stuff<br>
+ *<br>
+ * We don't support more than one programming environment<br>
+ * on any platform (yet), so we just return the empty<br>
+ * string for the environment we are compiled for,<br>
+ * and the string "unsupported programming environment"<br>
+ * for anything else.  (The Standard says that if these<br>
+ * values are used on a system which does not support<br>
+ * this environment -- determined via sysconf() -- then<br>
+ * the value we return is unspecified.  So, we return<br>
+ * something which will cause obvious breakage.)<br>
+ */<br>
+<br>
+    case _CS_POSIX_V6_ILP32_OFF32_CFLAGS:<br>
+    case _CS_POSIX_V6_ILP32_OFF32_LDFLAGS:<br>
+    case _CS_POSIX_V6_ILP32_OFF32_LIBS:<br>
+    case _CS_POSIX_V6_LPBIG_OFFBIG_CFLAGS:<br>
+    case _CS_POSIX_V6_LPBIG_OFFBIG_LDFLAGS:<br>
+    case _CS_POSIX_V6_LPBIG_OFFBIG_LIBS:<br>
+    case _CS_POSIX_V6_ILP32_OFFBIG_CFLAGS:<br>
+    case _CS_POSIX_V6_ILP32_OFFBIG_LDFLAGS:<br>
+    case _CS_POSIX_V6_ILP32_OFFBIG_LIBS:<br>
+    case _CS_POSIX_V6_LP64_OFF64_CFLAGS:<br>
+    case _CS_POSIX_V6_LP64_OFF64_LDFLAGS:<br>
+    case _CS_POSIX_V6_LP64_OFF64_LIBS:<br>
+    <br>
+<br>
+      p = UPE;<br>
+      if (len != 0 && buf != NULL){<br>
+        strlcpy(buf, p, len);<br>
+        }<br>
+        return (strlen(p) + 1);<br>
+<br>
+    default:<br>
+      errno = EINVAL;<br>
+      return (0);<br>
+  }<br>
+  /* NOTREACHED */<br>
+}<br>
diff --git a/spec/build/cpukit/librtemscpu.yml b/spec/build/cpukit/librtemscpu.yml<br>
index a43dcf0d48..81a86741bd 100644<br>
--- a/spec/build/cpukit/librtemscpu.yml<br>
+++ b/spec/build/cpukit/librtemscpu.yml<br>
@@ -1005,6 +1005,7 @@ source:<br>
 - cpukit/posix/src/condtimedwait.c<br>
 - cpukit/posix/src/condwait.c<br>
 - cpukit/posix/src/condwaitsupp.c<br>
+- cpukit/posix/src/confstr.c<br>
 - cpukit/posix/src/_execve.c<br>
 - cpukit/posix/src/fork.c<br>
 - cpukit/posix/src/key.c<br>
diff --git a/spec/build/testsuites/psxtests/grp.yml b/spec/build/testsuites/psxtests/grp.yml<br>
index 47dedac275..9aca26e694 100644<br>
--- a/spec/build/testsuites/psxtests/grp.yml<br>
+++ b/spec/build/testsuites/psxtests/grp.yml<br>
@@ -89,6 +89,8 @@ links:<br>
   uid: psxcond02<br>
 - role: build-dependency<br>
   uid: psxconfig01<br>
+- role: build-dependency<br>
+  uid: psxconfstr<br>
 - role: build-dependency<br>
   uid: psxdevctl01<br>
 - role: build-dependency<br>
diff --git a/spec/build/testsuites/psxtests/psxconfstr.yml b/spec/build/testsuites/psxtests/psxconfstr.yml<br>
new file mode 100644<br>
index 0000000000..252fc4601d<br>
--- /dev/null<br>
+++ b/spec/build/testsuites/psxtests/psxconfstr.yml<br>
@@ -0,0 +1,20 @@<br>
+SPDX-License-Identifier: CC-BY-SA-4.0 OR BSD-2-Clause<br>
+build-type: test-program<br>
+cflags: []<br>
+copyrights:<br>
+- Copyright (C) 2020 Eshan Dhawan (<a href="mailto:eshandhawan51@gmail.com" target="_blank">eshandhawan51@gmail.com</a>)<br>
+cppflags: []<br>
+cxxflags: []<br>
+enabled-by: true<br>
+features: c cprogram<br>
+includes: []<br>
+ldflags: []<br>
+links: []<br>
+source:<br>
+- testsuites/psxtests/psxconfstr/init.c<br>
+stlib:<br>
+- m<br>
+target: testsuites/psxtests/psxconfstr.exe<br>
+type: build<br>
+use-after: []<br>
+use-before: []<br>
diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am<br>
index aae5fe764a..246f5b82df 100755<br>
--- a/testsuites/psxtests/Makefile.am<br>
+++ b/testsuites/psxtests/Makefile.am<br>
@@ -358,6 +358,15 @@ psxconfig01_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psxconfig01) \<br>
        $(support_includes) -I$(top_srcdir)/include<br>
 endif<br>
<br>
+<br>
+psx_tests += psxconfstr<br>
+psx_screens += psxconfstr/psxconfstr.scn<br>
+psx_docs += psxconfstr/psxconfstr.doc<br>
+psxconfstr_SOURCES = psxconfstr/init.c <br>
+psxconfstr_CPPFLAGS = $(AM_CPPFLAGS) $(TEST_FLAGS_psxconfstr) \<br>
+       $(support_includes) <br>
+<br>
+<br>
 if TEST_psxdevctl01<br>
 psx_tests += psxdevctl01<br>
 psx_screens += psxdevctl01/psxdevctl01.scn<br>
diff --git a/testsuites/psxtests/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a> b/testsuites/psxtests/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
index c509086abc..96c937cb4d 100644<br>
--- a/testsuites/psxtests/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
+++ b/testsuites/psxtests/<a href="http://configure.ac" rel="noreferrer" target="_blank">configure.ac</a><br>
@@ -80,6 +80,7 @@ RTEMS_TEST_CHECK([psxconcurrency01])<br>
 RTEMS_TEST_CHECK([psxcond01])<br>
 RTEMS_TEST_CHECK([psxcond02])<br>
 RTEMS_TEST_CHECK([psxconfig01])<br>
+RTEMS_TEST_CHECK([psxconfstr])<br>
 RTEMS_TEST_CHECK([psxdevctl01])<br>
 RTEMS_TEST_CHECK([psxeintr_join])<br>
 RTEMS_TEST_CHECK([psxenosys])<br>
diff --git a/testsuites/psxtests/psxconfstr/init.c b/testsuites/psxtests/psxconfstr/init.c<br>
new file mode 100644<br>
index 0000000000..e38787132b<br>
--- /dev/null<br>
+++ b/testsuites/psxtests/psxconfstr/init.c<br>
@@ -0,0 +1,143 @@<br>
+/*<br>
+ *  @file<br>
+ *  @brief Test suite for confstr method<br>
+ */<br>
+<br>
+/*<br>
+ * SPDX-License-Identifier: BSD-2-Clause<br>
+ *<br>
+ * Copyright (C) 2020 Eshan Dhawan, Sebastian Huber<br>
+ *<br>
+ * Redistribution and use in source and binary forms, with or without<br>
+ * modification, are permitted provided that the following conditions<br>
+ * are met:<br>
+ * 1. Redistributions of source code must retain the above copyright<br>
+ *    notice, this list of conditions and the following disclaimer.<br>
+ * 2. Redistributions in binary form must reproduce the above copyright<br>
+ *    notice, this list of conditions and the following disclaimer in the<br>
+ *    documentation and/or other materials provided with the distribution.<br>
+ *<br>
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"<br>
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE<br>
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE<br>
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE<br>
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR<br>
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF<br>
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS<br>
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN<br>
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)<br>
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE<br>
+ * POSSIBILITY OF SUCH DAMAGE.<br>
+ */<br>
+<br>
+#ifdef HAVE_CONFIG_H<br>
+#include "config.h"<br>
+#endif<br>
+<br>
+#include <errno.h><br>
+#include <stdio.h><br>
+#include <string.h><br>
+#include <rtems.h><br>
+#include <rtems/test.h><br>
+#include <unistd.h><br>
+#include <rtems/bspIo.h><br>
+<br>
+#include "tmacros.h"<br>
+#include "test_support.h"<br>
+<br>
+const char rtems_test_name[] = "PSXCONFSTR";<br>
+<br>
+/* Forward declaration to avoid warnings */<br>
+rtems_task Init( rtems_task_argument ignored );<br>
+<br>
+static char buffer[512];<br>
+<br>
+static const T_action actions[] = {<br>
+  T_report_hash_sha256,<br>
+  T_check_task_context,<br>
+  T_check_file_descriptors,<br>
+  T_check_rtems_barriers,<br>
+  T_check_rtems_extensions,<br>
+  T_check_rtems_message_queues,<br>
+  T_check_rtems_partitions,<br>
+  T_check_rtems_periods,<br>
+  T_check_rtems_regions,<br>
+  T_check_rtems_semaphores,<br>
+  T_check_rtems_tasks,<br>
+  T_check_rtems_timers,<br>
+  T_check_posix_keys<br>
+};<br>
+<br>
+static const T_config config = {<br>
+  .name = "psxconfstr",<br>
+  .buf = buffer,<br>
+  .putchar = rtems_put_char,<br>
+  .buf_size = sizeof(buffer),<br>
+  .verbosity = T_VERBOSE,<br>
+  .now = T_now_clock,<br>
+  .action_count = T_ARRAY_SIZE(actions),<br>
+  .actions = actions<br>
+};<br>
+<br>
+/* init test function begins */ <br>
+T_TEST_CASE(confstr)<br>
+{<br>
+  <br>
+int r;<br>
+  char * buf ;<br>
+  const char UPE[] = "unsupported programming environment";<br>
+  size_t len1;<br>
+  len1 = strlen(UPE) + 1; <br>
+  r = confstr(_CS_PATH, buf, sizeof(buf));<br>
+  T_quiet_psx_success(r);<br>
+<br>
+  r = confstr(_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS, buf, sizeof(buf));<br>
+  T_quiet_eq_int(r, len1);<br>
+<br>
+  r = confstr(_CS_POSIX_V6_LP64_OFF64_LDFLAGS, buf, sizeof(buf));<br>
+  T_quiet_eq_int(r, len1);<br>
+<br>
+  r = confstr(_CS_POSIX_V7_ILP32_OFF32_CFLAGS, buf, sizeof(buf));<br>
+  T_quiet_eq_int(r, len1);<br>
+<br>
+  r = confstr(_CS_POSIX_V7_ILP32_OFFBIG_CFLAGS, buf, sizeof(buf));<br>
+  T_quiet_eq_int(r, len1);<br>
+<br>
+  r = confstr(_CS_POSIX_V7_LP64_OFF64_LIBS, buf, sizeof(buf));<br>
+  T_quiet_eq_int(r, len1);<br>
+<br>
+  r = confstr(_CS_POSIX_V6_LP64_OFF64_CFLAGS, buf, sizeof(buf));<br>
+  T_quiet_eq_int(r, len1);<br>
+<br>
+  r = confstr(_CS_PATH, buf, sizeof(buf));<br>
+  T_quiet_psx_success(r);<br>
+<br>
+}<br>
+<br>
+rtems_task Init(rtems_task_argument ignored)<br>
+{<br>
+  int exit_code;<br>
+<br>
+  TEST_BEGIN();<br>
+<br>
+  T_register();<br>
+  exit_code = T_main(&config);<br>
+  if (exit_code == 0) {<br>
+    TEST_END();<br>
+  }<br>
+<br>
+ rtems_test_exit(exit_code);<br>
+<br>
+}<br>
+#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER<br>
+#define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER<br>
+<br>
+#define CONFIGURE_MAXIMUM_TASKS 1<br>
+<br>
+#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION<br>
+<br>
+#define CONFIGURE_RTEMS_INIT_TASKS_TABLE<br>
+#define CONFIGURE_INIT<br>
+<br>
+#include <rtems/confdefs.h><br>
+/* end of file */<br>
diff --git a/testsuites/psxtests/psxconfstr/psxconfstr.doc b/testsuites/psxtests/psxconfstr/psxconfstr.doc<br>
new file mode 100644<br>
index 0000000000..43501791b8<br>
--- /dev/null<br>
+++ b/testsuites/psxtests/psxconfstr/psxconfstr.doc<br>
@@ -0,0 +1,17 @@<br>
+#  COPYRIGHT (c) 2020<br>
+#  On-Line Applications Research Corporation (OAR).<br>
+#<br>
+# SPDX-License-Identifier: BSD-2-Clause<br>
+#<br>
+<br>
+This file describes the directives and concepts tested by this test set.<br>
+<br>
+test set name:  psxconfstr<br>
+<br>
+Directives:<br>
+  Confstr()<br>
+<br>
+Concepts:<br>
+<br>
++ This test exercises the confstr method    <br>
+<br>
diff --git a/testsuites/psxtests/psxconfstr/psxconfstr.scn b/testsuites/psxtests/psxconfstr/psxconfstr.scn<br>
new file mode 100644<br>
index 0000000000..cb9e49dc72<br>
--- /dev/null<br>
+++ b/testsuites/psxtests/psxconfstr/psxconfstr.scn<br>
@@ -0,0 +1,4 @@<br>
+*** BEGIN OF TEST PSXCONFSTR ***<br>
+<br>
+*** END OF TEST PSXCONFSTR ***<br>
+<br>
-- <br>
2.27.0<br>
<br>
</blockquote></div></div>