#include "fd-util.h"
#include "format-util.h"
#include "fs-util.h"
+#include "path-util.h"
#include "string-util.h"
#include "tests.h"
#include "tmpfile-util.h"
uid_t uid;
int r;
+ FOREACH_STRING(s, "capsh", "getfacl", "ls") {
+ r = find_executable(s, NULL);
+ if (r < 0)
+ return log_tests_skipped_errno(r, "Could not find %s binary: %m", s);
+ }
+
fd = mkostemp_safe(fn);
assert_se(fd >= 0);
return 0;
}
-TEST(fd_acl_make_read_only) {
+TEST_RET(fd_acl_make_read_only) {
_cleanup_(unlink_tempfilep) char fn[] = "/tmp/test-empty.XXXXXX";
_cleanup_close_ int fd = -EBADF;
const char *cmd;
struct stat st;
+ int r;
+
+ FOREACH_STRING(s, "capsh", "getfacl", "ls", "stat") {
+ r = find_executable(s, NULL);
+ if (r < 0)
+ return log_tests_skipped_errno(r, "Could not find %s binary: %m", s);
+ }
fd = mkostemp_safe(fn);
assert_se(fd >= 0);
cmd = strjoina("stat ", fn);
assert_se(system(cmd) == 0);
+
+ return 0;
}
DEFINE_TEST_MAIN(LOG_INFO);
fd = safe_close(fd);
}
-TEST(copy_bytes) {
+TEST_RET(copy_bytes) {
_cleanup_close_pair_ int pipefd[2] = EBADF_PAIR;
_cleanup_close_ int infd = -EBADF;
int r, r2;
infd = open("/usr/lib/os-release", O_RDONLY|O_CLOEXEC);
if (infd < 0)
infd = open("/etc/os-release", O_RDONLY|O_CLOEXEC);
- assert_se(infd >= 0);
+ if (infd < 0)
+ return log_tests_skipped_errno(errno, "Could not open /usr/lib/os-release or /etc/os-release: %m");
assert_se(pipe2(pipefd, O_CLOEXEC) == 0);
r = copy_bytes(pipefd[1], infd, 1, 0);
assert_se(r == -EBADF);
+
+ return 0;
}
static void test_copy_bytes_regular_file_one(const char *src, bool try_reflink, uint64_t max_bytes) {
test_one("today");
test_one("tomorrow");
test_one_noutc("16:20 UTC");
- test_one_noutc("16:20 Asia/Seoul");
- test_one_noutc("tomorrow Asia/Seoul");
- test_one_noutc("2012-12-30 18:42 Asia/Seoul");
+ if (access("/usr/share/zoneinfo/Asia/Seoul", F_OK) >= 0) {
+ test_one_noutc("16:20 Asia/Seoul");
+ test_one_noutc("tomorrow Asia/Seoul");
+ test_one_noutc("2012-12-30 18:42 Asia/Seoul");
+ }
test_one_noutc("now");
test_one_noutc("+2d");
test_one_noutc("+2y 4d");
test_should_fail("1969-12-31 UTC");
test_should_fail("-1000y");
test_should_fail("today UTC UTC");
- test_should_fail("now Asia/Seoul");
- test_should_fail("+2d Asia/Seoul");
- test_should_fail("@1395716396 Asia/Seoul");
+ if (access("/usr/share/zoneinfo/Asia/Seoul", F_OK) >= 0) {
+ test_should_fail("now Asia/Seoul");
+ test_should_fail("+2d Asia/Seoul");
+ test_should_fail("@1395716396 Asia/Seoul");
+ }
#if SIZEOF_TIME_T == 8
test_should_pass("9999-12-30 23:59:59 UTC");
test_should_fail("9999-12-31 00:00:00 UTC");
}
TEST(parse_os_release) {
- /* Let's assume that we're running in a valid system, so os-release is available */
_cleanup_free_ char *id = NULL, *id2 = NULL, *name = NULL, *foobar = NULL;
- ASSERT_EQ(parse_os_release(NULL, "ID", &id), 0);
- log_info("ID: %s", id);
+
+ if (access("/etc/os-release", F_OK) >= 0 || access("/usr/lib/os-release", F_OK) >= 0) {
+ ASSERT_EQ(parse_os_release(NULL, "ID", &id), 0);
+ log_info("ID: %s", id);
+ }
ASSERT_EQ(setenv("SYSTEMD_OS_RELEASE", "/dev/null", 1), 0);
ASSERT_EQ(parse_os_release(NULL, "ID", &id2), 0);
xsprintf(spec, "%%%c", s->specifier);
r = specifier_printf(spec, SIZE_MAX, specifier_table, NULL, NULL, &resolved);
+ if (s->specifier == 'A' && r == -EUNATCH) /* os-release might be missing in build chroots */
+ continue;
if (s->specifier == 'm' && IN_SET(r, -EUNATCH, -ENOMEDIUM, -ENOPKG)) /* machine-id might be missing in build chroots */
continue;
assert_se(r >= 0);