Skip to content

Commit

Permalink
test: test escaping of outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Gottox committed Jun 4, 2024
1 parent bc65023 commit 059e42c
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
36 changes: 36 additions & 0 deletions test/tools/ls/escape.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/sh -ex

######################################################################
# @author Enno Boland ([email protected])
# @file escape.sh
# @created Monday Nov 20, 2023 18:24:05 CET

#
# @description This script creates a squashfs image, mounts it, and
# repacks it from the mounted path.
######################################################################

: "${BUILD_DIR:?BUILD_DIR is not set}"
: "${MKSQUASHFS:?MKSQUASHFS is not set}"
: "${SOURCE_ROOT:?SOURCE_ROOT is not set}"
: "${SQSH_LS:?SQSH_UNPACK is not set}"

MKSQUASHFS_OPTS="-no-xattrs -noappend -all-root -mkfs-time 0"

WORK_DIR="$BUILD_DIR/escape"

mkdir -p "$WORK_DIR"
cd "$WORK_DIR"

mkdir -p "$PWD/empty"

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

# shellcheck disable=SC2086
$MKSQUASHFS "$PWD/empty" "$PWD/escape.squashfs" -pf "$PWD/escape.pseudo" \
$MKSQUASHFS_OPTS
result=$($SQSH_LS -r --escape "$PWD/escape.squashfs")
[ "$result" = "/dir\e" ]

result=$($SQSH_LS -r --raw "$PWD/escape.squashfs")
[ "$result" = "$(printf "/dir\e\n")" ]
1 change: 1 addition & 0 deletions test/tools/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ sqsh_extended_test = [
'ls/large-tree.sh',
'ls/large-tree-lookup.sh',
'ls/utc.sh',
'ls/escape.sh',
]
sqsh_extended_fs_test = [
'fs/large-file.sh',
Expand Down

0 comments on commit 059e42c

Please sign in to comment.