Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run FreeBSD tests on Cirrus CI #292

Merged
merged 7 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
env:
CIRRUS_CLONE_DEPTH: 1

freebsd_task:
only_if: $CIRRUS_BRANCH == "main"
freebsd_instance:
image_family: freebsd-14-0
setup_script:
- pkg install -y autoconf automake libtool pkgconf fusefs-libs
- pkg install -y lzo2 liblz4 zstd meson git
- pkg install -y squashfs-tools coreutils
- kldload fusefs
- sysctl vfs.usermount=1
build_script:
- |
meson setup build \
-Dwerror=true \
-Dexamples=true \
-Dzlib=enabled \
-Dlz4=enabled \
-Dlzma=enabled \
-Dzstd=enabled \
-Dthreads=enabled \
-Dfuse-old=enabled \
-Dtest=extended
- meson compile -C build
test_script:
- MESON_TESTTHREADS=1 meson test --verbose -C build
install_script:
- meson install -C build
8 changes: 4 additions & 4 deletions examples/custom_mapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
// initialized from SqshConfig::source_size and expected to be set to actual
// size of the input file.
static int
mapper_init(struct SqshMapper *mapper, const void *input, size_t *size) {
mapper_init(struct SqshMapper *mapper, const void *input, uint64_t *size) {
(void)size;
int rv = 0;
FILE *file;
Expand Down Expand Up @@ -51,7 +51,7 @@ mapper_init(struct SqshMapper *mapper, const void *input, size_t *size) {
// to be set to a buffer of `size` bytes.
static int
mapper_map(
const struct SqshMapper *mapper, sqsh_index_t offset, size_t size,
const struct SqshMapper *mapper, uint64_t offset, size_t size,
uint8_t **data) {
int rv = 0;
FILE *file = sqsh_mapper_user_data(mapper);
Expand Down Expand Up @@ -104,8 +104,8 @@ static const struct SqshMemoryMapperImpl custom_mapper = {
// from the mapper at once. This field must be set as it is used as
// default value. Setting it to 0 is undefined behavior.
.block_size_hint = 1024 * 1024,
.init = mapper_init,
.map = mapper_map,
.init2 = mapper_init,
.map2 = mapper_map,
.unmap = mapper_unmap,
.cleanup = mapper_cleanup,
};
Expand Down
12 changes: 4 additions & 8 deletions libsqsh/src/posix/mmap_mapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
* @file mmap_mapper.c
*/

#define _LARGEFILE64_SOURCE
#define _FILE_OFFSET_BITS 64

#include <sqsh_error.h>
#include <sqsh_mapper.h>
Expand All @@ -44,27 +44,22 @@
#define TO_PTR(x) ((void *)(uintptr_t)(x))
#define FROM_PTR(x) ((int)(uintptr_t)(x))

#if defined(__APPLE__) || defined(__OpenBSD__)
# define off64_t off_t
# define lseek64 lseek
#endif

static int
sqsh_mapper_mmap_init(
struct SqshMapper *mapper, const void *input, uint64_t *size) {
(void)size;
(void)mapper;
int rv = 0;
int fd = -1;
off64_t pos = 0;
off_t pos = 0;

fd = open(input, 0);
if (fd < 0) {
rv = -errno;
goto out;
}

pos = lseek64(fd, 0, SEEK_END);
pos = lseek(fd, 0, SEEK_END);
if (pos < 0) {
rv = -errno;
goto out;
Expand All @@ -79,6 +74,7 @@ sqsh_mapper_mmap_init(
}
return rv;
}

static int
sqsh_mapping_mmap_map(
const struct SqshMapper *mapper, uint64_t offset, size_t size,
Expand Down
2 changes: 1 addition & 1 deletion test/libsqsh/integration.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ UTEST(integration, sqsh_test_extended_dir) {
ASSERT_EQ(0, rv);
}

#ifndef __OpenBSD__
#if !defined(__OpenBSD__) && !defined(__FreeBSD__)
UTEST(integration, sqsh_test_xattr) {
const char *expected_value = "1234567891234567891234567890001234567890";
int rv;
Expand Down
2 changes: 1 addition & 1 deletion test/libsqsh/integration_create.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cat > $tmp/pf <<EOF
"large_dir" D 0 777 2020 202020
"large_dir/link" s 777 2020 202020 ..
EOF
if [ `uname` != "OpenBSD" ]; then
if [ `uname` != "OpenBSD" ] && [ `uname` != "FreeBSD" ]; then
cat >> $tmp/pf <<EOF
"large_dir" x user.force_extended=true
"a" x user.foo=1234567891234567891234567890001234567890
Expand Down
7 changes: 7 additions & 0 deletions test/tools/fs/large-file.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ mkdir -p "$PWD/mnt"

$SQSHFS "$PWD/original.squashfs" "$PWD/mnt"

for _ in 1 2 3 4 5; do
if [ -f "$PWD/mnt/file.orig" ]; then
break
fi
sleep 0.5
done

cat "$PWD/mnt/file.orig" > "$PWD/file.extracted"

unmount "$PWD/mnt"
Expand Down
4 changes: 2 additions & 2 deletions test/tools/ls/escape.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cd "$WORK_DIR"

mkdir -p "$PWD/empty"

printf "dir\e d 777 0 0\n" > "$PWD/escape.pseudo";
printf "dir\33 d 777 0 0\n" > "$PWD/escape.pseudo";

# shellcheck disable=SC2086
$MKSQUASHFS "$PWD/empty" "$PWD/escape.squashfs" -pf "$PWD/escape.pseudo" \
Expand All @@ -33,4 +33,4 @@ result="$($SQSH_LS -r --escape "$PWD/escape.squashfs")"
[ "$result" = "$(printf "%s" "/dir\e")" ]

result="$($SQSH_LS -r --raw "$PWD/escape.squashfs")"
[ "$result" = "$(printf "/dir\e")" ]
[ "$result" = "$(printf "/dir\33")" ]
Loading