aboutsummaryrefslogtreecommitdiffstats
path: root/executor
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2024-06-27 08:05:05 +0200
committerDmitry Vyukov <dvyukov@google.com>2024-06-27 07:46:15 +0000
commit6ef39602f449b25d12299bddb48d9d1b56c4cbca (patch)
treecebe7531f7334d8063cf02bc82eabae529132e81 /executor
parent52ea34f88b0592c661d3ba1e7ca192292fe26582 (diff)
pkg/runtest: test feature detection
Fail some features in various ways for test OS, and check that features are detected properly.
Diffstat (limited to 'executor')
-rw-r--r--executor/common_test.h27
-rw-r--r--executor/executor_test.h19
2 files changed, 46 insertions, 0 deletions
diff --git a/executor/common_test.h b/executor/common_test.h
index c5f7f5bca..d580ae2ff 100644
--- a/executor/common_test.h
+++ b/executor/common_test.h
@@ -129,6 +129,21 @@ static long syz_compare_zlib(volatile long data, volatile long size, volatile lo
static void loop();
static int do_sandbox_none(void)
{
+ // Test various ways how feature setup can fail.
+ // We don't care about these features for test OS,
+ // this is just to test the feature support detection code.
+#if SYZ_EXECUTOR || SYZ_NET_INJECTION
+#if SYZ_EXECUTOR
+ if (flag_net_injection)
+#endif
+ fail("net injection is not supported");
+#endif
+#if SYZ_EXECUTOR || SYZ_DEVLINK_PCI
+#if SYZ_EXECUTOR
+ if (flag_devlink_pci)
+#endif
+ exitf("devlink_pci is not supported");
+#endif
loop();
return 0;
}
@@ -164,3 +179,15 @@ static long syz_inject_cover(volatile long a, volatile long b, volatile long c)
}
#endif
#endif
+
+#if SYZ_EXECUTOR || SYZ_SYSCTL
+static void setup_sysctl()
+{
+}
+#endif
+
+#if SYZ_EXECUTOR || (SYZ_CGROUPS && (SYZ_SANDBOX_NONE || SYZ_SANDBOX_SETUID || SYZ_SANDBOX_NAMESPACE || SYZ_SANDBOX_ANDROID))
+static void setup_cgroups()
+{
+}
+#endif
diff --git a/executor/executor_test.h b/executor/executor_test.h
index 0644e2d97..870dcb397 100644
--- a/executor/executor_test.h
+++ b/executor/executor_test.h
@@ -134,3 +134,22 @@ static long syz_inject_cover(volatile long a, volatile long b, volatile long c)
memset(cov->data + size, 0xcd, std::min<uint64>(100, cov->mmap_alloc_size - size));
return 0;
}
+
+static const char* setup_fault()
+{
+ return nullptr;
+}
+
+static const char* setup_leak()
+{
+ return "leak detection is not supported";
+}
+
+// Test various ways how feature setup can fail.
+// We don't care about these features for test OS,
+// this is just to test the feature support detection code.
+#define SYZ_HAVE_FEATURES 1
+static feature_t features[] = {
+ {rpc::Feature::Fault, setup_fault},
+ {rpc::Feature::Leak, setup_leak},
+};