[PATCH 2/2] added the test files for confstr

Eshan dhawan eshandhawan51 at gmail.com
Mon Jul 13 18:10:06 UTC 2020


closes #3373

Signed-off-by: Eshan dhawan <eshandhawan51 at gmail.com>
---
 libbsd.py                     |  1 +
 testsuite/confstr/test_main.c | 71 +++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+)
 create mode 100644 testsuite/confstr/test_main.c

diff --git a/libbsd.py b/libbsd.py
index 9beba660..581b3aed 100644
--- a/libbsd.py
+++ b/libbsd.py
@@ -5340,6 +5340,7 @@ class tests(builder.Module):
         self.addTest(mm.generator['test']('ipsec01', ['test_main']))
         self.addTest(mm.generator['test']('openssl01', ['test_main']))
         self.addTest(mm.generator['test']('openssl02', ['test_main']))
+        self.addTest(mm.generator['test']('confstr', ['test_main']))
 
 def load(mm):
 
diff --git a/testsuite/confstr/test_main.c b/testsuite/confstr/test_main.c
new file mode 100644
index 00000000..b841fa40
--- /dev/null
+++ b/testsuite/confstr/test_main.c
@@ -0,0 +1,71 @@
+/**
+ * @file
+ *
+ * Following methods are tested in this file : Confstr() 
+ */
+
+/*
+ * Copyright (c) 2020 Eshan Dhawan
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#include <sys/param.h>
+
+#include <errno.h>
+#include <limits.h>
+#include <paths.h>
+#include <string.h>
+#include <unistd.h>
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <rtems/libcsupport.h>
+#include <rtems.h>
+
+#define TEST_NAME "LIBBSD CONFSTR "
+
+static void 
+test_main(void)
+{
+  int r;
+  char * buf ;
+  const char UPE[] = "unsupported programming environment";
+  size_t len1;
+  len1 = strlen(UPE) + 1; 
+  r = confstr(_CS_PATH, buf, sizeof(buf));
+  if (r != 0){
+    printf("This Function is not supported");
+  }
+  assert( r == 0 );
+  r = confstr(_CS_POSIX_V6_ILP32_OFFBIG_CFLAGS, buf, sizeof(buf));
+  if ( r != len1 ){
+    printf("lenght not matched");
+  }
+  assert(r == len1);
+  
+  exit(0);
+}
+
+#include <rtems/bsd/test/default-init.h>
-- 
2.17.1



More information about the devel mailing list