Hello community,

here is the log from the commit of package stress-ng for openSUSE:Factory 
checked in at 2019-07-12 12:00:13
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/stress-ng (Old)
 and      /work/SRC/openSUSE:Factory/.stress-ng.new.4615 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "stress-ng"

Fri Jul 12 12:00:13 2019 rev:61 rq:714777 version:0.10.00

Changes:
--------
--- /work/SRC/openSUSE:Factory/stress-ng/stress-ng.changes      2019-06-24 
21:53:40.592120538 +0200
+++ /work/SRC/openSUSE:Factory/.stress-ng.new.4615/stress-ng.changes    
2019-07-12 12:00:19.884172840 +0200
@@ -1,0 +2,26 @@
+Thu Jul 11 20:44:08 UTC 2019 - Martin Hauke <[email protected]>
+
+- Update to version 0.10.00
+  * stress-pthread: abort if mutex lock is unlockable
+  * stress-cpu: use CLOCK_PROCESS_CPUTIME_ID to measure CPU consumed
+  * stress-cpu: fix CPU loading calculation
+  * core-helper: keeping on ringing SIGALRM until stressors get the
+    message
+  * stress-memthrash: make stressors more yielding
+  * stress-fork: do explicit keep_stressing() call rather than
+    simple flag check
+  * stress-fork: block SIGALRM and check for pending SIGALRMs
+  * Add stress_sigalrm_pending and stress_sigalrm_block helpers
+  * stress-brk: exercise zero expansion of brk
+  * stress-efivar: exercise efi variable interfaces a little more
+  * core-out-of-memory: refactor code, add a set adjustment helper
+  * core-sched: put sched types into a lookup table
+  * stress-socket: remove debug
+  * stress-dev: exercise /dev/nvram
+  * stress-socket: exercise IP_MTU if it is available
+  * stress-sctp: use setsockopt for more socket option exercising
+  * stress-sctp: add some sctp related getsockopt calls
+  * stress-fcntl: don't make EPERM a fatal test failure
+  * stress-chroot: don't make EPERM a fatal test failure
+
+-------------------------------------------------------------------

Old:
----
  stress-ng-0.09.60.tar.xz

New:
----
  stress-ng-0.10.00.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ stress-ng.spec ++++++
--- /var/tmp/diff_new_pack.BvOM6s/_old  2019-07-12 12:00:22.684172606 +0200
+++ /var/tmp/diff_new_pack.BvOM6s/_new  2019-07-12 12:00:22.688172605 +0200
@@ -18,7 +18,7 @@
 
 
 Name:           stress-ng
-Version:        0.09.60
+Version:        0.10.00
 Release:        0
 Summary:        Tool to load and stress a computer
 License:        GPL-2.0-only

++++++ stress-ng-0.09.60.tar.xz -> stress-ng-0.10.00.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/Makefile 
new/stress-ng-0.10.00/Makefile
--- old/stress-ng-0.09.60/Makefile      2019-06-22 10:46:27.000000000 +0200
+++ new/stress-ng-0.10.00/Makefile      2019-07-08 21:18:04.000000000 +0200
@@ -16,9 +16,9 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA.
 #
 
-VERSION=0.09.60
+VERSION=0.10.00
 #
-# Codename "portable pressure producer"
+# Codename "systematic system smasher"
 #
 
 CFLAGS += -Wall -Wextra -DVERSION='"$(VERSION)"' -O2 -std=gnu99
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/README new/stress-ng-0.10.00/README
--- old/stress-ng-0.09.60/README        2019-06-22 10:46:27.000000000 +0200
+++ new/stress-ng-0.10.00/README        2019-07-08 21:18:04.000000000 +0200
@@ -90,6 +90,10 @@
        make clean
        PEDANTIC=1 make
 
+To build with the Tiny C compiler:
+       make clean
+       CC=tcc make
+
 For more information, see: http://kernel.ubuntu.com/~cking/stress-ng/
 
 I am keen to add to the stress-ng project page any citations to research or
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/core-helper.c 
new/stress-ng-0.10.00/core-helper.c
--- old/stress-ng-0.09.60/core-helper.c 2019-06-22 10:46:27.000000000 +0200
+++ new/stress-ng-0.10.00/core-helper.c 2019-07-08 21:18:04.000000000 +0200
@@ -1043,6 +1043,11 @@
        (void)signum;
 
        g_keep_stressing_flag = false;
+       /*
+        * Trigger another SIGARLM until stressor gets the message
+        * that it needs to terminate
+        */
+       (void)alarm(1);
 }
 
 /*
@@ -1253,6 +1258,35 @@
 }
 
 /*
+ *  stress_sigalrm_pending()
+ *     return true if SIGALRM is pending
+ */
+bool stress_sigalrm_pending(void)
+{
+       sigset_t set;
+
+       (void)sigemptyset(&set);
+       (void)sigpending(&set);
+       return sigismember(&set, SIGALRM);
+
+}
+
+/*
+ *  stress_sigalrm_block()
+ *     block SIGALRM signals, use in conjunction with
+ *     stress_sigalrm_pending to check if a SIGALRM is
+ *     pending.
+ */
+void stress_sigalrm_block(void)
+{
+       sigset_t set;
+
+       (void)sigemptyset(&set);
+       (void)sigaddset(&set, SIGALRM);
+       (void)sigprocmask(SIG_BLOCK, &set, NULL);
+}
+
+/*
  *  stress_uint64_to_str()
  *     turn 64 bit size to human readable string
  */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/core-out-of-memory.c 
new/stress-ng-0.10.00/core-out-of-memory.c
--- old/stress-ng-0.09.60/core-out-of-memory.c  2019-06-22 10:46:27.000000000 
+0200
+++ new/stress-ng-0.10.00/core-out-of-memory.c  2019-07-08 21:18:04.000000000 
+0200
@@ -77,6 +77,33 @@
 }
 
 /*
+ *    set_adjustment()
+ *     try to set OOM adjustment, retry if EAGAIN or EINTR, give up
+ *     after multiple retries.
+ */
+static void set_adjustment(const char *name, const int fd, const char *str)
+{
+       const size_t len = strlen(str);
+       int i;
+
+       for (i = 0; i < 32; i++) {
+               ssize_t n;
+
+               n = write(fd, str, len);
+               if (n > 0)
+                       return;
+
+               if ((errno != EAGAIN) && (errno != EINTR)) {
+                       pr_dbg("%s: can't set oom_score_adj\n", name);
+                       return;
+               }
+       }
+       /* Unexpected failure, report why */
+       pr_dbg("%s: can't set oom_score_adj, errno=%d (%s)\n", name,
+               errno, strerror(errno));
+}
+
+/*
  *  set_oom_adjustment()
  *     attempt to stop oom killer
  *     if we have root privileges then try and make process
@@ -102,21 +129,13 @@
         */
        if ((fd = open("/proc/self/oom_score_adj", O_WRONLY)) >= 0) {
                char *str;
-               ssize_t n;
 
                if (make_killable)
                        str = OOM_SCORE_ADJ_MAX;
                else
                        str = high_priv ? OOM_SCORE_ADJ_MIN : "0";
 
-redo_wr1:
-               n = write(fd, str, strlen(str));
-               if (n <= 0) {
-                       if ((errno == EAGAIN) || (errno == EINTR))
-                               goto redo_wr1;
-                       if (errno)
-                               pr_dbg("%s: can't set oom_score_adj\n", name);
-               }
+               set_adjustment(name, fd, str);
                (void)close(fd);
                return;
        }
@@ -125,21 +144,13 @@
         */
        if ((fd = open("/proc/self/oom_adj", O_WRONLY)) >= 0) {
                char *str;
-               ssize_t n;
 
                if (make_killable)
                        str = high_priv ? OOM_ADJ_NO_OOM : OOM_ADJ_MIN;
                else
                        str = OOM_ADJ_MAX;
 
-redo_wr2:
-               n = write(fd, str, strlen(str));
-               if (n <= 0) {
-                       if ((errno == EAGAIN) || (errno == EINTR))
-                               goto redo_wr2;
-                       if (errno)
-                               pr_dbg("%s: can't set oom_adj\n", name);
-               }
+               set_adjustment(name, fd, str);
                (void)close(fd);
        }
        return;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/core-sched.c 
new/stress-ng-0.10.00/core-sched.c
--- old/stress-ng-0.09.60/core-sched.c  2019-06-22 10:46:27.000000000 +0200
+++ new/stress-ng-0.10.00/core-sched.c  2019-07-08 21:18:04.000000000 +0200
@@ -24,47 +24,50 @@
  */
 #include "stress-ng.h"
 
+typedef struct {
+       const int sched;
+       const char *const name;
+} sched_types_t;
+
+static sched_types_t sched_types[] = {
+#if defined(SCHED_BATCH)
+       { SCHED_BATCH,          "batch" },
+#endif
+#if defined(SCHED_DEADLINE)
+       { SCHED_DEADLINE,       "deadline" },
+#endif
+#if defined(SCHED_FIFO)
+       { SCHED_FIFO,           "fifo" },
+#endif
+#if defined(SCHED_IDLE)
+       { SCHED_IDLE,           "idle" },
+#endif
+#if defined(SCHED_OTHER)
+       { SCHED_OTHER,          "other" },
+#endif
+#if defined(SCHED_RR)
+       { SCHED_RR,             "rr" },
+#endif
+};
+
 #if (defined(_POSIX_PRIORITY_SCHEDULING) || defined(__linux__)) && \
     !defined(__OpenBSD__) && !defined(__minix__) && !defined(__APPLE__)
+
 /*
  *  get_sched_name()
  *     convert sched class to human readable string
  */
 const char *stress_get_sched_name(const int sched)
 {
-       switch (sched) {
-#if defined(SCHED_IDLE)
-       case SCHED_IDLE:
-               return "idle";
-#endif
-#if defined(SCHED_FIFO)
-       case SCHED_FIFO:
-               return "fifo";
-#endif
-#if defined(SCHED_RR)
-       case SCHED_RR:
-               return "rr";
-#endif
-#if defined(SCHED_OTHER)
-       case SCHED_OTHER:
-               return "other";
-#endif
-#if defined(SCHED_BATCH)
-       case SCHED_BATCH:
-               return "batch";
-#endif
-#if defined(SCHED_DEADLINE)
-       case SCHED_DEADLINE:
-               return "deadline";
-#endif
-       default:
-               return "unknown";
+       size_t i;
+
+       for (i = 0; i < SIZEOF_ARRAY(sched_types); i++) {
+               if (sched_types[i].sched == sched)
+                       return sched_types[i].name;
        }
+       return "unknown";
 }
-#endif
 
-#if (defined(_POSIX_PRIORITY_SCHEDULING) || defined(__linux__)) && \
-     !defined(__OpenBSD__) && !defined(__minix__) && !defined(__APPLE__)
 /*
  *  set_sched()
  *     are sched settings valid, if so, set them
@@ -160,7 +163,8 @@
                if (rc < 0) {
                        rc = -errno;
                        if (!quiet)
-                               pr_inf("Cannot set scheduler: errno=%d (%s)\n",
+                               pr_inf("Cannot set scheduler '%s': errno=%d 
(%s)\n",
+                                       stress_get_sched_name(sched),
                                        errno, strerror(errno));
                        return rc;
                }
@@ -181,7 +185,8 @@
        if (rc < 0) {
                rc = -errno;
                if (!quiet)
-                       pr_inf("Cannot set scheduler: errno=%d (%s)\n",
+                       pr_inf("Cannot set scheduler '%s': errno=%d (%s)\n",
+                               stress_get_sched_name(sched),
                                errno, strerror(errno));
                return rc;
        }
@@ -209,51 +214,22 @@
  */
 int32_t get_opt_sched(const char *const str)
 {
-#if defined(SCHED_OTHER)
-       if (!strcmp("other", str))
-               return SCHED_OTHER;
-#endif
-#if defined(SCHED_BATCH)
-       if (!strcmp("batch", str))
-               return SCHED_BATCH;
-#endif
-#if defined(SCHED_IDLE)
-       if (!strcmp("idle", str))
-               return SCHED_IDLE;
-#endif
-#if defined(SCHED_FIFO)
-       if (!strcmp("fifo", str))
-               return SCHED_FIFO;
-#endif
-#if defined(SCHED_RR)
-       if (!strcmp("rr", str))
-               return SCHED_RR;
-#endif
-#if defined(SCHED_DEADLINE)
-       if (!strcmp("deadline", str))
-               return SCHED_DEADLINE;
-#endif
+       size_t i;
+
+       for (i = 0; i < SIZEOF_ARRAY(sched_types); i++) {
+               if (!strcmp(sched_types[i].name, str))
+                       return sched_types[i].sched;
+       }
        if (strcmp("which", str))
                (void)fprintf(stderr, "Invalid sched option: %s\n", str);
-       (void)fprintf(stderr, "Available scheduler options are:"
-#if defined(SCHED_OTHER)
-               " other"
-#endif
-#if defined(SCHED_BATCH)
-               " batch"
-#endif
-#if defined(SCHED_DEADLINE)
-               " deadline"
-#endif
-#if defined(SCHED_IDLE)
-               " idle"
-#endif
-#if defined(SCHED_FIFO)
-               " fifo"
-#endif
-#if defined(SCHED_FIFO)
-               " rr"
-#endif
-               "\n");
+       if (SIZEOF_ARRAY(sched_types) == 0) {
+               (void)fprintf(stderr, "No scheduler options are available\n");
+       } else {
+               (void)fprintf(stderr, "Available scheduler options are:");
+               for (i = 0; i < SIZEOF_ARRAY(sched_types); i++) {
+                       fprintf(stderr, " %s", sched_types[i].name);
+               }
+               fprintf(stderr, "\n");
+       }
        _exit(EXIT_FAILURE);
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/core-shim.c 
new/stress-ng-0.10.00/core-shim.c
--- old/stress-ng-0.09.60/core-shim.c   2019-06-22 10:46:27.000000000 +0200
+++ new/stress-ng-0.10.00/core-shim.c   2019-07-08 21:18:04.000000000 +0200
@@ -503,11 +503,7 @@
 int shim_mlock(const void *addr, size_t len)
 {
 #if defined(HAVE_MLOCK)
-#if defined(__sun__)
-       return mlock((const caddr_t)addr, len);
-#else
        return mlock(addr, len);
-#endif
 #else
        return shim_enosys(0, addr, len);
 #endif
@@ -520,11 +516,7 @@
 int shim_munlock(const void *addr, size_t len)
 {
 #if defined(HAVE_MUNLOCK)
-#if defined(__sun__)
-       return munlock((const caddr_t)addr, len);
-#else
        return munlock(addr, len);
-#endif
 #else
        return shim_enosys(0, addr, len);
 #endif
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/stress-brk.c 
new/stress-ng-0.10.00/stress-brk.c
--- old/stress-ng-0.09.60/stress-brk.c  2019-06-22 10:46:27.000000000 +0200
+++ new/stress-ng-0.10.00/stress-brk.c  2019-07-08 21:18:04.000000000 +0200
@@ -136,15 +136,23 @@
                        uint8_t *ptr;
 
                        i++;
-                       if (i > 8) {
+                       if (i < 8) {
+                               /* Expand brk by 1 page */
+                               ptr = shim_sbrk((intptr_t)page_size);
+                       } else if (i < 9) {
+                               /* brk to same brk position */
+                               ptr = shim_sbrk(0);
+                               if (shim_brk(ptr) < 0)
+                                       ptr = (void *)-1;
+                       } else {
+                               /* Shrink brk by 1 page */
                                i = 0;
                                ptr = shim_sbrk(0);
                                ptr -= page_size;
                                if (shim_brk(ptr) < 0)
                                        ptr = (void *)-1;
-                       } else {
-                               ptr = shim_sbrk((intptr_t)page_size);
                        }
+
                        if (ptr == (void *)-1) {
                                if ((errno == ENOMEM) || (errno == EAGAIN)) {
                                        nomems++;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/stress-chroot.c 
new/stress-ng-0.10.00/stress-chroot.c
--- old/stress-ng-0.09.60/stress-chroot.c       2019-06-22 10:46:27.000000000 
+0200
+++ new/stress-ng-0.10.00/stress-chroot.c       2019-07-08 21:18:04.000000000 
+0200
@@ -177,7 +177,9 @@
         * We check for error, ENOENT can happen on termination
         * so ignore this error
         */
-       if ((ret1 >= 0) || ((errno1 != ENOTDIR) && (errno1 != ENOENT)))  {
+       if ((ret1 >= 0) || ((errno1 != ENOTDIR) &&
+                           (errno1 != ENOENT) && 
+                           (errno1 != EPERM)))  {
                pr_fail("%s: chroot(\"%s\"), expected ENOTDIR"
                        ", got instead errno=%d (%s)\n",
                        args->name, filename, errno1, strerror(errno1));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/stress-cpu.c 
new/stress-ng-0.10.00/stress-cpu.c
--- old/stress-ng-0.09.60/stress-cpu.c  2019-06-22 10:46:27.000000000 +0200
+++ new/stress-ng-0.10.00/stress-cpu.c  2019-07-08 21:18:04.000000000 +0200
@@ -2488,8 +2488,7 @@
         */
        bias = 0.0;
        do {
-               double t, delay;
-               double t1, t2, t3;
+               double delay, t1, t2, t3;
                struct timeval tv;
 
                t1 = time_now();
@@ -2516,7 +2515,38 @@
                        } while (t2 < slice_end);
                } else {
                        /* > 0, time slice in milliseconds */
-                       double slice_end = t1 +
+
+                       double slice_end;
+#if defined(CLOCK_PROCESS_CPUTIME_ID)
+                       struct timespec ts;
+                       static bool clock_failed = false;
+
+                       if (clock_failed)
+                               goto poll_time;
+
+                       if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts) < 0) {
+                               clock_failed = true;
+                               goto poll_time;
+                       }
+                       slice_end = (ts.tv_sec + ((double)ts.tv_nsec) / 
1000000000.0) +
+                               ((double)cpu_load_slice / 1000.0);
+
+                       do {
+                               (void)func(args->name);
+                               if (clock_gettime(CLOCK_PROCESS_CPUTIME_ID, 
&ts) < 0) {
+                                       clock_failed = true;
+                                       goto poll_time;
+                               }
+                               t2 = ts.tv_sec + ((double)ts.tv_nsec) / 
1000000000.0;
+                               if (!g_keep_stressing_flag)
+                                       break;
+                               inc_counter(args);
+                       } while (t2 < slice_end);
+
+                       goto delay_time;
+poll_time:
+#endif
+                       slice_end = t1 +
                                ((double)cpu_load_slice / 1000.0);
                        do {
                                (void)func(args->name);
@@ -2526,9 +2556,11 @@
                                inc_counter(args);
                        } while (t2 < slice_end);
                }
-               t = t2 - t1;
+#if defined(CLOCK_PROCESS_CPUTIME_ID)
+delay_time:
+#endif
                /* Must not calculate this with zero % load */
-               delay = t * (((100.0 / (double)cpu_load)) - 1.0);
+               delay = (((100 - cpu_load) * (t2 - t1)) / (double)cpu_load);
                delay -= bias;
 
                tv.tv_sec = delay;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/stress-dev.c 
new/stress-ng-0.10.00/stress-dev.c
--- old/stress-ng-0.09.60/stress-dev.c  2019-06-22 10:46:27.000000000 +0200
+++ new/stress-ng-0.10.00/stress-dev.c  2019-07-08 21:18:04.000000000 +0200
@@ -765,11 +765,22 @@
                (void)munmap(ptr, page_size);
        }
        if (read_page) {
-               char buffer[page_size];
-               ssize_t ret;
+               off_t off;
 
-               ret = read(fd, buffer, page_size);
-               (void)ret;
+               /* Try seeking */
+               off = lseek(fd, (off_t)0, SEEK_SET);
+#if defined(STRESS_X86)
+               if (off == 0) {
+                       char buffer[page_size];
+                       ssize_t ret;
+
+                       /* And try reading */
+                       ret = read(fd, buffer, page_size);
+                       (void)ret;
+               }
+#else
+               (void)off;
+#endif
        }
 
        ptr = mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
@@ -787,7 +798,7 @@
        (void)name;
        (void)devpath;
 
-       stress_dev_mem_mmap_linux(fd, false);
+       stress_dev_mem_mmap_linux(fd, true);
 }
 #endif
 
@@ -817,6 +828,19 @@
 }
 #endif
 
+#if defined(__linux__)
+static void stress_dev_nvram_linux(
+       const char *name,
+       const int fd,
+       const char *devpath)
+{
+       (void)name;
+       (void)devpath;
+
+       stress_dev_mem_mmap_linux(fd, true);
+}
+#endif
+
 #if defined(HAVE_LINUX_HPET_H)
 static void stress_dev_hpet_linux(
        const char *name,
@@ -997,6 +1021,7 @@
        DEV_FUNC("/dev/mem",    stress_dev_mem_linux),
        DEV_FUNC("/dev/kmem",   stress_dev_kmem_linux),
        DEV_FUNC("/dev/kmsg",   stress_dev_kmsg_linux),
+       DEV_FUNC("/dev/nvram",  stress_dev_nvram_linux),
 #endif
 #if defined(__linux__) && defined(STRESS_X86)
        DEV_FUNC("/dev/port",   stress_dev_port_linux),
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/stress-efivar.c 
new/stress-ng-0.10.00/stress-efivar.c
--- old/stress-ng-0.09.60/stress-efivar.c       2019-06-22 10:46:27.000000000 
+0200
+++ new/stress-ng-0.10.00/stress-efivar.c       2019-07-08 21:18:04.000000000 
+0200
@@ -47,6 +47,13 @@
 static bool *efi_ignore;
 static int dir_count;
 
+static const char * const efi_sysfs_names[] = {
+       "attributes",
+       "data",
+       "guid",
+       "size"
+};
+
 /*
  *  efi_var_ignore()
  *     check for filenames that are not efi vars
@@ -109,50 +116,73 @@
 }
 
 /*
- *  efi_get_variable()
- *     fetch a UEFI variable given its name.
+ *  efi_get_data()
+ *     read data from a raw efi sysfs entry
  */
-static int efi_get_variable(const args_t *args, const char *varname, efi_var 
*var)
+static int efi_get_data(
+       const args_t *args,
+       const char *varname,
+       const char *field,
+       void *buf,
+       size_t buf_len)
 {
-       int fd, n, ret, rc = 0;
-       int flags;
+       int fd, rc = -1;
+       ssize_t n;
        char filename[PATH_MAX];
        struct stat statbuf;
 
-       if ((!varname) || (!var))
-               return -1;
-
        (void)snprintf(filename, sizeof filename,
-               "%s/%s/raw_var", vars, varname);
-
+               "%s/%s/%s", vars, varname, field);
        if ((fd = open(filename, O_RDONLY)) < 0)
-               return -1;
+               return rc;
 
-       ret = fstat(fd, &statbuf);
-       if (ret < 0) {
+       if (fstat(fd, &statbuf) < 0) {
                pr_err("%s: failed to stat %s, errno=%d (%s)\n",
                        args->name, filename, errno, strerror(errno));
-               rc = -1;
                goto err_vars;
        }
 
-       (void)memset(var, 0, sizeof(efi_var));
+       (void)memset(buf, 0, buf_len);
 
-       if ((n = read(fd, var, sizeof(efi_var))) != sizeof(efi_var)) {
-               if (errno != EIO) {
-                       pr_err("%s: failed to read %s, errno=%d (%s)\n",
-                               args->name, filename, errno, strerror(errno));
-               }
-               rc = -1;
+       n = read(fd, buf, buf_len);
+       if ((n < 0) && (errno != EIO) && (errno != EAGAIN) && (errno != EINTR)) 
{
+               pr_err("%s: failed to read %s, errno=%d (%s)\n",
+                       args->name, filename, errno, strerror(errno));
                goto err_vars;
        }
 
+       rc = 0;
 err_vars:
        (void)close(fd);
 
-       (void)snprintf(filename, sizeof filename,
-               "%s/%s", efi_vars, varname);
+       return rc;
+}
 
+/*
+ *  efi_get_variable()
+ *     fetch a UEFI variable given its name.
+ */
+static int efi_get_variable(const args_t *args, const char *varname, efi_var 
*var)
+{
+       int fd, ret, rc = 0, flags;
+       size_t i;
+       ssize_t n;
+       char filename[PATH_MAX];
+       static char data[4096];
+       struct stat statbuf;
+
+       if ((!varname) || (!var))
+               return -1;
+
+       if (efi_get_data(args, varname, "raw_var", var, sizeof(efi_var)) < 0)
+               rc = -1;
+
+       /* Exercise reading the efi sysfs files */
+       for (i = 0; i < SIZEOF_ARRAY(efi_sysfs_names); i++) {
+               (void)efi_get_data(args, varname, efi_sysfs_names[i], data, 
sizeof(data));
+       }
+
+       (void)snprintf(filename, sizeof filename, "%s/%s", efi_vars, varname);
        if ((fd = open(filename, O_RDONLY)) < 0)
                return -1;
 
@@ -161,9 +191,18 @@
                pr_err("%s: failed to stat %s, errno=%d (%s)\n",
                        args->name, filename, errno, strerror(errno));
                rc = -1;
-               goto err_vars;
+               goto err_efi_vars;
+       }
+
+       n = read(fd, data, sizeof(data));
+       if ((n < 0) && (errno != EIO) && (errno != EAGAIN) && (errno != EINTR)) 
{
+               pr_err("%s: failed to read %s, errno=%d (%s)\n",
+                       args->name, filename, errno, strerror(errno));
+               rc = -1;
+               goto err_efi_vars;
        }
 
+
        ret = ioctl(fd, FS_IOC_GETFLAGS, &flags);
        if (ret < 0) {
                pr_err("%s: ioctl FS_IOC_GETFLAGS on %s failed, errno=%d 
(%s)\n",
@@ -177,7 +216,6 @@
                pr_err("%s: ioctl FS_IOC_SETFLAGS on %s failed, errno=%d 
(%s)\n",
                        args->name, filename, errno, strerror(errno));
                rc = -1;
-               goto err_efi_vars;
        }
 
 err_efi_vars:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/stress-fault.c 
new/stress-ng-0.10.00/stress-fault.c
--- old/stress-ng-0.09.60/stress-fault.c        2019-06-22 10:46:27.000000000 
+0200
+++ new/stress-ng-0.10.00/stress-fault.c        2019-07-08 21:18:04.000000000 
+0200
@@ -142,7 +142,7 @@
                if (i & 1)
                        (void)unlink(filename);
 
-               ptr = mmap(NULL, 1, PROT_READ | PROT_WRITE,
+               ptr = (uint8_t *)mmap(NULL, 1, PROT_READ | PROT_WRITE,
                        MAP_SHARED, fd, 0);
                (void)close(fd);
                fd = -1;
@@ -160,7 +160,7 @@
                }
                *ptr = 0;       /* Cause the page fault */
 
-               if (munmap(ptr, 1) < 0) {
+               if (munmap((void *)ptr, 1) < 0) {
                        pr_err("%s: munmap failed: errno=%d (%s)\n",
                                args->name, errno, strerror(errno));
                        break;
@@ -177,15 +177,12 @@
                 *  force reading a byte from the start of the page.
                 */
                if (len > (page_size << 1)) {
-                       ptrdiff_t offset = (page_size - 1) + mwc64() % (len - 
(page_size << 1));
-                       offset &= ~(args->page_size - 1);
-
                        if (mapto != MAP_FAILED) {
-                               ptr = mmap(mapto, page_size, PROT_READ,
+                               ptr = (uint8_t *)mmap(mapto, page_size, 
PROT_READ,
                                        MAP_ANONYMOUS | MAP_SHARED, -1, 0);
                                if (ptr != MAP_FAILED) {
                                        uint8_put(*ptr);
-                                       (void)munmap(ptr, page_size);
+                                       (void)munmap((void *)ptr, page_size);
                                }
                        }
                };
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/stress-fcntl.c 
new/stress-ng-0.10.00/stress-fcntl.c
--- old/stress-ng-0.09.60/stress-fcntl.c        2019-06-22 10:46:27.000000000 
+0200
+++ new/stress-ng-0.10.00/stress-fcntl.c        2019-07-08 21:18:04.000000000 
+0200
@@ -59,7 +59,9 @@
 static void check_return(const args_t *args, const int ret, const char *cmd)
 {
        if (ret < 0) {
-               if ((errno != EINVAL) && (errno != EINTR)) {
+               if ((errno != EINVAL) &&
+                   (errno != EINTR) &&
+                   (errno != EPERM)) {
                        pr_fail("%s: fcntl %s failed: "
                                "errno=%d (%s)\n",
                                args->name, cmd, errno, strerror(errno));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/stress-fork.c 
new/stress-ng-0.10.00/stress-fork.c
--- old/stress-ng-0.09.60/stress-fork.c 2019-06-22 10:46:27.000000000 +0200
+++ new/stress-ng-0.10.00/stress-fork.c 2019-07-08 21:18:04.000000000 +0200
@@ -44,12 +44,12 @@
  */
 static int stress_set_fork_max(const char *opt)
 {
-       uint64_t fork_max;
+       uint32_t fork_max;
 
-       fork_max = get_uint64(opt);
+       fork_max = get_uint32(opt);
        check_range("fork-max", fork_max,
                MIN_FORKS, MAX_FORKS);
-       return set_setting("fork-max", TYPE_ID_UINT64, &fork_max);
+       return set_setting("fork-max", TYPE_ID_UINT32, &fork_max);
 }
 
 /*
@@ -58,12 +58,12 @@
  */
 static int stress_set_vfork_max(const char *opt)
 {
-       uint64_t vfork_max;
+       uint32_t vfork_max;
 
-       vfork_max = get_uint64(opt);
+       vfork_max = get_uint32(opt);
        check_range("vfork-max", vfork_max,
                MIN_VFORKS, MAX_VFORKS);
-       return set_setting("vfork-max", TYPE_ID_UINT64, &vfork_max);
+       return set_setting("vfork-max", TYPE_ID_UINT32, &vfork_max);
 }
 
 /*
@@ -75,11 +75,14 @@
        const args_t *args,
        pid_t (*fork_fn)(void),
        const char *fork_fn_name,
-       const uint64_t fork_max)
+       const uint32_t fork_max)
 {
        static pid_t pids[MAX_FORKS];
        static int errnos[MAX_FORKS];
        int ret;
+#if defined(__APPLE__)
+       double time_end = time_now() + (double)g_opt_timeout;
+#endif
 
        set_oom_adjustment(args->name, true);
 
@@ -88,36 +91,37 @@
        (void)ret;
 
        do {
-               unsigned int i;
+               uint32_t i, n;
 
                (void)memset(pids, 0, sizeof(pids));
                (void)memset(errnos, 0, sizeof(errnos));
 
-               for (i = 0; i < fork_max; i++) {
+               for (n = 0; n < fork_max; n++) {
                        pid_t pid = fork_fn();
 
                        if (pid == 0) {
                                /* Child, immediately exit */
                                _exit(0);
                        } else if (pid < 0) {
-                               errnos[i] = errno;
+                               errnos[n] = errno;
                        }
                        if (pid > -1)
-                               (void)setpgid(pids[i], g_pgrp);
-                       pids[i] = pid;
-                       if (!g_keep_stressing_flag)
+                               (void)setpgid(pids[n], g_pgrp);
+                       pids[n] = pid;
+                       if (!keep_stressing())
                                break;
                }
-               for (i = 0; i < fork_max; i++) {
+               for (i = 0; i < n; i++) {
                        if (pids[i] > 0) {
                                int status;
-                               /* Parent, wait for child */
+                               /* Parent, kill and then wait for child */
+                               (void)kill(pids[i], SIGKILL);
                                (void)shim_waitpid(pids[i], &status, 0);
                                inc_counter(args);
                        }
                }
 
-               for (i = 0; i < fork_max; i++) {
+               for (i = 0; i < n; i++) {
                        if ((pids[i] < 0) && (g_opt_flags & OPT_FLAGS_VERIFY)) {
                                switch (errnos[i]) {
                                case EAGAIN:
@@ -130,6 +134,15 @@
                                }
                        }
                }
+#if defined(__APPLE__)
+               /*
+                *  SIGALRMs don't get reliably delivered on OS X on
+                *  vfork so check the time in case SIGARLM was not
+                *  delivered.
+                */
+               if ((fork_fn == vfork) && (time_now() > time_end))
+                       break;
+#endif
        } while (keep_stressing());
 
        return EXIT_SUCCESS;
@@ -141,7 +154,7 @@
  */
 static int stress_fork(const args_t *args)
 {
-       uint64_t fork_max = DEFAULT_FORKS;
+       uint32_t fork_max = DEFAULT_FORKS;
 
        if (!get_setting("fork-max", &fork_max)) {
                if (g_opt_flags & OPT_FLAGS_MAXIMIZE)
@@ -160,7 +173,7 @@
  */
 static int stress_vfork(const args_t *args)
 {
-       uint64_t vfork_max = DEFAULT_VFORKS;
+       uint32_t vfork_max = DEFAULT_VFORKS;
        register int ret;
 
        if (!get_setting("vfork-max", &vfork_max)) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/stress-memthrash.c 
new/stress-ng-0.10.00/stress-memthrash.c
--- old/stress-ng-0.09.60/stress-memthrash.c    2019-06-22 10:46:27.000000000 
+0200
+++ new/stress-ng-0.10.00/stress-memthrash.c    2019-07-08 21:18:04.000000000 
+0200
@@ -379,7 +379,7 @@
                size_t j;
 
                for (j = MATRIX_SIZE_MIN_SHIFT; j <= MATRIX_SIZE_MAX_SHIFT &&
-                    keep_stressing(); j++) {
+                    !thread_terminate && keep_stressing(); j++) {
                        size_t mem_size = 1 << (2 * j);
 
                        size_t i;
@@ -388,6 +388,7 @@
                                        break;
                        func(args, mem_size);
                        inc_counter(args);
+                       shim_sched_yield();
                }
        }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/stress-mergesort.c 
new/stress-ng-0.10.00/stress-mergesort.c
--- old/stress-ng-0.09.60/stress-mergesort.c    2019-06-22 10:46:27.000000000 
+0200
+++ new/stress-ng-0.10.00/stress-mergesort.c    2019-07-08 21:18:04.000000000 
+0200
@@ -57,6 +57,7 @@
 
 #if defined(HAVE_LIB_BSD)
 
+#if !defined(__OpenBSD__)
 /*
  *  stress_mergesort_handler()
  *     SIGALRM generic handler
@@ -70,6 +71,7 @@
                siglongjmp(jmp_env, 1);         /* Ugly, bounce back */
        }
 }
+#endif
 
 /*
  *  stress_mergesort_cmp_1()
@@ -136,10 +138,12 @@
                return EXIT_NO_RESOURCE;
        }
 
+#if !defined(__OpenBSD__)
        if (stress_sighandler(args->name, SIGALRM, stress_mergesort_handler, 
&old_action) < 0) {
                free(data);
                return EXIT_FAILURE;
        }
+#endif
 
        ret = sigsetjmp(jmp_env, 1);
        if (ret) {
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/stress-netlink-task.c 
new/stress-ng-0.10.00/stress-netlink-task.c
--- old/stress-ng-0.09.60/stress-netlink-task.c 2019-06-22 10:46:27.000000000 
+0200
+++ new/stress-ng-0.10.00/stress-netlink-task.c 2019-07-08 21:18:04.000000000 
+0200
@@ -233,7 +233,7 @@
        struct nlattr *na;
        nlmsg_t nlmsg;
        const pid_t pid = getpid();
-       uint16_t id = -1;
+       uint16_t id;
        uint64_t nivcsw = 0ULL; /* number of involuntary context switches */
        static char name[] = TASKSTATS_GENL_NAME;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/stress-ng.c 
new/stress-ng-0.10.00/stress-ng.c
--- old/stress-ng-0.09.60/stress-ng.c   2019-06-22 10:46:27.000000000 +0200
+++ new/stress-ng-0.10.00/stress-ng.c   2019-07-08 21:18:04.000000000 +0200
@@ -2750,7 +2750,9 @@
         */
        if (get_setting("log-file", &log_filename))
                pr_openlog(log_filename);
+#if defined(HAVE_SYSLOG_H)
        openlog("stress-ng", 0, LOG_USER);
+#endif
        log_args(argc, argv);
        log_system_info();
        log_system_mem_info();
@@ -2979,7 +2981,9 @@
        /*
         *  Close logs
         */
+#if defined(HAVE_SYSLOG_H)
        closelog();
+#endif
        pr_closelog();
        if (yaml) {
                pr_yaml(yaml, "...\n");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/stress-ng.h 
new/stress-ng-0.10.00/stress-ng.h
--- old/stress-ng-0.09.60/stress-ng.h   2019-06-22 10:46:27.000000000 +0200
+++ new/stress-ng-0.10.00/stress-ng.h   2019-07-08 21:18:04.000000000 +0200
@@ -1034,7 +1034,8 @@
 #endif
 
 /* print format attribute */
-#if defined(__GNUC__) && NEED_GNUC(3,2,0)
+#if ((defined(__GNUC__) && NEED_GNUC(3,2,0)) ||        \
+     (defined(__clang__) && NEED_CLANG(3, 7, 0)))
 #define FORMAT(func, a, b) __attribute__((format(func, a, b)))
 #else
 #define FORMAT(func, a, b)
@@ -3284,6 +3285,8 @@
 extern WARN_UNUSED char *stress_const_optdup(const char *opt);
 extern size_t stress_text_addr(char **start, char **end);
 extern WARN_UNUSED bool stress_check_capability(const int capability);
+extern WARN_UNUSED bool stress_sigalrm_pending(void);
+extern void stress_sigalrm_block(void);
 
 /*
  *  Indicate a stress test failed because of limited resources
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/stress-pthread.c 
new/stress-ng-0.10.00/stress-pthread.c
--- old/stress-ng-0.09.60/stress-pthread.c      2019-06-22 10:46:27.000000000 
+0200
+++ new/stress-ng-0.10.00/stress-pthread.c      2019-07-08 21:18:04.000000000 
+0200
@@ -41,9 +41,9 @@
 static pthread_cond_t cond;
 static pthread_mutex_t mutex;
 static shim_pthread_spinlock_t spinlock;
-static bool thread_terminate;
+static volatile bool keep_thread_running_flag;
+static volatile bool keep_running_flag;
 static uint64_t pthread_count;
-static sigset_t set;
 static pthread_info_t pthreads[MAX_PTHREAD];
 
 #endif
@@ -79,6 +79,35 @@
 }
 #endif
 
+static inline void stop_running(void)
+{
+       keep_running_flag = false;
+       keep_thread_running_flag = false;
+}
+
+/*
+ *  keep_running()
+ *     Check if SIGALRM is pending, set flags
+ *     to tell pthreads and main pthread stressor
+ *     to stop. Returns false if we need to stop.
+ */
+static bool keep_running(void)
+{
+       if (stress_sigalrm_pending())
+               stop_running();
+       return keep_running_flag;
+}
+
+/*
+ *  keep_thread_running()
+ *     Check if SIGALRM is pending and return false
+ *     if the pthread needs to stop.
+ */
+static bool keep_thread_running(void)
+{
+       return keep_running() & keep_thread_running_flag;
+}
+
 /*
  *  stress_pthread_func()
  *     pthread that exits immediately
@@ -96,14 +125,6 @@
        const args_t *args = ((pthread_args_t *)parg)->args;
 
        /*
-        *  Block all signals, let controlling thread
-        *  handle these
-        */
-#if !defined(__APPLE__) && !defined(__DragonFly__)
-       (void)sigprocmask(SIG_BLOCK, &set, NULL);
-#endif
-
-       /*
         *  According to POSIX.1 a thread should have
         *  a distinct alternative signal stack.
         *  However, we block signals in this thread
@@ -160,7 +181,10 @@
                goto die;
        }
 
-       if (thread_terminate)
+       /*
+        *  Did parent inform pthreads to terminate?
+        */
+       if (!keep_thread_running())
                goto die;
 
        /*
@@ -173,7 +197,7 @@
                        args->name, (int)tid, ret, strerror(ret));
                goto die;
        }
-       while (!thread_terminate) {
+       while (keep_thread_running()) {
                ret = pthread_cond_wait(&cond, &mutex);
                if (ret) {
                        pr_fail("%s: pthread_cond_wait failed, tid=%d, errno=%d 
(%s)",
@@ -204,6 +228,7 @@
        }
 #endif
 die:
+       (void)keep_running();
        return &nowt;
 }
 
@@ -213,18 +238,26 @@
  */
 static int stress_pthread(const args_t *args)
 {
-       bool ok = true;
        bool locked = false;
-       bool try_unlock = true;
        uint64_t limited = 0, attempted = 0;
        uint64_t pthread_max = DEFAULT_PTHREAD;
        int ret;
        pthread_args_t pargs = { args, NULL };
+       sigset_t set;
+
+       keep_running_flag = true;
 
+       /*
+        *  Block SIGALRM and SIGUSR2, instead
+        *  use sigpending in pthread or this process
+        *  to check if SIGALRM has been sent.
+        */
+       sigemptyset(&set);
+       sigaddset(&set, SIGALRM);
 #if defined(SIGUSR2)
-       if (stress_sighandler(args->name, SIGUSR2, SIG_IGN, NULL) < 0)
-               return EXIT_FAILURE;
+       sigaddset(&set, SIGUSR2);
 #endif
+       sigprocmask(SIG_BLOCK, &set, NULL);
 
        if (!get_setting("pthread-max", &pthread_max)) {
                if (g_opt_flags & OPT_FLAGS_MAXIMIZE)
@@ -252,16 +285,15 @@
                return EXIT_FAILURE;
        }
 
-       (void)sigfillset(&set);
        do {
                uint64_t i, j;
 
-               thread_terminate = false;
+               keep_thread_running_flag = true;
                pthread_count = 0;
 
                (void)memset(&pthreads, 0, sizeof(pthreads));
 
-               for (i = 0; (i < pthread_max) && (!args->max_ops || 
get_counter(args) < args->max_ops); i++) {
+               for (i = 0; i < pthread_max; i++) {
                        pargs.data = (void *)&pthreads[i];
 
                        ret = pthread_create(&pthreads[i].pthread, NULL,
@@ -275,11 +307,11 @@
                                /* Something really unexpected */
                                pr_fail("%s: pthread_create failed, errno=%d 
(%s)",
                                        args->name, ret, strerror(ret));
-                               ok = false;
+                               stop_running();
                                break;
                        }
                        inc_counter(args);
-                       if (!g_keep_stressing_flag)
+                       if (!(keep_running() && keep_stressing()))
                                break;
                }
                attempted++;
@@ -296,7 +328,7 @@
                                if (ret) {
                                        pr_fail("%s: pthread_mutex_lock failed 
(parent), errno=%d (%s)",
                                                args->name, ret, strerror(ret));
-                                       ok = false;
+                                       stop_running();
                                        goto reap;
                                }
                                locked = true;
@@ -308,9 +340,8 @@
                                if (ret) {
                                        pr_fail("%s: pthread_mutex_unlock 
failed (parent), errno=%d (%s)",
                                                args->name, ret, strerror(ret));
-                                       ok = false;
+                                       stop_running();
                                        /* We failed to unlock, so don't try 
again on reap */
-                                       try_unlock = false;
                                        goto reap;
                                }
                                locked = false;
@@ -320,51 +351,30 @@
                                break;
                }
 
-               if (!locked) {
-                       ret = pthread_mutex_lock(&mutex);
-                       if (ret) {
-                               pr_fail("%s: pthread_mutex_lock failed 
(parent), errno=%d (%s)",
-                                       args->name, ret, strerror(ret));
-                               ok = false;
-                               goto reap;
-                       }
-                       locked = true;
-               }
-reap:
-
 #if defined(HAVE_TGKILL) && defined(SIGUSR2)
                for (j = 0; j < i; j++) {
                        if (pthreads[j].tid)
                                (void)syscall(__NR_tgkill, args->pid, 
pthreads[j].tid, SIGUSR2);
                }
 #endif
-               thread_terminate = true;
+reap:
+               keep_thread_running_flag = false;
                ret = pthread_cond_broadcast(&cond);
                if (ret) {
                        pr_fail("%s: pthread_cond_broadcast failed (parent), 
errno=%d (%s)",
                                args->name, ret, strerror(ret));
-                       ok = false;
+                       stop_running();
                        /* fall through and unlock */
                }
-               if (locked && try_unlock) {
-                       ret = pthread_mutex_unlock(&mutex);
-                       if (ret) {
-                               pr_fail("%s: pthread_mutex_unlock failed 
(parent), errno=%d (%s)",
-                                       args->name, ret, strerror(ret));
-                               ok = false;
-                       } else {
-                               locked = false;
-                       }
-               }
                for (j = 0; j < i; j++) {
                        ret = pthread_join(pthreads[j].pthread, NULL);
                        if ((ret) && (ret != ESRCH)) {
                                pr_fail("%s: pthread_join failed (parent), 
errno=%d (%s)",
                                        args->name, ret, strerror(ret));
-                               ok = false;
+                               stop_running();
                        }
                }
-       } while (ok && keep_stressing());
+       } while (!locked && keep_running() && keep_stressing());
 
        if (limited) {
                pr_inf("%s: %.2f%% of iterations could not reach "
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/stress-sctp.c 
new/stress-ng-0.10.00/stress-sctp.c
--- old/stress-ng-0.09.60/stress-sctp.c 2019-06-22 10:46:27.000000000 +0200
+++ new/stress-ng-0.10.00/stress-sctp.c 2019-07-08 21:18:04.000000000 +0200
@@ -29,6 +29,7 @@
        { NULL, "sctp-ops N",    "stop after N SCTP bogo operations" },
        { NULL, "sctp-domain D", "specify sctp domain, default is ipv4" },
        { NULL, "sctp-port P",   "use SCTP ports P to P + number of workers - 
1" },
+       { NULL, "sctp-sched S",  "specify sctp scheduler" },
        { NULL, NULL,            NULL }
 };
 
@@ -80,6 +81,61 @@
 #if defined(HAVE_LIB_SCTP) &&  \
     defined(HAVE_NETINET_SCTP_H)
 
+#define STRESS_SCTP_SOCKOPT(opt, type)                 \
+{                                                      \
+       type info;                                      \
+       socklen_t opt_len = sizeof(info);               \
+       int ret;                                        \
+                                                       \
+       ret = getsockopt(fd, IPPROTO_SCTP, opt,         \
+                &info, &opt_len);                      \
+       if (ret == 0) {                                 \
+               ret = setsockopt(fd, IPPROTO_SCTP, opt, \
+                       &info, opt_len);                \
+       }                                               \
+}
+
+/*
+ *  stress_sctp_sockopts()
+ *     exercise some SCTP specific sockopts
+ */
+static void stress_sctp_sockopts(const int fd)
+{
+#if defined(SCTP_RTOINFO)
+       STRESS_SCTP_SOCKOPT(SCTP_RTOINFO, struct sctp_rtoinfo)
+#endif
+#if defined(SCTP_ASSOCINFO)
+       STRESS_SCTP_SOCKOPT(SCTP_ASSOCINFO, struct sctp_assocparams)
+#endif
+#if defined(SCTP_INITMSG)
+       STRESS_SCTP_SOCKOPT(SCTP_INITMSG, struct sctp_initmsg)
+#endif
+#if defined(SCTP_NODELAY)
+       STRESS_SCTP_SOCKOPT(SCTP_NODELAY, int)
+#endif
+#if defined(SCTP_PRIMARY_ADDR)
+       STRESS_SCTP_SOCKOPT(SCTP_PRIMARY_ADDR, struct sctp_prim)
+#endif
+#if defined(SCTP_PEER_ADDR_PARAMS)
+       STRESS_SCTP_SOCKOPT(SCTP_PEER_ADDR_PARAMS, struct sctp_paddrparams)
+#endif
+#if defined(SCTP_EVENTS)
+       STRESS_SCTP_SOCKOPT(SCTP_EVENTS, struct sctp_event_subscribe)
+#endif
+#if defined(SCTP_MAXSEG)
+       STRESS_SCTP_SOCKOPT(SCTP_MAXSEG, struct sctp_assoc_value)
+#endif
+#if defined(SCTP_STATUS)
+       STRESS_SCTP_SOCKOPT(SCTP_STATUS, struct sctp_status)
+#endif
+#if defined(SCTP_GET_PEER_ADDR_INFO) && 0
+       STRESS_SCTP_SOCKOPT(SCTP_GET_PEER_ADDR_INFO, struct sctp_paddrinfo)
+#endif
+#if defined(SCTP_GET_ASSOC_STATS)
+       STRESS_SCTP_SOCKOPT(SCTP_GET_ASSOC_STATS, struct sctp_assoc_stats)
+#endif
+}
+
 /*
  *  stress_sctp_client()
  *     client reader
@@ -260,6 +316,7 @@
                                        msgs++;
                                }
                        }
+                       stress_sctp_sockopts(sfd);
                        (void)close(sfd);
                }
        } while (keep_stressing());
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/stress-ng-0.09.60/stress-socket.c 
new/stress-ng-0.10.00/stress-socket.c
--- old/stress-ng-0.09.60/stress-socket.c       2019-06-22 10:46:27.000000000 
+0200
+++ new/stress-ng-0.10.00/stress-socket.c       2019-07-08 21:18:04.000000000 
+0200
@@ -233,6 +233,20 @@
                                break;
                        }
                } while (keep_stressing());
+
+#if defined(AF_INET) &&        \
+    defined(IPPROTO_IP)        &&      \
+    defined(IP_MTU)
+               /* Exercise IP_MTU */
+               if (socket_domain == AF_INET) {
+                       int ret, mtu;
+                       socklen_t mtu_len = sizeof(mtu);
+
+                       ret = getsockopt(fd, IPPROTO_IP, IP_MTU, &mtu, 
&mtu_len);
+                       (void)ret;
+               }
+#endif
+
                (void)shutdown(fd, SHUT_RDWR);
                (void)close(fd);
        } while (keep_stressing());


Reply via email to