]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Move more complicated tests out of memcheck/tests/solaris/scalar_ioctl
authorIvo Raisr <ivosh@ivosh.net>
Tue, 29 Sep 2015 18:57:56 +0000 (18:57 +0000)
committerIvo Raisr <ivosh@ivosh.net>
Tue, 29 Sep 2015 18:57:56 +0000 (18:57 +0000)
to memcheck/tests/solaris/ioctl.
While at it, remove a fixed size buffer as reported by Florian Krohm.
n-i-bz

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@15690

memcheck/tests/solaris/Makefile.am
memcheck/tests/solaris/ioctl.c [new file with mode: 0644]
memcheck/tests/solaris/ioctl.stderr.exp [new file with mode: 0644]
memcheck/tests/solaris/ioctl.stdout.exp [new file with mode: 0644]
memcheck/tests/solaris/ioctl.vgtest [new file with mode: 0644]
memcheck/tests/solaris/scalar_ioctl.c
memcheck/tests/solaris/scalar_ioctl.stderr.exp

index 8736c87234dc58f46142e231e3129b18bfaa1575..458276983c0733c81c37c42d8a3b710515abd9e2 100644 (file)
@@ -20,6 +20,7 @@ EXTRA_DIST = \
        getzoneoffset.stderr.exp getzoneoffset.vgtest \
        gethrtime.stderr.exp gethrtime.stdout.exp gethrtime.vgtest \
        gethrusec.stderr.exp gethrusec.stdout.exp gethrusec.vgtest \
+       ioctl.stderr.exp ioctl.stdout.exp ioctl.vgtest \
        ldynsym.stderr.exp ldynsym.stdout.exp ldynsym.vgtest \
        lsframe1.stderr.exp lsframe1.stdout.exp lsframe1.vgtest \
        lsframe2.stderr.exp lsframe2.stdout.exp lsframe2.vgtest \
@@ -60,6 +61,7 @@ check_PROGRAMS = \
        gethrtime \
        inlinfo \
        inlinfo_nested.so \
+       ioctl \
        ldynsym \
        lsframe1 \
        lsframe2 \
@@ -147,6 +149,7 @@ AM_CFLAGS   += $(AM_FLAG_M3264_PRI)
 AM_CXXFLAGS += $(AM_FLAG_M3264_PRI)
 
 door_kill_LDADD = -lpthread
+ioctl_LDADD = -lsocket
 ldynsym_LDFLAGS = -Wl,--strip-all
 pkcs11_LDADD = -lpkcs11
 sendfilev_LDADD = -lsendfile
diff --git a/memcheck/tests/solaris/ioctl.c b/memcheck/tests/solaris/ioctl.c
new file mode 100644 (file)
index 0000000..9f7e53a
--- /dev/null
@@ -0,0 +1,91 @@
+/* Tests for ioctl wrappers.
+   More complicated ones than just trivial ones in scalar_ioctl. */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <strings.h>
+#include <unistd.h>
+#include <net/if.h>
+#include <sys/socket.h>
+#include <sys/sockio.h>
+
+/* sockio */
+__attribute__((noinline))
+static int test_SIOCGIFCONF(void)
+{
+   int fd = socket(AF_INET, SOCK_DGRAM, 0);
+   if (fd < 0)
+      perror("socket");
+
+   int n_ifs;
+   if (ioctl(fd, SIOCGIFNUM, &n_ifs) < 0)
+      perror("ioctl(SIOCGIFNUM)");
+
+   struct ifconf ifc;
+   ifc.ifc_len = (n_ifs + 1) * sizeof(struct ifreq);
+   ifc.ifc_buf = malloc((n_ifs + 1) * sizeof(struct ifreq));
+   if (ifc.ifc_buf == NULL)
+      perror("malloc");
+
+   if (ioctl(fd, SIOCGIFCONF, &ifc) < 0)
+      perror("ioctl(SIOCGIFCONF)");
+
+   /* Check definedness of ifc attributes ... */
+   int x = 0;
+   if (ifc.ifc_len != 0) x = -1; else x = -2;
+   if (ifc.ifc_req != NULL) x = -3; else x = -4;
+   if (strcmp(ifc.ifc_req[0].ifr_name, "") != 0) x = -5; else x = -6;
+   /* ... and now one which is not defined. */
+   if (strcmp(ifc.ifc_req[n_ifs].ifr_name, "") != 0) x = -7; else x = -8;
+
+   free(ifc.ifc_buf);
+   close(fd);
+   return x;
+}
+
+__attribute__((noinline))
+static int test_SIOCGLIFCONF(void)
+{
+   int fd = socket(AF_INET, SOCK_DGRAM, 0);
+   if (fd < 0)
+      perror("socket");
+
+   struct lifnum lifn;
+   lifn.lifn_family = AF_INET;
+   lifn.lifn_flags = 0;
+   if (ioctl(fd, SIOCGLIFNUM, &lifn) < 0)
+      perror("ioctl(SIOCGLIFNUM)");
+
+   struct lifconf lifc;
+   lifc.lifc_family = AF_INET;
+   lifc.lifc_flags = 0;
+   lifc.lifc_len = (lifn.lifn_count + 1) * sizeof(struct lifreq);
+   lifc.lifc_buf = malloc((lifn.lifn_count + 1) * sizeof(struct lifreq));
+   if (lifc.lifc_buf == NULL)
+      perror("malloc");
+
+   if (ioctl(fd, SIOCGLIFCONF, &lifc) < 0)
+      perror("ioctl(SIOCGLIFCONF)");
+
+   /* Check definedness of lifc attributes ... */
+   int x = 0;
+   if (lifc.lifc_len != 0) x = -1; else x = -2;
+   if (lifc.lifc_req != NULL) x = -3; else x = -4;
+   if (strcmp(lifc.lifc_req[0].lifr_name, "") != 0) x = -5; else x = -6;
+   /* ... and now one which is not defined. */
+   if (strcmp(lifc.lifc_req[lifn.lifn_count].lifr_name, "") != 0)
+      x = -7; else x = -8;
+
+   free(lifc.lifc_buf);
+   close(fd);
+   return x;
+}
+
+int main(void)
+{
+   /* sockio */
+   test_SIOCGIFCONF();
+   test_SIOCGLIFCONF();
+
+   return 0;
+}
diff --git a/memcheck/tests/solaris/ioctl.stderr.exp b/memcheck/tests/solaris/ioctl.stderr.exp
new file mode 100644 (file)
index 0000000..146ea8d
--- /dev/null
@@ -0,0 +1,8 @@
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: test_SIOCGIFCONF (ioctl.c:39)
+   by 0x........: main (ioctl.c:87)
+
+Conditional jump or move depends on uninitialised value(s)
+   at 0x........: test_SIOCGLIFCONF (ioctl.c:76)
+   by 0x........: main (ioctl.c:88)
+
diff --git a/memcheck/tests/solaris/ioctl.stdout.exp b/memcheck/tests/solaris/ioctl.stdout.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/memcheck/tests/solaris/ioctl.vgtest b/memcheck/tests/solaris/ioctl.vgtest
new file mode 100644 (file)
index 0000000..a0daa78
--- /dev/null
@@ -0,0 +1,2 @@
+prog: ioctl
+vgopts: -q
index c4b4c79dc9e5f0f142767db0c72f8be0bcbc76c7..dfc39fbce14442a67b79157e1a7e9897a04d37e6 100644 (file)
@@ -1,10 +1,9 @@
-/* Basic ioctl test. */
+/* Basic ioctl scalar tests. */
 
 #define __EXTENSIONS__ 1
 
 #include "scalar.h"
 
-#include <unistd.h>
 #include <net/if.h>
 #include <sys/crypto/ioctl.h>
 #include <sys/dtrace.h>
@@ -223,49 +222,15 @@ __attribute__((noinline))
 static void sys_ioctl_SIOCGIFCONF_2(void)
 {
    struct ifconf ifc;
-   char buf[5];
+   char buf[] = "";
 
-   ifc.ifc_len = x0 + 5;
+   ifc.ifc_len = x0 + 1;
    ifc.ifc_buf = (void *) (x0 + buf);
 
    GO(SYS_ioctl, "(SIOCGIFCONF), 5s 0m");
    SY(SYS_ioctl, x0 - 1, x0 + SIOCGIFCONF, &ifc + x0); FAIL;
 }
 
-__attribute__((noinline))
-static int sys_ioctl_SIOCGIFCONF_3(void)
-{
-   int fd = socket(AF_INET, SOCK_DGRAM, 0);
-   if (fd < 0)
-      perror("socket");
-
-   int n_ifs;
-   if (ioctl(fd, SIOCGIFNUM, &n_ifs) < 0)
-      perror("ioctl(SIOCGIFNUM)");
-
-   struct ifconf ifc;
-   ifc.ifc_len = (n_ifs + 1) * sizeof(struct ifreq);
-   ifc.ifc_buf = malloc((n_ifs + 1) * sizeof(struct ifreq));
-   if (ifc.ifc_buf == NULL)
-      perror("malloc");
-
-   GO(SYS_ioctl, "(SIOCGIFCONF), 1s 0m");
-   if (ioctl(fd, SIOCGIFCONF, &ifc) < 0)
-      perror("ioctl(SIOCGIFCONF)");
-
-   /* Check definedness of ifc attributes ... */
-   int x = 0;
-   if (ifc.ifc_len != 0) x = -1; else x = -2;
-   if (ifc.ifc_req != NULL) x = -3; else x = -4;
-   if (strcmp(ifc.ifc_req[0].ifr_name, "") != 0) x = -5; else x = -6;
-   /* ... and now one which is not defined. */
-   if (strcmp(ifc.ifc_req[n_ifs].ifr_name, "") != 0) x = -7; else x = -8;
-
-   free(ifc.ifc_buf);
-   close(fd);
-   return x;
-}
-
 __attribute__((noinline))
 static void sys_ioctl_SIOCGIFFLAGS(void)
 {
@@ -356,9 +321,9 @@ __attribute__((noinline))
 static void sys_ioctl_SIOCGLIFCONF_2(void)
 {
    struct lifconf lifc;
-   char buf[5];
+   char buf[] = "";
 
-   lifc.lifc_len = x0 + 5;
+   lifc.lifc_len = x0 + 1;
    lifc.lifc_buf = (void *) (x0 + buf);
    lifc.lifc_family = x0 + 1;
    lifc.lifc_flags = x0 + 0;
@@ -367,45 +332,6 @@ static void sys_ioctl_SIOCGLIFCONF_2(void)
    SY(SYS_ioctl, x0 - 1, x0 + SIOCGLIFCONF, &lifc + x0); FAIL;
 }
 
-__attribute__((noinline))
-static int sys_ioctl_SIOCGLIFCONF_3(void)
-{
-   int fd = socket(AF_INET, SOCK_DGRAM, 0);
-   if (fd < 0)
-      perror("socket");
-
-   struct lifnum lifn;
-   lifn.lifn_family = AF_INET;
-   lifn.lifn_flags = 0;
-   if (ioctl(fd, SIOCGLIFNUM, &lifn) < 0)
-      perror("ioctl(SIOCGLIFNUM)");
-
-   struct lifconf lifc;
-   lifc.lifc_family = AF_INET;
-   lifc.lifc_flags = 0;
-   lifc.lifc_len = (lifn.lifn_count + 1) * sizeof(struct lifreq);
-   lifc.lifc_buf = malloc((lifn.lifn_count + 1) * sizeof(struct lifreq));
-   if (lifc.lifc_buf == NULL)
-      perror("malloc");
-
-   GO(SYS_ioctl, "(SIOCGLIFCONF), 1s 0m");
-   if (ioctl(fd, SIOCGLIFCONF, &lifc) < 0)
-      perror("ioctl(SIOCGLIFCONF)");
-
-   /* Check definedness of lifc attributes ... */
-   int x = 0;
-   if (lifc.lifc_len != 0) x = -1; else x = -2;
-   if (lifc.lifc_req != NULL) x = -3; else x = -4;
-   if (strcmp(lifc.lifc_req[0].lifr_name, "") != 0) x = -5; else x = -6;
-   /* ... and now one which is not defined. */
-   if (strcmp(lifc.lifc_req[lifn.lifn_count].lifr_name, "") != 0)
-      x = -7; else x = -8;
-
-   free(lifc.lifc_buf);
-   close(fd);
-   return x;
-}
-
 __attribute__((noinline))
 static void sys_ioctl_SIOCGLIFFLAGS(void)
 {
@@ -557,7 +483,6 @@ int main(void)
    /* sockio */
    sys_ioctl_SIOCGIFCONF();
    sys_ioctl_SIOCGIFCONF_2();
-   sys_ioctl_SIOCGIFCONF_3();
    sys_ioctl_SIOCGIFFLAGS();
    sys_ioctl_SIOCGIFFLAGS_2();
    sys_ioctl_SIOCGIFNETMASK();
@@ -568,7 +493,6 @@ int main(void)
    sys_ioctl_SIOCGLIFBRDADDR_2();
    sys_ioctl_SIOCGLIFCONF();
    sys_ioctl_SIOCGLIFCONF_2();
-   sys_ioctl_SIOCGLIFCONF_3();
    sys_ioctl_SIOCGLIFFLAGS();
    sys_ioctl_SIOCGLIFFLAGS_2();
    sys_ioctl_SIOCGLIFNETMASK();
index 5a53d6eb61f6035d3384e00a810d7fe4b4901340..fdb1a56508091a3752f49f49b7954df35acac97d 100644 (file)
@@ -463,12 +463,6 @@ Syscall param ioctl(SIOCGIFCONF, ifconf->ifc_buf) points to uninitialised byte(s
    ...
  Address 0x........ is on thread 1's stack
 
----------------------------------------------------------
- 54:               SYS_ioctl (SIOCGIFCONF), 1s 0m
----------------------------------------------------------
-Conditional jump or move depends on uninitialised value(s)
-   ...
-
 ---------------------------------------------------------
  54:               SYS_ioctl (SIOCGIFFLAGS) 3s 2m
 ---------------------------------------------------------
@@ -661,12 +655,6 @@ Syscall param ioctl(SIOCGLIFCONF, lifconf->lifc_flags) points to uninitialised b
    ...
  Address 0x........ is on thread 1's stack
 
----------------------------------------------------------
- 54:               SYS_ioctl (SIOCGLIFCONF), 1s 0m
----------------------------------------------------------
-Conditional jump or move depends on uninitialised value(s)
-   ...
-
 ---------------------------------------------------------
  54:               SYS_ioctl (SIOCGLIFFLAGS) 3s 2m
 ---------------------------------------------------------