Fix cookbook redoxer stage root selection

This commit is contained in:
2026-04-19 09:26:57 +01:00
parent 02607243e6
commit 2fd08dcf43
2 changed files with 102 additions and 2 deletions
@@ -0,0 +1,94 @@
diff --git a/tests/sys_eventfd/eventfd.c b/tests/sys_eventfd/eventfd.c
new file mode 100644
--- /dev/null
+++ b/tests/sys_eventfd/eventfd.c
@@ -0,0 +1,27 @@
+#include <assert.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <sys/eventfd.h>
+#include <unistd.h>
+
+int main(void) {
+ int fd = eventfd(2, 0);
+ assert(fd >= 0);
+ eventfd_t value = 0;
+ assert(eventfd_read(fd, &value) == 0);
+ assert(value == 2);
+ assert(eventfd_write(fd, 5) == 0);
+ assert(eventfd_read(fd, &value) == 0);
+ assert(value == 5);
+ assert(close(fd) == 0);
+
+ int semfd = eventfd(2, EFD_SEMAPHORE);
+ assert(semfd >= 0);
+ assert(eventfd_read(semfd, &value) == 0);
+ assert(value == 1);
+ assert(eventfd_read(semfd, &value) == 0);
+ assert(value == 1);
+ assert(close(semfd) == 0);
+ puts("eventfd ok");
+ return 0;
+}
diff --git a/tests/sys_signalfd/signalfd.c b/tests/sys_signalfd/signalfd.c
new file mode 100644
--- /dev/null
+++ b/tests/sys_signalfd/signalfd.c
@@ -0,0 +1,22 @@
+#include <assert.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdint.h>
+#include <sys/signalfd.h>
+#include <unistd.h>
+
+int main(void) {
+ sigset_t mask;
+ assert(sigemptyset(&mask) == 0);
+ assert(sigaddset(&mask, SIGUSR1) == 0);
+ assert(sigprocmask(SIG_BLOCK, &mask, NULL) == 0);
+ int fd = signalfd(-1, &mask, sizeof(mask));
+ assert(fd >= 0);
+ assert(kill(getpid(), SIGUSR1) == 0);
+ struct signalfd_siginfo info;
+ assert(read(fd, &info, sizeof(info)) == (ssize_t)sizeof(info));
+ assert(info.ssi_signo == SIGUSR1);
+ assert(info.ssi_pid == (uint32_t)getpid());
+ assert(close(fd) == 0);
+ puts("signalfd ok");
+ return 0;
+}
diff --git a/tests/sys_timerfd/timerfd.c b/tests/sys_timerfd/timerfd.c
new file mode 100644
--- /dev/null
+++ b/tests/sys_timerfd/timerfd.c
@@ -0,0 +1,27 @@
+#include <assert.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/timerfd.h>
+#include <unistd.h>
+
+int main(void) {
+ int fd = timerfd_create(CLOCK_REALTIME, 0);
+ assert(fd >= 0);
+ struct itimerspec spec;
+ memset(&spec, 0, sizeof(spec));
+ spec.it_value.tv_nsec = 1000000;
+ assert(timerfd_settime(fd, 0, &spec, NULL) == 0);
+
+ uint64_t expirations = 0;
+ assert(read(fd, &expirations, sizeof(expirations)) == (ssize_t)sizeof(expirations));
+ assert(expirations >= 1);
+
+ struct itimerspec cur;
+ assert(timerfd_gettime(fd, &cur) == 0);
+
+ memset(&spec, 0, sizeof(spec));
+ spec.it_value.tv_sec = 1;
+ assert(timerfd_settime(fd, TFD_TIMER_ABSTIME | TFD_TIMER_CANCEL_ON_SET, &spec, NULL) == 0);
+ assert(close(fd) == 0);
+ puts("timerfd ok");
+ return 0;
+}
+8 -2
View File
@@ -1,4 +1,5 @@
use std::env;
use std::path::Path;
fn main() {
let mut args: Vec<String> = env::args().collect();
@@ -7,10 +8,15 @@ fn main() {
args.insert(2, "--".to_string());
if args[1] == "write-exec" {
if let Ok(stage_dir) = std::env::var("COOKBOOK_STAGE") {
args.insert(2, format!("{}/root", stage_dir));
args.insert(2, "--folder".to_string());
let folder = format!("{stage_dir}/root");
args.insert(2, stage_dir);
args.insert(2, "--root".to_string());
if Path::new(&folder).exists() {
args.insert(2, folder);
args.insert(2, "--folder".to_string());
}
}
}
}