* tests/semop.c: New file.
* tests/semop.test: New test.
* tests/.gitignore: Add semop.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(DECODER_TESTS): Add semop.test.
---
 tests/.gitignore  |  1 +
 tests/Makefile.am |  2 ++
 tests/semop.c     | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/semop.test  |  6 ++++++
 4 files changed, 64 insertions(+)
 create mode 100644 tests/semop.c
 create mode 100755 tests/semop.test

diff --git a/tests/.gitignore b/tests/.gitignore
index f3ee629..3d1dbef 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -138,6 +138,7 @@ seccomp-filter
 seccomp-filter-v
 seccomp-strict
 select
+semop
 sendfile
 sendfile64
 set_ptracer_any
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e9cd625..f31b600 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -188,6 +188,7 @@ check_PROGRAMS = \
        seccomp-filter-v \
        seccomp-strict \
        select \
+       semop \
        sendfile \
        sendfile64 \
        set_ptracer_any \
@@ -394,6 +395,7 @@ DECODER_TESTS = \
        seccomp-filter.test \
        seccomp-strict.test \
        select.test \
+       semop.test \
        sendfile.test \
        sendfile64.test \
        sethostname.test \
diff --git a/tests/semop.c b/tests/semop.c
new file mode 100644
index 0000000..3d3cb93
--- /dev/null
+++ b/tests/semop.c
@@ -0,0 +1,55 @@
+#include "tests.h"
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/sem.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+union semun
+{
+       int val;
+       struct semid_ds *buf;
+       unsigned short *array;
+       struct seminfo *__buf;
+};
+
+static int id = -1;
+
+static void
+cleanup(void)
+{
+       semctl(id, 0, IPC_RMID, 0);
+       id = -1;
+}
+
+int
+main(void)
+{
+       id = semget (IPC_PRIVATE, 1, 0600);
+       if (id <0)
+               perror_msg_and_skip("semget");
+       atexit(cleanup);
+
+       union semun sem_union;
+       sem_union.val = 0;
+       if (semctl(id, 0, SETVAL, sem_union) == -1)
+               perror_msg_and_skip("semctl");
+
+       struct sembuf sem_b;
+       sem_b.sem_num = 0;
+       sem_b.sem_op = 1;
+       sem_b.sem_flg = SEM_UNDO;
+
+       if (semop(id, &sem_b, 1))
+               perror_msg_and_skip("semop, 1");
+       printf("semop(%d, [{0, 1, SEM_UNDO}], 1) = 0\n", id);
+
+       sem_b.sem_op = -1;
+       if (semop(id, &sem_b, 1))
+               perror_msg_and_skip("semop, -1");
+       printf("semop(%d, [{0, -1, SEM_UNDO}], 1) = 0\n", id);
+
+       puts("+++ exited with 0 +++");
+       return 0;
+}
diff --git a/tests/semop.test b/tests/semop.test
new file mode 100755
index 0000000..7e8f32c
--- /dev/null
+++ b/tests/semop.test
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Check semop syscall decoding.
+
+. "${srcdir=.}/init.sh"
+run_strace_match_diff -a32
-- 
1.8.3.1




------------------------------------------------------------------------------
Find and fix application performance issues faster with Applications Manager
Applications Manager provides deep performance insights into multiple tiers of
your business applications. It resolves application problems quickly and
reduces your MTTR. Get your free trial!
https://ad.doubleclick.net/ddm/clk/302982198;130105516;z
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to