[CRIU] [PATCH 8/9] test/zdtm: a few fixes to compile tests on Alpine
Andrei Vagin
avagin at openvz.org
Sat Sep 30 01:41:44 MSK 2017
From: Andrei Vagin <avagin at virtuozzo.com>
Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
test/zdtm/static/file_locks01.c | 8 ++++++++
test/zdtm/static/ghost_holes00.c | 5 +++++
test/zdtm/static/ipc_namespace.c | 6 +++---
test/zdtm/static/netns-dev.c | 1 +
test/zdtm/static/poll.c | 2 +-
test/zdtm/static/pthread01.c | 2 +-
test/zdtm/static/sigpending.c | 26 ++++++++++++++++++++++----
7 files changed, 41 insertions(+), 9 deletions(-)
diff --git a/test/zdtm/static/file_locks01.c b/test/zdtm/static/file_locks01.c
index aadc5e422..399a42835 100644
--- a/test/zdtm/static/file_locks01.c
+++ b/test/zdtm/static/file_locks01.c
@@ -10,6 +10,14 @@
#include "zdtmtst.h"
#include "fs.h"
+#ifndef LOCK_MAND
+#define LOCK_MAND 32
+#endif
+
+#ifndef LOCK_READ
+#define LOCK_READ 64
+#endif
+
const char *test_doc = "Check that flock locks are restored";
const char *test_author = "Qiang Huang <h.huangqiang at huawei.com>";
diff --git a/test/zdtm/static/ghost_holes00.c b/test/zdtm/static/ghost_holes00.c
index 11561d9fe..214a39141 100644
--- a/test/zdtm/static/ghost_holes00.c
+++ b/test/zdtm/static/ghost_holes00.c
@@ -19,6 +19,11 @@ TEST_OPTION(filename, string, "file name", 1);
#define BUFSIZE 4096
static unsigned char buf4k[BUFSIZE];
+#ifndef SEEK_DATA
+#define SEEK_DATA 3
+#define SEEK_HOLE 4
+#endif
+
#ifdef HEAD_HOLE
#define HH 1
#else
diff --git a/test/zdtm/static/ipc_namespace.c b/test/zdtm/static/ipc_namespace.c
index 84331d370..a7f0fd103 100644
--- a/test/zdtm/static/ipc_namespace.c
+++ b/test/zdtm/static/ipc_namespace.c
@@ -12,9 +12,9 @@
#define CLONE_NEWIPC 0x08000000
-extern int msgctl (int __msqid, int __cmd, struct msqid_ds *__buf) __THROW;
-extern int semctl (int __semid, int __semnum, int __cmd, ...) __THROW;
-extern int shmctl (int __shmid, int __cmd, struct shmid_ds *__buf) __THROW;
+extern int msgctl (int __msqid, int __cmd, struct msqid_ds *__buf);
+extern int semctl (int __semid, int __semnum, int __cmd, ...);
+extern int shmctl (int __shmid, int __cmd, struct shmid_ds *__buf);
struct ipc_ids {
int in_use; /* TODO: Check for 0 */
diff --git a/test/zdtm/static/netns-dev.c b/test/zdtm/static/netns-dev.c
index 4efbeba7e..8763773cc 100644
--- a/test/zdtm/static/netns-dev.c
+++ b/test/zdtm/static/netns-dev.c
@@ -1,6 +1,7 @@
#include <unistd.h>
#include <stdlib.h>
#include <dirent.h>
+#include <linux/limits.h>
#include "zdtmtst.h"
diff --git a/test/zdtm/static/poll.c b/test/zdtm/static/poll.c
index 33bc0bd4a..53d801a0b 100644
--- a/test/zdtm/static/poll.c
+++ b/test/zdtm/static/poll.c
@@ -9,7 +9,7 @@
#include <time.h>
#include <sys/stat.h>
-#include <sys/poll.h>
+#include <poll.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/wait.h>
diff --git a/test/zdtm/static/pthread01.c b/test/zdtm/static/pthread01.c
index 2520fcfee..1e84463ee 100644
--- a/test/zdtm/static/pthread01.c
+++ b/test/zdtm/static/pthread01.c
@@ -33,7 +33,7 @@ static char *decode_signal(const sigset_t *s, char *buf)
#define COLLECT(sig) \
do { \
- if ((long)s->__val[0] & (long)sigmask(sig)) \
+ if (sigismember(s, sig)) \
strcat(buf, #sig " "); \
} while (0)
diff --git a/test/zdtm/static/sigpending.c b/test/zdtm/static/sigpending.c
index 4adcfa626..b6d224c75 100644
--- a/test/zdtm/static/sigpending.c
+++ b/test/zdtm/static/sigpending.c
@@ -28,6 +28,24 @@ static int thread_nr;
# define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
+/* cr_siginfo is declared to get an offset of _sifields */
+union cr_siginfo {
+ struct {
+ int si_signo;
+ int si_errno;
+ int si_code;
+
+ union {
+ int _pad[10];
+ /* ... */
+ } _sifields;
+ } _info;
+ siginfo_t info;
+};
+typedef union cr_siginfo cr_siginfo_t;
+
+#define siginf_body(s) (&((cr_siginfo_t *)(s))->_info._sifields)
+
#ifdef __i386__
/*
* On x86_32 kernel puts only relevant union member when signal arrives,
@@ -44,9 +62,9 @@ static int thread_nr;
*/
# define _si_fields_sz 12
#else
-# define _si_fields_sz (sizeof(siginfo_t) - offsetof(siginfo_t, _sifields))
+# define _si_fields_sz (sizeof(siginfo_t) - offsetof(cr_siginfo_t, _info._sifields))
#endif
-#define siginfo_filled (offsetof(siginfo_t, _sifields) + _si_fields_sz)
+#define siginfo_filled (offsetof(cr_siginfo_t, _info._sifields) + _si_fields_sz)
static pthread_mutex_t exit_lock;
static pthread_mutex_t init_lock;
@@ -90,7 +108,7 @@ static void sig_handler(int signal, siginfo_t *info, void *data)
}
crc = ~0;
- if (datachk((uint8_t *) &info->_sifields, _si_fields_sz, &crc)) {
+ if (datachk((uint8_t *) siginf_body(info), _si_fields_sz, &crc)) {
fail("CRC mismatch\n");
return;
}
@@ -172,7 +190,7 @@ int send_siginfo(int signo, pid_t pid, pid_t tid, int group, siginfo_t *info)
info->si_code = si_code;
si_code--;
info->si_signo = signo;
- datagen((uint8_t *) &info->_sifields, _si_fields_sz, &crc);
+ datagen((uint8_t *) siginf_body(info), _si_fields_sz, &crc);
sent_sigs++;
--
2.13.3
More information about the CRIU
mailing list