eBPF-based security platform
testing: wrap nanosleep() in the image cleanup test
Daniel Borkmannd12ede887028
diff --git a/Makefile.shirudo b/Makefile.shirudoindex 11dd1783..66a506d1 100644--- a/Makefile.shirudo+++ b/Makefile.shirudo@@ -847,7 +847,7 @@ testing/helper/test-image-cleanup: testing/helper/test-image-cleanup.c \@printf ' CC $@\n'$(Q)$(CC) $(CFLAGS) $(LDFLAGS) $(RPATH_LDFLAGS) -o $@ \$(filter-out %.h util/image_runtime.c,$^) \- -Wl,--wrap=dm_verity_remove,--wrap=usleep \+ -Wl,--wrap=dm_verity_remove,--wrap=nanosleep \$(STATIC_LIBS) $(DYNAMIC_LIBS)testing/helper/test-mode-objects: testing/helper/test-mode-objects.c \diff --git a/testing/helper/image-cleanup.h b/testing/helper/image-cleanup.hindex 0a149aa3..2daa1001 100644--- a/testing/helper/image-cleanup.h+++ b/testing/helper/image-cleanup.h@@ -4,12 +4,12 @@#ifndef SHIRUDO_TEST_IMAGE_CLEANUP_H#define SHIRUDO_TEST_IMAGE_CLEANUP_H-#include <unistd.h>+#include <time.h>#include "util/dm_verity.h"int __wrap_dm_verity_remove(struct dm_verity *device,bool deferred);-int __wrap_usleep(useconds_t usec);+int __wrap_nanosleep(const struct timespec *req, struct timespec *rem);#endif /* SHIRUDO_TEST_IMAGE_CLEANUP_H */diff --git a/testing/helper/test-image-cleanup.c b/testing/helper/test-image-cleanup.cindex 27a4f075..a96e3886 100644--- a/testing/helper/test-image-cleanup.c+++ b/testing/helper/test-image-cleanup.c@@ -20,9 +20,10 @@ int __wrap_dm_verity_remove(struct dm_verity *device,return remove_calls <= busy_calls ? -EBUSY : remove_result;}-int __wrap_usleep(useconds_t usec)+int __wrap_nanosleep(const struct timespec *req, struct timespec *rem){- if (usec != 10000 || remove_calls != sleep_calls + 1)+ if (req->tv_sec || req->tv_nsec != 10000000 ||+ remove_calls != sleep_calls + 1)invalid_call = true;sleep_calls++;return 0;