test(proot): address benchmark review findings

This commit is contained in:
Kurt Himebauch committed 2026-10-28 10:19:29 -04:00
1 parent ac8d97e098
commit 2c3c135b52
9 files changed
+44 -10

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
#ifndef DROIDDECK_BENCH_CHECKS_H
#define DROIDDECK_BENCH_CHECKS_H
/* Benchmark assertions execute the operations being measured. */
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <assert.h>
#endif
+1 -1
View File
@@ -3,7 +3,7 @@ static void interruption_hook(const long *);
#define FP_SVC_TEST_HOOK interruption_hook
#endif
#include "../fastpath/fastpath.c"
#include <assert.h>
#include "checks.h"
#include <sys/wait.h>
#include <linux/futex.h>
#include <signal.h>
+1 -1
View File
@@ -1,5 +1,5 @@
#include "../fastpath/fastpath.c"
#include <assert.h>
#include "checks.h"
#include <linux/filter.h>
#include <linux/seccomp.h>
#include <sys/prctl.h>
+1 -1
View File
@@ -1,5 +1,5 @@
#define _GNU_SOURCE
#include <assert.h>
#include "checks.h"
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
+1 -1
View File
@@ -1,5 +1,5 @@
#define _GNU_SOURCE
#include <assert.h>
#include "checks.h"
#include <dlfcn.h>
#include <fcntl.h>
#include <stdio.h>
+1 -1
View File
@@ -1,5 +1,5 @@
#define _GNU_SOURCE
#include <assert.h>
#include "checks.h"
#include <dlfcn.h>
#include <fcntl.h>
#include <pthread.h>
+4 -3
View File
@@ -1,5 +1,5 @@
#define _GNU_SOURCE
#include <assert.h>
#include "checks.h"
#include <dlfcn.h>
#include <errno.h>
#include <fcntl.h>
@@ -59,8 +59,9 @@ int main(int argc, char **argv) {
}
assert(fts_close(fts) == 0);
printf("fts: %u files %u dirs %u links\n", files, dirs, links);
char resolved[4096];
assert(realpath(link, resolved) && !strcmp(resolved, path));
char resolved[4096], canonical[4096];
assert(realpath(path, canonical));
assert(realpath(link, resolved) && !strcmp(resolved, canonical));
struct passwd pw, *found;
char buf[16384];
r = getpwnam_r("root", &pw, buf, sizeof buf, &found);
+12 -1
View File
@@ -14,11 +14,22 @@ class FastPathSvcEncodingTest(unittest.TestCase):
self.skipTest("cc is not available")
with tempfile.TemporaryDirectory() as directory:
program = Path(directory) / "check.c"
program.write_text(source.replace('"HEADER"', '"' + HEADER.with_name(header).as_posix() + '"'))
program.write_text(source.replace('"HEADER"', '"' + (HEADER.parent / header).as_posix() + '"'))
output = Path(directory) / "check"
subprocess.run(["cc", "-O2", "-Wall", "-Wextra", "-Werror", str(program), "-o", str(output)], check=True)
subprocess.run([str(output)], check=True, timeout=10)
def test_benchmark_checks_execute_with_ndebug(self):
self.compile_check(r'''
#define NDEBUG
#include "HEADER"
int main(void) {
int calls = 0;
assert(++calls == 1);
return calls != 1;
}
''', "../bench/checks.h")
def test_stack_bounds_and_alternate_stack_fallback(self):
self.compile_check(r'''
#define _GNU_SOURCE