<div dir="ltr"><div>This looks close to me but I see some minor issues. I have tried to annotate them. </div><div><br></div><div>The spacing ones could be spaces vs tabs. Not sure.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Sep 10, 2020 at 3:48 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">Adds Confstr file To RTEMS with test<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                    | 105 +++++++++++++++<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         | 125 ++++++++++++++++++<br>
 testsuites/psxtests/psxconfstr/psxconfstr.doc |  17 +++<br>
 testsuites/psxtests/psxconfstr/psxconfstr.scn |   4 +<br>
 7 files changed, 262 insertions(+)<br>
 create mode 100644 cpukit/posix/src/confstr.c<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 e5009e53c9..1c9e4697f1 100644<br>
--- a/cpukit/Makefile.am<br>
+++ b/cpukit/Makefile.am<br>
@@ -509,6 +509,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..71041db462<br>
--- /dev/null<br>
+++ b/cpukit/posix/src/confstr.c<br>
@@ -0,0 +1,105 @@<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>
+__SCCSID("@(#)confstr.c        8.1 (Berkeley) 6/4/93");<br>
+__FBSDID("$FreeBSD$");<br></blockquote><div><br></div><div>Probably worth adding a comment above that the FreeBSD version</div><div>was reduced to what made sense on RTEMS.</div><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>
+#include <sys/param.h><br>
+<br>
+#include <errno.h><br>
+#include <limits.h><br>
+#include <paths.h><br>
+#include <string.h><br>
+#include <unistd.h><br><br></blockquote><div>If you do that, you won't need all these headers.</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">
+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>
+#ifndef __rtems__<br>
+       case _CS_PATH:<br>
+               p = _PATH_STDPATH;<br>
+               goto docopy;<br>
+#endif<br></blockquote><div><br></div><div>It looks like the body of the other cases were gutted from the freebsd </div><div>code. Why keep an ifndef RTEMS here? This is just going to produce </div><div>an error for an unknown name via the default case. If we are going to</div><div>delete all non-FreeBSD code from this and make it a more RTEMS </div><div>specific implementation, you might as well just do this:</div><div><br></div><div>        case _CS_PATH:</div><div>              errno = EINVAL;<br>              return (0);  <br></div><div><br></div><div>That keeps the order like the FreeBSD without ifdefs.</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>
+                * 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>
+       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>
+<br>
+               p = UPE;<br>
+               goto docopy;<br>
+<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>
+<br>
+                       p = UPE;<br>
+               goto docopy;<br></blockquote><div><br></div><div><br></div><div>Spacing. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<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>
+                       p = UPE;<br>
+               goto docopy;<br></blockquote><div><br></div><div>Spacing. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
+<br>
+<br>
+docopy:<br>
+               if (len != 0 && buf != NULL)<br>
+                       strlcpy(buf, p, len);<br>
+               return (strlen(p) + 1);<br>
+<br>
+       default:<br>
+               errno = EINVAL;<br>
+               return (0);<br>
+       }<br>
+       /* NOTREACHED */<br>
+}<br>
diff --git a/testsuites/psxtests/Makefile.am b/testsuites/psxtests/Makefile.am<br>
index aae5fe764a..f0910330a9 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>
+if TEST_psxgetcpuclockid01<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_psxgetcpuclockid01) \<br>
+       $(support_includes)<br>
+endif<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..7219470559<br>
--- /dev/null<br>
+++ b/testsuites/psxtests/psxconfstr/init.c<br>
@@ -0,0 +1,125 @@<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></blockquote><div>Is this a remnant of a copied test? Is it used?</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">
+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>
+<br>
+  T_quiet_psx_success(r);<br>
+  r = confstr(_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS, buf, sizeof(buf));<br>
+  T_quiet_eq_int(r, len1);<br>
+<br>
+}<br><br></blockquote><div>You should exercise every known good value for a name. Plus a randomly bad one.</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">
+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..e353f74ae7<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>
+  Pthread_getcpuclockid()<br></blockquote><div><br></div><div>Not right.</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>
+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..705a08d51b<br>
--- /dev/null<br>
+++ b/testsuites/psxtests/psxconfstr/psxconfstr.scn<br>
@@ -0,0 +1,4 @@<br>
+*** BEGIN OF TEST PSXGETCPUCLOCKID 1 ***<br>
+<br>
+*** END OF TEST PSXGETCPUCLOCKID 1 ***<br>
+<br></blockquote><div><br></div><div>I'm betting this isn't right either. :)</div><div><br></div><div>--joel</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>
2.17.1<br>
<br>
</blockquote></div></div>