1
0
mirror of https://github.com/systemd/systemd.git synced 2024-10-29 21:55:36 +03:00

Merge pull request #27298 from mrc0mmand/test-async-tweaks

test: modernize test-async a bit
This commit is contained in:
Luca Boccassi 2023-04-16 23:32:33 +01:00 committed by GitHub
commit ad7793b59c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View File

@ -341,7 +341,7 @@ the journal instead of only when logging in debug mode.
`systemd-sysusers`
* `SOURCE_DATE_EPOCH` — if unset, the field of the date of last password change
* `$SOURCE_DATE_EPOCH` — if unset, the field of the date of last password change
in `/etc/shadow` will be the number of days from Jan 1, 1970 00:00 UTC until
today. If `$SOURCE_DATE_EPOCH` is set to a valid UNIX epoch value in seconds,
then the field will be the number of days until that time instead. This is to

View File

@ -4,8 +4,9 @@
#include <unistd.h>
#include "async.h"
#include "macro.h"
#include "fs-util.h"
#include "tmpfile-util.h"
#include "tests.h"
static bool test_async = false;
@ -15,24 +16,22 @@ static void *async_func(void *arg) {
return NULL;
}
int main(int argc, char *argv[]) {
TEST(test_async) {
_cleanup_(unlink_tempfilep) char name[] = "/tmp/test-asynchronous_close.XXXXXX";
int fd;
char name[] = "/tmp/test-asynchronous_close.XXXXXX";
fd = mkostemp_safe(name);
assert_se(fd >= 0);
asynchronous_close(fd);
assert_se(asynchronous_job(async_func, NULL) >= 0);
assert_se(asynchronous_sync(NULL) >= 0);
sleep(1);
assert_se(fcntl(fd, F_GETFD) == -1);
assert_se(errno == EBADF);
assert_se(test_async);
(void) unlink(name);
return 0;
}
DEFINE_TEST_MAIN(LOG_DEBUG);