summaryrefslogtreecommitdiffhomepage
path: root/test/syscalls/linux/rseq/rseq.cc
diff options
context:
space:
mode:
authorZach Koopmans <zkoopmans@google.com>2020-08-19 14:44:42 -0700
committergVisor bot <gvisor-bot@google.com>2020-08-19 14:46:55 -0700
commitf8a9483002a31eb96f99c93a77293ade35a8da5a (patch)
tree07a67b3c737b357026fe62f0a2ea5f88da48b1bb /test/syscalls/linux/rseq/rseq.cc
parent182f66ee5e6dc0206531a31f4d0d66cbb58e8a76 (diff)
Fix return for rseq_test.
Accept 128 + SIGNAL as well as SIGNAL as valid returns for fork/exec tests. Also, make changes so that test compiles in opensource. Test had compile errors on latest Ubuntu 16.04 image with updated bazel to 3.4.0 (as well as base 2.0) used for Kokoro tests. PiperOrigin-RevId: 327510310
Diffstat (limited to 'test/syscalls/linux/rseq/rseq.cc')
-rw-r--r--test/syscalls/linux/rseq/rseq.cc87
1 files changed, 49 insertions, 38 deletions
diff --git a/test/syscalls/linux/rseq/rseq.cc b/test/syscalls/linux/rseq/rseq.cc
index f036db26d..6f5d38bba 100644
--- a/test/syscalls/linux/rseq/rseq.cc
+++ b/test/syscalls/linux/rseq/rseq.cc
@@ -74,84 +74,95 @@ int TestUnaligned() {
// Sanity test that registration works.
int TestRegister() {
struct rseq r = {};
- if (int ret = sys_rseq(&r, sizeof(r), 0, 0); sys_errno(ret) != 0) {
+ int ret = sys_rseq(&r, sizeof(r), 0, 0);
+ if (sys_errno(ret) != 0) {
return 1;
}
return 0;
-};
+}
// Registration can't be done twice.
int TestDoubleRegister() {
struct rseq r = {};
- if (int ret = sys_rseq(&r, sizeof(r), 0, 0); sys_errno(ret) != 0) {
+ int ret = sys_rseq(&r, sizeof(r), 0, 0);
+ if (sys_errno(ret) != 0) {
return 1;
}
- if (int ret = sys_rseq(&r, sizeof(r), 0, 0); sys_errno(ret) != EBUSY) {
+ ret = sys_rseq(&r, sizeof(r), 0, 0);
+ if (sys_errno(ret) != EBUSY) {
return 1;
}
return 0;
-};
+}
// Registration can be done again after unregister.
int TestRegisterUnregister() {
struct rseq r = {};
- if (int ret = sys_rseq(&r, sizeof(r), 0, 0); sys_errno(ret) != 0) {
+
+ int ret = sys_rseq(&r, sizeof(r), 0, 0);
+ if (sys_errno(ret) != 0) {
return 1;
}
- if (int ret = sys_rseq(&r, sizeof(r), kRseqFlagUnregister, 0);
- sys_errno(ret) != 0) {
+ ret = sys_rseq(&r, sizeof(r), kRseqFlagUnregister, 0);
+ if (sys_errno(ret) != 0) {
return 1;
}
- if (int ret = sys_rseq(&r, sizeof(r), 0, 0); sys_errno(ret) != 0) {
+ ret = sys_rseq(&r, sizeof(r), 0, 0);
+ if (sys_errno(ret) != 0) {
return 1;
}
return 0;
-};
+}
// The pointer to rseq must match on register/unregister.
int TestUnregisterDifferentPtr() {
struct rseq r = {};
- if (int ret = sys_rseq(&r, sizeof(r), 0, 0); sys_errno(ret) != 0) {
+
+ int ret = sys_rseq(&r, sizeof(r), 0, 0);
+ if (sys_errno(ret) != 0) {
return 1;
}
struct rseq r2 = {};
- if (int ret = sys_rseq(&r2, sizeof(r2), kRseqFlagUnregister, 0);
- sys_errno(ret) != EINVAL) {
+
+ ret = sys_rseq(&r2, sizeof(r2), kRseqFlagUnregister, 0);
+ if (sys_errno(ret) != EINVAL) {
return 1;
}
return 0;
-};
+}
// The signature must match on register/unregister.
int TestUnregisterDifferentSignature() {
constexpr int kSignature = 0;
struct rseq r = {};
- if (int ret = sys_rseq(&r, sizeof(r), 0, kSignature); sys_errno(ret) != 0) {
+ int ret = sys_rseq(&r, sizeof(r), 0, kSignature);
+ if (sys_errno(ret) != 0) {
return 1;
}
- if (int ret = sys_rseq(&r, sizeof(r), kRseqFlagUnregister, kSignature + 1);
- sys_errno(ret) != EPERM) {
+ ret = sys_rseq(&r, sizeof(r), kRseqFlagUnregister, kSignature + 1);
+ if (sys_errno(ret) != EPERM) {
return 1;
}
return 0;
-};
+}
// The CPU ID is initialized.
int TestCPU() {
struct rseq r = {};
r.cpu_id = kRseqCPUIDUninitialized;
- if (int ret = sys_rseq(&r, sizeof(r), 0, 0); sys_errno(ret) != 0) {
+ int ret = sys_rseq(&r, sizeof(r), 0, 0);
+ if (sys_errno(ret) != 0) {
return 1;
}
@@ -163,13 +174,13 @@ int TestCPU() {
}
return 0;
-};
+}
// Critical section is eventually aborted.
int TestAbort() {
struct rseq r = {};
- if (int ret = sys_rseq(&r, sizeof(r), 0, kRseqSignature);
- sys_errno(ret) != 0) {
+ int ret = sys_rseq(&r, sizeof(r), 0, kRseqSignature);
+ if (sys_errno(ret) != 0) {
return 1;
}
@@ -185,13 +196,13 @@ int TestAbort() {
rseq_loop(&r, &cs);
return 0;
-};
+}
// Abort may be before the critical section.
int TestAbortBefore() {
struct rseq r = {};
- if (int ret = sys_rseq(&r, sizeof(r), 0, kRseqSignature);
- sys_errno(ret) != 0) {
+ int ret = sys_rseq(&r, sizeof(r), 0, kRseqSignature);
+ if (sys_errno(ret) != 0) {
return 1;
}
@@ -207,13 +218,13 @@ int TestAbortBefore() {
rseq_loop(&r, &cs);
return 0;
-};
+}
// Signature must match.
int TestAbortSignature() {
struct rseq r = {};
- if (int ret = sys_rseq(&r, sizeof(r), 0, kRseqSignature + 1);
- sys_errno(ret) != 0) {
+ int ret = sys_rseq(&r, sizeof(r), 0, kRseqSignature + 1);
+ if (sys_errno(ret) != 0) {
return 1;
}
@@ -229,13 +240,13 @@ int TestAbortSignature() {
rseq_loop(&r, &cs);
return 1;
-};
+}
// Abort must not be in the critical section.
int TestAbortPreCommit() {
struct rseq r = {};
- if (int ret = sys_rseq(&r, sizeof(r), 0, kRseqSignature + 1);
- sys_errno(ret) != 0) {
+ int ret = sys_rseq(&r, sizeof(r), 0, kRseqSignature + 1);
+ if (sys_errno(ret) != 0) {
return 1;
}
@@ -251,13 +262,13 @@ int TestAbortPreCommit() {
rseq_loop(&r, &cs);
return 1;
-};
+}
// rseq.rseq_cs is cleared on abort.
int TestAbortClearsCS() {
struct rseq r = {};
- if (int ret = sys_rseq(&r, sizeof(r), 0, kRseqSignature);
- sys_errno(ret) != 0) {
+ int ret = sys_rseq(&r, sizeof(r), 0, kRseqSignature);
+ if (sys_errno(ret) != 0) {
return 1;
}
@@ -277,13 +288,13 @@ int TestAbortClearsCS() {
}
return 0;
-};
+}
// rseq.rseq_cs is cleared on abort outside of critical section.
int TestInvalidAbortClearsCS() {
struct rseq r = {};
- if (int ret = sys_rseq(&r, sizeof(r), 0, kRseqSignature);
- sys_errno(ret) != 0) {
+ int ret = sys_rseq(&r, sizeof(r), 0, kRseqSignature);
+ if (sys_errno(ret) != 0) {
return 1;
}
@@ -306,7 +317,7 @@ int TestInvalidAbortClearsCS() {
}
return 0;
-};
+}
// Exit codes:
// 0 - Pass